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

naxil

Well-Known Member
OP
Member
Joined
Oct 26, 2011
Messages
846
Trophies
1
XP
665
Country
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!
 

nl255

Well-Known Member
Member
Joined
Apr 9, 2004
Messages
2,999
Trophies
2
XP
2,785
Country
Install Virtualbox and Windows XP Black Edition (Virtualbox is a free download and XP Black is available from the usual sources).
 

Acidflare

HomeBrew Beta Tester
Member
Joined
Aug 16, 2013
Messages
1,106
Trophies
0
Age
34
Location
Nether World
XP
268
Country
Canada

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.
 

YourHero

Well-Known Member
Member
Joined
Apr 22, 2010
Messages
1,025
Trophies
0
XP
502
Country
United States
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.
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.
 

Acidflare

HomeBrew Beta Tester
Member
Joined
Aug 16, 2013
Messages
1,106
Trophies
0
Age
34
Location
Nether World
XP
268
Country
Canada
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.

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
 

naxil

Well-Known Member
OP
Member
Joined
Oct 26, 2011
Messages
846
Trophies
1
XP
665
Country
Italy
damn.. possible is not possible do the emunand.bin patch directly on linux? or not exist another way? like hex it?
 

naxil

Well-Known Member
OP
Member
Joined
Oct 26, 2011
Messages
846
Trophies
1
XP
665
Country
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?
 

Acidflare

HomeBrew Beta Tester
Member
Joined
Aug 16, 2013
Messages
1,106
Trophies
0
Age
34
Location
Nether World
XP
268
Country
Canada
sorry i do another question.. what the dragmehere.bat file do on emunand.bin ? what is the diff from emunand.bin to rednand.bin?
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
 

b1l1s

Well-Known Member
Member
Joined
May 2, 2015
Messages
151
Trophies
0
XP
161
Country
Malaysia
sorry i do another question.. what the dragmehere.bat file do on emunand.bin ? what is the diff from emunand.bin to rednand.bin?


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>
 

mid-kid

GBAtemp spamBOT
Member
Joined
Aug 2, 2012
Messages
879
Trophies
0
Age
25
XP
1,163
Country
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>

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.

damn.. possible is not possible do the emunand.bin patch directly on linux? or not exist another way? like hex 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.
 

b1l1s

Well-Known Member
Member
Joined
May 2, 2015
Messages
151
Trophies
0
XP
161
Country
Malaysia
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



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.

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.

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

Cyan

GBATemp's lurking knight
Former Staff
Joined
Oct 27, 2002
Messages
23,749
Trophies
4
Age
45
Location
Engine room, learning
XP
15,648
Country
France
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.
 
  • Like
Reactions: DarkMatterCore

b1l1s

Well-Known Member
Member
Joined
May 2, 2015
Messages
151
Trophies
0
XP
161
Country
Malaysia
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.


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.
 

Cyan

GBATemp's lurking knight
Former Staff
Joined
Oct 27, 2002
Messages
23,749
Trophies
4
Age
45
Location
Engine room, learning
XP
15,648
Country
France
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.
 

b1l1s

Well-Known Member
Member
Joined
May 2, 2015
Messages
151
Trophies
0
XP
161
Country
Malaysia
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.


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.
 

naxil

Well-Known Member
OP
Member
Joined
Oct 26, 2011
Messages
846
Trophies
1
XP
665
Country
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!
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    K3Nv2 @ K3Nv2: It's mostly the ones that are just pictures and no instructions at all