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 > Max size of sources ? => Dev' env' pb => please help

#46641 - Herve13 - Tue Jun 28, 2005 3:35 pm

Hi all,

I'm trying to put a gnu project to the NDS.
Compiling went fine, but linking raise problem :


e:\ndsdev\devkitarm\bin\..\lib\gcc\arm-elf\3.4.4\..\..\..\..\arm-elf\bin\ld.exe: address 0x9440c8 of new.elf section .data is not within region dtcm



file sources are > 7Mo
and .o files are > 5.5 Mo


may it be the problem ?
does any workaround exist ?

TIA

Herve


Last edited by Herve13 on Wed Jun 29, 2005 10:36 am; edited 2 times in total

#46644 - strager - Tue Jun 28, 2005 4:15 pm

What are you trying to do? Define large arrays?

If so, define them as const. Elsewise, they will try to be copied to DTCM or EWRAM[2] or IWRAM, which is not what you want, is it?

There could be some other problem. And why in the world do you have 7MB source files?!!? That I do not understand...

#46646 - gladius - Tue Jun 28, 2005 4:17 pm

Currently, the DevkitArm compiler puts all variables and static arrays into the DTCM region, which is only 32Kb. So if your program has more than 32Kb of variables+arrays declared (note, arrays that are malloc()'ed are okay) then you will get that error.

You can work around this by adding EWRAM_BSS to the end of any uninitialized variables that are not speed critical, so they will be put into main ram. If they are initialized, use VAR_IN_EXRAM. So something like this:

u8 array[0x1000]; <-- original
u8 array[0x1000] EWRAM_BSS; <--- new

u32 values[0x10] = {0,0,0,0...}; <-- original
u32 values[0x10] VAR_IN_EXRAM = {0,0,0,0...}; <---new

As a side note, the combined size of the code across your arm7&9 must be less than 4 megabytes using the current loader method.

#46647 - Herve13 - Tue Jun 28, 2005 4:43 pm

Thanks for your answers !

strager : that's not my code !
So, I can't explain why there are so much code !!!

The larger files define static struct objects, and initialize them.
And I can't add the directives EWRAM_BSS or VAR_IN_EXRAM : it doesn't compile !!!

I'm usiong devkitarm12 and mingw to compile
(and I'm able to compile a lot of others projects)


Could it be because there are a lot of static functions/objects ?
I'm not really an expert on such topics...

#46652 - MrAdults - Tue Jun 28, 2005 5:32 pm

The way I'm currently dealing with this is by modifying ds_arm9.ld to move data into ewram, and explicitly defining what goes into dtcm (this is not necessary to make things operational, and is only done for the sake of performance on critical data). I recommend taking this approach if you are porting a project that is at all large-scale.

-Rich

#46711 - Herve13 - Wed Jun 29, 2005 7:39 am

Someone told me to put the extra word EWRAM_DATA infront of my variable declarations :
EWRAM_DATA struct john doo0[] = {
{722,1}, {795,2}, {684,2}, {758,0},
{759,0}, {796,0}
};


For him, it compiled fine on his development environment.
but not for me !!!

I'm using last devkitpro/arm/ppc/ndslib/mssys versions.
But when I compile, it says :

c:/devkitpro/projects/project/arm9/sgf/patterns.c:27: error: syntax error before "struct"


any help ?

#46720 - strager - Wed Jun 29, 2005 3:17 pm

Herve13 wrote:
Someone told me to put the extra word EWRAM_DATA infront of my variable declarations

You must put them after the array name and count, but before the = {...}. That might fix the error.

#46721 - Ethos - Wed Jun 29, 2005 3:43 pm

1) declare predefined arrays as const

2) if you are using global arrays...do not allocate space on the stack, use malloc to allocate space on the heap
_________________
Ethos' Homepage (Demos/NDS 3D Tutorial)