Can't write file to nitrofs

support for the ARM toolchain
Post Reply
ashairey
Posts: 10
Joined: Fri Jan 27, 2012 2:33 pm

Can't write file to nitrofs

Post by ashairey » Sat Jan 10, 2015 3:13 pm

Hello,

I am using the latest devkitARM version r43, installed via the installer
All is working fine and nicely. However i got a problem with writing a file to the filesystem.
For this is am using the nitrofs\nitrofsdir example.
After a make i start the nds file up with DeSmuMe 0.9.10 and the files that are include are read nicely. If i use the build in nitrofs viewer i can find the files.

But when i try to write a file to the file system the file doesn't show up in the viewer. I've tried to create the file and to use an already existing file. Both action these me that the where succesful but nothing appears.

The example already has a file1.txt include and i try to overwrite that one
This is one of the many code variants i tried but till now not succes.
Could anyone help me with this?

Code: Select all

//---------------------------------------------------------------------------------
void TestWrite()
//---------------------------------------------------------------------------------
{
	FILE * fp;

	fp = fopen ("file1.txt", "w");
	fprintf(fp, "%s %s %s %d", "We", "are", "in", 2015);
   
	fclose(fp);

}
Nor this form will work either
char incoming_buffer[256];
//This buffer is filled earlier and a check comfirms that it holds data.

/Create a temporary Var in the FAT system to control saving
FILE* save_file;
//Open the file you are saving to or create it if it is not present
save_file=fopen("evntgrps.txt", "wb"); //wb = create/truncate & write
//Write data into the file
fwrite(&incoming_buffer, 1, sizeof(incoming_buffer), save_file);
//Close the file
fclose(save_file);

elhobbs
Posts: 352
Joined: Thu Jul 02, 2009 1:19 pm

Re: Can't write file to nitrofs

Post by elhobbs » Sat Jan 10, 2015 7:52 pm

Nitrofs is read only. Also keep in mind that desmume is not perfect. Generally you should test on hardware too. The issue could be desmume.

ashairey
Posts: 10
Joined: Fri Jan 27, 2012 2:33 pm

Re: Can't write file to nitrofs

Post by ashairey » Sun Jan 11, 2015 10:57 am

I've tried it on real hardware too and with NO$GBA all with the same results but if it's readonly then that clears the smoke.

I also tried the included nds\filesystem\libfat\libfatdir example but i couldn't get that one to write a file either. Could it be the same issue of being readonly too?

btw, when i compile the libfatdir example it won't work on real hardware nor in any emulator.
I get this error 'fatInitDefault failure: terminating'

I need to write a file to the card, any suggestion to do so would be helpfull.

Thanks
Bram

elhobbs
Posts: 352
Joined: Thu Jul 02, 2009 1:19 pm

Re: Can't write file to nitrofs

Post by elhobbs » Sun Jan 11, 2015 4:39 pm

Libfat requires that the nds file be patched for your specific loader card. for first gen cards this was a manual process. Newer cards auto patch. the libfat examples do work. i do not think libfat works on no$gba and desmume requires configuration and both are version dependant. Which loader card are you using on hardware? My first thoughts are that you are using an older card that requires manual patching or there may be an issue with your sd card.

ashairey
Posts: 10
Joined: Fri Jan 27, 2012 2:33 pm

Re: Can't write file to nitrofs

Post by ashairey » Sun Jan 11, 2015 8:09 pm

Some background.
About 3-4 year ago i made some software and games for the DS with i believe was v20 of devkitARM.
By then i was able too use DLDI patch with the driver for my card a M3 card (indeed an older card) and got writing to a file was working. By then i started also to work on a project to use a DS as a domotica controller but dswifi had issues that stopped me. Now i found out that dswifi was fixed and i picked up the project again but by now the file save part isn't working anymore. All the software i made back then worked on an emulator and on actual hardware

Today the libfat example don't work on Hardware, NO$GBA v2.7d and dsemume v09.10, neither patched or not. However if i patch the nds file with dldi and the mpcf driver then libfat initialize when i use dsemume but still not on hardware or NO$GBA. I know that this mpcf driver isn't the right driver for my card so it's no surprise that it didn't work on hardware. However the right driver is M3sd_alt.dldi. That one i have used all the time back then but i won't help me now anymore. So to summerize things. I use proven hardware and tools that worked before but my toolchain has made a huge leap over the years.

I tried a few old games i made back then and started the old nds files up on the mentioned emulators and hardware and they still work, including save and loading data via libfat which i used back them. So apparently the libfat in the toolchain is changed, but i might be wrong here.

ashairey
Posts: 10
Joined: Fri Jan 27, 2012 2:33 pm

Re: Can't write file to nitrofs

Post by ashairey » Sat Jan 17, 2015 11:49 am

Some feedback on this topic.
Got it working again on an old M3 movie player card using Libfat and M3sd_alt.dldi driver
The ROM runs on hardware, not in DeSmuMe v09.10 nor No$gbs v2.7d
However hardware it the one we need so its not a real problem.

Thx for the comments

WinterMute
Site Admin
Posts: 1369
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Can't write file to nitrofs

Post by WinterMute » Thu Jan 22, 2015 1:10 am

DeSmuME will work fine if you set the slot 2 config to auto and use the --cflash-path option to set the path containing files you want libfat to see. It builds a fat image from the files on disk.

The other option is to set slot2 to MPCF Flash Card Device and select "use path of the loaded ROM".
Help keep devkitPro toolchains free, Donate today

devkitPro IRC support
Personal Blog

ashairey
Posts: 10
Joined: Fri Jan 27, 2012 2:33 pm

Re: Can't write file to nitrofs

Post by ashairey » Fri Jan 23, 2015 10:20 am

The other option is to set slot2 to MPCF Flash Card Device and select "use path of the loaded ROM".
Thx, this works perfectly and will make development a lot faster.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests