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.

RM48L952: Which Flash Controller Register allows FAPI access to Banks 0 and 1

Part Number: RM48L952
Other Parts Discussed in Thread: HALCOGEN

Hello,

  We are using the Hercules board rm48l952zwt and halcogen 4.03.00 for building the drivers and app code, and the TI bootloader on bank 0 sector 0 that boots and then jumps to the halcogen based drivers/app code. We discovered an issue with the TI bootloader, that if a power brownout occured in the bootloader it would corrupt the contents of flash. This was not a problem if we used a pure debug version based only on the halcogen built drivers, which locks bank 0 and 1 access and access to bank 7 is only allowed via the eeprom/flash emulation api. However, we need a bootloader because we want to allow for dynamic upgrades of our application on the field of course. In a different thread, a TI engineer said TI would work on a newer version of the bootloader because the one available for our platform is about 6 years old.  Since we have to solve the problem for our customers, in the meantime, we created a bootloader from the HalCoGen generated code that does not have the brownout problem because access to flash for erases/writes is blocked by default in what HalCoGen generates. Now we want to only in the circumstance of an upgrade to allow erase/write access using the FAPI library as the TI bootloader allows for (and thereby limiting the risk of brownouts to only during upgrades), which registers in the flash controller do we use to allow for that (i.e., BROT, FBSE, etc.) and can erase/write access be controlled at the sector level (and the rest of the bank can be protected from brownouts by not enabling write/erase access) or is it only at the overall bank level that we either block access to erase/write or allow access?  Thank you.

  • Hi Tammy,

    Which bootloader do you use, CAN , UART, or Ethernet?
  • Hi QJ,

     It is the with 5.2.12 version of the TI bootloader and one of your colleagues named Jean Marc helped in having the bootloader load a new application image over SPI from the SDCard using the FAPI drivers (we do not use the CAN, UART of Ethernet interfaces).

    So with Jean Marc how it worked was the old 5.2.12 TI bootloader would check a bit in flash that the application would set or clear depending on whether there was an upgrade to new software. If the flag is clear, it would just jump to the sector of flash with the start of the application that was built on HalCoGen drivers. If you remember, the problem was a few of our customers experienced brownouts with the TI platform when the bootloader is running which would corrupt flash but if the brownout occured when it got to the HalCoGen based application no problems. So while we are waiting on TI's official new release, we made a bootloader from the HalCoGen we are using and of course because flash is locked to erases/writes we do not have the problem with brownouts. But now, when we need the bootloader to replace the application in the other sectors of flash, we need to be able to unlock the flash via the registers to replace the application with the upgrade. This at least limits the risk to only when there are upgrades which is a couple times a year. All the other boots will be default like HalCoGen does it locking the flash so a brownout will not corrupt it.  Let me know if you want me to upload the bootloaders. So just wanted to know which registers we need to use to allow erase/writes like in the 5.2.12 version that we can change at runtime to allow for the scenerio of the upgrade.  Thank you.

  • Hi QJ,

      Please see attached. First zip is bootloader project based on the TI bootloader with the problem of corruption of flash with brownout when bootloader is running but we have access to flash for an upgrade, and 2nd bootloader based on halcogen (I included both HalCoGen 4.3.00 and 4.7.00 for you to see, just exclude the halcogen driver directory you do not care about), where now it is protected from brownout but we do not have access to flash anymore for upgrade.  Thank you. Tammy

    2818.OriginalTIBootloaderBased.zip

    4578.HalcoGenBootloaderBased.zip

  • The flash bank protection register and sector enable register can be used for protect the flash from writing/erasing.
  • Hi QJ,

    Great thank you. I am using the august 2013 version of RM48 reference manual. So

    FFF8 7030h FBPROT Flash Bank Protection Register
    Bit Field Value Description
    31-1 Reserved 0 Read returns 0. Writes have no effect.
    0 PROTL1DIS PROTL1DIS: Level 1 Protection Disabled
    Level 1 Protection Disable bit. Setting this bit disables protection from writing to the
    OTPPROTDIS bits as well as the Sector Enable registers FBSE for all banks. Clearing this
    bit enables protection and disables write access to the OTPPROTDIS register bits and
    FBSE register.
    0 Level 1 protection is disabled.
    1 Level 1 protection is enabled.

    So I have to set FBPROT bit 0 = 0?

    and FFF8 7034h FBSE Flash Bank Sector Enable Register
    Bit Field Value Description
    31-16 Reserved 0 Read returns 0. Writes have no effect.
    15-0 BSE Bank Sector Enable
    Each bit corresponds to a flash sector in the bank specified by the FMAC register. Bit 0
    corresponds to sector 0, bit 1 corresponds to sector 1, etc. These bits can be set only when
    PROTL1DIS = 1 and in privilege mode.
    0 The corresponding numbered sector is disabled for program or erase access.
    1 The corresponding numbered sector is enabled for program or erase access.


    and for FBPROT for the corresponding sectors in bank 0/1 have to set those bits to 1?

    Is it still necessarry for me to do the _coredisableFlashEcc_() also? Thank you again, Tammy

  • Hi QJ,

    So if the version of the technical manual is correct we have to do below, but where is PROTL1DIS to set that to 1, etc.? The manual stated that to modify the FBSE, we have to set the FMAC to the bank we want to erase/program and "...These bits can be set only when PROTL1DIS = 1 and in privilege mode...":

    ...
    _coreDisableFlashEcc_();
    flashWREG->FBPROT = 0; //0 Level 1 protection is disabled.
    ?? //These bits can be set only when PROTL1DIS = 1 and in privilege mode.
    flashWREG->FMAC = 0; //bank specified by the FMAC register bank 0
    flashWREG->FBSE = 0x7FF0; //bank 0 excl 1st four sectors with bootloader
    flashWREG->FMAC = 0; //bank specified by the FMAC register bank 1
    flashWREG->FBSE = 0x7FFF;//bank 1

    // Erase Application Flash Region
    FapiStatus = bootloader_FlashEraseApplication();

    also when we set the pair FMAC and then FBSE, can we do both banks up front or do I have to integrate into where we use FAPI for the flash erase to go from bank to bank for the relative sectors on that bank? The TI based bootloader code is the same I used in HalCoGen, and everything was done before entering the flash access code, so it seems odd that would be necessary to do now. Thank you.

  • Hello Tammy,

    Two functions in F021 flash API can be used to enable the bank and sectors:
    Fapi_setActiveFlashBank(...);
    Fapi_enableMainBankSectors(...)
    I think your flash erase/program function [bootloader_FlashEraseApplication()] uses those 2 functions. You don't need to enable bank/sector before calling the function.

    Normally the bootloader is in privilege mode, and the application is in user mode (if want to switch to privilege mode, user needs to call SVC, etc). The banks and sectors are protected in user mode.

    Only 1 bank can be selected at a time.
  • Hi QJ,

    Thank you I understand. Did you see the zip files I uploaded (see above a few comments back)? The Fapi functions do not work over the either the HalCoGen 4.3.00 or 4.7.00 generated bootloader. The good news is the browwnout problem goes away, but then same Fapi functions no longer are able to access the flash. Thank you again, Tammy

  • Hi QJ,

    I will attach one more time in case uploads did not get through. Please see attached. Second zip is bootloader project based on the TI bootloader with the problem of corruption of flash with brownout when bootloader is running but we have access to flash for an upgrade, and 1st zip file is bootloader based on halcogen (I included both HalCoGen 4.3.00 and 4.7.00 for you to see that both HalCoGen based bootloader have registers set so that the FAPI functions do not have access, where now it is protected from brownout but we do not have access to flash anymore for upgrade. 

    Some of the differences in the sys_core.asm register for example, in the HalCoGen generated sys_core:

     ; Switch to System Mode ( Shares User Mode registers ) (M = 11111)
      cps #31

    whereas the other TI bootloader sys_core.asm

    ; Switch back to Supervisor Mode (M = 10011)
     cps #19

    So, is the problem we need to to switch from system mode to supervisor mode for the FAPI libs to have access?

    Thank you. Tammy

    1882.HalcoGenBootloaderBased.zip

    8787.OriginalTIBootloaderBased.zip

  • Hi Tammy,

    The F021 flash APIs must run in a privileged mode (a mode other than user) to allow access to the FMC controller registers. System Mode is a privileged mode, it should be ok to run F021 flash APIs.

    I created a uart bootloader using the drivers from HAlCoGen, it can program application code to bank1. I tested it on TMS570LC43x MCU.
  • Hi QJ, We are on the RM48. When I clicked the link I did not see the bootloader you did. Can you attached again so I can do a diff between what HalCoGen generates for the RM48 versus the MS570? Did you use a newer version of the FAPI libraries then the one TI provides with the RM48?  Thanks. Tammy

  • Hi QJ, good news I got further along with single stepping. When I have both disable Ecc and the clearing of the FBROT like you suggested above before trying to execute the FAPI functions, it seems to work Ok now single stepping.

    _coreDisableFlashEcc_();
    flashWREG->FBPROT = 0; //0 Level 1 protection is disabled.

    I will test running without debugger now. Thank you again.
  • Hello Tammy,

    1. Both the HALCoGen generated HW driver and the previous driver I used in the original bootloader work the same way.

    2. I generated a new uart bootloader using HalCoGen generated HW driver, it works fine. This is for LS3137 device (I didn't find a RM48 HDK). You can modify it for RM48 device (change the device part number, select the little endian instead of big32), and do a test on your board. 

    https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/312/2376.TMS570LS3137HDK_5F00_UART_5F00_Bootlader.7z

    BTW, you need to check you HW design to figure out the power supply issue which causes the brownout. The voltage drop caused the reset is out of device spec.

    The boot loader downloaded from ti.com is an example so it is not entirely vetted for use in a safety system.

  • When you test bootloader I gave you today, please add a breakpoint at;

    Size = Ymodem_Receive(UART, &tab_1024[0]);

    in bl_uart.c

    Otherwise it doesn't work. I will fix the delay issue later.
  • Hi QJ, OK will try this now. Thank you.