Homebrew NVRAM questions

ground

Well-Known Member
OP
Member
Joined
Mar 22, 2007
Messages
907
Trophies
0
XP
572
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?
 

Coto

-
Member
Joined
Jun 4, 2010
Messages
2,979
Trophies
2
XP
2,565
Country
Chile
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
 

zoogie

playing around in the end of life
Developer
Joined
Nov 30, 2014
Messages
8,560
Trophies
2
XP
15,000
Country
Micronesia, Federated States of
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

ground

Well-Known Member
OP
Member
Joined
Mar 22, 2007
Messages
907
Trophies
0
XP
572
Country
Netherlands
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

General chit-chat
Help Users
  • No one is chatting at the moment.
    K3Nv2 @ K3Nv2: Least they got head in the end