#163696 - Kayvon - Thu Oct 09, 2008 5:33 am
I've been playing around with EFS because it looked so awesome. Unfortunately I haven't been able to get even the example to work:
Code: |
EFS init OK!
found NDS path: GBA ROM
/test.txt content: 'EFS ok!'
size: 8 bytes
/folder/test.txt content:
writehere16byte
write test done! : 16 bytes
/folder/test.txt new content:
writehere16byte
Press A for directory tests. |
First off, it's a little funny that the 's' is missing at the end of what should be "writehere16bytes."
The real problem, though, is that nothing is being written to /folder/test.txt. From the source coude, the message "writehere16byte" should be replaced with "16b Written OK!" I've tried this on both Ensata and my Supercard SD, but I continually get the same result.
Am I doing something wrong? I'm really hoping the problem is on my end, not with EFS or the Supercard. I've even tried the pre-compiled example.
#163699 - hacker013 - Thu Oct 09, 2008 6:32 am
EFS is for an internal filesystem in the .nds file itself.
_________________
Website / Blog
Let the nds be with you.
#163715 - Sweater Fish Deluxe - Thu Oct 09, 2008 5:51 pm
I don't think writing is supported on slot-2 flash carts. I think it's because slot-2 carts load the ROM into onboard RAM and then run it from there and apparently EFSlib uses that mirrored version in extended memory for reading and writing instead of the one on your SD card. You'll notice that the path listed is "GBA ROM" not the actual path on your SD card.
Shouldn't it be possible to write to both the version in RAM and the one in FAT simultaneously so that EFS_lib would support writing on slot-2 carts? Or is there some technical obstacle here that I'm not aware of?
...word is bondage...
#163716 - Kayvon - Thu Oct 09, 2008 5:54 pm
hacker013 wrote: |
EFS is for an internal filesystem in the .nds file itself. |
Yes, maybe I should have mentioned that in the problem, but I assumed everyone knew what EFS was (or could google it if they didn't).
Sweater Fish Deluxe wrote: |
I don't think writing is supported on slot-2 flash carts. |
That explains it.
Sweater Fish Deluxe wrote: |
Shouldn't it be possible to write to both the version in RAM and the one in FAT simultaneously |
Perhaps, but I have no idea how to do that. I'll just stick with creating a highScore file in the \data directory instead.
#164169 - Zalo - Wed Oct 22, 2008 9:16 pm
Hi. I also have a SuperCard SD. My problem is different. I don't need to write anything, but I need to list the directories in my SD. The problem is that this doesn't work. And I have been trying everything. Finally I decided to compile the example with a small change
Code: |
// chdir to a directory then list its content
iprintf("\nListing 'fat:/' directory:\n");
chdir("fat:/");
dir = diropen("./");
if(dir != NULL) {
buffer = (u8*)malloc(EFS_MAXNAMELEN);
while(!(dirnext(dir, (char*)buffer, &st))) {
if(st.st_mode & S_IFDIR)
iprintf("DIR : %s\n", buffer);
else
iprintf("FILE: %s, size: %d bytes\n", buffer, st.st_size);
}
iprintf("end of directory.\n");
dirclose(dir);
free(buffer);
}
else
{
iprintf("BAD DIR");
}
|
I just try to display the main directory in my SD. The problem is that it displays "BAD DIR". So... I don't know what's going on. I am patching the nds both with the efs and dldi patcher so it should, work, right? Why am I the only one having problems with this???? Please, any help will be welcome. I am completely stuck.
_________________
-----
Zalo
#164222 - tepples - Thu Oct 23, 2008 9:55 pm
Can you paste the whole main() function? Where are you calling fatInitDefault()?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#164228 - Zalo - Thu Oct 23, 2008 10:21 pm
Well... that's the thing I am discovering now... I am not calling fatInitDefault(), because I am calling EFS_Init(EFS_AND_FAT | EFS_DEFAULT_DEVICE, NULL).
It is pretty weird, but calling this function in slot2 devices with EFS_AND_FAT doesn't init libfat
I am now calling FatInitDefault after that call to EFS_Init. It seems to work. But I am still not sure if that is the way to do things. I mean, if someone releases its homebrew using EFS_AND_FAT it is not going to be able to work in slot2 devices... it doesn't matter how you patch it.
Besides, after adding fatInitDefault() it stops working in no$GBA :( (that's not surprise, anyway)
_________________
-----
Zalo
#164236 - Cydrak - Fri Oct 24, 2008 2:37 am
Ah, this. Short answer is, you can't use both RAM and SD on the M3 and Supercards. Well, not at the same time.
I think Sweater Fish nailed the problem here... since SC's schlep the whole NDS into the slot-2 RAM, and EFS looks there first, it doesn't even bother with libfat. Why not? In this case, it would give you other problems. The 32MB RAM in the Supercard is all slot-2 allows for, leaving no room for the SD registers! However, there's a "stealth" reg at the very end to switch them. M3 and others appear similar.
Since neither libfat or efslib know about that, they will always conflict in this situation. A general fix will have to muck about with one of these (efslib most likely).
#164241 - Zalo - Fri Oct 24, 2008 9:10 am
Wow... thanks for the explanation. I had no idea about all this.
So, you mean I can't create a program that mainly uses EFS but it has an option to load a file from the SD just using EFSInit()?? It was an improvement I wanted to make for a game I made, just to load new levels.
I am going to look for more info about that register you are talking about. I think all this can be fixed because it is weird to read from de RAM and the SD at the same time
_________________
-----
Zalo
#164275 - Zalo - Sat Oct 25, 2008 12:01 pm
Sorry to ask again... but it is being hard to find info
Just a couple of questions
If it is true that in supercard devices the hole SD is loaded into the RAM and them executed from there... then how does some apps bigger that 32 megs work?
Where can I find more info about that register on Supercard to switch between reading from RAM and SD. If I use an old release of devkitarm (I think is r20), then everything works fine, but when I change to r23 it is imposible to load anything from the SD. I can load the data stored in the nds using EFS but when I try chdir("fat:/") it gets freeze :(
_________________
-----
Zalo
#164285 - Cydrak - Sun Oct 26, 2008 6:20 am
Zalo wrote: |
So, you mean I can't create a program that mainly uses EFS but it has an option to load a file from the SD just using EFSInit()?? |
Not as far as I know. I had to tweak EFS to get it working (but see below).
Easiest would be to stop it searching the RAM entirely, but then you lose support for some things: emulators, launching from flashcarts, or from the SC's RAM (as happens in my setup). I think you can just patch that out of EFS_Init(), add an option, whatever.
Zalo wrote: |
If it is true that in supercard devices the hole SD is loaded into the RAM and them executed from there... then how does some apps bigger that 32 megs work? |
Is there really homebrew that large? The only thing bigger is the SD, so if it doesn't fit in RAM, and it still works, that's what it must use... this is, after all, the normal situation for slot-1.
Zalo wrote: |
Where can I find more info about that register on Supercard to switch between reading from RAM and SD. |
Code: |
// Cribbed from libfat, DSLinux and Lick's RAM library.
// Note: I have SC Lite; others are untested.
#define REG_SC_MODE ( *(vu16*) 0x09FFFFFE )
enum {
SC_RAM = 5, // 32MB RAM, writable
SC_MEDIA = 3, // SD i/o (high 16MB)
};
void sc_mode(int newMode) {
REG_SC_MODE = 0xA55A;
REG_SC_MODE = 0xA55A;
REG_SC_MODE = newMode;
REG_SC_MODE = newMode;
} |
Yeah, these are all but undocumented, so it's hard to find a good source... some of the code and links have disappeared. There's still NDSTech wiki:Flash Cartridges but it doesn't shed too much light. Just for kicks, I tossed up a quick test. It's not exhaustive, but here's how modes 0..7 look to me:
Code: |
REG_SC_MODE SD RAM accessible
(read) i/o? read write
0,4 0x9e72 -- -- --
2,6 0xffff yes -- --
1 0x0001 -- 32MB --
3 0xffff yes 16MB --
5 0x0005 -- 32MB 32MB
7 0xffff yes 16MB 16MB |
Mode 0 is apparently used (with higher bits) to control other things, such as the flash ROM. With the right setup, you can boot back to the menu this way. Note: while #7 looks tempting, DSLinux sources caution against combining SD and writes to RAM due to some sort of conflict.
Zalo wrote: |
If I use an old release of devkitarm (I think is r20), then everything works fine, ... |
Huh, that's odd. It *should* work on r23 if you make sure it's in the right mode: RAM for EFS, SD for FAT. Although you can try switching manually, I would highly suggest making it automatic somehow, or you'll eventually be digging for the one or two calls that got left out.
#164305 - Zalo - Mon Oct 27, 2008 2:43 pm
That sounds very good! Thanks. I'll try to use it when I come home this afternoon
Is there any way to make this changes only for my SuperCard and the program still works on other cards or do I have to create two versions?
By the way... the link is broken :(
_________________
-----
Zalo