SLAA450G April   2010  – April 2020

 

  1.   Creating a Custom Flash-Based Bootloader (BSL)
    1.     Trademarks
    2. 1 5xx and 6xx Bootloader Customization
      1. 1.1 BSL Memory Layout
        1. 1.1.1 Z-Area
        2. 1.1.2 BSL Reserved Memory Locations
      2. 1.2 Device Start-up Sequence
        1. 1.2.1 BSL Protect Function
          1. 1.2.1.1 Protection of BSL Memory
          2. 1.2.1.2 Checking for BSL Invoke
      3. 1.3 TI-Supplied BSL Software
        1. 1.3.1 Software Overview
        2. 1.3.2 Software File Details
          1. 1.3.2.1 BSL430_Low_Level_Init.s43 (IAR) / BSL430_Low_Level_Init.asm (CCS)
          2. 1.3.2.2 BSL_Device_File.h
          3. 1.3.2.3 lnk430FXXXX_BSL_AREA.xcl (IAR) / MSP430Fxxxx_BSL.cmd (CCS)
        3. 1.3.3 Known Limitations in CCS CSL Code Example
          1. 1.3.3.1 Memory Allocation of BSL Code Under Linker Command File
          2. 1.3.3.2 BSL Functions Supported in the Default Setting Project
          3. 1.3.3.3 How to Accomodate Full Function of BSL
          4. 1.3.3.4 Using Modified boot_hook.h and boot.c (CCS Only)
      4. 1.4 Creation of Custom Peripheral Interface
        1. 1.4.1 PI_init ()
        2. 1.4.2 PI_receivePacket()
        3. 1.4.3 PI_sendData(int bufSize)
      5. 1.5 BSL Development and Debug
        1. 1.5.1 Development and Testing
        2. 1.5.2 Special Notes and Tips
        3. 1.5.3 USB BSL External Oscillator Frequency
    3. 2 G2xx Bootloader Creation and Customization
      1. 2.1 Target System Specification
      2. 2.2 BSL Specification
        1. 2.2.1 Functionality
          1. 2.2.1.1 Entry Sequence
          2. 2.2.1.2 Synchronization
          3. 2.2.1.3 Erasing Previous Flash Content
          4. 2.2.1.4 Receiving and Writing New User Data
          5. 2.2.1.5 Data Verification
        2. 2.2.2 Memory Footprint
        3. 2.2.3 Peripherals
      3. 2.3 Implementation
        1. 2.3.1 BSL Assembler Code
          1. 2.3.1.1 Save DCO Calibration Data
          2. 2.3.1.2 Linker Command File
            1. 2.3.1.2.1 Locating the Linker Command File
            2. 2.3.1.2.2 Modify Linker File
            3. 2.3.1.2.3 Force the IDE to Use Custom Linker File
          3. 2.3.1.3 Project Settings
        2. 2.3.2 User Application
      4. 2.4 BSL Operation
        1. 2.4.1 Hardware Setup
        2. 2.4.2 Connection to Host
          1. 2.4.2.1 Determining COM Port
          2. 2.4.2.2 Setup of COM Port
        3. 2.4.3 Operate BSL - Standard Sequence
        4. 2.4.4 Create New Code to Download Through BSL
          1. 2.4.4.1 Create Custom Application
          2. 2.4.4.2 Save Calibration Data
          3. 2.4.4.3 Make User Application Code a BSL Update File
            1. 2.4.4.3.1 Using CCS
            2. 2.4.4.3.2 Using IAR
          4. 2.4.4.4 Obtaining XOR Checksum
            1. 2.4.4.4.1 Send User Data
            2. 2.4.4.4.2 Read Checksum
            3. 2.4.4.4.3 Send Acquired Checksum
            4. 2.4.4.4.4 Verify Data
            5. 2.4.4.4.5 Save Checksum
        5. 2.4.5 Getting Ready for Production
    4. 3 Frequently Asked Questions (FAQ)
  2.   Revision History

