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

General • Compiling code to specific ram section

$
0
0
Hello,

as a last resort I would like to relocate my IRQ handler to the sram4-7 section.
(short story long: I have a program for RP2350B, one of the cores is calculating a 240 rows of image data 25x / sec, and each line data - 65 words - is sent to a configured PIO using DMA.The other core is configured to handle GPIO interrupt and must respond immediately. But it sometimes fails to do so, I don't know why. My faint suspect is that in A2 the bus prio was not implemented properly: I have an A4 board and on it the interrupts and the screen are handled well. That will a separate post, btw... So now I would like to separate the two cores' data and code as much as possible...)


The code is anyway running from RAM (copy_to_ram) but I'm afraid that in my case it is not enough.
So far I've edited the {pico_sdk_root}\sdk\2.2.0\src\rp2_common\pico_crt0\rp2350\memmap_copy_to_ram.ld file and added the followings:

Code:

RAM4_7(rwx) : ORIGIN = 0x20040000, LENGTH = 256k
in the MEMORY block and

Code:

    .sram4_7 (NOLOAD) : {      . = ALIGN(4);      *(.sram4_7*)    } > RAM4_7
in the SECTIONS block.

In case I use the

Code:

__attribute__((section(".sram4_7")))
marker with a variable, then I can see that the variable is located in the 0x20040000-0x20080000 area (in the .elf.map file)

But how would I do that with function?

As a bonus, extra question: how to do that with an inline assembly which starts as

Code:

__attribute__((naked))void gpio_irq_handler_asm_a2(void) {    __asm__ volatile (        ".thumb\n"        ".syntax unified\n"        . . .

Statistics: Posted by dikdom — Sun Dec 21, 2025 2:54 pm



Viewing all articles
Browse latest Browse all 8041

Trending Articles