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.

MSP430F5659: Mass erase using the USB BSL

Part Number: MSP430F5659
Other Parts Discussed in Thread: MSP430USBDEVPACK,

Hi,

I want to perform a mass erase using the TI USB BSL on my MSP430F5659 via USB. Is there a GUI that exists? I have downloaded MSP430USBDEVPACK, MSP430_USB_Firmware_Upgrade_Example, and BSL scripter, but haven't been able to easily do a mass erase. I think the BSL scripter would do the job, but it looks like I need to write a script. Is there an example or something that exists? Also, from the source code of BSL_USB_GUI, there are references to MASS_ERASE, but the GUI does not have the option of just doing that.

Thank you,

Fred

  • If I remember right, RX_PASSWORD command will trigger mass erase, so script should be...
    MODE 5xx USB
    RX_PASSWORD
    DELAY 1000
  • Thanks, but I don't think it worked.

    I want to do a mass erase because my jtag is locked, and the datasheet said that performing a mass_erase with unlock the jtag. Right now, it's still locked.
  • Hi Fred,

    I see 2 questions here, and please let me answer them one by one.

    1. Mass erase using the USB BSL

    The simplest way to trigger mass erase by USB BSL is to use "RX_PASSWORD" command with a wrong password, which would trigger the "mass erase on incorrect password" according to the MSP430™ Flash Device Bootloader (BSL) User's Guide.

    More specifically, in order to do that, please firstly download the latest BSL Scripter here. Then in the package you can find the examples at path .\ScriptExampleWindows\5xx_usb and you only need to take three lines to do the job.

    MODE 5xx USB
    //gives wrong password to do
    //mass erase in the memory
    RX_PASSWORD pass32_wrong.txt
    RX_PASSWORD pass32_default.txt

    Please note that, as highlighted in the document below, the "password" referred to here is BSL password that is located between addresses 0xFFE0 and 0xFFFF, and "mass erase" is performed ONLY on main code flash memory.

    2. Unlock JTAG debug interface by USB BSL

    JTAG lock key is located between address 0x17FC to 0x17FF, and it actually resides in the BSL memory address range, so appropriate action must be taken to unprotect the memory area before programming the protection key. This can be done by a regular memory write access by writing directly to the SYSBSLC register address (0x0182) and setting the SYSBSLPE to 0. Afterward, the BSL memory behaves like regular flash memory and a JTAG lock key can be programmed.

    This operation cannot be done by BSL mass erase because it actually does not touch JTAG lock key at all.

    Nevertheless, it is still possible to unlock JTAG debug interface by USB BSL. Please refer to the script below.

    MODE 5xx USB
    //gives wrong password to do
    //mass erase in the memory
    RX_PASSWORD pass32_wrong.txt
    RX_PASSWORD pass32_default.txt
    RX_DATA_BLOCK_FAST RAM_BSL_USB.txt
    SET_PC 0x2504
    DELAY 3000
    ////////////////////////////////////
    //Start the RAM USB BSL application
    ////////////////////////////////////
    MODE 5xx USB
    RX_PASSWORD .\pass32_default.txt
    RX_DATA_BLOCK .\Clear_SYSBSLPE.txt
    RX_DATA_BLOCK .\JTAG_UNLOCK.txt

    The content of Clear_SYSBSLPE.txt is

    @0182
    03 00 
    q

    and the content of JTAG_UNLOCK.txt is

    @17FC
    00 00 00 00
    q

    Last but not least, do read this post for more important information about the consequence of this operation and the possible solution.

    Please kindly be thoughtful and careful when performing these operations!

  • As always, thanks for your reply and contribution to the community!
  • Thank you!

    However, I somehow bricked my device, so I can't test until I get a new MSP to replace the old one. I'll update the thread once I've tested that.

  • Hi Philo,

    Just to let you know that it worked perfectly, thank you!
  • Hi Philo,

    I was wondering, what is the purpose of these lines?
    RX_DATA_BLOCK_FAST RAM_BSL_USB.txt
    SET_PC 0x2504

    The USB BSL region is at 0x1000, so what are we writing at 0x2500?

    Thank you,
    Fred
  • Hi Fred,

    By "RX_DATA_BLOCK_FAST RAM_BSL_USB.txt" the USB BSL firmware is programmed to RAM starting at address 0x2500.

    By "SET_PC 0x2504" the program counter (PC) is directed to the USB BSL in RAM. This command: 1) ends the USB BSL session started from BSL flash memory (address range 0x1000 - 0x17FF) and 2) starts a new USB BSL session from RAM.

    According to MSP430™ Flash Device Bootloader (BSL) User's Guide, it is necessary to load the USB BSL to device RAM and then start it from there.

    Keep in mind that by default the USB BSL is started from its BSL flash memory, and the JTAG lock key is also in BSL flash memory. In order to avoid simultaneous reading/fetching/erasing/writing of the same BSL flash memory, it is necessary to execute USB BSL from RAM.

    By the way, for more information regarding flash memory operations, please refer to Chapter 7 Flash Memory Controller of MSP430x5xx and MSP430x6xx Family User's Guide.

  • Hi Philo,

    Is that because 0x17FC is in a BSL segment, thus the BSL segment needs to be erased first before writing to 0x17FC?

    I see in the USB BSL code that there are some #ifdef RAM_BASED_BSL regions. Would the flash-only compiled code work in the RAM BSL?

  • Hi Fred,

    Regarding your questions,

    user4725373 said:

    Is that because 0x17FC is in a BSL segment, thus the BSL segment needs to be erased first before writing to 0x17FC?

    Not exactly correct. It is only writing flash memory (by RX_DATA_BLOCK), but it would conflict with simultaneous code fetching (executing USB BSL from BSL flash memory). Knowledge of flash memory operations could be very helpful here, so please read the Chapter 7 Flash Memory Controller of MSP430x5xx and MSP430x6xx Family User's Guide if you have further questions.

    In fact, I have just found more information that further confirms the necessity of loading USB BSL to RAM and executing from there. Please check the updated post above.

    user4725373 said:

    I see in the USB BSL code that there are some #ifdef RAM_BASED_BSL regions. Would the flash-only compiled code work in the RAM BSL?

    Not sure if I understand your question here, but let me try to answer it with below.

    You can get the latest TI official BSL source code and compiled images here. In the folder of your device family you can find the BSL_Device_File.h file with various #define macros there. Usually by default "RAM_WRITE_ONLY_BSL" is effective but "FULL_FLASH_BSL" and "RAM_BASED_BSL" are commented out (ineffective). If you build your project with this configuration, then you can get the TI default factory USB BSL that is initially programmed to the BSL flash memory and only supports three commands (RX_DATA_BLOCK_FAST, RX_PASSWORD and SET_PC). Of course, you can customize the BSL_Device_File.h file by yourself and hence build your own customized BSL according to your own requirements.

    By the way, there are already compiled USB BSL images available for you. More specifically, for the USB BSL image to be loaded to your MSP430F5659, please go to <PACKAGE_PATH>\Released_BSL_Images\MSP430F665x_Family\USB BSL and you can find USB BSL images to be programmed to BSL flash memory (BSL_VERSION.txt) as well as RAM-based USB BSL images (RAM_BSL_VERSION.txt).

    Officially TI has already clearly distinguished BSL versions, and please kindly use the correct version accordingly.

  • I see.

    Very clear answer, thank you!

**Attention** This is a public forum