This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to mark that bootload should be performed?

Hi.

I am currently working on the CAN bootloader which is based on the TI CAN bootloader as available from TI website. I have the bootloader up and running and able to perform bootload. However, I am in a bit of a struggle to figure out a good way how to indicate that a bootload should be performed on next startup. The physical pin option as in the TI example does not suit the application.

I thought that I could just scramble the "verification" code in the flash for the bootloader, but I seem to be having some problems doing that from the application code. In the application I use the F021 library to read and write to the EEPROM bank of the MCU, So I thought that it might be simple to just switch from the eeprom bank (7) bank to the flash bank (0). However, when I try to do this it generates undefEntry interrupt.

So I have two options: 1) Solve the issue with the main program flash access 2) Find another way how to notify the bootloader that bootload should be performed. I would appreciate help with either of the options.

static Fapi_StatusType set_active_flash_btl_sector (void)
{
    Fapi_StatusType set_active_sectors_status = Fapi_Status_Success;
    set_active_sectors_status = Fapi_setActiveFlashBank(BOOTLOAD_FLASH_BANK); //BOOTLOAD_FLAS_BANK=Fapi_FlashBank0
    if (Fapi_Status_Success == set_active_sectors_status)//never comes here the Fapi_setActiveFlashBank causes to go to undefEntry interrupt vector
    {
        set_active_sectors_status = Fapi_enableMainBankSectors((uint16_t)((uint16_t)1U << BOOTLOAD_FLAG_SECTOR));    //BOOTLOAD_FLAG_SECTOR=13
    }
    if (Fapi_Status_Success == set_active_sectors_status)
    {
        while (FAPI_CHECK_FSM_READY_BUSY != Fapi_Status_FsmReady)
        {
        }
    }
    return set_active_sectors_status;
}

Using TMS570LS033x MCU.

Thanks,

Ringolds

  • A common method is to save a key value in a known location in main Flash or EEPROM bank. At startup, the bootloader will check the value at this location and make the dcision based on the value read back.

    Before accessing the EEPROM bank, you need to setup wait state correctly. It has separate configuration registers. You cannot execute code from EEPROM bank.

    Thanks and regards,

    Zhaohong
  • Hi Zhaohong,

    As I mentioned I am already using a flag value in Flash (last program flash sector). And in the main application that I am successfully bootloading to the target with the bootloader I want to modify this value. I am storing the flag value in flash as I am using EEPROM for other purposes thus I would not like to put it there. I have the EEPROM access set up and working in the bootloaded application. However as I mentioned every time when I try to exectute the function that i posted in my original post the MCU generates "Undefined Instruction Interrupt". This interrupt is caused from somewhere within F021 api when calling the Fapi_setActiveFlashBank function and setting the flash bank to bank 0. I have no idea why it is behaving in such way though.Any suggestions would be appreciated.

    Ringolds.

  • I think I found out the problem myself.

    The F021 Flash API library cannot be executed from the same bank as the active bank
    selected for the API commands to operate on. On single bank devices, the F021 Flash API
    must be executed from RAM.