#43081 - LOUD NOISES - Wed May 18, 2005 9:54 pm
I'm trying to store some information in the EWRAM and I'm running into trouble. Whenever I declare a variable stored in EWRAM the compile takes about 5 times as long as normal and produces a 24 MB file. I'm declaring the variable like so
static unsigned char grid[192][256] __attribute__ ((section (".ewram"))) = { 0 };
Any ideas?
#43091 - tepples - Thu May 19, 2005 12:02 am
Try this first:
Leave off the " = { 0 }" at the end of the declaration.
If that doesn't work:
Using the section ".ewram" will cause the compiler to actually copy the array into the binary. If you just want a big zero-filled array, try putting it in a section that the linker script considers zero-filled and destined for the Nintendo DS's 4 MB EWRAM. Try the names ".bss" or ".sbss"; I haven't read the Nintendo DS link script myself, but extrapolating from the GBA link script and what I've read in this section, one of those should work.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#43102 - LOUD NOISES - Thu May 19, 2005 2:43 am
Using the section ".sbss" seems to be working perfectly. Thanks for your help.
#43147 - tepples - Thu May 19, 2005 2:53 pm
".bss", or "block storage section", is the name of a memory section used by the linker. Like ".data", it is writable, but unlike ".data", the contents of ".bss" are not stored in the executable; rather, they're zero-filled before the startup code calls main().
".sbss", or "second block storage section", is a term referring to a second zero-filled section on some platforms, similar to ".bss" and usually in a larger, slower area of memory. For instance, on the Game Boy Advance, ".bss" goes in IWRAM (32 KB, 32-bit, 0 wait state), and ".sbss" goes in EWRAM (256 KB, 16-bit, 2 wait states unless overclocked through an officially undocumented register).
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#43148 - Mollusk - Thu May 19, 2005 2:58 pm
Ok, thanks a lot ! It's really clear now for me :)
#43169 - LOUD NOISES - Thu May 19, 2005 7:44 pm
Oh wait, that's 48 kb. That must explain the problem with IWRAM.