Bootloader from XMC4500 to XMC4800

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

cross mob
User12223
Level 2
Level 2
First solution authored
Hi,

I have successfully created a new project on my XMC4800 based on a similar project for my XMC4500.
I previously created a bootloader that writes my main application to flash memory by transferring the binary file, using 1K Xmodem protocol via UART, to the XMC4500.

I am "simply" trying to port this existing bootloader project to my new XMC4800 processor.
I first thought it would be as simple as remapping memory locations, but as this didn't seem to work, I have tried all sorts. Now I need your help.

My working, existing program makes use of the ABM0 functionality. The program is in line with the Reference Manuals...
• Program flash with application and ABM header
• Drive TCK and TMS to launch Normal boot mode
• Configure STCON.SWCON per Table 27-2
• Clear Reset Source in SCU.RSTSTAT using the register RSTCLR.RSCLR
• Issue a system reset

I have played around with storing the ABM header in a fixed address, the last 32 bytes of the first 64 KB physical sector. I have stored the header in the last 32 bytes of the next 64 KB physical sector. I have stored the header in all types of place.

I have used my debugging tool to ensure the application is written to my desired start address. I could also see that my ABM0 header was being correctly written.
To inform that the transfer has been successfully completed, I display the CRC32 and the application length stored in the ABM0 header memory address.

As mentioned, the bootloader works on my XMC4500, however, when trying to recreate the bootloader for the XMC4800, something has gone wrong.
A difference between the 2 processors is the size of the flash memory, though, as my application is only 3kb, I did not think this to be relevant, based on the similarities on the Reference Manuals, and used the same starting addresses.

I am not really getting anywhere and I am unsure of where I have gone wrong, any thoughts of where or what I've missed/done wrong?

Any help would be appreciated.

Thanks,

Steven
0 Likes
1 Solution
User12223
Level 2
Level 2
First solution authored
Hi,

I have managed to solve the issue. I had to add the following to the linker script...

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

These address ranges are specific to my application, but are still fairly generic.

I am not sure it said this in the Reference manual, though I may have overlooked it.
Adding this to the linker file fixes the flash address of ABM header inside linker script to last 32byte of the first 64KB, where the ABM0 header exists.

Thanks for all the help though, I really appreciate the support.

Thanks,

Steven

View solution in original post

0 Likes
5 Replies
User12223
Level 2
Level 2
First solution authored
Hi,

I have been working day and night to solve this but am no closer, I have ruled out a few possibilities though.

I have compared transfer on both processors, ruling out transfer.
I have compared data at specified memory addresses, ie start addresses and ABM0 header address, ruling out storage.

This leaves me to think that after doing a SSW reset, the XMC4800 is not starting from my start address.
I have confirmed the ABM0 header is expected and followed the guidance in the reference manual.

I am running out of ideas on what else to try, can any one else point me in the right direction?

Thanks,

Steven
0 Likes
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked
Hi Steven,

What is happening to the control when you are working with XMC4800 ? Is it moving to diagnostic monitor mode ? What is the status of SCU_TSW0 register on failure? What is the error code you are getting?

See table Table 27-5 Error events and codes in the reference manual.

Best Regards,
Vasanth
0 Likes
User12223
Level 2
Level 2
First solution authored
Hi Vasanth,

The control of the XMC4800 is as expected until the SSW reset. Once the application and ABM header have been successfully flashed, the following is called (as per existing XMC4500 bootloader and example project)...

1)
/* Restart in alternative bootmode 0 */
/* Clear the reset cause field for proper reset detection of the ssw */
XMC_SCU_RESET_ClearDeviceResetReason();

2)
/* Set ABM0 as boot mode in SWCON field of STCON register */
XMC_SCU_SetBootMode(XMC_SCU_BOOTMODE_ABM0);

