+ Reply to Thread
Results 1 to 6 of 6

Thread: Bootloader from XMC4500 to XMC4800

  1. #1
    Beginner Beginner Steven M is on a distinguished road
    Join Date
    Sep 2016
    Posts
    19
    Points
    145

    Bootloader from XMC4500 to XMC4800

    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

  2. #2
    Beginner Beginner Steven M is on a distinguished road
    Join Date
    Sep 2016
    Posts
    19
    Points
    145
    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

  3. #3
    Advanced Advanced
    Infineon Employee
    Infineon Employee
    Vasanth is on a distinguished road
    Join Date
    Nov 2020
    Posts
    67
    Points
    1380
    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
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

  4. #4
    Beginner Beginner Steven M is on a distinguished road
    Join Date
    Sep 2016
    Posts
    19
    Points
    145
    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<<PPB_AIRCR_VECTKEY_Pos | 0x1 << PPB_AIRCR_PRIGROUP_Pos;

    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

  5. #5
    Beginner Beginner Steven M is on a distinguished road
    Join Date
    Sep 2016
    Posts
    19
    Points
    145
    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<<PPB_AIRCR_VECTKEY_Pos | 0x1 << PPB_AIRCR_PRIGROUP_Pos;
    }
    }
    }


    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<<PPB_AIRCR_VECTKEY_Pos | 0x1 << PPB_AIRCR_PRIGROUP_Pos;
    }
    }
    }
    }


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

  6. #6
    Beginner Beginner Steven M is on a distinguished road
    Join Date
    Sep 2016
    Posts
    19
    Points
    145
    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

+ Reply to Thread

Tags for this Thread

Disclaimer

All content and materials on this site are provided “as is“. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.