Filling non-contiguous MEMORY blocks
Christophe Lyon
christophe.lyon@linaro.org
Tue Sep 2 08:44:27 GMT 2025
Hi,
On Tue, 2 Sept 2025 at 10:31, R. Diez via Binutils
<binutils@sourceware.org> wrote:
>
> Hi all:
>
> I have an STM32F407VGT6 microcontroller with several non-contiguous MEMORY blocks: SRAM1, SRAM2, SRAM3 and SRAM CCM (core coupled memory). It would be nice if the linker could automatically fill one after the other with data sections (I am simplifying some hardware restrictions).
>
> The flash memory layout is also weird. The interrupt/boot vector must be on the first flash sector, the next flash sectors are also small, but from a particular sector number, the flash sectors are much bigger. Ideally, you want to fill the first sector with the vector table and then some text sections (executable code), then skip a few small flash sectors where you want to store user configuration data, and afterwards continue filling the big flash sectors with the rest of the text sections.
>
> Is there a way to tell the linker to fill a MEMORY block, and, when it's full, continue filling another MEMORY block?
>
> I am doing this manually now, which is a pain and wastes space.
Have you tried the linker option --enable-non-contiguous-regions ?
(and maybe --enable-non-contiguous-regions-warnings, to detect
potential problems?)
IIUC your need, they were designed for this kind of use-case.
Thanks,
Christophe
>
> I also have an STM32G0B1RET6 microcontroller with a hardware bug (errata) which triggers when the CPU crosses flash banks when executing code. Therefore, you want to leave an unused space in the middle of flash (between flash banks).
>
> I haven't found a way to tell the linker to leave a particular address range unused, or to place a particular section at a particular address, so that other sections are placed either before or after that area in a MEMORY block. Or have I missed something?
>
> One way to achieve that would be to define two MEMORY blocks for the Flash memory, but then I would have the same problem as described above: how to tell the linker to continue placing sections in the second Flash block when the first one is full.
>
> Thanks in advance,
> rdiez
>
More information about the Binutils
mailing list