nrf_dfu_flash_store change to QSPI function -> callback issue in nrfx_qspi_write

Hi

I'm chnaging the Secure Bootloader to an external falsh for bank1, connected with QSPI.

In the function on_data_obj_write_request is the call for nrf_dfu_flash_store (file nrf_dfu_req_handler.c

static void on_data_obj_write_request(nrf_dfu_request_t * p_req, nrf_dfu_response_t * p_res)
{
    NRF_LOG_DEBUG("Handle NRF_DFU_OP_OBJECT_WRITE (data)");

    if (!nrf_dfu_validation_init_cmd_present())
    {
        /* Can't accept data because DFU isn't initialized by init command. */
        p_res->result = NRF_DFU_RES_CODE_OPERATION_NOT_PERMITTED;
        return;
    }

    uint32_t const data_object_offset = s_dfu_settings.progress.firmware_image_offset -
                                        s_dfu_settings.progress.firmware_image_offset_last;

    if ((p_req->write.len + data_object_offset) > s_dfu_settings.progress.data_object_size)
    {
        /* Can't accept data because too much data has been received. */
        NRF_LOG_ERROR("Write request too long");
        p_res->result = NRF_DFU_RES_CODE_INVALID_PARAMETER;
        return;
    }

    uint32_t const write_addr = m_firmware_start_addr + s_dfu_settings.write_offset;
    /* CRC must be calculated before handing off the data to fstorage because the data is
     * freed on write completion.
     */
    uint32_t const next_crc =
        crc32_compute(p_req->write.p_data, p_req->write.len, &s_dfu_settings.progress.firmware_image_crc);

    ASSERT(p_req->callback.write);

    ret_code_t ret =
        nrf_dfu_flash_store(write_addr, p_req->write.p_data, p_req->write.len, p_req->callback.write);

    if (ret != NRF_SUCCESS)
    {
        /* When nrf_dfu_flash_store() fails because there is no space in the queue,
         * stop processing the request so that the peer can detect a CRC error
         * and retransmit this object. Remember to manually free the buffer !
         */
        p_req->callback.write((void*)p_req->write.p_data);
        return;
    }

    /* Update the CRC of the firmware image. */
    s_dfu_settings.write_offset                   += p_req->write.len;
    s_dfu_settings.progress.firmware_image_offset += p_req->write.len;
    s_dfu_settings.progress.firmware_image_crc     = next_crc;

    /* This is only used when the PRN is triggered and the 'write' message
     * is answered with a CRC message and these field are copied into the response.
     */
    p_res->write.crc    = s_dfu_settings.progress.firmware_image_crc;
    p_res->write.offset = s_dfu_settings.progress.firmware_image_offset;
}

There is a callback which is needed:

ret_code_t ret =
        nrf_dfu_flash_store(write_addr, p_req->write.p_data, p_req->write.len, p_req->callback.write);

inside this function I use the QSPI function:

hal_qspi_write(&p_src, len, (dest & EXTERNAL_FLASH_ADDRESS_LOWER_BYTES), (void*)callback))

which at the end is calling the nrfx function nrfx_qspi_write. 

Here I should have a callback, but I don't know what I should implement.

The original callback in the nrf_fstorage_write is implemented like this:
return (p_fs->p_api)->write(p_fs, dest, p_src, len, p_context);

ret_code_t nrf_fstorage_write(nrf_fstorage_t const * p_fs,
                              uint32_t               dest,
                              void           const * p_src,
                              uint32_t               len,
                              void                 * p_context)
{
    NRF_FSTORAGE_PARAM_CHECK(p_fs,        NRF_ERROR_NULL);
    NRF_FSTORAGE_PARAM_CHECK(p_src,       NRF_ERROR_NULL);
    NRF_FSTORAGE_PARAM_CHECK(p_fs->p_api, NRF_ERROR_INVALID_STATE);
    NRF_FSTORAGE_PARAM_CHECK(len,         NRF_ERROR_INVALID_LENGTH);

    /* Length must be a multiple of the program unit. */
    NRF_FSTORAGE_PARAM_CHECK(!(len % p_fs->p_flash_info->program_unit), NRF_ERROR_INVALID_LENGTH);

    /* Source and destination addresses must be word-aligned. */
    NRF_FSTORAGE_PARAM_CHECK(addr_is_aligned32(dest),                NRF_ERROR_INVALID_ADDR);
    NRF_FSTORAGE_PARAM_CHECK(addr_is_aligned32((uint32_t)p_src),     NRF_ERROR_INVALID_ADDR);
    NRF_FSTORAGE_PARAM_CHECK(addr_is_within_bounds(p_fs, dest, len), NRF_ERROR_INVALID_ADDR);

    return (p_fs->p_api)->write(p_fs, dest, p_src, len, p_context);
}

