On Fri, Mar 26, 2021 at 11:14 AM Gregory Nutt <spudan...@gmail.com> wrote:
> > Speaking of the linker, is there a way to use a combination of the
> > linker script and __attribute__ incantations in the code to detect
> > automatically the size that g_sram4_reserve should be and entirely
> > eliminate the need for the user to specify the start and end of each
> > region in Kconfig?
>
> Are you thinking of something like this in the linker script:
>
>     .sram4_reserve :
>     {
>        _sram4_reserve_begin = ABSOLUTE(.);
>        *(.sram4)
>        _sram4_reserve_end = ABSOLUTE(.);
>     }
>
> And in the C code:
>
>     #define SRAM4_RESERVE_BEGIN &_sram4_reserve_begin
>     #define SRAM4_RESERVE_END &_sram4_reserve_end
>
> The implied size depends on the size of all .sram4 sections.  I assume
> this would be positioned at the beginning of SRAM4 and the size of the
> region that could be added to the heap would be SRAM4_RESERVE_END
> through SRAM_END.


Yes, that's what I had in mind (but I didn't know what incantations
would do it).

So, if I understand correctly, anyone can declare a static buffer like this:

static uint8_t g_spi6_txbuf[SPI6_DMABUFSIZE_ADJUSTED]
SPI6_DMABUFSIZE_ALGN locate_data(".sram4");

and automatically the heap will not overlap it?

Nathan

Reply via email to