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.

RM42L432: UAR Bootloader: Can't erase Sector, FMSTAT indicates secotor is locked

Part Number: RM42L432

Hello, 

I'm using the bootloader as described in theapplication note spna188. 

So far I made no changes to the provided firmware, other than some basic confiogurations to adapt it to my custom board. 

The problem is that it gets stuck while trying to erase sector 0.

This is the relevant part of the code: 

-----------------------------------------------------------------------------------------------------------
Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, eraseStartAddr); while( FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy ); FAPI_GET_FSM_STATUS; while(FAPI_GET_FSM_STATUS != Fapi_Status_Success);
-----------------------------------------------------------------------------------------------------------

The call to  FAPI_GET_FSM_STATUS always returns 0x11, indicating that the sector is locked. 

Here is my linker file: 

---------------------------------------------------

--retain="*(.intvecs)"

MEMORY
{
    VECTORS    (X)   : origin=0x00000000 length=0x00000020
    FLASH_API  (RX)  : origin=0x00000020 length=0x000014E0
    FLASH0     (RX)  : origin=0x00001500 length=0x0005EB00   
    SRAM       (RW)  : origin=0x08002000 length=0x00006000  
    STACK      (RW)  : origin=0x08000000 length=0x00002000
}
SECTIONS
{
   .intvecs : {} > VECTORS
   flashAPI :
   {
     
      bl_flash.obj (.text)

     --library= ..\F021_API_CortexR4_LE.lib < FlashStateMachine.IssueFsmCommand.obj
                   FlashStateMachine.SetActiveBank.obj
     	           FlashStateMachine.InitializeFlashBanks.obj
     		   FlashStateMachine.EnableMainSectors.obj
     		   FlashStateMachine.IssueFsmCommand.obj
     		   FlashStateMachine.ScaleFclk.obj
                   Init.obj
                   Utilities.CalculateEcc.obj
                   Utilities.WaitDelay.obj
                   Utilities.CalculateFletcher.obj
                   Read.MarginByByte.obj
                   Read.Common.obj
                   Read.FlushPipeline.obj
                   Read.WdService.obj
                   Async.WithAddress.obj
                   Program.obj > (.text)
   } load = FLASH_API, run = SRAM, LOAD_START(api_load), RUN_START(api_run), SIZE(api_size)

   .text  > FLASH0
   .const > FLASH0
   .cinit > FLASH0
   .pinit > FLASH0
   .data  > SRAM
   .bss   > SRAM
}


Are there any extra steps to unlock the secors? 

Thanks a lot for your help!

  • Hello,

    Your code is located in sector 0, and exception vector used by your code is also located sector 0. The code except for F021 flash APIs is executed from flash. So you can not erase the sector 0.  

    Can you change the application start address?

  • Thanks QJ

    Turns out I made a mistake in reporting the problem. 

    My application start adress is set to 0x00020000 (Sector 13) and the bootloader tries to erase sector 13 (not 0 as reported previously).

    After looking into the issue a bit more I figured what the problem is. 

    The API call to enable the sectors was only enabling the first 8 sectors. 

    Using this call: 

    Fapi_enableMainBankSectors(0xFFFF);        /* used for API 2.01*/
            

    resolved the iussue :-)

    Thanks 

    Günter

  • It's good to know you have solved the problem.