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.

boot loader flash-3

Other Parts Discussed in Thread: TMS570LS3137

7776.assembly 0x8000aec fail for Flash access.zipWe are developing the bootboader based on TI F021 API functions. My current test code tries to erase a section and them program.

 

I can get

F021_InitializeBanks( ), and F021_ActiveBank_EnableSectors() and   F021_SectorErase()  without error status.

 

However after that, during F021_Erase_Check( ), the code flies away.

          while( (bytes > 0) )

 {    if(*dst1++ != 0xFFFFFFFF)                          

{      error = 2;      }

  bytes -= 0x4;

 }

Step into the asembly of section above, it flies at  instruction LDR R5, [R5] when R5 is 0x00060000, the starting sector address, the flash access.

 

I attached my linker configuration, map file and flash register value. The devlopment system is IAR.

Just want to see if my register setting or configuration is not correct to make this happen. Thanks,

  • Hi Huichun,

    Can you please let us know what is the device you are using?Also, when you mention that the code flies away, you mean you get any aborts or the device hangs in a lockup state or something ? Can you let us know the exact behavior so that it is easy to understand more about the problem

    Regards,
    Praveen

  • Device: TMS570LS3137

    when it tries to execute that assemly command, it goes to the abort handler.

  • Hello Huichun,

    Can you check if there are any MPU settings in your code that is configured for the flash area? If you have configured the MPU, can you share the MPU settings?

    Regards,
    Praveen

  • 5857.tms570ls3137_cstartup.s

    1

    A little update, with the attached startup code, which is the modified one based on the default one from IAR. (I need to commend out the section), I can pass the previous issue. (the flash access *dst1  in Erase_Check()). Is it do-not-care item or necessary? Is there a separate template of bootloader start up code?

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

            ; this section is commented out otherwise flash can not be accessed,

            ;Auxiliary control register, these are listed similiar as cp15.s

     //       MRC p15, #0,r1,c1,c0,#1                     ; Read Auxiliary control register

     //      ORR r1, r1, #0x02000000                     ; Bit25 is ATCM ECC check enable

      //      MCR p15, #0, r1, c1, c0, #1                 ; Write Auxiliary control register

            nop

            nop

            nop

      //      MRC p15, #0,r1,c1,c0,#1                     ; Read Auxiliary control register

      //     ORR r1, r1, #0x00000001                     ; Bit0 is ATCM external error into CPU enable

      //      MCR p15, #0, r1, c1, c0, #1                 ; Write Auxiliary control register

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

     However, on ARM reference manual, we do have c6, MPU Region Access Control Registers. Do we need make any change of that one?

    2

     I am working in the IAR debug mode, after power up, if  comment out the section above, the flash default is 0xFFFFFFFF. I can fill in the flash with others before main, close the memory window and after erase to see if it is working. However it can pass SectorErase() with successful status, but in Erase_Check( ) I can see it is not 0xFFFFFFFF. If there anything wrong with my test method in the debug mode? Or any special setting for flash access in debug mode. In which condition, it shows flash erase status successful, but actually not.

     

    3

    Since I know It is power up default is 0xFFFFFFFF, so I do not open the memory window and check erase successful or not, but program. It is stuck at while(FAPI_GET_FSM_STATUS != Fapi_Status_Success); in BlockProgram( ).  What issue can cause flash erase stuck here.

     

    4

    I assume the flash contents should be there after power down. However after power down and debug without downloading, the flash contents in the memory window is 0xFFFFFFFF, not others I just filled in before power down. what can cause that?

     

  • Huichun,

    You need to disable Cortex R4 ATCM ECC when checking erased Flash.

    Thanks and regards,

    Zhaohong

  • zhaohong,

    I do comment out in the start up code as below (also in attached file) if it is what you mention.

     

     // MRC p15,#0,r1,c9,c12,#0                     ; Read PMNC register in privileged mode
           // ORR r1, r1, #0x00000010                     ; Bit4 enable export of the events to the event bus (send ECC error to the flash wrapper)
           // MCR p15,#0,r1,c9,c12,#0                     ; Write PMNC register in privileged mode

     

    If not, let me know which resgiter I should deal with.

     

    A little update for item 2 and 4 mentioned above for flash Erase. You can ignore 2 and 4 by using the problem statement below.

     Under an non-flash related project, I use the memory fill from IAR to fill in a flash sector, and I can power up/down and download the same program, and check the flash keeps the filled in value. Then I download my test code with InitializeBank, SectAtcivebank, and secor erase, I step in and flash does change after sector erase.

     

    However,  if in my test code I filled in the memory atin the startup code, then after sector erase, the contents will not be 0xFFFFFFFF though status =0 which is successful. 

     

    The good news sound the erase can work. But any special setting for flash access in debug mode. And what kind of change the memory fill can make to the MCU flash mode?

     

    The issue still exist on item 1 (start up initialization),  and 3 ( not be able to  program with successful status)
           

  • Huichun,

    A bootloader should work as follows.

    (1) Start execution from Flash after reset.

    (2) Copy code/data from Flash to RAM.

    (3) Start execution from RAM.

    The main bootloader function has to be executed from RAM because you cannot erase/program a Flash bank while executing from the same bank. It is not clear to me from which memory you execute the Flash API.

    Thanks and regards,

    Zhaohong