Linux question: how to make rednand from emunand.bin on that os?

Discussion in '3DS - Flashcards & Custom Firmwares' started by naxil, May 15, 2015.

  1. naxil
    OP

    naxil GBAtemp Advanced Fan

    Member
    740
    96
    Oct 26, 2011
    Italy
    Hello, i try to install cfw 4.5 on my 3dsxl. I have extract the emunand.bin with the linux/macosx tool, but now i need to use the step called drug_your_emunandhere.bat.
    How to do that step on linux (i use lubuntu 14.04).
    If some people here know all the step on linux iam very HAPPY!
     
  2. nl255

    nl255 GBAtemp Addict

    Member
    2,610
    375
    Apr 9, 2004
    Install Virtualbox and Windows XP Black Edition (Virtualbox is a free download and XP Black is available from the usual sources).
     
  3. YourHero

    YourHero GBAtemp Maniac

    Member
    1,011
    224
    Apr 22, 2010
    United States
  4. Acidflare

    Acidflare HomeBrew Beta Tester

    Member
    1,107
    120
    Aug 16, 2013
    Canada
    Nether World
    that will only work if WINE will work with whatever program is being used with the .bat that guide will work, I would go with a VirtualBox with Windows XP Black Edition installed, just remember naxil that you'll have a .vhd file on your computer this will be your windows image VHD stands for Virtual Hard Disk just incase you didn't know, I would keep this installation so that any time you come into a windows program that doesn't have a linux counter-part you can load up virtualbox and run the program in windows.
     
  5. YourHero

    YourHero GBAtemp Maniac

    Member
    1,011
    224
    Apr 22, 2010
    United States
    I have a friend who uses wine for a lot of things. It has come a long way. He should seriously give it a try.
     
  6. Acidflare

    Acidflare HomeBrew Beta Tester

    Member
    1,107
    120
    Aug 16, 2013
    Canada
    Nether World
    last I checked WINE wasn't very good for Windows CLI applications, also WINE stands for Wine Is Not an Emulator. lol funny name but it works. thought I'd point that out.
    I don't have many uses for linux now a days besides system recoveries So I don't use it much anymore last time I used WINE for windows functionality in linux was back in 2009 that's a long 6 years of development they've gone through since i've used it so I could be wrong, but I would say ultimately if naxil wants to continuously have a windows installation for times like this it would be useful.

    Also I know that WINE is harder to get set up (from my own experiences in 2009) then a Virtual Machine yeah there's no windows setup to go through and everything is done for you but the WINE configuration application can get complicated at the first couple of glances it took me quite a bit of time to get it going some windows applications don't run unless a desktop area is rendered so figuring out all of these settings for each and every single windows application can be a bit of a pain some applications even need a their folder run as a separate drive letter.
    I'm not saying that he shouldn't try out WINE if he wants to I just think that VirtualBox is the best user-friendly way to go especially when it comes to using multiple windows programs
     
  7. VerseHell

    VerseHell GBAtemp Psycho!

    Member
    3,067
    1,067
    Jun 29, 2014
    France
  8. naxil
    OP

    naxil GBAtemp Advanced Fan

    Member
    740
    96
    Oct 26, 2011
    Italy
    damn.. possible is not possible do the emunand.bin patch directly on linux? or not exist another way? like hex it?
     
  9. naxil
    OP

    naxil GBAtemp Advanced Fan

    Member
    740
    96
    Oct 26, 2011
    Italy
    sorry i do another question.. what the dragmehere.bat file do on emunand.bin ? what is the diff from emunand.bin to rednand.bin?
     
  10. Acidflare

    Acidflare HomeBrew Beta Tester

    Member
    1,107
    120
    Aug 16, 2013
    Canada
    Nether World
    okay seems like your a fluent user of linux, a .bat is the windows equivalent to a .sh script.
    as you know a .sh script is a pre-compiled set of CLI commands to be run when the .sh script is called a .bat is the same thing but for Windows CLI not linux CLI they use different syntax's
    the .bat must be extracting the .bin modifying it and repacking it(with compression if needed) into a file called rednand.bin
     
  11. b1l1s

    b1l1s GBAtemp Regular

    Member
    151
    84
    May 2, 2015
    Malaysia

    The batch file only prepend 512bytes of dummy data to the emunand.bin to trick emuNAND Tool, since you are using linux you can't run the tool anyway. Just dd your emunand starting from sector 1(use 'seek' option) of your SD card.

    Something like this should work:
    Code:
    dd bs=512 seek=1 if=emunand.bin of=<yoursdcard>
     
  12. mid-kid

    mid-kid GBAtemp spamBOT

    Member
    879
    962
    Aug 2, 2012
    Yes, either this (skips one block of 512 bytes (bs) at the start of the output (seek)), or you create a 512 byte long blank file (the file created by drag_emunand_here.bat contains newlines instead of being blank), and append your NAND to it like this:
    Code:
    fallocate -l 512 REDNAND.bin
    cat MY_EMUNAND.bin >> REDNAND.bin
    ITT: People suggesting to use WINE or an emulator for running a 25 line long batch file instead of reading what it does and replicating it.

    Yes... You can do that. Just open up GHex, enter insert mode and press 1024 times the "0" key with the cursor at the beginning of the file.

    Also, WINE actually supports running .bat files (using "wineconsole thing.bat"), but as with everything WINE-related, YMMV.
    The reason why drag_emunand_here.bat doesn't work is because it tries to write to the same file it reads from (it does something like "file dummy.bin dummy.bin > dummy.bin"), which is disallowed on linux.
     
  13. gudenau

    gudenau Largely ignored

    Member
    GBAtemp Patron
    gudenau is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    3,300
    1,253
    Jul 7, 2010
    United States
    /dev/random
    What is the contents of the bat file?
     
  14. b1l1s

    b1l1s GBAtemp Regular

    Member
    151
    84
    May 2, 2015
    Malaysia


    He doesn't need the intermediary rednand.bin since he can't use emuNAND Tool without wine. dd'ing the whole thing to SD kills two birds with one stone.

    This thread kind of reminds me of people running desmume in virtualbox to get WiFi cap. SMH.
     
  15. Cyan

    Cyan GBATemp's lurking knight

    Global Moderator
    18,726
    9,022
    Oct 27, 2002
    France
    Engine room, learning
    A little explanation about this padding.

    When gateway released the emuNAND, they decided to put it as the start of the SD card instead of the end, probably in order to keep sector numbers intact.
    Sector 12 of the NAND would be located at sector 12 of the SD card.

    But to keep the card's file system as FAT32 located after that NAND dump, they needed to keep the MBR (sector 0) intact.
    So, they moved the NAND sector 0 at the end of the NAND

    [MBR][NAND sect1 to end][NAND sect0] [FAT32]

    Red NAND is doing it differently and Redirect all sector's access to sector+offset.
    no need to cut the first sector.
    [MBR][NAND sector 0 on SD Sector 1, etc.][FAT32]


    Why does users add an empty sector on their NAND dump to convert it to RedNAND?
    It's not a conversion at all.
    It's only used to trick EmuNAND Tools, for simplicity for noobs. It was the first method used instead of re-writing a proper tools to manage NANDs.


    EmuNAND tools takes the NAND, cut the first sector and place it at the end.

    converting NAND to RedNAND means doing it like that [NAND].bin --> "[Empty][NAND]".bin

    If you give EmuNAND tool a RedNAND.bin (with the dummy empty sector at the start), it will do it's usual function: place the first (empty) sector at the end of the NAND and will start writing the rest of the NAND file at Sector1 (the sector 0 of the NAND will be on sector1 of the SD, sector 1 of the NAND will be on sector2 of the SD, etc.)

    If you want to write a NAND on your SD card compatible with CFW/rxTools/etc., just write it at sector 1. (preserve the MBR at sector 0)
    if you want to write a NAND on your SD card compatible with Gateway/R4-3DS/MT then start writing are sector 1 but skip the first NAND sector, which you will write last and placed at the end.



    But RedNAND can then be placed anywhere on the SD card, not necessarily on Sector 1.
    You can even have multiple NANDs on a single card.
    What's needed is the NAND launcher to know where to start looking to mount that NAND.
     
    DarkMatterCore likes this.
  16. b1l1s

    b1l1s GBAtemp Regular

    Member
    151
    84
    May 2, 2015
    Malaysia

    Hopefully someone will take the hint(not like dualnand but something that prompts users to select which emunand to boot). :P Actually what's stopping CFW devs from redirecting nand reads/writes to a file instead? It will obviously be a bit slower, but it makes things simpler for users.
     
  17. Cyan

    Cyan GBATemp's lurking knight

    Global Moderator
    18,726
    9,022
    Oct 27, 2002
    France
    Engine room, learning
    it could be a text file with offsets (start sector list) to the start of each dumps on a non-partitioned area. but it could be harder to setup for the newbies.
    or it could automatically listing all nand_xx.bin files on FAT32 partition, it's not hard to get the start sector with stat() function now that Gateway is compatible with FAT32, and it will then use sector's access so there will be no slowdown.

    or in two phases, for better compatibility with all nand loaders:
    A program (computer or better homebrew) which generate the txt file, and asks you which NAND you want to boot next.
    nand.cfg
    inside there will be first sector of the nand.bin file to load.

    Then launch your favorite homebrew NAND loader (rxTools) which first loads the nand.cfg to find the sector to boot, no menu to code into the loader. the menu could be on the external homebrew.
     
  18. VerseHell

    VerseHell GBAtemp Psycho!

    Member
    3,067
    1,067
    Jun 29, 2014
    France
  19. b1l1s

    b1l1s GBAtemp Regular

    Member
    151
    84
    May 2, 2015
    Malaysia

    I was actually thinking about redirecting nand reads/writes to the SD FAT fs (which is why it could be slower). So the user would only need to copy their emunand.bin to the SD card. No need to mess around with sectors and what not.

    Your idea should work too. The first sector is all that's needed, the location of the NCSD header(RED or GW/MT) can be determined at runtime.
     
  20. naxil
    OP

    naxil GBAtemp Advanced Fan

    Member
    740
    96
    Oct 26, 2011
    Italy
    so i need to do? i insert my SD on linux and fdisk see "only" 1 partition callled sdd*1.
    I can use dd instead for extract it? and dd again for flash? tool like gparted see a empty 1gb partition but linux not see it, see only the second fat32.
    So u can tellme like a child what i need to do in terminal for:
    1: extract the gateway formatted nand
    2: patch it with dummy part for REDNAND use
    3: reinject it with dd...
    THANK U!