update firmware via uart from android

Hi all,

I use nRF52832 connect a android device with uart, and I want to update firmware via uart.

I can update my nrf device success on pc for test with the help of your colleagues and this link.

But I have no idea how to do this on android device.

And if I don't want to use nrfutil do you guys have any other example for me to update the version?

Any help or suggestion is appreciated!

Best regards

Lurn

Parents Reply Children
  • Hi Lurn,

    Can you please explain what you are trying to achieve? I.e. why and when it is you want to change the version number  from the application?

  • Hi Vidar,

    I want to check and change the version number when updating the device, just a question about modifying it in the code.

    And the format of the version number can only be a number of type uint32_t, right?

    Best regards,

    Lurn

  • Hi Lurn,

    You can read the version number from the application, but not change it.

    The version number can be specified as an integer or a version string (converted to an integer). From nrfutil's help menu:

      --application-version INTEGER   The application version.
      --application-version-string TEXT
                                      The application version string, e.g.
                                      "2.7.31". Will be converted to an integer,
                                      e.g. 20731.
    

    Best regards,

    Vidar

  • Hi Vidar,

    Thanks for your help. I will try it.

    Best regards,

    Lurn

  • Hi Vidar,

    I used the DFU master code from here to test the process .

    I can transfer files but never succeed.

    The process is as follows.

    1. I flash the DFU master application on the master board.

    2. make sure my target board in DFU mode.

    3. program the init.bin and app.bin to master board.

    4. connect master board and target board.

    5. run the DFU master.

    In source code the application_image_address = 0x30000;

    and I get error like this

    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (data)
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x8
    00> <warning> nrf_dfu_serial: DFU request completed with result: 0x8
    00> <info> nrf_dfu_serial_uart: Allocated buffer 20000554
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_CRC_GET (data)
    00> <debug> nrf_dfu_req_handler: Offset:0, CRC:0x00000000
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    00> <debug> nrf_dfu_serial: Sending Response: [0x3, 0x1]
    00> <info> nrf_dfu_serial_uart: Allocated buffer 20000554
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_EXECUTE (data)
    00> <debug> nrf_dfu_req_handler: Whole firmware image received. Postvalidating.
    00> <error> app: Received a fault! id: 0x00004002, pc: 0x00000000, info: 0x200046F0
    # SEGGER J-Link RTT Viewer V7.00a Terminal Log File
    # Compiled: 15:35:52 on Apr 16 2021
    # Logging started @ 20 Apr 2023 14:48:20
    (Connection lost)
    (Connection lost)(Connection lost)(Connection lost)(Connection lost)(Connection lost)
    (Connection lost)(Connection lost)(Connection lost)(Connection lost)(Connection lost)(Connection lost)(Connection lost)(Connect
    00> <info> app: Inside main
    00> 
    00> <info> app: Bootloader 0
    00> Settings 2 
    00>  Application 0
    00> 
    00> <debug> app: In nrf_bootloader_init
    00> 
    00> <debug> nrf_dfu_settings: Calling nrf_dfu_settings_init()...
    00> 
    00> <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
    00> 
    00> <debug> nrf_dfu_settings: Using settings page.
    00> 
    00> <debug> nrf_dfu_settings: Copying forbidden parts from backup page.
    00> 
    00> <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
    00> 
    00> <info> nrf_dfu_settings: Backing up settings page to address 0x7E000.
    00> 
    00> <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
    00> 
    00> <debug> app: Enter nrf_bootloader_fw_activate
    00> 
    00> <info> app: No firmware to activate.
    00> 
    00> <info> app: Boot validation failed. No valid app to boot.
    00> 
    00> <debug> app: DFU mode because app is not valid.
    00> 
    00> <info> nrf_bootloader_wdt: WDT is not enabled
    00> 
    00> <debug> app: in weak nrf_dfu_init_user
    00> 
    00> <debug> app: timer_stop (0x20000020)
    00> 
    00> <debug> app: timer_activate (0x20000020)
    00> 
    00> <info> app: Entering DFU mode.
    00> 
    00> <debug> app: Initializing transports (found: 1)
    00> 
    00> <debug> nrf_dfu_serial_uart: serial_dfu_transport_init()
    00> 
    00> <debug> nrf_dfu_serial_uart: serial_dfu_transport_init() completed
    00> 
    00> <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
    00> 
    00> <debug> app: Enter main loop
    00> 
    00> <debug> nrf_dfu_serial: Received ping 1
    00> 
    00> <info> nrf_dfu_serial_uart: Allocated buffer 20000554
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_PING
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    00> 
    00> <debug> nrf_dfu_serial: Sending Response: [0x9, 0x1]
    00> 
    00> <debug> app: Shutting down transports (found: 1)
    00> 
    00> <info> nrf_dfu_serial_uart: Allocated buffer 20000554
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_CREATE (command)
    00> 
    00> <debug> app: timer_stop (0x20000020)
    00> 
    00> <debug> app: timer_activate (0x20000020)
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    00> 
    00> <debug> nrf_dfu_serial: Sending Response: [0x1, 0x1]
    00> 
    00> <info> nrf_dfu_serial_uart: Allocated buffer 200005D8
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (command)
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    00> 
    00> <info> nrf_dfu_serial_uart: Allocated buffer 20000554
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (command)
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    00> 
    00> <info> nrf_dfu_serial_uart: Allocated buffer 200005D8
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (command)
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    00> 
    00> <info> nrf_dfu_serial_uart: Allocated buffer 200005D8
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_CRC_GET (command)
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    00> 
    00> <debug> nrf_dfu_serial: Sending Response: [0x3, 0x1]
    00> 
    00> <info> nrf_dfu_serial_uart: Allocated buffer 200005D8
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_EXECUTE (command)
    00> 
    00> <error> nrf_dfu_validation: Execute with faulty offset
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x8
    00> 
    00> <warning> nrf_dfu_serial: DFU request completed with result: 0x8
    00> 
    00> <debug> nrf_dfu_serial: Sending Response: [0x4, 0x8]
    00> 
    00> <info> nrf_dfu_serial_uart: Allocated buffer 200005D8
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_CREATE (data)
    00> 
    00> <error> nrf_dfu_req_handler: Cannot create data object without valid init command
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x8
    00> 
    00> <warning> nrf_dfu_serial: DFU request completed with result: 0x8
    00> 
    00> <debug> nrf_dfu_serial: Sending Response: [0x1, 0x8]
    00> 
    00> <info> nrf_dfu_serial_uart: Allocated buffer 20000554
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (data)
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x8
    00> 
    00> <warning> nrf_dfu_serial: DFU request completed with result: 0x8
    00> 
    00> <info> nrf_dfu_serial_uart: Allocated buffer 20000554
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_CRC_GET (data)
    00> 
    00> <debug> nrf_dfu_req_handler: Offset:0, CRC:0x00000000
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    00> 
    00> <debug> nrf_dfu_serial: Sending Response: [0x3, 0x1]
    00> 
    00> <info> nrf_dfu_serial_uart: Allocated buffer 20000554
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_EXECUTE (data)
    00> 
    00> <debug> nrf_dfu_req_handler: Whole firmware image received. Postvalidating.
    00> 
    00> <error> app: Received a fault! id: 0x00004002, pc: 0x00000000, info: 0x200046F0
    00> 
    
    # Logging stopped @ 20 Apr 2023 14:50:07
    

    In readme it shows the address.

    so I change the application_image_address = 0x10000;

    the error log is here

    00> <error> nrf_dfu_validation: Failed to decode init packet
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x5
    00> <warning> nrf_dfu_serial: DFU request completed with result: 0x5
    00> <debug> nrf_dfu_serial: Sending Response: [0x4, 0x5]
    00> <info> nrf_dfu_serial_uart: Allocated buffer 20000554
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_CREATE (data)
    00> <error> nrf_dfu_req_handler: Cannot create data object without valid init command
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x8
    00> <warning> nrf_dfu_serial: DFU request completed with result: 0x8
    00> <debug> nrf_dfu_serial: Sending Response: [0x1, 0x8]
    00> <error> app: Received an error: 0x00000004!

    # SEGGER J-Link RTT Viewer V7.00a Terminal Log File
    # Compiled: 15:35:52 on Apr 16 2021
    # Logging started @ 20 Apr 2023 14:56:49
    00> <debug> nrf_dfu_serial: Received ping 1
    00> 
    00> <info> nrf_dfu_serial_uart: Allocated buffer 20000554
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_PING
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    00> 
    00> <debug> nrf_dfu_serial: Sending Response: [0x9, 0x1]
    00> 
    00> <debug> app: Shutting down transports (found: 1)
    00> 
    00> <info> nrf_dfu_serial_uart: Allocated buffer 20000554
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_CREATE (command)
    00> 
    00> <debug> app: timer_stop (0x20000020)
    00> 
    00> <debug> app: timer_activate (0x20000020)
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x4
    00> 
    00> <warning> nrf_dfu_serial: DFU request completed with result: 0x4
    00> 
    00> <debug> nrf_dfu_serial: Sending Response: [0x1, 0x4]
    00> 
    00> <info> nrf_dfu_serial_uart: Allocated buffer 200005D8
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (command)
    00> 
    00> <error> nrf_dfu_validation: Init command larger than expected.
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x3
    00> 
    00> <warning> nrf_dfu_serial: DFU request completed with result: 0x3
    00> 
    00> <info> nrf_dfu_serial_uart: Allocated buffer 20000554
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (command)
    00> 
    00> <error> nrf_dfu_validation: Init command larger than expected.
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x3
    00> 
    00> <warning> nrf_dfu_serial: DFU request completed with result: 0x3
    00> 
    00> <info> nrf_dfu_serial_uart: Allocated buffer 20000554
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_CRC_GET (command)
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    00> 
    00> <debug> nrf_dfu_serial: Sending Response: [0x3, 0x1]
    00> 
    00> <info> nrf_dfu_serial_uart: Allocated buffer 20000554
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_EXECUTE (command)
    00> 
    00> <error> nrf_dfu_validation: Handler: Invalid init command.
    00> 
    00> <error> nrf_dfu_validation: Failed to decode init packet
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x5
    00> 
    00> <warning> nrf_dfu_serial: DFU request completed with result: 0x5
    00> 
    00> <debug> nrf_dfu_serial: Sending Response: [0x4, 0x5]
    00> 
    00> <info> nrf_dfu_serial_uart: Allocated buffer 20000554
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_CREATE (data)
    00> 
    00> <error> nrf_dfu_req_handler: Cannot create data object without valid init command
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x8
    00> 
    00> <warning> nrf_dfu_serial: DFU request completed with result: 0x8
    00> 
    00> <debug> nrf_dfu_serial: Sending Response: [0x1, 0x8]
    00> 
    00> <error> app: Received an error: 0x00000004!
    00> 
    
    # Logging stopped @ 20 Apr 2023 14:57:33
    

    can you tell me what is wrong?

    Best regards,

    Lurn

Related