Homebrew NVRAM questions

  • Thread starter Thread starter ground
  • Start date Start date
  • Views Views 1,831
  • Replies Replies 5

ground

Well-Known Member
Member
Joined
Mar 22, 2007
Messages
907
Reaction score
282
Trophies
1
XP
607
Country
Netherlands
Hello,

Today i started making my own NDS tool for NVRAM writing& editing. But i ran into a problem, and now I am hoping somebody can help me here.

First off all, I got NVRAM dumping working with this code:
clearscreen();
printf("\x1b[1;1HDumping NVRAM");
fatInitDefault();
FILE* file=fopen("nvram.bin", "w");
u8* temp=(u8*)malloc(256*1024);
readFirmware(0x00,temp,256*1024);
fwrite(temp,1,256*1024,file);
fclose(file);
free(temp);
printf("\x1b[2;1HDone");
This code works fine, and i got the same result when i use this tool : https://github.com/44670/NVReader
, except for the first 4 bytes, which are off (they are always 00 in nvreader).

But writing the exact same .bin file back to the NVRAM results in a dsmode brick for me. I am using the following code for it:
clearscreen();
printf("\x1b[1;1HWriting NVRAM");
fatInitDefault();
FILE* file=fopen("nvram.bin", "rb");
writeFirmware(0x00,file,256*1024);
fclose(file);
printf("\x1b[2;1HDone");
does anybody have an idea what i am missing here?
 
there may be a fread missing in the nvram write.

you need to extract the nvram binary from the SD controller first, and then use that one to write it anywhere

that's what i believe
 
FILE* file=fopen("nvram.bin", "w");

should be "wb"
i don't know if that fixes it but it's a start.

you can also check out wintermute's tool that does the same thing for a reference/second opinion whatever you want to call it.
https://github.com/WinterMute/nintendo-ds-tools/tree/master/firmware/nds/fwTool
the libnds functions for nvram writing have changed recently, it's all done from the arm9 alone now.

you can also read/write nvram from 3ds mode now. it may be more stable. here's an example.
https://github.com/Steveice10/FBI/commit/95c6ce3f832ee3d929e154ea728e0733f1d55310
 
Last edited by zoogie,
  • Like
Reactions: ground
there may be a fread missing in the nvram write.

you need to extract the nvram binary from the SD controller first, and then use that one to write it anywhere

that's what i believe
of course, that was it! thank you. it is working now.
for the ones who want to see the code:

clearscreen();
printf("\x1b[1;1HWriting NVRAM");
fatInitDefault();
FILE* file=fopen("nvram.bin", "rb");
u8* temp = (u8*)malloc(256*1024);
fread(temp,1,256*1024,file);
writeFirmware(0x00,temp,256*1024);
free(temp);
fclose(file);
printf("\x1b[2;1HDone");
 
  • Like
Reactions: Coto

Site & Scene News

Popular threads in this forum