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 > How can i change arm9 execute address?

#117308 - alex_III - Sat Feb 03, 2007 7:00 pm

I use devkitPro libnds to write ds program.
arm9 execute address default is 0x02000000
Is there any way to change it?
for example change to 0x02500000
I have no idea ..thx a lot

#117314 - tepples - Sat Feb 03, 2007 8:04 pm

The main RAM is 0x02000000 through 0x023FFFFF. Did you want to execute out of an address mirror?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#117322 - alex_III - Sat Feb 03, 2007 8:37 pm

just for example...change to 0x02100000

#117323 - tepples - Sat Feb 03, 2007 8:41 pm

I'm guessing that this would involve changes to the link script and to the parameters passed to ndstool.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#117340 - Lick - Sat Feb 03, 2007 11:38 pm

Go to your Makefile, look up the line with ndstool and add parameters to change the address.

To find the parameters, simply run ndstool.exe for the usage.
_________________
http://licklick.wordpress.com

#117359 - alex_III - Sun Feb 04, 2007 3:55 am

i tried the parameters

-r9 0x02100000(ARM9 RAM address)
-e9 0x02100000(ARM9 RAM entry)

addresses changed but .nds can't run now..
maybe these parameters just change the addresses in header

#117369 - Sausage Boy - Sun Feb 04, 2007 10:24 am

It most likely doesn't work because your program thinks it's running from 0x02000000 anyways. You need to change that at some other place, if you're lucky it's in the Makefile, or maybe it's hidden somewhere deep in devkitARM. What are you trying to accomplish anyways?
_________________
"no offense, but this is the gayest game ever"

#117386 - alex_III - Sun Feb 04, 2007 4:13 pm

hope you can understand my english
i try to write a ds game trainer
the trainer have to run before ds game
actually i don't know how to do it..i am a rookie

i use devkitPro libnds to write a ds game trainer.
and add trainer to the end of ds game arm9
then from game's arm9 execute address jump to trainer
finally at the end of trainer jump back to ds game
so i want to know how to change trainer's arm9 execute address
or is there any better way to do it?

for example
02000800 b 02100000 ds game arm9 execute address
02000804
:
020FFFFC ds game arm9 end


02100000 trainer start
02100004
:
02110000 b 02000804 trainer end

#117399 - tepples - Sun Feb 04, 2007 5:11 pm

What you want to do is edit a copy of the link script so that your trainer code is linked to run from 0x02100000.

EDIT: clarification of what I meant, in bold
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.


Last edited by tepples on Sun Feb 04, 2007 6:37 pm; edited 1 time in total

#117405 - wintermute - Sun Feb 04, 2007 6:33 pm

tepples wrote:
What you want to do is edit the link script so that your trainer code is linked to run from 0x02100000.


No, you most definitely don't want to do that.

In the arm9 Makefile for your project (you are using one of the standardised templates aren't you) you need to edit LDFLAGS so it reads as follows.

Code:

LDFLAGS   =   -specs=ds_arm9.specs -Wl,--section-start,.init=0x02100000 -g $(ARCH) -Wl,-Map,$(notdir $*.map)


The address given can be anywhere in ewram.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog

#117409 - kusma - Sun Feb 04, 2007 6:50 pm

another simple solution would be to overwrite the first instruction of the application (the one at 02000000?) with a branch to an unused location. Then do your patching, and perform the original first instruction before branching back.

#117417 - alex_III - Sun Feb 04, 2007 8:05 pm

Code:

LDFLAGS   =   -specs=ds_arm9.specs -Wl,--section-start,.init=0x02100000 -g $(ARCH) -Wl,-Map,$(notdir $*.map)


It's working!!
thanks to everyone for helping!!!

#117475 - wintermute - Mon Feb 05, 2007 1:20 am

tepples wrote:
What you want to do is edit a copy of the link script so that your trainer code is linked to run from 0x02100000.

EDIT: clarification of what I meant, in bold


Marginally better but still no cigar.

The advantage of the approach I specified using linker flags is that it will still work even if the linkscript changes.

When I switched from arm-elf to arm-eabi tools several things changed in the linkscripts and the crt0 files and the old files were no longer compatible with the new toolchain. If future binutils updates require tweaks then using a copy of the old linkscripts will cause failures again.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog