Hello,
I am trying to define an RAM area that should not be initialized by the C library init function. I found an old thread about that (http://www.keil.com/forum/11937/) but the proposed solution does not work.
I use a scatter file that define the section like that :
RW_BOOTLOADER 0x10000020 UNINIT 0x0000FFE0 { *.o (Bootram) *.o (Bootstack) }
I try to define the area in assembly code or also in C code by :
BLStackSize EQU 0x00004000 AREA Bootstack, NOINIT, READWRITE, ALIGN=3 BLStackMem SPACE BLStackSize BLStackTop
U32 __attribute__((section("Bootstack"),zero_init)) Bootstack[0x1000];
In any case I get the following result in the map file :
Execution Region RW_BOOTLOADER (Exec base: 0x10000020, Load base: 0x0001ef14, Size: 0x00005030, Max: 0x0000ffe0, ABSOLUTE, UNINIT, COMPRESSED[0x00000024]) Exec Addr Load Addr Size Type Attr Idx E Section Name Object 0x10000020 COMPRESSED 0x00001030 Data RW 328 Bootram fiveco_bootloader.o 0x10001050 - 0x00004000 Zero RW 329 Bootstack fiveco_bootloader.o
My understand is that any zero init or uninit area in any section with UNINIT keyword should not be initialized by the C lib as explained in www.keil.com/.../armlink_pge1362075670305.htm
But tests with standard lib (or microlib) with Keil toolchain 5.24.1 show always an initialization by __scatter_zi.o object.
What is wrong in my approach ??
Many thanks by advance ! Antoine
Hi Robert,
Your understanding is nearly correct. Bootram and bootstack are used in a pre-main code et are no more used in main code. It is why the two regions can overlap and so, yes I now what I do when I turn error L6221E to a warning.
But since the initialization is done by the call to __main function of Keil lib, the bootram and bootstack are not initialized at startup because I use them before that call.
It is so why I do not want them to be initialized by the lib, since they are no more useful at that time.
So, in your points : 1) Yes, but it is done by my code and not by the lib. 2) Yes, it is correct before main code. But it is initialized later when calling __main and it is what I try to avoid. 3) Yes and overlap is under control. 4) It is not relevant for my problem, but to be clear, since their is 3 regions with .ANY, this force the linker to put file_config object in this one (due to limitations of NXP LPC RAM architecture).
I hope that I am clear.
Thanks. Antoine
It sounds like you might need to overlay directive
http://www.keil.com/support/docs/3723.htm
That helps some.
1) Yes, but it is done by my code and not by the lib.
OK, you initialize Bootram yourself, but when __scatter is called (as part of calling __main) it seems like it will will be initialized again.
2) Yes, it is correct before main code. But it is initialized later when calling __main and it is what I try to avoid.
It appears as if you are doing it correct such that Bootstack will not be zero initialized and Bootram will be re-initialized when __main is called. Please just verify that BootRam is being initialized and that even though I think Bootstack should not be initialized to 0, it is being initialized to zero. (obviously if you are still using that stack, having it set back to zero is an issue)
Only ZI data in UNINIT sections remain un-initialized, however any RW data in the UNINIT section does get initialized.
Everything posted so far addresses how to make a Zero Init section to not initialize. It explains why if your Zero Init data gets optimized into a RW region that even though you said it should not be initialized, it will still be initialized.