I'm quite confused when it comes to alignment.
I opened linker script to make some modifications, so that I can fit two binaries into flash. (Relatively new to embedded, but frankly I learn fast).
I use stm32f091Rx. Which has 256kB of flash memory.
A little about my plan to implement Over the Air update:
1. 4kB- bootloader.
2. 2KB- placeholder (I want to keep a place holder on flash to jump to specific application., so bootloader know where to jump next in the next reboot).
3. 100kB - Application v1.
4. 100kB - Application v2.
Originally bootloader always jump to 0x0800000 which is hardcoded in bootloader.
And in my project, the bootloader don't do the update, but the application does the OTA and then save the new location in the placeholder (2 in the above flash schematic).
1. I want to place the header of the firmware. Where is the best place? (at the beginning, how to manage without vector table) or (at the some place at the end?)
2. What is the purpose of alignment? I had written ALIGN 2048, So that the start address of the header is divisible by 2048 and beginning of the page.
But why do I want it? What if I not do it?
What is the difference between using the above statement vs just using __attribute__((section("MAMBA"))); after the variable definition and then placing mamba in a specific section?
4. ABSOLUTE keyword in scatter file is default. So what is FIXED? If I want to do FOTA update do I need to make some modifications?
Usually this is in front of vector table for example MCUboot uses that kind of layout.
If you put an absolute address which is already aligned, ALIGN attribute is not necessary.ALIGN attribute is usually used for aligning data sections if it is required.
This should produce the same result, so it is a matter of preference which way you do it.
You most likely do not need FIXED attribute.