3)
/* Trigger power on reset */
PPB->AIRCR = 1 << PPB_AIRCR_SYSRESETREQ_Pos |0x5FA<
However, after the SSW reset (3), debug is lost to the processor. Due to this, I am unsure of the memory address the processor restarts or if an error occurs.
This also means I cannot check the SCU_TSW0 register or the error code.

Am I doing anything wrong?

Thanks,

Steven
0 Likes
User12223
Level 2
Level 2
First solution authored
Here is a more detailed description of my bootloader.

It is running FreeRTOS with 2 Main threads.
Thread 1 - wait 10 seconds. If not bootloader mode not entered, SSW reset and startup from ABM0
Thread 2 - Wait for user to enter bootloader mode. If entered bootloader mode, transfer application using 1K Xmodem protocol via UART. After, SSW reset and startup from ABM0.

Below are the main snippets of the code, though if easier I am happy to pass on the project...

Thanks,

Steven




#define ABM_HEADER_MAGIC_KEY 0xA5C3E10FU

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 */
uint32_t Dummy[3];
} ABM_HEADER_t;

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

CRC32_INFO_t *pCRCInfo = (CRC32_INFO_t *)FLASH_CRC32INFO_ADDRESS; // Get where the CRC32 information


int main (void)
{
DAVE_STATUS_t init_status;

init_status = DAVE_Init(); /* Initialization of DAVE APPs */

if(init_status == DAVE_STATUS_SUCCESS)
{
// Have we got a valid image
bImageValid = CalculatetValidateImage(eValidateCRC32);

start_rtos_entities();

vTaskStartScheduler();
}
}


Thread 1
void vStartMainAppCallback( void * pvParameters)
{
for( ;; )
{
vTaskDelay(10 Seconds);

if( !bBootMode )
{
// Not in bootload mode and have an valid image.
XMC_SCU_RESET_ClearDeviceResetReason();
XMC_SCU_SetBootMode(XMC_SCU_BOOTMODE_ABM0);
PPB->AIRCR = 1 << PPB_AIRCR_SYSRESETREQ_Pos |0x5FA< }
}
}


Thread 2
void RxCommsTask( void * pvParameters)
{
for( ;; )
{
if ( XMODEM_RxTrigger() )
{
bBootMode = true; // Indicate that we have entered bootload mode

if( XMODEM_ReceiveFile() )
{
// Write the information to flash memory (CRC32, Start address, file lengths and number of blocks)
crc32Info.start = (uint32_t) 0x0C0FFF00UL;
crc32Info.crc32 = CalCRC32;
crc32Info.blockcnt = block_num;
crc32Info.length = block_num * 1024;
writeCRC32InfoFlash();

// File transfer successful start the main application.
XMC_SCU_RESET_ClearDeviceResetReason();
XMC_SCU_SetBootMode(XMC_SCU_BOOTMODE_ABM0);
PPB->AIRCR = 1 << PPB_AIRCR_SYSRESETREQ_Pos |0x5FA< }
}
}
}


void writeCRC32InfoFlash()
{
memset (flashCRC32InfoPage, 0, 1024);
memcpy (flashCRC32InfoPage, &crc32Info, sizeof(CRC32_INFO_t));

// Erase the last sector if not done
XMC_FLASH_ErasePhysicalSector(XMC_FLASH_PHY_SECTOR_15);

XMC_FLASH_ProgramPage((uint32_t *)((uint32_t)0x0C010000UL), (uint32_t *)crc32Info);
}
0 Likes
User12223
Level 2
Level 2
First solution authored
Hi,

I have managed to solve the issue. I had to add the following to the linker script...

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

These address ranges are specific to my application, but are still fairly generic.

I am not sure it said this in the Reference manual, though I may have overlooked it.
Adding this to the linker file fixes the flash address of ABM header inside linker script to last 32byte of the first 64KB, where the ABM0 header exists.

Thanks for all the help though, I really appreciate the support.

Thanks,

Steven
0 Likes