Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 7483

General • Assigning a variable to section in PSRAM

$
0
0
I'm trying to create a global variable in a memory section which points to external PSRAM (0x11000000). I have done this by creating a new section in the ld script after .binary_info:

Code:

    .extram (NOLOAD) : {        . = ALIGN(4);        __extram_start__ = .;        *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.extram*)))        . = ALIGN(4);        __extram_end__ = .;    } > EXTRAM
And then utilizing it in the code:

Code:

uint8_t audio_buffers[2][AUDIO_BUFFER_SIZE * REPETITION_RATE * 2U] __attribute__ ((section(".extram"))) = {0};
The problem with this is that it also allocates into .bss. I can see this when I use `size build/elf.elf`. If I make it larger than the internal memory it complains:

Code:

/home/x/memmap.ld:250 cannot move location counter backwards (from 2013e32c to 2007e000)
However, if I run with a size which fits, then in the debugger I can see that it appears at the correct address in the external memory. So it apparently gets allocated twice, once in .bss and again in .extram. I'm not sure how to prevent this.

Statistics: Posted by empathicqubit — Tue Oct 29, 2024 9:29 am — Replies 0 — Views 19



Viewing all articles
Browse latest Browse all 7483

Trending Articles