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 > Why large malloc (new) call fail on DS [FIXED]

#39714 - Darkain - Mon Apr 11, 2005 6:17 pm

I was playing around w/ the addresses that malloc returned:
Code:
0x02001010 - first malloc
0x020010C0 - class instance (new)
0x02001100 - buffer instance (malloc, 0x16000 bytes, end address 0x02017100, right thru MAIN and other functions)
0x02034FBB - ROM DATA1
0x02033ECB - ROM DATA2
0x0200811C - MAIN function pointer


I was wondering why using malloc (or new which calls malloc) was failing for anything that was about 12kb or larger.

malloc starts allocating things at offset about 0x1000, and the ARM9 bin is copied to an offset of 0x4000. Because of this, we are limited to 12kb of RAM before we start over-writing the code segment copied into RAM.

i'm no expert on how the crt0 is setup for the ARM9, but *something* has to change. if the starting address for memory allocation has to be static, at least make it at offset 0x100000, which is exactly 1MB into RAM. this would allow for 1MB ARM9.bin, 2.5MB for RAM, and 512KB for ARM7.bin


[EDIT]
http://cvs.sourceforge.net/viewcvs.py/devkitpro/buildscripts/dka-crtls/ds_arm9.ld
Thanx to WntrMute, the bug is now gone. There should be no more problems with malloc/new (untill you try to use more than 3.5MB of RAM :P)
_________________
-=- Darkain Dragoon -=-
http://www.darkain.com
DarkStar for Nintendo DS

#40417 - Pacifist - Mon Apr 18, 2005 8:49 pm

I appologise for not knowing what the hell I'm doing but:

I'm having problems with this 12 kb memory limit and would love to use the fixed linker script provided to fix it. Unfortunately I don't know what linker scripts are or what to do with them.

Does anyone feel like coddling the noob? it would be much appreciated.

#40439 - wintermute - Mon Apr 18, 2005 10:08 pm

copy the file over the ds_arm9.ld found in <path to devkitARM>/arm-elf/lib

done :P

#40443 - Pacifist - Mon Apr 18, 2005 10:13 pm

So simple yet so baffling for the clueless.

thank you a great deal!