Now the DFU is strating on bank1 but the App is generating an error because data is missing because of this callack I guess?

I was following this topic:

https://devzone.nordicsemi.com/f/nordic-q-a/48961/dfu-with-external-qspi-memory

Parents
  • I add the 2 files, bank 0 was DFU process with call to internal flash, this one was running ok like expected. (stopped the transfer in debugging mode after some packets)

    The other log of bank1 with call to external QSPI falsh has failed.

    nRF Connect, 2024-06-21
    No name (F9:3E:58:83:16:DF)
    V	13:15:26.644	Connecting to F9:3E:58:83:16:DF...
    D	13:15:26.644	gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M)
    D	13:15:26.973	[Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
    I	13:15:26.973	Connected to F9:3E:58:83:16:DF
    V	13:15:26.977	Discovering services...
    D	13:15:26.977	gatt.discoverServices()
    D	13:15:26.990	[Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
    I	13:15:27.319	Connection parameters updated (interval: 7.5ms, latency: 0, timeout: 5000ms)
    D	13:15:27.632	[Callback] Services discovered with status: 0
    I	13:15:27.632	Services discovered
    V	13:15:27.648	Generic Access (0x1800)
    - Device Name [R W] (0x2A00)
    - Appearance [R] (0x2A01)
    - Peripheral Preferred Connection Parameters [R] (0x2A04)
    - Central Address Resolution [R] (0x2AA6)
    Generic Attribute (0x1801)
    - Service Changed [I] (0x2A05)
       Client Characteristic Configuration (0x2902)
    Device Information (0x180A)
    - Manufacturer Name String [R] (0x2A29)
    - Model Number String [R] (0x2A24)
    - Serial Number String [R] (0x2A25)
    - Hardware Revision String [R] (0x2A27)
    - Software Revision String [R] (0x2A28)
    Unknown Service (7189498b-a0b1-4e80-8f20-18fd31da8b3a)
    - Unknown Characteristic [I N R W] (71891401-a0b1-4e80-8f20-18fd31da8b3a)
       Client Characteristic Configuration (0x2902)
    - Unknown Characteristic [R W] (71891402-a0b1-4e80-8f20-18fd31da8b3a)
    Secure DFU Service (0xFE59)
    - Buttonless DFU [I W] (8ec90003-f315-4f60-9fb8-838830daea50)
       Client Characteristic Configuration (0x2902)
    D	13:15:27.648	gatt.setCharacteristicNotification(00002a05-0000-1000-8000-00805f9b34fb, true)
    D	13:15:27.654	gatt.setCharacteristicNotification(71891401-a0b1-4e80-8f20-18fd31da8b3a, true)
    I	13:15:27.707	Connection parameters updated (interval: 30.0ms, latency: 0, timeout: 5000ms)
    I	13:15:28.282	PHY updated (TX: LE 2M, RX: LE 2M)
    V	13:15:31.008	[DFU] DFU service started
    V	13:15:31.008	[DFU] Opening file...
    I	13:15:31.025	[DFU] Firmware file opened successfully
    V	13:15:31.025	[DFU] Connecting to DFU target...
    D	13:15:31.025	[DFU] gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferredPhy = LE_1M | LE_2M)
    I	13:15:31.041	[DFU] Connected to F9:3E:58:83:16:DF
    V	13:15:31.041	[DFU] Discovering services...
    D	13:15:31.041	[DFU] gatt.discoverServices()
    I	13:15:31.041	[DFU] Services discovered
    W	13:15:31.042	[DFU] Application with buttonless update found
    V	13:15:31.042	[DFU] Jumping to the DFU Bootloader...
    V	13:15:31.042	[DFU] Enabling indications for 8ec90003-f315-4f60-9fb8-838830daea50
    D	13:15:31.042	[DFU] gatt.setCharacteristicNotification(8ec90003-f315-4f60-9fb8-838830daea50, true)
    D	13:15:31.042	[DFU] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x02-00)
    I	13:15:31.094	[DFU] Data written to descr.8ec90003-f315-4f60-9fb8-838830daea50
    V	13:15:31.094	[DFU] Notifications enabled for 8ec90003-f315-4f60-9fb8-838830daea50
    A	13:15:31.094	[DFU] Indications enabled
    V	13:15:31.095	[DFU] Writing to characteristic 8ec90003-f315-4f60-9fb8-838830daea50, value (0x): 01
    D	13:15:31.095	[DFU] gatt.writeCharacteristic(8ec90003-f315-4f60-9fb8-838830daea50, value=0x01, WRITE_TYPE_DEFAULT)
    A	13:15:31.155	[DFU] Enter bootloader sent (Op Code = 1)
    I	13:15:31.186	[DFU] Notification received from 8ec90003-f315-4f60-9fb8-838830daea50, value (0x): 20-01-01
    A	13:15:31.187	[DFU] Response received (Op Code = 1, Status = 1)
    V	13:15:31.187	[DFU] Disconnecting...
    D	13:15:31.188	[DFU] gatt.disconnect()
    I	13:15:31.197	[DFU] Disconnected
    D	13:15:31.198	[DFU] gatt.refresh() (hidden)
    D	13:15:31.198	[DFU] gatt.disconnect()
    D	13:15:31.198	[DFU] gatt.close()
    V	13:15:31.198	[DFU] Scanning for the DFU Bootloader... (timeout 5000 ms)
    I	13:15:31.726	Connection parameters updated (interval: 7.5ms, latency: 0, timeout: 5000ms)
    I	13:15:32.057	Connection parameters updated (interval: 30.0ms, latency: 0, timeout: 5000ms)
    I	13:15:32.342	[DFU] DFU Bootloader found with address F9:3E:58:83:16:E0
    V	13:15:32.356	[DFU] DFU service started
    I	13:15:32.356	[DFU] Firmware file opened successfully
    V	13:15:32.356	[DFU] Connecting to DFU target...
    D	13:15:32.389	[DFU] gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferredPhy = LE_1M | LE_2M)
    I	13:15:32.483	[DFU] Connected to F9:3E:58:83:16:E0
    V	13:15:32.483	[DFU] Discovering services...
    D	13:15:32.483	[DFU] gatt.discoverServices()
    D	13:15:32.600	[DFU] [Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
    I	13:15:33.214	[DFU] Services discovered
    V	13:15:33.268	[DFU] Requesting new MTU...
    D	13:15:33.268	[DFU] gatt.requestMtu(517)
    I	13:15:33.268	[DFU] MTU changed to: 247
    V	13:15:33.268	[DFU] Enabling notifications for 8ec90001-f315-4f60-9fb8-838830daea50
    D	13:15:33.268	[DFU] gatt.setCharacteristicNotification(8ec90001-f315-4f60-9fb8-838830daea50, true)
    D	13:15:33.268	[DFU] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x01-00)
    I	13:15:33.268	[DFU] Data written to descr.8ec90001-f315-4f60-9fb8-838830daea50
    V	13:15:33.268	[DFU] Notifications enabled for 8ec90001-f315-4f60-9fb8-838830daea50
    A	13:15:33.268	[DFU] Notifications enabled
    V	13:15:33.268	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 06-01
    D	13:15:33.268	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50, value=0x06-01, WRITE_TYPE_DEFAULT)
    I	13:15:33.311	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
    I	13:15:33.311	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-06-01-00-02-00-00-D2-00-00-00-29-C8-73-B4
    A	13:15:33.311	[DFU] Command object info received (Max size = 512, Offset = 210, CRC = B473C829)
    A	13:15:33.311	[DFU] Received CRC match Init packet
    V	13:15:33.311	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 04
    D	13:15:33.311	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50, value=0x04, WRITE_TYPE_DEFAULT)
    I	13:15:33.337	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
    I	13:15:33.359	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-04-01
    A	13:15:33.359	[DFU] Command object executed
    V	13:15:33.359	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 06-02
    D	13:15:33.359	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50, value=0x06-02, WRITE_TYPE_DEFAULT)
    I	13:15:33.382	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
    I	13:15:33.383	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-06-01-00-10-00-00-00-00-00-00-00-00-00-00
    A	13:15:33.383	[DFU] Data object info received (Max size = 4096, Offset = 0, CRC = 00000000)
    V	13:15:33.384	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 01-02-00-10-00-00
    D	13:15:33.385	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50, value=0x01-02-00-10-00-00, WRITE_TYPE_DEFAULT)
    I	13:15:33.422	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
    I	13:15:33.422	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-01-01
    A	13:15:33.422	[DFU] Data object (1/117) created
    D	13:15:33.422	[DFU] wait(400)
    A	13:15:33.815	[DFU] Uploading firmware...
    V	13:15:33.815	[DFU] Sending firmware to characteristic 8ec90002-f315-4f60-9fb8-838830daea50...
    V	13:15:33.881	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 03
    D	13:15:33.881	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50, value=0x03, WRITE_TYPE_DEFAULT)
    I	13:15:34.097	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-03-01-00-10-00-00-7C-E3-92-0A
    I	13:15:34.097	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
    A	13:15:34.100	[DFU] Checksum received (Offset = 4096, CRC = 0A92E37C)
    V	13:15:34.100	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 04
    D	13:15:34.100	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50, value=0x04, WRITE_TYPE_DEFAULT)
    I	13:15:34.138	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-04-01
    I	13:15:34.138	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
    A	13:15:34.138	[DFU] Data object executed
    V	13:15:34.138	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 01-02-00-10-00-00
    D	13:15:34.138	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50, value=0x01-02-00-10-00-00, WRITE_TYPE_DEFAULT)
    I	13:15:34.164	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
    I	13:15:34.165	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-01-01
    A	13:15:34.165	[DFU] Data object (2/117) created
    D	13:15:34.165	[DFU] wait(400)
    A	13:15:34.566	[DFU] Uploading firmware...
    V	13:15:34.566	[DFU] Sending firmware to characteristic 8ec90002-f315-4f60-9fb8-838830daea50...
    V	13:15:34.621	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 03
    D	13:15:34.621	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50, value=0x03, WRITE_TYPE_DEFAULT)
    I	13:15:34.642	[DFU] PHY updated (TX: LE 2M, RX: LE 2M)
    I	13:15:34.725	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-03-01-00-10-00-00-7C-E3-92-0A
    I	13:15:34.725	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
    A	13:15:34.725	[DFU] Checksum received (Offset = 4096, CRC = 0A92E37C)
    W	13:15:34.725	[DFU] 4096 bytes were lost
    V	13:15:34.725	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 02-01-00
    D	13:15:34.725	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50, value=0x02-01-00, WRITE_TYPE_DEFAULT)
    I	13:15:34.748	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-02-01
    I	13:15:34.748	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
    A	13:15:34.748	[DFU] Packet Receipt Notif Req (Op Code = 2) sent (Value = 1)
    A	13:15:34.748	[DFU] Resuming uploading firmware...
    V	13:15:34.748	[DFU] Sending firmware to characteristic 8ec90002-f315-4f60-9fb8-838830daea50...
    D	13:15:37.192	[Callback] Connection state changed with status: 8 and new state: DISCONNECTED (0)
    E	13:15:37.193	Error 8 (0x8): GATT CONN TIMEOUT
    I	13:15:37.193	Disconnected
    D	13:15:37.220	[Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
    E	13:16:10.129	[DFU] Device has disconnected
    D	13:16:10.129	[DFU] gatt.disconnect()
    D	13:16:10.218	[DFU] gatt.close()
    D	13:16:10.221	[DFU] [Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
    V	13:16:10.231	[DFU] DFU service started
    I	13:16:10.231	[DFU] Firmware file opened successfully
    V	13:16:10.231	[DFU] Connecting to DFU target...
    D	13:16:10.261	[DFU] gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferredPhy = LE_1M | LE_2M)
    

    nRF Connect, 2024-06-21
    DFU_09 16:DF (F9:3E:58:83:16:E0)
    V	12:59:17.720	Connecting to F9:3E:58:83:16:E0...
    D	12:59:17.720	gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M)
    D	12:59:17.785	[Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
    I	12:59:17.785	Connected to F9:3E:58:83:16:E0
    V	12:59:17.798	Discovering services...
    D	12:59:17.798	gatt.discoverServices()
    D	12:59:17.813	[Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
    I	12:59:18.196	Connection parameters updated (interval: 15.0ms, latency: 0, timeout: 6000ms)
    I	12:59:18.400	Connection parameters updated (interval: 7.5ms, latency: 0, timeout: 5000ms)
    D	12:59:18.499	[Callback] Services discovered with status: 0
    I	12:59:18.499	Services discovered
    V	12:59:18.503	Generic Access (0x1800)
    - Device Name [R W] (0x2A00)
    - Appearance [R] (0x2A01)
    - Peripheral Preferred Connection Parameters [R] (0x2A04)
    - Central Address Resolution [R] (0x2AA6)
    Generic Attribute (0x1801)
    Secure DFU Service (0xFE59)
    - DFU Packet [WNR] (8ec90002-f315-4f60-9fb8-838830daea50)
    - DFU Control Point [N W] (8ec90001-f315-4f60-9fb8-838830daea50)
       Client Characteristic Configuration (0x2902)
    I	12:59:18.580	Connection parameters updated (interval: 15.0ms, latency: 0, timeout: 6000ms)
    I	12:59:20.703	PHY updated (TX: LE 2M, RX: LE 2M)
    V	12:59:34.654	[DFU] DFU service started
    V	12:59:34.654	[DFU] Opening file...
    I	12:59:34.683	[DFU] Firmware file opened successfully
    V	12:59:34.683	[DFU] Connecting to DFU target...
    D	12:59:34.683	[DFU] gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferredPhy = LE_1M | LE_2M)
    I	12:59:34.688	[DFU] Connected to F9:3E:58:83:16:E0
    V	12:59:34.688	[DFU] Discovering services...
    D	12:59:34.688	[DFU] gatt.discoverServices()
    I	12:59:34.689	[DFU] Services discovered
    V	12:59:34.705	[DFU] Requesting new MTU...
    D	12:59:34.705	[DFU] gatt.requestMtu(517)
    I	12:59:34.719	[DFU] MTU changed to: 247
    V	12:59:34.719	[DFU] Enabling notifications for 8ec90001-f315-4f60-9fb8-838830daea50
    D	12:59:34.719	[DFU] gatt.setCharacteristicNotification(8ec90001-f315-4f60-9fb8-838830daea50, true)
    D	12:59:34.721	[DFU] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x01-00)
    I	12:59:34.780	[DFU] Data written to descr.8ec90001-f315-4f60-9fb8-838830daea50
    V	12:59:34.780	[DFU] Notifications enabled for 8ec90001-f315-4f60-9fb8-838830daea50
    A	12:59:34.780	[DFU] Notifications enabled
    V	12:59:34.780	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 06-01
    D	12:59:34.780	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50, value=0x06-01, WRITE_TYPE_DEFAULT)
    I	12:59:34.809	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
    I	12:59:34.810	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-06-01-00-02-00-00-00-00-00-00-00-00-00-00
    A	12:59:34.810	[DFU] Command object info received (Max size = 512, Offset = 0, CRC = 00000000)
    V	12:59:34.810	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 02-00-00
    D	12:59:34.810	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50, value=0x02-00-00, WRITE_TYPE_DEFAULT)
    I	12:59:34.839	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
    I	12:59:34.839	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-02-01
    A	12:59:34.839	[DFU] Packet Receipt Notif disabled (Op Code = 2, Value = 0)
    V	12:59:34.839	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 01-01-D2-00-00-00
    D	12:59:34.839	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50, value=0x01-01-D2-00-00-00, WRITE_TYPE_DEFAULT)
    I	12:59:34.869	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
    I	12:59:34.869	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-01-01
    A	12:59:34.870	[DFU] Command object created
    V	12:59:34.870	[DFU] Writing to characteristic 8ec90002-f315-4f60-9fb8-838830daea50 value (0x): 12-CF-01-0A-88-01-08-01-12-83-01-08-8A-44-10-34-1A-04-80-02-A3-02-20-00-28-00-30-00-38-F8-81-1D-42-24-08-03-12-20-08-73-6A-FB-5F-BF-64-22-A5-7A-B3-3F-E6-DC-3A-1F-12-8F-88-27-D4-67-AA-C4-77-BB-D4-E1-74-CF-A0-2D-48-00-52-44-08-03-12-40-7E-0E-2C-0D-F3-00-9B-CB-95-64-E8-66-2A-DA-6D-83-14-64-B8-81-BB-1C-91-E1-DA-2F-95-B3-55-33-85-00-63-1D-41-C0-7F-EB-54-8E-EC-33-AF-AF-6C-59-44-B5-DE-60-AA-68-14-31-02-85-E0-B7-0D-E4-11-9E-FA-FF-10-00-1A-40-E0-DA-01-4D-ED-0F-57-DA-44-26-CF-8C-66-F0-D2-CF-B4-39-E6-A3-6C-23-85-8F-4F-2E-60-EA-87-D1-16-75-FC-E2-19-FC-F3-0C-CB-76-95-F1-64-A4-75-5B-13-B7-64-94-9C-59-D1-3C-77-E8-F9-6B-CB-C7-65-3D-A1-EE
    D	12:59:34.870	[DFU] gatt.writeCharacteristic(8ec90002-f315-4f60-9fb8-838830daea50, value=0x12-CF-01-0A-88-01-08-01-12-83-01-08-8A-44-10-34-1A-04-80-02-A3-02-20-00-28-00-30-00-38-F8-81-1D-42-24-08-03-12-20-08-73-6A-FB-5F-BF-64-22-A5-7A-B3-3F-E6-DC-3A-1F-12-8F-88-27-D4-67-AA-C4-77-BB-D4-E1-74-CF-A0-2D-48-00-52-44-08-03-12-40-7E-0E-2C-0D-F3-00-9B-CB-95-64-E8-66-2A-DA-6D-83-14-64-B8-81-BB-1C-91-E1-DA-2F-95-B3-55-33-85-00-63-1D-41-C0-7F-EB-54-8E-EC-33-AF-AF-6C-59-44-B5-DE-60-AA-68-14-31-02-85-E0-B7-0D-E4-11-9E-FA-FF-10-00-1A-40-E0-DA-01-4D-ED-0F-57-DA-44-26-CF-8C-66-F0-D2-CF-B4-39-E6-A3-6C-23-85-8F-4F-2E-60-EA-87-D1-16-75-FC-E2-19-FC-F3-0C-CB-76-95-F1-64-A4-75-5B-13-B7-64-94-9C-59-D1-3C-77-E8-F9-6B-CB-C7-65-3D-A1-EE, WRITE_TYPE_NO_RESPONSE)
    I	12:59:34.873	[DFU] Data written to 8ec90002-f315-4f60-9fb8-838830daea50
    A	12:59:34.873	[DFU] Command object sent (CRC = B473C829)
    V	12:59:34.873	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 03
    D	12:59:34.873	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50, value=0x03, WRITE_TYPE_DEFAULT)
    I	12:59:34.900	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-03-01-D2-00-00-00-29-C8-73-B4
    I	12:59:34.901	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
    A	12:59:34.902	[DFU] Checksum received (Offset = 210, CRC = B473C829)
    V	12:59:34.902	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 04
    D	12:59:34.902	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50, value=0x04, WRITE_TYPE_DEFAULT)
    I	12:59:34.929	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
    I	12:59:34.944	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-04-01
    A	12:59:34.944	[DFU] Command object executed
    V	12:59:34.944	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 06-02
    D	12:59:34.945	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50, value=0x06-02, WRITE_TYPE_DEFAULT)
    I	12:59:34.974	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
    I	12:59:34.974	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-06-01-00-10-00-00-00-00-00-00-00-00-00-00
    A	12:59:34.974	[DFU] Data object info received (Max size = 4096, Offset = 0, CRC = 00000000)
    V	12:59:34.999	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 01-02-00-10-00-00
    D	12:59:34.999	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50, value=0x01-02-00-10-00-00, WRITE_TYPE_DEFAULT)
    I	12:59:35.112	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-01-01
    I	12:59:35.112	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
    A	12:59:35.112	[DFU] Data object (1/117) created
    D	12:59:35.112	[DFU] wait(400)
    A	12:59:35.513	[DFU] Uploading firmware...
    V	12:59:35.513	[DFU] Sending firmware to characteristic 8ec90002-f315-4f60-9fb8-838830daea50...
    V	12:59:35.548	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 03
    D	12:59:35.548	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50, value=0x03, WRITE_TYPE_DEFAULT)
    I	12:59:35.605	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
    I	12:59:35.606	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-03-01-00-10-00-00-7C-E3-92-0A
    A	12:59:35.607	[DFU] Checksum received (Offset = 4096, CRC = 0A92E37C)
    V	12:59:35.608	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 04
    D	12:59:35.608	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50, value=0x04, WRITE_TYPE_DEFAULT)
    I	12:59:35.634	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
    I	12:59:35.816	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-04-01
    A	12:59:35.816	[DFU] Data object executed
    V	12:59:35.816	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 01-02-00-10-00-00
    D	12:59:35.816	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50, value=0x01-02-00-10-00-00, WRITE_TYPE_DEFAULT)
    I	12:59:35.844	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
    I	12:59:35.844	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-01-01
    A	12:59:35.844	[DFU] Data object (2/117) created
    D	12:59:35.844	[DFU] wait(400)
    A	12:59:36.245	[DFU] Uploading firmware...
    V	12:59:36.245	[DFU] Sending firmware to characteristic 8ec90002-f315-4f60-9fb8-838830daea50...
    V	12:59:36.319	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 03
    D	12:59:36.319	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50, value=0x03, WRITE_TYPE_DEFAULT)
    I	12:59:36.356	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
    I	12:59:36.356	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-03-01-00-20-00-00-BA-00-F7-3B
    A	12:59:36.357	[DFU] Checksum received (Offset = 8192, CRC = 3BF700BA)
    V	12:59:36.357	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 04
    D	12:59:36.357	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50, value=0x04, WRITE_TYPE_DEFAULT)
    I	12:59:36.385	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
    I	12:59:36.552	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-04-01
    A	12:59:36.552	[DFU] Data object executed
    V	12:59:36.552	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 01-02-00-10-00-00
    D	12:59:36.552	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50, value=0x01-02-00-10-00-00, WRITE_TYPE_DEFAULT)
    I	12:59:36.579	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
    I	12:59:36.579	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-01-01
    A	12:59:36.579	[DFU] Data object (3/117) created
    D	12:59:36.579	[DFU] wait(400)
    A	12:59:36.981	[DFU] Uploading firmware...
    V	12:59:36.981	[DFU] Sending firmware to characteristic 8ec90002-f315-4f60-9fb8-838830daea50...
    V	12:59:37.053	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 03
    D	12:59:37.054	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50, value=0x03, WRITE_TYPE_DEFAULT)
    I	12:59:37.105	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
    I	12:59:37.106	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-03-01-00-30-00-00-AC-76-E2-39
    A	12:59:37.106	[DFU] Checksum received (Offset = 12288, CRC = 39E276AC)
    V	12:59:37.107	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 04
    D	12:59:37.107	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50, value=0x04, WRITE_TYPE_DEFAULT)
    I	12:59:37.135	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
    I	12:59:37.290	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-04-01
    A	12:59:37.290	[DFU] Data object executed
    V	12:59:37.290	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 01-02-00-10-00-00
    D	12:59:37.290	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50, value=0x01-02-00-10-00-00, WRITE_TYPE_DEFAULT)
    I	12:59:37.332	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-01-01
    I	12:59:37.333	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
    A	12:59:37.333	[DFU] Data object (4/117) created
    D	12:59:37.333	[DFU] wait(400)
    A	12:59:37.734	[DFU] Uploading firmware...
    V	12:59:37.735	[DFU] Sending firmware to characteristic 8ec90002-f315-4f60-9fb8-838830daea50...
    V	12:59:37.814	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 03
    D	12:59:37.814	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50, value=0x03, WRITE_TYPE_DEFAULT)
    D	12:59:43.546	[Callback] Connection state changed with status: 8 and new state: DISCONNECTED (0)
    E	12:59:43.547	Error 8 (0x8): GATT CONN TIMEOUT
    I	12:59:43.547	Disconnected
    E	12:59:43.557	[DFU] Error (0x85): GATT ERROR
    V	12:59:43.558	[DFU] Disconnecting...
    D	12:59:43.597	[DFU] gatt.disconnect()
    I	12:59:43.597	[DFU] Disconnected
    D	12:59:43.597	[DFU] gatt.refresh() (hidden)
    D	12:59:43.597	[DFU] gatt.disconnect()
    D	12:59:43.605	[DFU] gatt.close()
    D	12:59:43.605	[DFU] wait(600)
    D	12:59:43.605	[Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
    D	12:59:43.617	[DFU] [Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
    D	12:59:44.205	gatt.close()
    D	12:59:44.215	wait(200)
    V	12:59:44.418	Connecting to F9:3E:58:83:16:E0...
    D	12:59:44.418	gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M)
    

  • I saw that the Offset of the packet 2 is still 4096 and therefore from packet 1, here is the error:

  • So this means that the init packet is good, right?

    After that, you decide whether you want to check whether the image itself is good or not (you mentioned that it was checked at an earlier stage, right?)

    If you skip that check, or it looks good, then starts the process of deleting the old image in bank0, and replace it with the image in the QSPI flash. Usually, this is triggered by the DFU master sending the image in chunks. I guess you can look for that, and re-use parts of it. But basically, the work that needs to be done is to erase all the pages needed for the new image, and write the data from the QSPI flash to bank0. After this, you can restart, and the bootloader should detect that there is a new image present (I think). When it does, it will check the CRC once more, and store the findings into the bootloader settings. Then it will do a final reset, and boot up the appplication.

    At least, from memory, this is the flow. I guess you can start by copying the image, resetting, and see how it behaves.

    Best regards,

    Edvin

  • NB: I will be out of office next week, so if you reply, this will be assigned to someone else. I hope you get it working, and if not, your questions will be handled by one of my colleagues.

    Best regards,

    Edvin

  • Hi Edvin

    It's working!!!

    I had to update also the function nrf_crypto_hash_calculate to read in parts the QSPI flash and loop the update function (read to RAM, nrf_crypto_hash_update, loop again until size is finished)

    Thank you so much, I'm in vacation also, now its even sweeter to go :-)

  • Hello,

    That is awsome! Nothing like taking a vacation after you got everything working! 

    Then let's hope it is case closed for now. If any related questions should pop up during July, I suggest you create a new ticket, where you can link to this one for background information. 

    If something pops up in August or later, then you can use this one.

    Have a nice summer!

    Best regards,

    Edvin

  • Thank you, have a nice time aswell

    just for information for others: I check the additional bootloader flag here line 33:

    ret_code_t nrf_bootloader_init(nrf_dfu_observer_t observer)
    {
    	NRF_LOG_DEBUG("In nrf_bootloader_init");
    	ret_code_t                            ret_val;
    	nrf_bootloader_fw_activation_result_t activation_result;
    	uint32_t                              initial_timeout;
    	bool                                  dfu_enter = false;
    	m_user_observer = observer;
    
    	if (NRF_BL_DEBUG_PORT_DISABLE)
    	{
    		nrf_bootloader_debug_port_disable();
    	}
    
    #if NRF_BL_DFU_ENTER_METHOD_BUTTON
    	dfu_enter_button_init();
    #endif
    	ret_val = nrf_dfu_settings_init(false);
    
    	if (ret_val != NRF_SUCCESS)
    	{
    		return NRF_ERROR_INTERNAL;
    	}
    
    #if NRF_BL_DFU_ALLOW_UPDATE_FROM_APP
    
    	// Postvalidate if DFU has signaled that update is ready.
    	if (s_dfu_settings.bank_current == NRF_DFU_CURRENT_BANK_1)
    	{
    		postvalidate();
    	}
    
        if (NRF_BL_DFU_ENTER_METHOD_GPREGRET &&
    	        ((nrf_power_gpregret_get() & BOOTLOADER_QSPI_START_MASK) == BOOTLOADER_QSPI_START))
    	{
            init_package_qspi_handle();
    		dfu_enter_flags_clear();
    	}
    
    #endif
    	// Check if an update needs to be activated and activate it.
    	activation_result = nrf_bootloader_fw_activate();
    
    	switch (activation_result)

Reply
  • Thank you, have a nice time aswell

    just for information for others: I check the additional bootloader flag here line 33:

    ret_code_t nrf_bootloader_init(nrf_dfu_observer_t observer)
    {
    	NRF_LOG_DEBUG("In nrf_bootloader_init");
    	ret_code_t                            ret_val;
    	nrf_bootloader_fw_activation_result_t activation_result;
    	uint32_t                              initial_timeout;
    	bool                                  dfu_enter = false;
    	m_user_observer = observer;
    
    	if (NRF_BL_DEBUG_PORT_DISABLE)
    	{
    		nrf_bootloader_debug_port_disable();
    	}
    
    #if NRF_BL_DFU_ENTER_METHOD_BUTTON
    	dfu_enter_button_init();
    #endif
    	ret_val = nrf_dfu_settings_init(false);
    
    	if (ret_val != NRF_SUCCESS)
    	{
    		return NRF_ERROR_INTERNAL;
    	}
    
    #if NRF_BL_DFU_ALLOW_UPDATE_FROM_APP
    
    	// Postvalidate if DFU has signaled that update is ready.
    	if (s_dfu_settings.bank_current == NRF_DFU_CURRENT_BANK_1)
    	{
    		postvalidate();
    	}
    
        if (NRF_BL_DFU_ENTER_METHOD_GPREGRET &&
    	        ((nrf_power_gpregret_get() & BOOTLOADER_QSPI_START_MASK) == BOOTLOADER_QSPI_START))
    	{
            init_package_qspi_handle();
    		dfu_enter_flags_clear();
    	}
    
    #endif
    	// Check if an update needs to be activated and activate it.
    	activation_result = nrf_bootloader_fw_activate();
    
    	switch (activation_result)

Children
No Data
Related