2020-06-26 02:20 AM
Hello,
I try to construct a project but i don't achieve to do what i want.
My MCU is an STM32G070CB an I use MDK Essential 5.28 (Flex) Version: 5.28.0.0 with Compiler V6.12.
I explain my need :
In my projet, my memory space is coomposed of a boot part and an application part.
The two parts are independant Keil projets. It' OK for us and mastering this point.
I must optimize flash mamory space and we have common part of code beetween boot part and application part.
So, I've create an other keil project to generate a .Lib of common code part.
Il this .Lib, i've created a struct containing pointer of all public functions of my .lib.
I add this Lib in my boot keil project (considering the boot part will package this lib in the output).
I've create scatter file to have space for boot part and space for Lib space.
My problem is to put my struct defined in my .lib (containing pointers on lib functions) into flash, at start of section dedicaded to my lib memory part.
In my lib project, i've defined my struct something like :
static const t_LibHeader s_LibHeader __attribute__((section("myLibSect"),used)) = {
myLibPointerA,
myLibPointerB,
}
In my scatter file of boot project i've defined something like :
LR_IROM2 LIB_ROM_BASE LIB_ROM_SIZE { ; Lib region size_region
ER_IROMHEADER LIB_ROM_BASE LIB_ROM_SIZE/2 { ;
lib.o (myLibSect, +RO)
}
ER_IROM2 +0 LIB_ROM_SIZE/2 { ;
moduleA.o (+RO)
moduleA.o (+RO)
}
RW_IRAM2 RAM_BASE+RAM_SIZE LIB_RAM_SIZE { ; RW data
moduleA.o (+RW +ZI)
moduleA.o (+RW +ZI)
}
}
I've also add "--keep=Lib.o(myLibSect)" in the linker misc ctontrols of my boot project.
The result I currently have at build is :
.\project\project.sct: Warning: L6319W: Ignoring --keep command. Cannot find section Lib.o(myLibSect).
.\project\project.sct(99): warning: L6314W: No section matches pattern lib.o(RO).
I already have put a struct in Flash using specific section, scatter file and --keep linker diretive inside a keil project for an other need and it work's.
The difference I have is that in my previous exprerience, my file containing data structure was compiled by my keil project, no comming from a pre-compiled lib.
How can i store my struct in flash were i wan't ? Is there an oher way ?
Best regards,
2020-07-02 03:07 AM
I've resolve himself with a hack.
I've just declared my const data in a .h instead of a .c.
Then i've include this .h in my boot part.
myLibSect symbol is now viewed by the linker and my data correctly embedded where i want.