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

  • 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

  • J-Link - Web control panel [RTT]
    General
    Settings
    Breakpoints
    RTT
    Log
    CPU Regs
    Target Power
    SWV
    RAWTrace
    STrace
    LiveTrace
    Flash
    Commander
    Help
    Status & Settings
    Control block address:
    (0 == Auto-detection)
    Status:
    Data rate:
    Total received:
    Buffered:
    Target -> Host
    Show data for channel:
    
    <info> app: Inside main
    
    <debug> app: In nrf_bootloader_init
    
    <debug> nrf_dfu_settings: Calling nrf_dfu_settings_init()...
    
    <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
    
    <debug> nrf_dfu_settings: Using settings page.
    
    <debug> nrf_dfu_settings: Copying forbidden parts from backup page.
    
    <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
    
    <info> nrf_dfu_settings: Backing up settings page to address 0xFE000.
    
    <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
    
    <debug> app: Enter nrf_bootloader_fw_activate
    
    <info> app: No firmware to activate.
    
    <info> app: Boot validation failed. No valid app to boot.
    
    <debug> app: DFU mode because app is not valid.
    
    <info> nrf_bootloader_wdt: WDT is not enabled
    
    <debug> app: in weak nrf_dfu_init_user
    
    <debug> app: timer_stop (0x20000024)
    
    <debug> app: timer_activate (0x20000024)
    
    <info> app: Entering DFU mode.
    
    <debug> app: Initializing transports (found: 1)
    
    <debug> nrf_dfu_serial_uart: serial_dfu_transport_init()
    
    <debug> nrf_dfu_serial_uart: serial_dfu_transport_init() completed
    
    <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
    
    <debug> app: Enter main loop
    
    <debug> nrf_dfu_serial: Received ping 2
    
    <info> nrf_dfu_serial_uart: Allocated buffer 20002784
    
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_PING
    
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    
    <debug> nrf_dfu_serial: Sending Response: [0x9, 0x1]
    
    <debug> nrf_dfu_serial: Set receipt notif target: 0
    
    <info> nrf_dfu_serial_uart: Allocated buffer 20002784
    
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_RECEIPT_NOTIF_SET
    
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    
    <debug> nrf_dfu_serial: Sending Response: [0x2, 0x1]
    
    <debug> nrf_dfu_serial: Received serial mtu
    
    <info> nrf_dfu_serial_uart: Allocated buffer 20002784
    
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_MTU_GET
    
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    
    <debug> nrf_dfu_serial: Sending Response: [0x7, 0x1]
    
    <info> nrf_dfu_serial_uart: Allocated buffer 20002784
    
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_SELECT (command)
    
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    
    <debug> nrf_dfu_serial: Sending Response: [0x6, 0x1]
    
    <debug> app: Shutting down transports (found: 1)
    
    <info> nrf_dfu_serial_uart: Allocated buffer 20002784
    
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_CREATE (command)
    
    <debug> app: timer_stop (0x20000024)
    
    <debug> app: timer_activate (0x20000024)
    
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    
    <debug> nrf_dfu_serial: Sending Response: [0x1, 0x1]
    
    <info> nrf_dfu_serial_uart: Allocated buffer 20002808
    
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (command)
    
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    
    <info> nrf_dfu_serial_uart: Allocated buffer 20002784
    
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (command)
    
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    
    <info> nrf_dfu_serial_uart: Allocated buffer 20002808
    
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (command)
    
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    
    <info> nrf_dfu_serial_uart: Allocated buffer 20002808
    
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_CRC_GET (command)
    
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    
    <debug> nrf_dfu_serial: Sending Response: [0x3, 0x1]
    
    <info> nrf_dfu_serial_uart: Allocated buffer 20002808
    
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_EXECUTE (command)
    
    <debug> nrf_dfu_validation: PB: Init packet data len: 66
    
    <info> nrf_dfu_validation: Signature required. Checking signature.
    
    <info> nrf_dfu_validation: Calculating hash (len: 66)
    
    <info> nrf_dfu_validation: Verify signature
    
    <error> nrf_dfu_validation: Signature failed (err_code: 0x8542)
    
    <debug> nrf_dfu_validation: Signature:
    
    <debug> nrf_dfu_validation:  63 5A E4 21 FA CA 7B 6F|cZ.!..{o
    
    <debug> nrf_dfu_validation:  60 66 FF 66 A4 3D AE 1D|`f.f.=..
    
    <debug> nrf_dfu_validation:  7B C9 C4 FC A8 1B EB B2|{.......
    
    <debug> nrf_dfu_validation:  3F D6 3F DD EF C0 77 D8|?.?...w.
    
    <debug> nrf_dfu_validation:  8A 67 1E 31 97 86 7E 40|.g.1..~@
    
    <debug> nrf_dfu_validation:  8C CB 7A 1A E0 00 BA C6|..z.....
    
    <debug> nrf_dfu_validation:  C9 8C A1 F6 75 7A 49 47|....uzIG
    
    <debug> nrf_dfu_validation:  AE 70 A6 43 67 A8 EF EC|.p.Cg...
    
    <debug> nrf_dfu_validation: Hash:
    
    <debug> nrf_dfu_validation:  41 BC A1 D5 5C CA D1 3C|A...\..<
    
    <debug> nrf_dfu_validation:  F4 D3 38 BB 2D 4E 78 18|..8.-Nx.
    
    <debug> nrf_dfu_validation:  8E 07 2A 96 2A 6C 23 81|..*.*l#.
    
    <debug> nrf_dfu_validation:  25 B9 92 3C 06 4D 5A 78|%..<.MZx
    
    <debug> nrf_dfu_validation: Public Key:
    
    <debug> nrf_dfu_validation:  31 3B 27 BA 4A 84 39 E5|1;'.J.9.
    
    <debug> nrf_dfu_validation:  09 73 89 FC 6E 66 C4 AA|	s..nf..
    
    <debug> nrf_dfu_validation:  B5 9F 8E 4D 66 CD C7 EF|...Mf...
    
    <debug> nrf_dfu_validation:  2F 22 FD 1E CC E1 5C 6D|/"....\m
    
    <debug> nrf_dfu_validation:  81 03 9C 52 25 F3 03 1F|...R%...
    
    <debug> nrf_dfu_validation:  9F 6C 0C 27 6F 9A F3 AA|.l.'o...
    
    <debug> nrf_dfu_validation:  B0 FD 54 22 4D C6 D8 05|..T"M...
    
    <debug> nrf_dfu_validation:  90 9F 57 13 37 32 B3 01|..W.72..
    
    <warning> nrf_dfu_validation: Prevalidation failed.
    
    <debug> nrf_dfu_validation: Init command:
    
    <debug> nrf_dfu_validation:  08 01 10 E1 9C 03 1A 02|........
    
    <debug> nrf_dfu_validation:  80 02 20 00 28 00 30 00|.. .(.0.
    
    <debug> nrf_dfu_validation:  38 CC A2 05 42 24 08 03|8...B$..
    
    <debug> nrf_dfu_validation:  12 20 77 84 3B E1 FB FB|. w.;...
    
    <debug> nrf_dfu_validation:  98 F0 04 BC 7A 6E 92 54|....zn.T
    
    <debug> nrf_dfu_validation:  2C C1 10 22 D1 BE B8 0C|,.."....
    
    <debug> nrf_dfu_validation:  86 03 4B E4 58 9A FD 99|..K.X...
    
    <debug> nrf_dfu_validation:  E0 7D 48 00 52 04 08 01|.}H.R...
    
    <debug> nrf_dfu_validation:  12 00                  |..      
    
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x5
    
    <warning> nrf_dfu_serial: DFU request completed with result: 0x5
    
    <debug> nrf_dfu_serial: Sending Response: [0x4, 0x5]
    
    Host -> Target
    Send CR on <Return>
    Send LF on <Return>
    
     
    
    SEGGER Microcontroller GmbH || www.segger.com

    I added the bootloader running in debug mode's RTT JLINK lopg.

    Thanks

  • Hi David, 

    I see this <error> nrf_dfu_validation: Signature failed (err_code: 0x8542). You are likely missing some configuration settings to enable hashing in SW. 

    uECC does not implement hash functions, so you need to use the nrf hash implementation. 

    I don't see why you would want to use uECC when HW accelerated crypto is available, but if you really want to use uECC, you can compare the configuration settings for an nrf52832 project or the file in this post that uses this backend by default. 

    -Amanda H.

Related