Announcements

Help us improve the Power & Sensing Selection Guide. Share feedback

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

cross mob
User13153
Level 1
Level 1
Hello,

if I use the Bootloader IAP XMC47 example without any optimization it works properly.
But if I use any optimization level the abm header is no longer available.

Optimization (-Os / -O1)

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


These are the intersting defines:

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
};


linker_script.ld:

MEMORY
{
FLASH_1_cached(RX) : ORIGIN = 0x08000000, LENGTH = 0x200000
FLASH_1_uncached(RX) : ORIGIN = 0x0C000000, LENGTH = 0x200000
PSRAM_1(!RX) : ORIGIN = 0x1FFE8000, LENGTH = 0x18000
DSRAM_1_system(!RX) : ORIGIN = 0x20000000, LENGTH = 0x20000
DSRAM_2_comm(!RX) : ORIGIN = 0x20020000, LENGTH = 0x20000
SRAM_combined(!RX) : ORIGIN = 0x1FFE8000, LENGTH = 0x58000
}

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


Are there any hints preventing the abm header against optimization?
Thank you.

regards,
TestJoe
0 Likes
2 Replies
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
Hi,

Please try defining ABM0_Header as:

static const ABM_Header_t __attribute__((section(".flash_abm"), used))
ABM0_Header = {
.MagicKey = ABM_HEADER_MAGIC_KEY,
.StartAddress = 0x08010000, /* Start Flash Physical Sector 1 */
.Length = 0xFFFFFFFF,
.ApplicationCRC32 = 0xFFFFFFFF,
.HeaderCRC32 = 0xE176A4E6
};


Regards,
Jesus
0 Likes
User7921
Level 3
Level 3
Hi Jesus,

I know this thread is pretty old, but I ran into a similar problem.

My application matches your ABM Header exactly. App is starting at 0x08010000. The Bootloader is located at 0x08000000.

You've been mentioning a CRC of 0xE176A4E6.


ABM0_Header = { .MagicKey = ABM_HEADER_MAGIC_KEY, .StartAddress = 0x08010000, /* Start Flash Physical Sector 1 */ .Length = 0xFFFFFFFF, .ApplicationCRC32 = 0xFFFFFFFF, .HeaderCRC32 = 0xE176A4E6};
I'm good with that, but I fail to calculate the CRC using any of my CRC32 functions. Even when using the XMC FCE unit.

Could you please give me a hint how to set up the XMC's internal unit to calculate the CRC for the first 4 uint32 values of the above header so that the result is 0xE176A4E6?
Or any function to calculate it correctly?

Any help is highly appreciated.

Michael
0 Likes