#153518 - HLMetroid - Tue Apr 01, 2008 10:17 am
Does anyone know how to get EFSlib working with iDeaS, or any other NDS emulator?
I am trying to run the PAlib EFSlib example, but when I run it in iDeaS, it just freezes at "Please wait, searching NDS...".
If anyone could help me getting iDeaS to read the files from EFSlib, that would be great.
Thanks.
#153570 - silent_code - Wed Apr 02, 2008 3:01 am
try no$gba instead. every time i use ideas to check my code, it crashes. i stopped trying recently. :^C
dualis is also ok, if you don't have heave 3D stuff.
no$ is the way to go (imho) when it comes to an emulator, at least for now.
good luck and happy coding!
Last edited by silent_code on Wed Apr 02, 2008 4:57 am; edited 1 time in total
#153571 - bsder - Wed Apr 02, 2008 4:16 am
I would also recommend looking at desmume.
http://desmume.org/
The best part is that it is completely open source, so you can instrument your code any way you want.
#153574 - SevenString - Wed Apr 02, 2008 6:55 am
silent_code wrote: |
try no$gba instead. every time i use ideas to check my code, it crashes. i stopped trying recently. :^C
dualis is also ok, if you don't have heave 3D stuff.
no$ is the way to go (imho) when it comes to an emulator, at least for now.
good luck and happy coding! |
Yeah, I'm very impressed by no$gba. It's currently my emulator of choice.
_________________
"Artificial Intelligence is no match for natural stupidity."
#153581 - HLMetroid - Wed Apr 02, 2008 9:31 am
Thanks for your help so far.
I tried some stuff, but I've gotten stuck now.
I'm using this batch file to patch the .ds.gba file to try and get it working with no$gba.
Code: |
call build_fcsr.bat fat.img fcsr
padbin 512 test.ds.gba
copy /b test.ds.gba + fat.img test_debug.ds.gba
dlditool fcsr.dldi test_debug.ds.gba
|
I've found out that changing this in efs_lib.h:
Code: |
#define EFS_fopen(n) fopen(n, "rb+")
|
to just "rb" allows me to see the files, but obviously doesn't let me write 16 bytes to a file. And it also doesn't seem to show the contents of the files either.
Code: |
FAT init ok
EFS init ok
found NDS path:
/test.txt content: ''
/folder/test.txt content:
write test done! : 0 bytes
/folder/test.txt new content:
writehere16bytes
Listing '/list/' directory:
DIR : .
DIR : ..
FILE: FILE1.TXT
FILE: FILE2.TXT
FILE: FILE3.TXT
DIR : testfolder
end of directory.
|
So does anybody know how to get EFSlib working so that I can read & write to files properly?
#153587 - wintermute - Wed Apr 02, 2008 2:52 pm
HLMetroid wrote: |
Thanks for your help so far.
I tried some stuff, but I've gotten stuck now.
I'm using this batch file to patch the .ds.gba file to try and get it working with no$gba.
|
There's no need to create a .ds.gba file. Provided you don't add a wifi banner to the binary ( -o opyion in ndstool ) then .nds will work perfectly well.
Quote: |
I've found out that changing this in efs_lib.h:
Code: |
#define EFS_fopen(n) fopen(n, "rb+")
|
|
I don't know about anyone else but that macro disturbs the heck out of me. What on earth does that define gain?
Quote: |
So does anybody know how to get EFSlib working so that I can read & write to files properly? |
EFSlib is read only
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog
#153593 - Noda - Wed Apr 02, 2008 4:40 pm
wintermute wrote: |
Quote: |
I've found out that changing this in efs_lib.h:
Code: |
#define EFS_fopen(n) fopen(n, "rb+")
|
|
I don't know about anyone else but that macro disturbs the heck out of me. What on earth does that define gain?
|
Simply because it allows to switch to libfat read/write by simply defining #define EFS_USE_REAL_FAT, for such case.
Quote: |
Quote: |
So does anybody know how to get EFSlib working so that I can read & write to files properly? |
EFSlib is read only |
Wrong, EFSlib support writing, as long as the space is pre-allocated. To test it on emulators that support libfat, juste use the define written up there (uncomment it on efslib.h") so it will works as standard libfat, which makes it easier to use on emulators.
#153598 - wintermute - Wed Apr 02, 2008 5:48 pm
Noda wrote: |
Simply because it allows to switch to libfat read/write by simply defining #define EFS_USE_REAL_FAT, for such case.
|
And how exactly does that differ from using the normal stdio functions with out such random oddness? It's perfectly possible to change the default device based on runtime conditions.
Quote: |
Wrong, EFSlib support writing, as long as the space is pre-allocated. To test it on emulators that support libfat, juste use the define written up there (uncomment it on efslib.h") so it will works as standard libfat, which makes it easier to use on emulators. |
That's just *nasty*. In any case you should be testing your code on hardware as much as possible, none of the open source emulators are anywhere near usable or accurate enough to be trusted.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog
#153605 - HLMetroid - Wed Apr 02, 2008 8:23 pm
Alright, I'll explain the problem I have now.
Basically, I've been reading this page to try and remedy my problem:
http://forum.gbadev.org/viewtopic.php?t=13195&postdays=0&postorder=asc&highlight=efslib&start=60
Now, I read a bit down the page where Marcel24 says that "rb+" causes him problems with reading the files, and to change it to "rb".
So that's what I did, and it let me see the files, but not write to them, which could explain why the write test fails.
But what I want to know is how I can leave it at "rb+" and still manage to see and write to files?
I also read on the same page that bob_fossil mentions there is a bug in the EFS_GetFileSize function when EFS_REAL_FAT_MODE is #defined.
It doesn't seem to be fixed yet, so it could be attributing to the fact that I can't seem to read files either (I think the /test.txt content should be 'EFS Ok!' instead of '').
Thanks for your replies so far guys.
#153636 - Blash - Thu Apr 03, 2008 8:33 am
I had the same problem few days ago so i can sympathize
First let "rb+" as it is. That's not the problem
Try this code for the example
Code: |
int size;
size = EFS_GetFileSize(file);
EFS_fseek(file,0,SEEK_SET);
buffer = (u8*)malloc(size);
EFS_fread(buffer, 1, size, file);
buffer[size-1] = '\0';
iprintf("\n/test.txt content: '%s'\n", buffer);
|
#153639 - HLMetroid - Thu Apr 03, 2008 9:51 am
Well I just tried that now. It didn't seem to fix the problem. Thanks though.
I think the problem is to do with it not finding files, eg. it fails on this line:
Because I can list the directories fine, just not the files in "rb+" mode.
So this is how I am opening the files, basically the same as the example I think:
Code: |
file = EFS_fopen("test.txt");
if(file != NULL) {
int size;
size = EFS_GetFileSize(file);
EFS_fseek(file,0,SEEK_SET);
buffer = (u8*)malloc(size);
EFS_fread(buffer, 1, size, file);
buffer[size-1] = '\0';
iprintf("\n/test.txt content: '%s'\n", buffer);
free(buffer);
EFS_fclose(file);
} |
So I was thinking the problem was either with EFSlib, or with my batch file.
So here's my batch file:
Code: |
call build.bat
call build_fcsr.bat fat.img efsroot
padbin 512 efs_lib.nds
copy /b efs_lib.nds + fat.img efs_lib_debug.nds
dlditool fcsr.dldi efs_lib_debug.nds |
Am I missing a step from either of these things?
#153640 - Blash - Thu Apr 03, 2008 9:55 am
Have you copied first efs_lib.nds in your efsroot directory?
#153703 - HLMetroid - Fri Apr 04, 2008 4:19 am
Well, doing that gave me better results, thanks.
But still only in "rb" mode.
So are these the right steps? Are there some I should add or shouldn't do?
1. Run Build.bat (builds and efs patches)
2. Copy the efs_lib.nds into efsroot
3. Run build_fcsr.bat (builds the efsroot directory into efsroot.img)
4. In the root directory, do a "copy /b efs_lib.nds efs_lib_ds.nds"
5. Run padbin 512 efs_lib_ds.nds
6. Run copy /b efs_lib_ds.nds + efsroot.img efs_debug.nds
7. dlditool fcsr efs_debug.nds
Once I've done these I then load efs_debug.nds up in no$gba. If I have efs_lib.h in "rb+" mode it still doesn't work though.
So since I think it has to do with the file being detected as null, maybe it could be that I'm missing/shouldn't do a step, the Makefile I'm using could be wrong in some way, or some code is wrong.
Thanks for your help so far guys.
#153705 - Noda - Fri Apr 04, 2008 5:04 am
Writing is not supported by emulators (ideas accept rb+, but writing has no effect), so you have to test on real ds those functions.
#153708 - HLMetroid - Fri Apr 04, 2008 5:45 am
Ok, that would mean that it seems to work then. Thanks everyone for your help.