gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Chishm Loader in PAlib

#138204 - calcprogrammer1 - Tue Aug 21, 2007 3:51 am

Since this is sort of off topic for Chishm's topic, I'll move this discussion to it's own topic.

I'm trying to use Chishm's Bootloader with PAlib. Currently, I put the ARM7 files (nds_loader_arm7.h and .c) in PAlib/lib/arm7 and added #include "nds_loader_arm7.h" and the check function to main.c for the arm7. Then I copied the load.bin (not renamed, renamed made load_bin_bin.h) to PAlib/lib/arm9/data, then copied the nds_loader_arm9.h and .c to PAlib/lib/arm9. I added #include "nds_loader_arm9.h" to the main.c in there too. Then I tried the fast build thing. This is what I got:

[Images not permitted - Click here to view it]

Any ideas?

EDIT: Just noticed the load.bin didn't compile, I cleaned and tried again.

[Images not permitted - Click here to view it]

It says there's an error that REG_EXEMEMCNT isn't declared. I looked at the source file (nds_loader_arm9.c) and...well, it isn't declared, it's used in the line:

Code:
REG_EXEMEMCNT |= ARM7_OWNS_ROM | ARM7_OWNS_CARD;


If such function or variable is declared in the ARM7 code, maybe the arm9 code isn't seeing it...well, I've looked through both ARM7 files (.h and .c) and found no REG_EXEMEMCNT, so that isn't it... Is this declared in the load.bin file? libnds? libfat? Where is REG_EXEMEMCNT declared to begin with, that way it could be added or compiled in with the PAlib compile.


EDIT AGAIN :) :

A google search of "REG_EXEMEMCNT" turned up some interesting posts. Apparently REG_EXEMEMCNT was renamed REG_EXMEMCNT, and this edit makes it compile just fine :P Now to test the code to see if it WORKS.
_________________
DS Firmware 1, Datel Games n' Music card / Chism's FW hacked GBA MP v2 CF

There's no place like 127.0.0.1.

#138208 - calcprogrammer1 - Tue Aug 21, 2007 4:52 am

