This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

secure_bootloader_uart_mbr_pca10056_debug questions

Parents
  • I tried following your instructions with my ARM host connected to the MIMEW board so I decided to flash the bootloader directly to the Nordic SDK and use Jimmy Wong's C++ program by the SDK's USB interface.

    I also did not succeed.

    Here is what I did.

    Thanks You.


    1) Bootloader
     a) Copied pca10056_uart_debug_266089 zip to E:\Nordic\nRF5_SDK_17.0.2_d674dde\examples\dfu\secure_bootloader
     b) Cleared button and hardware flow control
        //==========================================================
        // <e> NRF_BL_DFU_ENTER_METHOD_BUTTON - Enter DFU mode on button press.
        //==========================================================
        #ifndef NRF_BL_DFU_ENTER_METHOD_BUTTON
        #define NRF_BL_DFU_ENTER_METHOD_BUTTON 0
        #endif
        // <o> NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN  - Button for entering DFU mode.
        
        //==========================================================
        // <q> NRF_DFU_SERIAL_UART_USES_HWFC  - HWFC configuration
        
        
        #ifndef NRF_DFU_SERIAL_UART_USES_HWFC
        #define NRF_DFU_SERIAL_UART_USES_HWFC 0
        #endif
     c) Added to Preprocessor
        RX_PIN_NUMBER=8
        TX_PIN_NUMBER=6
        CTS_PIN_NUMBER=7
        RTS_PIN_NUMBER=5
     d) Remarked as no leds
        static void dfu_observer(nrf_dfu_evt_type_t evt_type)
        {
            switch (evt_type)
            {
                case NRF_DFU_EVT_DFU_FAILED:
                case NRF_DFU_EVT_DFU_ABORTED:
                case NRF_DFU_EVT_DFU_INITIALIZED:
        #if LEDS_NUMBER > 0
                    bsp_board_init(BSP_INIT_LEDS);
                    bsp_board_led_on(BSP_BOARD_LED_0);
                    bsp_board_led_on(BSP_BOARD_LED_1);
                    bsp_board_led_off(BSP_BOARD_LED_2);
        #endif
                    break;
                case NRF_DFU_EVT_TRANSPORT_ACTIVATED:
        #if LEDS_NUMBER > 0
                    bsp_board_led_off(BSP_BOARD_LED_1);
                    bsp_board_led_on(BSP_BOARD_LED_2);
        #endif
                    break;
                case NRF_DFU_EVT_DFU_STARTED:
                    break;
                default:
                    break;
            }
        }
     e) Flashed the built secure_bootloader_uart_mbr_pca10056_debug.hex and s140_nrf52_7.2.0_softdevice.hex (for my program use).
       Now the DFU bootloader runs since there is no application.
     
    2) Build my application package app_dfu_package.zip
    nrfutil pkg generate --hw-version 52 --application-version 1 --application E:\Projects\Nordic\alfa_laval_gateway\pca10056\s140\ses\Output\Debug\Exe\alfa_laval_gateway_pca10056_s140.hex --sd-req 0x0100 --key-file E:\Projects\Nordic\alfalval_gateway_keys\priv.pem E:\Projects\Nordic\AlfaLavalFlashfiles\app_dfu_package.zip
    pause

    3) I built Jimmy Wong's c++ program that my ARM host's code is built upon and ran it on my PC connected to the Nordic SDK, since something might have gotten messed up in my conversion code.
    In the end I will perform an application update recived by a cellular modem on our ARM host and update the MIMEW board serially.
    Jimmy's C++ program also failed when trying to program the data part before it sends the application code.
    In dfu_serial_execute_obj() the dfu_serial_get_rsp() returns an error.

    jimmywongbluetooth.wordpress.com/.../

    Sending Application image.
    SLIP: --> [9, 1]
    SLIP: <-- [96, 9, 1, 1]
    Set Packet Receipt Notification 0
    SLIP: --> [2, 0, 0]
    SLIP: <-- [96, 2, 1]
    SLIP: --> [7]
    SLIP: <-- [96, 7, 1, 131, 0]
    Sending init packet...
    Selecting Object: type:1
    SLIP: --> [6, 1]
    SLIP: <-- [96, 6, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    Object selected:  max_size:512 offset:0 crc:0x00000000
    SLIP: --> [1, 1, 141, 0, 0, 0]
    SLIP: <-- [96, 1, 1]
    Streaming Data: len:141 offset:0 crc:0x00000000
    SLIP: --> [8, 18, 138, 1, 10, 68, 8, 1, 18, 64, 8, 1, 16, 52, 26, 2, 128, 2, 32, 0, 40, 0, 48, 0, 56, 140, 175, 9, 66, 36, 8, 3, 18, 32, 212, 176, 254, 147, 100, 224, 60, 28, 43, 210, 13, 155, 200, 58, 136, 167, 98, 55, 196, 194, 68, 233, 177, 134, 127, 163, 183, 171, 47, 30, 252]
    SLIP: --> [8, 147, 72, 0, 82, 4, 8, 1, 18, 0, 16, 0, 26, 64, 191, 204, 125, 154, 71, 87, 252, 12, 223, 86, 90, 21, 50, 67, 33, 114, 149, 210, 212, 134, 102, 233, 32, 13, 115, 212, 214, 80, 143, 187, 128, 2, 123, 76, 156, 183, 137, 129, 62, 134, 1, 75, 75, 0, 130, 172, 198, 62, 157, 235, 79]
    SLIP: --> [8, 192, 112, 57, 190, 116, 143, 0, 214, 130, 56, 229, 181, 185]
    SLIP: --> [3]
    SLIP: <-- [96, 3, 1, 141, 0, 0, 0, 115, 111, 140, 185]
    SLIP: --> [4]
    SLIP: <-- [96, 4, 5]
    Bad result code (0x5)!

    E:\Nordic\nRF5_SDK_17.0.2_d674dde\examples\nrf-slim-serial-uart-dfu-host-c-code-master\Debug\UartSecureDFU.exe (process 21456) exited with code 1.
    To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
    Press any key to close this window . . .



     

Reply
  • I tried following your instructions with my ARM host connected to the MIMEW board so I decided to flash the bootloader directly to the Nordic SDK and use Jimmy Wong's C++ program by the SDK's USB interface.

    I also did not succeed.

    Here is what I did.

    Thanks You.


    1) Bootloader
     a) Copied pca10056_uart_debug_266089 zip to E:\Nordic\nRF5_SDK_17.0.2_d674dde\examples\dfu\secure_bootloader
     b) Cleared button and hardware flow control
        //==========================================================
        // <e> NRF_BL_DFU_ENTER_METHOD_BUTTON - Enter DFU mode on button press.
        //==========================================================
        #ifndef NRF_BL_DFU_ENTER_METHOD_BUTTON
        #define NRF_BL_DFU_ENTER_METHOD_BUTTON 0
        #endif
        // <o> NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN  - Button for entering DFU mode.
        
        //==========================================================
        // <q> NRF_DFU_SERIAL_UART_USES_HWFC  - HWFC configuration
        
        
        #ifndef NRF_DFU_SERIAL_UART_USES_HWFC
        #define NRF_DFU_SERIAL_UART_USES_HWFC 0
        #endif
     c) Added to Preprocessor
        RX_PIN_NUMBER=8
        TX_PIN_NUMBER=6
        CTS_PIN_NUMBER=7
        RTS_PIN_NUMBER=5
     d) Remarked as no leds
        static void dfu_observer(nrf_dfu_evt_type_t evt_type)
        {
            switch (evt_type)
            {
                case NRF_DFU_EVT_DFU_FAILED:
                case NRF_DFU_EVT_DFU_ABORTED:
                case NRF_DFU_EVT_DFU_INITIALIZED:
        #if LEDS_NUMBER > 0
                    bsp_board_init(BSP_INIT_LEDS);
                    bsp_board_led_on(BSP_BOARD_LED_0);
                    bsp_board_led_on(BSP_BOARD_LED_1);
                    bsp_board_led_off(BSP_BOARD_LED_2);
        #endif
                    break;
                case NRF_DFU_EVT_TRANSPORT_ACTIVATED:
        #if LEDS_NUMBER > 0
                    bsp_board_led_off(BSP_BOARD_LED_1);
                    bsp_board_led_on(BSP_BOARD_LED_2);
        #endif
                    break;
                case NRF_DFU_EVT_DFU_STARTED:
                    break;
                default:
                    break;
            }
        }
     e) Flashed the built secure_bootloader_uart_mbr_pca10056_debug.hex and s140_nrf52_7.2.0_softdevice.hex (for my program use).
       Now the DFU bootloader runs since there is no application.
     
    2) Build my application package app_dfu_package.zip
    nrfutil pkg generate --hw-version 52 --application-version 1 --application E:\Projects\Nordic\alfa_laval_gateway\pca10056\s140\ses\Output\Debug\Exe\alfa_laval_gateway_pca10056_s140.hex --sd-req 0x0100 --key-file E:\Projects\Nordic\alfalval_gateway_keys\priv.pem E:\Projects\Nordic\AlfaLavalFlashfiles\app_dfu_package.zip
    pause

    3) I built Jimmy Wong's c++ program that my ARM host's code is built upon and ran it on my PC connected to the Nordic SDK, since something might have gotten messed up in my conversion code.
    In the end I will perform an application update recived by a cellular modem on our ARM host and update the MIMEW board serially.
    Jimmy's C++ program also failed when trying to program the data part before it sends the application code.
    In dfu_serial_execute_obj() the dfu_serial_get_rsp() returns an error.

    jimmywongbluetooth.wordpress.com/.../

    Sending Application image.
    SLIP: --> [9, 1]
    SLIP: <-- [96, 9, 1, 1]
    Set Packet Receipt Notification 0
    SLIP: --> [2, 0, 0]
    SLIP: <-- [96, 2, 1]
    SLIP: --> [7]
    SLIP: <-- [96, 7, 1, 131, 0]
    Sending init packet...
    Selecting Object: type:1
    SLIP: --> [6, 1]
    SLIP: <-- [96, 6, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    Object selected:  max_size:512 offset:0 crc:0x00000000
    SLIP: --> [1, 1, 141, 0, 0, 0]
    SLIP: <-- [96, 1, 1]
    Streaming Data: len:141 offset:0 crc:0x00000000
    SLIP: --> [8, 18, 138, 1, 10, 68, 8, 1, 18, 64, 8, 1, 16, 52, 26, 2, 128, 2, 32, 0, 40, 0, 48, 0, 56, 140, 175, 9, 66, 36, 8, 3, 18, 32, 212, 176, 254, 147, 100, 224, 60, 28, 43, 210, 13, 155, 200, 58, 136, 167, 98, 55, 196, 194, 68, 233, 177, 134, 127, 163, 183, 171, 47, 30, 252]
    SLIP: --> [8, 147, 72, 0, 82, 4, 8, 1, 18, 0, 16, 0, 26, 64, 191, 204, 125, 154, 71, 87, 252, 12, 223, 86, 90, 21, 50, 67, 33, 114, 149, 210, 212, 134, 102, 233, 32, 13, 115, 212, 214, 80, 143, 187, 128, 2, 123, 76, 156, 183, 137, 129, 62, 134, 1, 75, 75, 0, 130, 172, 198, 62, 157, 235, 79]
    SLIP: --> [8, 192, 112, 57, 190, 116, 143, 0, 214, 130, 56, 229, 181, 185]
    SLIP: --> [3]
    SLIP: <-- [96, 3, 1, 141, 0, 0, 0, 115, 111, 140, 185]
    SLIP: --> [4]
    SLIP: <-- [96, 4, 5]
    Bad result code (0x5)!

    E:\Nordic\nRF5_SDK_17.0.2_d674dde\examples\nrf-slim-serial-uart-dfu-host-c-code-master\Debug\UartSecureDFU.exe (process 21456) exited with code 1.
    To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
    Press any key to close this window . . .



     

Children
  • Hi, 

    DavidKaplan said:
    use Jimmy Wong's C++ program by the SDK's USB interface.

    Are you using the USB interface? Since Jimmy's example is based on the Serial (UART) DFU, you might need some modifications. 

    -Amanda H.

  • Hi,

    You are using the USB interface and run on the UART bootloader , right?

    On the UART, it used the 64bytes payload.

    if you use the USB, the size would be changed on both side.

  • Shalom!

    I am using the uart interface of an Arm processor in my project connected to a MIMEW Nordic boardMS88F2.

    I also tried to run the bootloader on the nRF52840-DK using the nrf-slim-serial-uart-dfu-host-c-code c++ project code.

    I am thinking that maybe I missed a step in preparing the app_dfu_package.zip file.

    I tried creating it with my application's debug version and then with its release version with the same results.

    Does the debug version change its start address or is it just with more debug information?

    Is there documentation of the bootloader and its error codes?

    I need to get this working as our customer is waiting and the prototype working.

    Thanks

  • Shalom!

    I used your nrf-slim-serial-uart-dfu-host-c-code c++ code. I do not see the RX_BUF_SIZE define. There are:

    #define UART_SLIP_SIZE_MAX        128
    #define UART_SLIP_BUFF_SIZE        (UART_SLIP_SIZE_MAX * 2 + 1)

    Should I try to change this to 64?

    I converted the C++ code to C code on my ARM processor host by way of its uart at 115,200BPS. I may have a problem somewhere but I can ping and communicate with the bootloader. It just replies with an error code after sending the 141 dat part of the app_dfu_package.zip file saying that the offset and the CRC are wrong.

    I also tried to run the bootloader on the nRF52840-DK using the nrf-slim-serial-uart-dfu-host-c-code c++ project code compiled by Visual Studio but also got errors.

    Do you have any tips on how I can advance on this?

    Our customer of course as always, is waiting.

    Is there bootloader documentation that I can look at with error codes?

    Can I see what is happening by running the bootloader in the debugger?

    Where should I set break points?

    tThank you

    David Kaplan

  • Shalom!

    I added back in the bytes on the wire debug from your code using my ARM host with uart to the MIMEW board running the bootloader that AMANDA sent me (uart_data_to_buff with logger_buff).

    I do not know what I missed.

    I can see that the ARM is sending the dat object from your enum

    NRF_DFU_OP_OBJECT_WRITE      = 0x08,     //!< Write selected object.

    and that the bootloader is replying with

    NRF_DFU_RES_CODE_INVALID_OBJECT          = 0x05,    //!< Data object does not match the firmware and hardware requirements, the signature is wrong, or parsing the command failed.

    I think something is wrong with the creation of the packet.

    I use the following script:

    nrfutil pkg generate --hw-version 52 --application-version 1 --application app_pca10056_s140.hex --sd-req 0x0100 --key-file priv.pem app_dfu_package.zip

    I generated my key and added the public key to the bootloader.

    REM # Generate a private key in E:\Projects\Nordic\keys\priv.pem
    nrfutil keys generate E:\Projects\Nordic\keys\priv.pem
    REM # Display the generated private key (in little-endian format)
    nrfutil keys display --key sk --format hex E:\Projects\Nordic\keys\priv.pem
    REM # Display the public key that corresponds to the generated private key
    REM # (in little-endian format)
    nrfutil keys display --key pk --format hex E:\Projects\Nordic\keys\priv.pem
    REM # Display the public key that corresponds to the generated private key
    REM # (in code format to be used with DFU)
    nrfutil keys display --key pk --format code E:\Projects\Nordic\keys\priv.pem
    REM # Write the public key that corresponds to the generated private key
    REM # to the file public_key.c (in code format)
    nrfutil keys display --key pk --format code E:\Projects\Nordic\keys\priv.pem --out_file public_key.c

    This is my debug output on my ARM host:

    18/03/2021 08:04:27[dfu_serial.c: 201] SLIP: --> [9, 1]
    18/03/2021 08:04:27[dfu_serial.c: 216] SLIP: <-- [96, 9, 1, 1]
    18/03/2021 08:04:27[dfu_serial.c: 281] Set Packet Receipt Notification 0
    18/03/2021 08:04:27[dfu_serial.c: 201] SLIP: --> [2, 0, 0]
    18/03/2021 08:04:27[dfu_serial.c: 216] SLIP: <-- [96, 2, 1]
    18/03/2021 08:04:27[dfu_serial.c: 201] SLIP: --> [7]
    18/03/2021 08:04:27[dfu_serial.c: 216] SLIP: <-- [96, 7, 1, 131, 0]
    18/03/2021 08:04:27[dfu_serial.c: 658] Sending init packet...
    18/03/2021 08:04:27[dfu_serial.c: 334] Selecting Object: type:1
    18/03/2021 08:04:27[dfu_serial.c: 201] SLIP: --> [6, 1]
    18/03/2021 08:04:27[dfu_serial.c: 216] SLIP: <-- [96, 6, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    18/03/2021 08:04:27[dfu_serial.c: 353] Object selected:  max_size:512 offset:0 crc:0x00000000
    18/03/2021 08:04:27[dfu_serial.c: 201] SLIP: --> [1, 1, 141, 0, 0, 0]
    18/03/2021 08:04:27[dfu_serial.c: 216] SLIP: <-- [96, 1, 1]
    18/03/2021 08:04:27[dfu_serial.c: 479] Streaming Data: len:141 offset:0 crc:0x00000000
    18/03/2021 08:04:27[dfu_serial.c: 201] SLIP: --> [8, 18, 138, 1, 10, 68, 8, 1, 18, 64, 8, 1, 16, 52, 26, 2, 128, 2, 32, 0, 40, 0, 48, 0, 56, 172, 176, 9, 66, 3
    18/03/2021 08:04:27[dfu_serial.c: 201] SLIP: --> [8, 149, 72, 0, 82, 4, 8, 1, 18, 0, 16, 0, 26, 64, 233, 165, 75, 205, 210, 244, 117, 73, 136, 125, 228, 33, 23
    18/03/2021 08:04:27[dfu_serial.c: 201] SLIP: --> [8, 44, 221, 86, 18, 186, 11, 160, 235, 13, 164, 6, 164, 247]
    18/03/2021 08:04:27[dfu_serial.c: 201] SLIP: --> [3]
    18/03/2021 08:04:27[dfu_serial.c: 216] SLIP: <-- [96, 3, 1, 141, 0, 0, 0, 19, 235, 178, 0]
    18/03/2021 08:04:27[dfu_serial.c: 201] SLIP: --> [4]
    18/03/2021 08:04:27[dfu_serial.c: 216] SLIP: <-- [96, 4, 5]
    18/03/2021 08:04:27[dfu_serial.c: 231] Bad result code (0x5)!

    Any help would be appreciated.

    David Kaplan

Related