Using abm header with optimization

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User13153
Level 1
Level 1
Hello,

just trying to implement the example: USBD_MS_BOOTLOADER_IAP_XMC47
Without any optimization level it seems to be working on my XMC4800.

But if I'm using any of the given optimization levels, the abm header is no longer available.

lst-file:

With optimization (-Os)

Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00004744 08000000 0c000000 00008000 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 Stack 00000800 1ffe8000 1ffe8000 00018000 2**0
ALLOC
2 .data 000000b8 1ffe8800 0c004744 00010800 2**2
CONTENTS, ALLOC, LOAD, DATA
3 .bss 0000072c 1ffe88b8 0c0047fc 000108b8 2**2


No optimization

Sections:
Idx Name Size VMA LMA File off Algn
0 .text 000076dc 08000000 0c000000 00008000 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .abm 00000014 0800ffe0 0c00ffe0 00017fe0 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 Stack 00000800 1ffe8000 1ffe8000 00018000 2**0
ALLOC
3 .data 000000b8 1ffe8800 0c0076dc 00010800 2**2
CONTENTS, ALLOC, LOAD, DATA
4 .bss 0000072c 1ffe88b8 0c007794 000108b8 2**2


I think something needs to be protect if any optimization is active:

main.c:

#define ABM_HEADER_MAGIC_KEY 0xA5C3E10F

typedef struct ABM_Header {
uint32_t MagicKey; /**< Magic key. Always 0xA5C3E10F */
uint32_t StartAddress; /**< Start address of the programm to load */
uint32_t Length; /**< Length of the programm to load. */
uint32_t ApplicationCRC32; /**< CRC32 Sum of the complete application code */
uint32_t HeaderCRC32; /**< CRC32 Sum of the four fields before */
} ABM_Header_t;

static const ABM_Header_t __attribute__((section(".flash_abm")))
ABM0_Header = {
.MagicKey = ABM_HEADER_MAGIC_KEY,
.StartAddress = 0x08020000, /* Start Flash Physical Sector 8 */
.Length = 0xFFFFFFFF,
.ApplicationCRC32 = 0xFFFFFFFF,
.HeaderCRC32 = 0xEF423163 // for .StartAddress = 0x08020000
};


linker_script.ld:

.abm ABSOLUTE(0x0800FFE0): AT(0x0800FFE0 | 0x04000000)
{
KEEP(*(.flash_abm))
} > FLASH_1_cached


Thanks for any hints.

Regards,
TestJoe
0 Likes
1 Reply