Ok, so I think I've got it all sorted out, but there's some problems left. I put the .h files in PAlib/include/PA9.h and PAlib/include/PA7.h (did #include "arm9/nds_loader_arm9.h" etc, put the .h'es in PAlib/include/arm9 and PAlib/include/arm7 respectively. Then, I recompiled PAlib, and it worked. Now, in my program DSFile, I have:

//PAlib and libfat includes:

#include <PA9.h>
#include <fat.h>
#include <sys/dir.h>

//DSFile graphics includes:

#include "gfx/all_gfx.c"
#include "gfx/all_gfx.h"

//in DSFile's source folder:

#include "global.h" //global defines, function def's, and vars
#include "file.h" //file functions
#include "screen.h" //graphics functions
#include "input.h" //get keys, touch, etc

Then, in my input.h file, I have a function "getKeys()". It is in charge of all the key input (up, down, a, and b).

...
if(Pad.Newpress.B){
strcpy(currentdir,fixFilename(currentdir,position));
runNdsFile(currentdir);
getFileList();
position=0;
updateScreen(position)
...

But, when compiling, I get this:

Linking...
main.o: In function 'getKeys(int&)':
c:/devkitPro/Projects/DSFile2/DSFile2/source/input.h(35): undefined reference to 'runNdsFile'
collect2: 1d returned 1 exit status
make[1]: *** [/c/devkitPro/Projects/DSFile2/DSFile2/Release/DSFile2.elf] Error 1
make: *** [build] Error 2
Build log was saved at "file://c:\devkitPro\Projects\DSFile2\DSFile2\Release\BuildLog.htm"
DSFile2 - 0 error (s), 1 warning(s)
=============Rebuild All: 1 succeeded, 0 failed, 0 skipped ============
_________________
DS Firmware 1, Datel Games n' Music card / Chism's FW hacked GBA MP v2 CF

There's no place like 127.0.0.1.

#138218 - spinal_cord - Tue Aug 21, 2007 10:13 am

in the arm9 code it calls

return runNds (load_bin, load_bin_size, st.st_ino, false, true);

however palib does not add _bin to the end of the load.bin file, so the arguments are wrong.
you can either change that line (and the include at the top) to
return runNds (load, load_size, st.st_ino, false, true);
or rename load.bin to load_bin.bin

neither solutions help load a file though.
_________________
I'm not a boring person, it's just that boring things keep happening to me.
Homepage

#138233 - calcprogrammer1 - Tue Aug 21, 2007 3:49 pm

Are you sure? Look at my second screenshot, it compiles "load.bin" and then in the build folder, there's "load_bin.h" and "load.o", if I rename it load_bin.bin, I get a "load_bin.o" and a "load_bin_bin.h".

I changed load_bin to load, and load_bin_size to load_size, recompiled, and got this error:

nds_loader_arm9.c
c:/devkitPro/PAlib/lib/arm9/nds_loader_arm9.c: In function 'runNdsFile':
c:/devkitPro/PAlib/lib/arm9/nds_loader_arm9.c:253: error: 'load' undeclared

I also get the same saying 'load_size' undeclared.

I've changed it back, it compiles fine.

Now the problem is the undefined reference again. Undefined reference, according to sites I've searched for, has to do with how you include a library or something, but I don't know. All the rest of PAlib works fine, just when I use the runNdsFile() function it gives the undefined reference.
_________________
DS Firmware 1, Datel Games n' Music card / Chism's FW hacked GBA MP v2 CF

There's no place like 127.0.0.1.

#138236 - tondopie - Tue Aug 21, 2007 4:49 pm

I have said this many times... you will have to re-write the way PAlib handles .bin files. Try starting with the makefile.
_________________
Development Blog: http://teendev.org
Homebrew Podcast: http://homebrewcast.net
Web Design: http://xtendesign.net

#138239 - calcprogrammer1 - Tue Aug 21, 2007 5:03 pm

I opened PAlib's makefile, it archives files, all the PAlib ones were there, so I added the nds_loader_arm9.o file, hopefully that will make it work.

Hmm...

Now it returns a different error:

Code:
------ Rebuild All started: Project: boottest, Configuration: Release Win32 ------
Performing Makefile project actions
Cleaning... boottest
logo.bmp
logo_wifi.bmp
main.cpp
Linking...
c:/devkitPro/PAlib/lib\libpa9.a(nds_loader_arm9.o): In function `runNds':
nds_loader_arm9.c:(.text+0x550): undefined reference to `_io_dldi'
nds_loader_arm9.c:(.text+0x564): undefined reference to `_io_dldi'
collect2: ld returned 1 exit status
make[1]: *** [/c/devkitPro/Projects/boottest/boottest/Release/boottest.elf] Error 1
make: *** [build] Error 2
Build log was saved at "file://c:\devkitPro\Projects\boottest\boottest\Release\BuildLog.htm"
boottest - 0 error(s), 0 warning(s)
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

_________________
DS Firmware 1, Datel Games n' Music card / Chism's FW hacked GBA MP v2 CF

There's no place like 127.0.0.1.

#138241 - tondopie - Tue Aug 21, 2007 5:08 pm

that's not the problem. you don't need to get that archived. It gets archived automatically. It's the load.bin that needs to be handled differently. Open up a regular arm9 makefile and open up a PAlib arm9 makefile and see the difference.
_________________
Development Blog: http://teendev.org
Homebrew Podcast: http://homebrewcast.net
Web Design: http://xtendesign.net

#138244 - calcprogrammer1 - Tue Aug 21, 2007 5:23 pm

Normal makefile:
Code:
BINFILES     :=     $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))


PAlib makefile:
Code:
BINFILES     :=     $(foreach dir, $(SOURCES),$(notdir $(wildcard $(dir)/*.bin)))


I tried replacing it, it has compile errors. I'm looking through the PAlib makefile, trying to find bin, I found this:

Code:
define bin202
     cp $(<) $(*).tmp
     $(OBJCOPY) -I binary -O elf32-littlearm -B arm \
     --rename-section .data=.rodata \
     --redefine-sym _binary_$*_tmp_start=$*\
     --redefine-sym _binary_$*_tmp_end=$*_end\
     --redefine-sym _binary_$*_tmp_size=$*_size\
     $(*).tmp $(@)
     echo "extern const u8" $(*)"[];" > $(*).h
     echo "extern const u32" $(*)_size[]";" >> $(*).h
     rm $(*).tmp
endef

_________________
DS Firmware 1, Datel Games n' Music card / Chism's FW hacked GBA MP v2 CF

There's no place like 127.0.0.1.

#138249 - tondopie - Tue Aug 21, 2007 7:51 pm

you'll have to figure it out yourself. I don't have access to a compiler right now. It will require having all you data files renamed in your includes.
_________________
Development Blog: http://teendev.org
Homebrew Podcast: http://homebrewcast.net
Web Design: http://xtendesign.net

#138258 - Lick - Tue Aug 21, 2007 10:13 pm

Does PALib's FAT library has its own version of "_io_dldi"? Because it's a libfat variable.
_________________
http://licklick.wordpress.com

#138259 - calcprogrammer1 - Tue Aug 21, 2007 10:24 pm

PAlib's FAT library is absent, I don't think PAfs supports FAT, so I'm already using libfat in my program (not necessarily PAlib though, but fat.h is in my program)
_________________
DS Firmware 1, Datel Games n' Music card / Chism's FW hacked GBA MP v2 CF

There's no place like 127.0.0.1.

#138288 - spinal_cord - Wed Aug 22, 2007 10:09 am

I included nds_loader_arm9.h in my main.c, not the palib one. It seemed to work fine, but still no launching.
_________________
I'm not a boring person, it's just that boring things keep happening to me.
Homepage

#138300 - calcprogrammer1 - Wed Aug 22, 2007 3:05 pm

I have it compiling now too (added libfat includes to my test project), but it crashes whenever it gets to runNdsFile().
_________________
DS Firmware 1, Datel Games n' Music card / Chism's FW hacked GBA MP v2 CF

There's no place like 127.0.0.1.

#138318 - spinal_cord - Wed Aug 22, 2007 10:57 pm

Thats as far as I've got also.

Surely someone who knows loaders (or palib) well can help.
_________________
I'm not a boring person, it's just that boring things keep happening to me.
Homepage

#138334 - tondopie - Thu Aug 23, 2007 1:03 am

Lick wrote:
Does PALib's FAT library has its own version of "_io_dldi"? Because it's a libfat variable.


that's a very good point. PAlib might have its own FAT wrapper. I know older versions had their own FAT libs. I don't know it\f that is still the case though.
_________________
Development Blog: http://teendev.org
Homebrew Podcast: http://homebrewcast.net
Web Design: http://xtendesign.net

#139911 - spinal_cord - Tue Sep 11, 2007 1:43 pm

Sorry to bump this again, but does anyone know how to get this (or any dldi) loader to work in palib?
_________________
I'm not a boring person, it's just that boring things keep happening to me.
Homepage

#139946 - tondopie - Tue Sep 11, 2007 11:01 pm

nope, not if it requires .bin files.
_________________
Development Blog: http://teendev.org
Homebrew Podcast: http://homebrewcast.net
Web Design: http://xtendesign.net