Frequently Asked Questions (FAQ)

  1. Question: Where can I download the source code and firmware images of the BSL 430?
  2. Answer: The source code and the firmware images are available from the CUSTOM-BSL430 link at Bootloader (BSL) for MSP low-power microcontrollers.

  3. Question: What is the benefit having the Custom BSL programmed in protected memory and overwriting the TI factory BSL rather than just having the Custom BSL in main memory space?
  4. Answer: When the Custom BSL is programmed in the protected memory, it is secured from erasing and unintended execution. This configuration also supports the invoke sequence, where the bootcode executes the BSL when the invoke sequence is applied. In addition, the custom BSL does not occupy any of the main memory space.

  5. Question: Can the BSL be debugged?
  6. Answer: Yes. After starting the debug session, set the Program Counter (PC) to point to the BSL entry location (@0x1000).

  7. Question: How to switch from the BSL to an application?
  8. Answer: The factory BSL (also included in the Custom BSL) provides the SET PC command. This command sets the PC register to the given address to start the application.

  9. Question: What is the default BSL password for empty devices?
  10. Answer: The devices that come from the factory are erased, and the interrupt vectors are blank (0xFF). This means that the BSL password for initial programming is the default password (all 0xFF).

  11. Question: What does the MASS ERASE BSL command do?
  12. Answer: The MASS ERASE command erases all banks of the main memory. Information memory segments A to D and the BSL segments A to D are not erased.

  13. Question: If the device is protected using the JTAG Lock, is memory access still possible?
  14. Answer: Yes, by using BSL when the BSL is unlocked with the correct password.

  15. Question: How to recover an overwritten BSL?
  16. Answer: If the BSL signature is corrupted or the BSL application is not functional, the BSL can still be recovered or reprogrammed using JTAG or SBW, as long as these interfaces are not locked.

  17. Question: How to debug the BSL example code in IAR?
  18. Answer: The IAR project in the Custom BSL430 package was built in IAR 6.30.

    1. Choose the project to execute. This example demonstrates how to choose the MSP430F543xA_TA_UART project.
    2. faq1_select_project.pngFigure 9. Select the Project
    3. Check these settings: In the project options, under FET debugger, and the Download tab (see Figure 10), select the “Allow erase/write access to the BSL flash memory” and “Erase main and information memory”.
    4. faq2_project_properties.pngFigure 10. Setting in Project Properties
    5. After compiling the project, start the debug session.
    6. Open the Register View, and manually set the PC to 0x1000, which is the entry location of the BSL (see Figure 11).
    7. faq3_set_pc.pngFigure 11. Set the PC to the Location of BSL
    8. Run the BSL in the debugger. The program starts on the BSL entry function (see Figure 12).
    9. faq4_run_debug.pngFigure 12. Run the Debug Session

  19. Question: How to debug the BSL example code in CCS?
  20. Answer: MSP430 Custom BSL 1.1.0 provides the CCS example that can be easily imported to CCS.

    1. After the project is imported, go to the Project Properties, and configure the programming setup (see Figure 13).
    2. faq-ccs-debug-setup.pngFigure 13. Debug Setup
    3. As Figure 13 shows, select Debug → MSP43x Options.
    4. Under "Download Options", select "Allow Read/Write/Erase access to BSL memory".

      Under "Erase Options", select "Erase main and information memory".

    5. Build the project (see Figure 14).
    6. NOTE

      Due to current compiler restraints in CCS, some Custom BSL combinations will not compile under 2KB memory. If the application must have the BSL completely in its 2KB memory region, use IAR to compile the custom BSL.

      faq-ccs-build-project.pngFigure 14. Build Project
    7. Run the debug mode, pause the session, and then open the "Registers" view.
    8. Set the PC to 0x1000, which is the entry location of the BSL (see Figure 15).
    9. faq-ccs-setup-pc.pngFigure 15. Set PC to BSL Address
    10. Continue the debug mode.
    11. When the debug mode is paused, the "Disassembly" view shows that the BSL is executed (see Figure 16).
    12. Add a breakpoint to debug the source code.
    13. faq-ccs-check-bsl-is-executed.pngFigure 16. BSL is Executed