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.

MSPM0G3107: Can not enter BSL mode

Part Number: MSPM0G3107
Other Parts Discussed in Thread: MSPM0G3507, LP-MSPM0G3507, UNIFLASH

Tool/software:

Refer to bsl_software_invoke_app_demo_uart_LP_MSPM0G3507_nortos_ticlang, we want to duplicate the same method to

enter BSL mode by invokeBSLAsm() on G3107. But MCU will always reset on G3107 (can not stay in BSL "wait for command" state as illustration).

I also try DL_SYSCTL_resetDevice(DL_SYSCTL_RESET_BOOTLOADER_ENTRY), but not work as well.

Please help to advise the way to enter BSL mode on G3107 by software invoke.

__STATIC_INLINE void invokeBSLAsm(void)
{
/* Erase SRAM completely before jumping to BSL */
__asm(
#if defined(__GNUC__)
".syntax unified\n" /* Load SRAMFLASH register*/
#endif
"ldr r4, = 0x41C40018\n" /* Load SRAMFLASH register*/
"ldr r4, [r4]\n"
"ldr r1, = 0x03FF0000\n" /* SRAMFLASH.SRAM_SZ mask */
"ands r4, r1\n" /* Get SRAMFLASH.SRAM_SZ */
"lsrs r4, r4, #6\n" /* SRAMFLASH.SRAM_SZ to kB */
"ldr r1, = 0x20300000\n" /* Start of ECC-code */
"adds r2, r4, r1\n" /* End of ECC-code */
"movs r3, #0\n"
"init_ecc_loop: \n" /* Loop to clear ECC-code */
"str r3, [r1]\n"
"adds r1, r1, #4\n"
"cmp r1, r2\n"
"blo init_ecc_loop\n"
"ldr r1, = 0x20200000\n" /* Start of NON-ECC-data */
"adds r2, r4, r1\n" /* End of NON-ECC-data */
"movs r3, #0\n"
"init_data_loop:\n" /* Loop to clear ECC-data */
"str r3, [r1]\n"
"adds r1, r1, #4\n"
"cmp r1, r2\n"
"blo init_data_loop\n"
/* Force a reset calling BSL after clearing SRAM */
"str %[resetLvlVal], [%[resetLvlAddr], #0x00]\n"
"str %[resetCmdVal], [%[resetCmdAddr], #0x00]"
: /* No outputs */
: [ resetLvlAddr ] "r"(&SYSCTL->SOCLOCK.RESETLEVEL),
[ resetLvlVal ] "r"(DL_SYSCTL_RESET_BOOTLOADER_ENTRY),
[ resetCmdAddr ] "r"(&SYSCTL->SOCLOCK.RESETCMD),
[ resetCmdVal ] "r"(
SYSCTL_RESETCMD_KEY_VALUE | SYSCTL_RESETCMD_GO_TRUE)
: "r1", "r2", "r3", "r4");
}

  • Does the default demo code works well with bsl_software_invoke_app_demo_uart_LP_MSPM0G3507_nortos_ticlang?

    Normally, after the MCU generate a Reset, you will lose your debugger connection with MSPM0. How do you know "can not stay in BSL "wait for command" state as illustration"?

    Which bootloader your are using? The default bootloader?

    Here is a doc which includes the introduction to bootloader application:https://www.ti.com/lit/an/slaae88c/slaae88c.pdf

  • Hi Eason,

    1. We use default bootloader (ROM based BSL)

    2. Default demo code "bsl_software_invoke_app_demo_uart_LP_MSPM0G3507_nortos_ticlang" works on our target, to enter BSL mode by key pressed.

    3. We implement UART interface on our target. Thus, we use UART command to enter BSL(assume  invokeBSLAsm() works), 1~2 seconds

        after then, the boot-up message shows on UART console, that's why I think MSPM0 can't stay in BSL sate.

    UART command code :

    if (strcmp(command, "bsl") == 0) {
        LOG("enter BSL mode!");
        vTaskDelay( pdMS_TO_TICKS( 1000U ) );
        //DL_SYSCTL_resetDevice(DL_SYSCTL_RESET_BOOTLOADER_ENTRY);
        invokeBSLAsm();
        while (1) {
            __WFI();
        }

    }

    Thanks.

  • Hi Eason,

      We are running FreeRTOS (freertos_builds_LP_MSPM0G3507_release_ticlang_2_00_00_03) on our target, is that will be a possible

      issue to not stay in BSL mode?

    Thanks.

  • Not quite sure. Here is an example which may can give you some help: https://www.ti.com/lit/an/slaaec9/slaaec9.pdf

    Can you disable all the interrupt before calling invokeBSLAsm()?  

  • Hi Eason

      I try to use another demo "uart_echo_LP_MSPM0G3507_freertos_ticlang" to check if BSL update can be run on FreeRTOS.

      It works on LP-MSPM0G3507 EV-KIT, but still not work on our target. Good news is the system won't reset, but it still have some error message

      on Uniflash as shown in below

      What does that mean: {63}{00} ?.

    Thanks.

    success log:

    [2024/9/25 下午5:41:12] [INFO] CORTEX_M0P: Invoking Bootloader....
    [2024/9/25 下午5:41:15] [INFO] CORTEX_M0P:
    [2024/9/25 下午5:41:15] [INFO] CORTEX_M0P: BSL Connected
    [2024/9/25 下午5:41:15] [INFO] CORTEX_M0P: Command Interpreter version: [0x0100] Build ID: [0x0100] Application version: [0x00000000] Active Plugin Interface version: [0x0001] BSL Max buffer size: [0x3EC0] BSL Buffer Start address: [0x20000160] BCR Config ID: [0x00000x0001] BSL Config ID [0x00000x0001]
    [2024/9/25 下午5:41:15] [INFO] CORTEX_M0P: [80] [01] [00] [19] [B2] [B8] [96] [49]
    [2024/9/25 下午5:41:15] [INFO] CORTEX_M0P: {00}{08} {19} {00} {31} {00} {01} {00} {01} {00} {00} {00} {00} {01} {00} {C0} {3E} {60} {01} {00} {20} {01} {00} {00} {00} {01} {00} {00} {00} {0B} {5F} {2D} {D1}

    error log:

    [2024/9/26 下午6:25:01] [INFO] CORTEX_M0P: Invoking Bootloader....
    [2024/9/26 下午6:25:03] [INFO] CORTEX_M0P:
    [2024/9/26 下午6:25:03] [ERROR] CORTEX_M0P: [ACK_ERROR]Unknown ACK value!
    [2024/9/26 下午6:25:03] [INFO] CORTEX_M0P: [80] [01] [00] [19] [B2] [B8] [96] [49]
    [2024/9/26 下午6:25:03] [INFO] CORTEX_M0P: {63}{00}
    [2024/9/26 下午6:25:03] [ERROR] CORTEX_M0P: [ERROR_MESSAGE]Process is failed!

      

  • 1. What you do that can make it stay in BSL mode?

    2. Can you use a digital analysier to catch the wave and compare it with the right one? It will be more clear than read the Uniflash log. And this doc https://www.ti.com/lit/ug/slau887/slau887.pdf?ts=1727431097313 will describe the protocol. 

  • Hi Eason,

      demo app: bsl_software_invoke_app_demo_uart_LP_MSPM0G3507_nortos_ticlang

      I try TI tool - BSL_GUI_EXE where at \ti\mspm0_sdk_2_02_00_05\tools\bsl\

      There is an UART command 0xbb I can't find at any documents @MSPM0_BSL_GUI.py #line321

      any document to describe these UART commands?   

      UART_S.send_data(ser_port, b"\xbb")
      response01 = UART_S.read_data(ser_port, 1)

      The problem is If I enter BSL by press S2 and to do update right after, then it will return '51' (update OK)

               log : 

               Find MSP COM port:COM7
               Configure UART: 9600 baudrate, 8 data bits (LSB first), no parity, and 1 stop bit.
               [test]send connection pack: b'\x80\x01\x00\x12:aD\xde'
               [test]get response
               [test]get response 51
               MSPM0 is in BSL mode.
               Get device ID...

      but If I wait for 5 seconds or more, then it'll no response (update FAIL)

      I think BSL is in 'Sleep' state, and I try to resend connection pack but not work (refer TI doc slau887 3.1.1.2)

      Is my way not correct to wake up device from BSL?

      

      Thanks.

  • I try to send 0xAA , but still can not get any response from device.

    Refer to TI document slaaec9 on page.11: 

    Below are two steps need to be performed before starting firmware upgrade process:

    1. Send one-byte command 0x55 to check application code execution status, so that you know which

    application code need to be upgraded.

    2. Send one-byte command 0x11 to check bootloader status, if device responds 0x51, means that bootloader is

    in active status and is ready for firmware upgrade. Otherwise, you need to send one-byte command 0xAA to

    force bootloader from suspend to active status first

  • Hi Eason,

      Another issue on freeRTOS to switch to BSL mode seems not work properly

     demo app: uart_echo_LP_MSPM0G3507_freertos_ticlang

     EV-KIT: remove J101 JUMP of NRST

     Modify TI BSL_GUI as below, to send "0x22" to enter BSL,

     and modify  uart_echo_LP_MSPM0G3507_freertos to receive "0x22" to execute invokeBSLAsm() to enter BSL

     1) when EV-KIT has programmed bsl_software_invoke_app_demo_uart,  it's work to update FW through BSL_GUI

     2) when EV-KIT has programmed uart_echo_LP_MSPM0G3507_freertos, NOK

     

    diff --git a/MSPM0_BSL_GUI.py b/MSPM0_BSL_GUI.py
    index 1890657..f8401c6 100644
    --- a/MSPM0_BSL_GUI.py
    +++ b/MSPM0_BSL_GUI.py
    @@ -29,6 +29,7 @@
      * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
      * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     """
    +import codecs^M
     import tkinter
     from tkinter import *
     from tkinter.filedialog import *
    @@ -113,6 +114,14 @@ class Tkinter_app:
    
             self.label3 = Label(frame3, text="(Download: Just support UART with XDS110)")
             self.label3.pack()
    +        ^M
    +        self.button4 = Button(text="Reboot", command=self.reboot_thread)^M
    +        self.button4.pack(side="left")^M
    +        self.button4.place(relx=0.05, rely=0.21)^M
    +^M
    +        self.label4 = Label(text="(Reboot: Exit BSL mode)")^M
    +        self.label4.pack(side="left")^M
    +        self.label4.place(relx=0, rely=0.26)^M
    
             self.rad_button = Radiobutton(
                 frame3,
    @@ -240,6 +249,8 @@ class Tkinter_app:
             #     print(self.passwordfile)
             self.textlog.see(END)
             self.textlog.config(state=DISABLED)
    +    def reboot_thread(self):^M
    +        self.textlog.insert(INSERT, "Device reboot.\n", "normal")^M
         def downlaod_thread(self):
             T = threading.Thread(target=self.download, args=())
             T.start()
    @@ -306,8 +317,16 @@ class Tkinter_app:
                         "normal",
                     )
                     self.textlog.see(END)
    +                UART_S.send_data(ser_port, b"\x22")^M
    +                response_ = UART_S.read_data(ser_port, 10)^M
    +                response_str = codecs.decode(response_, 'hex').decode('utf-8')^M
    +                self.textlog.insert(INSERT, '[test] ' + str(response_str) + '\n', "normal")^M
    +                self.textlog.see(END)^M
    +                ^M
                     UART_S.send_data(ser_port, self.connection_pack)
                     response_ = UART_S.read_data(ser_port, 1)
    +                self.textlog.insert(INSERT, '[test]send connection pack: ' + str(self.connection_pack) + '\n', "normal")^M
    +                self.textlog.insert(INSERT, '[test]get response' + str(response_) + '\n', "normal")^M
                     if self.xds_v.get() == "a":
                         subprocess.run(
                             self.path
    @@ -325,8 +344,36 @@ class Tkinter_app:
                                 encoding='utf-8')
                     # print(type(response))
                     # print(response)
    -                UART_S.send_data(ser_port, b"\xbb")
    -                response01 = UART_S.read_data(ser_port, 1)
    +                retry = 0^M
    +                retry_times = 1^M
    +                while retry < retry_times:^M
    +                    UART_S.send_data(ser_port, b"\x55")^M
    +                    response013 = UART_S.read_data(ser_port, 1)^M
    +                    self.textlog.insert(INSERT, '[test]get response01(0x55)' + str(response013) + '\n', "normal")^M
    +                    UART_S.send_data(ser_port, b"\xbb")^M
    +                    response01 = UART_S.read_data(ser_port, 1)^M
    +                    self.textlog.insert(INSERT, '[test]get response01(0xbb)' + str(response01) + '\n', "normal")^M
    +                    UART_S.send_data(ser_port, b"\x11")^M
    +                    response012 = UART_S.read_data(ser_port, 1)^M
    +                    self.textlog.insert(INSERT, '[test]get response01(0x11)' + str(response012) + '\n', "normal")^M
    +                    if response01 == "51":^M
    +                        retry = 0^M
    +                        break;^M
    +                    else:^M
    +                        if retry == retry_times:^M
    +                            retry = 0^M
    +                            self.textlog.insert(INSERT, "[test] Err: No response<EF><BC><81>\n", "error")^M
    +                            self.textlog.see(END)^M
    +                            break;^M
    +                        retry += 1^M
    +                        time.sleep(1)^M
    +                        UART_S.send_data(ser_port, self.connection_pack)^M
    +                        response_ = UART_S.read_data(ser_port, 1)^M
    +                        #self.textlog.insert(INSERT, '[test]send connection pack: ' + str(self.connection_pack) + '\n', "normal")^M
    +                        #self.textlog.insert(INSERT, '[test]get response' + str(response_) + '\n', "normal")^M
    +                        self.textlog.insert(INSERT, '[test]send uart: 0xaa\n', "normal")^M
    +                        UART_S.send_data(ser_port, b"\xaa")^M
    +                    ^M
                     #                print(response)
                     if response01 == "51":
                         self.textlog.insert(
    @@ -335,10 +382,12 @@ class Tkinter_app:
                         self.textlog.see(END)
                         UART_S.send_data(ser_port, self.get_ID_pack)
                         response1 = UART_S.read_data(ser_port, 33)
    +                    self.textlog.insert(INSERT, '[test]get response1 ' + str(response1) + '\n', "normal")^M
                         self.textlog.insert(INSERT, "Send the password...\n", "normal")
                         self.textlog.see(END)
                         UART_S.send_data(ser_port, self.password_pack)
                         response2 = UART_S.read_data(ser_port, 1)
    +                    self.textlog.insert(INSERT, '[test]get response2 ' + str(response2) + '\n', "normal")^M
                         check = self.check_pack(response2)
                         if check:
                             response2 = UART_S.read_data(ser_port, 9)
    (END)
    

     looks like invokeBSLAsm() not work in freeRTOS, could you help to check on this?

    Thanks.

  •   There is an UART command 0xbb I can't find at any documents @MSPM0_BSL_GUI.py #line321

      any document to describe these UART commands? 

    Sorry not to reply you in such a log time. For this problem, please refer to this App note:https://www.ti.com/lit/an/slaae88c/slaae88c.pdf?ts=1730252803725. It is an added command to invoke BSL in application code.

    and modify  uart_echo_LP_MSPM0G3507_freertos to receive "0x22" to execute invokeBSLAsm() to enter BSL

    As you remake the code, have you debug the code and check whether it execute the invokeBSLAsm()?

  • Hi Eason,

      1. Yes, I understand "0x22" is an added command to invoke BSL in bsl_software_invoke_app_demo_uart

          But I confused is the command "0xbb" shown in MSPM0_BSL_GUI.py #line321

          

     UART_S.send_data(ser_port, b"\xbb")
     response01 = UART_S.read_data(ser_port, 1)

    2. My debug log "enter BSL!" was shown when BSL_GUI has sent command "0x22", but there is no response when BSL_GUI query device in BSL mode

        through command "0xbb"

        

        uart_echo_LP_MSPM0G3507_freertos I changed :

         a. baud rate config change to 9600

         b. uartecho.c to add command "0x22" to enter BSL mode

    --- a/uartecho.c
    +++ b/uartecho.c
    @@ -45,6 +45,46 @@
     /*
      *  ======== mainThread ========
      */
    +__STATIC_INLINE void invokeBSLAsm(void)
    +{
    +    /* Erase SRAM completely before jumping to BSL */
    +    __asm(
    +#if defined(__GNUC__)
    +        ".syntax unified\n" /* Load SRAMFLASH register*/
    +#endif
    +        "ldr     r4, = 0x41C40018\n" /* Load SRAMFLASH register*/
    +        "ldr     r4, [r4]\n"
    +        "ldr     r1, = 0x03FF0000\n" /* SRAMFLASH.SRAM_SZ mask */
    +        "ands    r4, r1\n"           /* Get SRAMFLASH.SRAM_SZ */
    +        "lsrs    r4, r4, #6\n"       /* SRAMFLASH.SRAM_SZ to kB */
    +        "ldr     r1, = 0x20300000\n" /* Start of ECC-code */
    +        "adds    r2, r4, r1\n"       /* End of ECC-code */
    +        "movs    r3, #0\n"
    +        "init_ecc_loop: \n" /* Loop to clear ECC-code */
    +        "str     r3, [r1]\n"
    +        "adds    r1, r1, #4\n"
    +        "cmp     r1, r2\n"
    +        "blo     init_ecc_loop\n"
    +        "ldr     r1, = 0x20200000\n" /* Start of NON-ECC-data */
    +        "adds    r2, r4, r1\n"       /* End of NON-ECC-data */
    +        "movs    r3, #0\n"
    +        "init_data_loop:\n" /* Loop to clear ECC-data */
    +        "str     r3, [r1]\n"
    +        "adds    r1, r1, #4\n"
    +        "cmp     r1, r2\n"
    +        "blo     init_data_loop\n"
    +        /* Force a reset calling BSL after clearing SRAM */
    +        "str     %[resetLvlVal], [%[resetLvlAddr], #0x00]\n"
    +        "str     %[resetCmdVal], [%[resetCmdAddr], #0x00]"
    +        : /* No outputs */
    +        : [ resetLvlAddr ] "r"(&SYSCTL->SOCLOCK.RESETLEVEL),
    +        [ resetLvlVal ] "r"(DL_SYSCTL_RESET_BOOTLOADER_ENTRY),
    +        [ resetCmdAddr ] "r"(&SYSCTL->SOCLOCK.RESETCMD),
    +        [ resetCmdVal ] "r"(
    +            SYSCTL_RESETCMD_KEY_VALUE | SYSCTL_RESETCMD_GO_TRUE)
    +        : "r1", "r2", "r3", "r4");
    +}
    +
     void mainThread(void *arg0)
     {
         size_t rdCount = 0;
    @@ -82,6 +122,17 @@ void mainThread(void *arg0)
                 }
             }
    
    +        if (input == 0x22) {
    +            UART_write(uart, "enter BSL!", 10, &bytesWritten);
    +            //vTaskDelay( pdMS_TO_TICKS( 100U ) );
    +            delay_cycles(1000000);
    +            //DL_SYSCTL_resetDevice(DL_SYSCTL_RESET_BOOTLOADER_ENTRY);
    +            invokeBSLAsm();
    +            while (1) {
    +                __WFI();
    +            }
    +        }
    +
             bytesWritten = 0;
             while (bytesWritten == 0) {
                 status = UART_write(uart, &input, 1, &bytesWritten);

    Thanks.

  •   But I confused is the command "0xbb" shown in MSPM0_BSL_GUI.py #line321

    This is just to send a byte that not the BSL package header 0x80 to trigger the header error(0x51) response from MSPM0, if a byte 0x51 response from MSPM0 after send 0xbb, that means the device in the BSL mode, so that we can do BSL operations later.

    2. My debug log "enter BSL!" was shown when BSL_GUI has sent command "0x22", but there is no response when BSL_GUI query device in B

    I think you should do some modification of the GUI, right?

    The original GUI  do not support software trigger to send 0x22. But you can do it before send 0xbb, it is better to wait some time to send the 0xbb, the delay time you can set about 300ms. Do you have a logic analyzer like Seleae on your side? If yes, it is better to share me the UART signals directly to me for analyze. 

  • Hi Gary,

      Thanks for your explain to the purpose by sending 0xbb command.

      Yes, I did some modification on GUI to send 0x22 to enter BSL mode. Just to keep the test condition almost the same between non-RTOS and freeRTOS.

      I've tried to add delay time before sending 0xbb, but there is still no any response. (0x22 -> 0.5s delay -> connection pack ->  0.5s delay -> 0xbb)

        

     

      my testing is non-RTOS and freeRTOS with the same GUI and invokeBSL code on LP-3507 target board

      OK: non-RTOS (bsl_software_invoke_app_demo_uart) + GUI + LP-3507

      NG: freeRTOS (uart_echo_LP_MSPM0G3507_freertos,  modification with 9600bps and 0x22 command) + GUI + LP-3507

    Thanks.

  • So you mean without the freeRTOS you can do it with no issue.The issue just happen when using freeRTOS, right?

    If so, you can refer to the section 4.3.2.1 Flash-Based 0x0 Address BSL Demo for MSPM0C

     https://www.ti.com/lit/an/slaae88c/slaae88c.pdf 

    Especially the comments below

  • Hi Gary,

      Yes, issue just happened on freeRTOS for software invoke (hardware invoke is OK)

      

      refer to 4.3.2.1, but this section looks like to apply in C-series MCU (without ROM) but not G-series MCU (with ROM) we used for MSPM0G3507.

      I add a disable IRQ command  from the comments to clear IRQ before enter BSL, but not work as well.

    NVIC_ClearPendingIRQ(UART0_INT_IRQn);
    
    invokeBSLAsm();
    while (1) {
        __WFI();
    }

    Thanks.

  • but this section looks like to apply in C-series MCU (without ROM) but not G-series MCU (with ROM) we used for MSPM0G3507

    It do not matter, it also need to follow with other MSPM0 devices.

    It is not only to clear pending IRQs, you need to disable all the interrupts to avoid any interrupts during the jump. 

  • Hi Gary,

      

      Thanks, it works now!