I am working on an IOS app to do BLE OTA of custom hardware. I'm currently using a development kit to simulate the hardware.
I am using this flowchart to try to do an OTA update from my IOS application.
What I've done so far:
- Created an IOS application to connect and work with the radio application code. The application code appears to work well.
- Performed and OAT update of the hardware from the nRF Connect app. This works every time.
- Added commands to my IOS app to start the DFU bootloader. This also works, the application code on the radio disconnects and the DFU bootloader starts advertising and I can connect to it.
- I can set the PRN value to zero (since I didn't want to deal with it at the moment)
- Successfully send the select, create and init data packets.
What I don't understand is that the calculate CRC (0x03) command sent after the init packet data returns zero for the offset and the CRC.
The following are logs from my IOS application. Everything appears to match the flow chart except the response to the CRC command.
DFUController: Found '.dat' file, size = 141, crc = 0xC3DB5CE3 DFUController: Found '.bin' file, size = 68168, crc = 0xCF637DD3 central.state is .poweredOn DFU Connected Found service with uuid FE59 <CBCharacteristic: 0x281f30120, UUID = 8EC90002-F315-4F60-9FB8-838830DAEA50, properties = 0x4, value = (null), notifying = NO> <CBCharacteristic: 0x281f30060, UUID = 8EC90001-F315-4F60-9FB8-838830DAEA50, properties = 0x18, value = {length = 11, bytes = 0x6003010000000000000000}, notifying = NO> DFUController: In start() DFUController: In reset() DFUController: In sendInitSetPRN() DFUController: Writing to control point: 0x02 0x00 0x00 DFUController: In processResponse(): data = 0x60 0x02 0x01 DFUController: In processPRNResponse - success DFUController: In sendInitRequest() DFUController: Writing to control point: 0x06 0x01 DFUController: In processResponse(): data = 0x60 0x06 0x01 0x00 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 DFUController: In processInitRequest, maxSize = 0x00000200 (512), offset = 0x00000000 (0) DFUController: In processInitRequest - success - calling sendInitCreate() DFUController: In sendInitCreate() DFUController: Writing to control point: 0x01 0x01 0x8D 0x00 0x00 0x00 DFUController: In processResponse(): data = 0x60 0x01 0x01 DFUController: In processInitCreateResponse - success size: 0x0000008D, bytesLeft: 0x00000079, pCRC: 0xE1C3FCDE, cCRC: 0xC3DB5CE3 DFUController: Writing to data point: 0x12 0x8A 0x01 0x0A 0x44 0x08 0x01 0x12 0x40 0x08 0x00 0x10 0x34 0x1A 0x02 0x81 0x02 0x20 0x00 0x28 size: 0x0000008D, bytesLeft: 0x00000065, pCRC: 0x05B44867, cCRC: 0xC3DB5CE3 DFUController: Writing to data point: 0x00 0x30 0x00 0x38 0xC8 0x94 0x04 0x42 0x24 0x08 0x03 0x12 0x20 0xFC 0x02 0x63 0x89 0x41 0xFC 0x47 size: 0x0000008D, bytesLeft: 0x00000051, pCRC: 0x298DB4D0, cCRC: 0xC3DB5CE3 DFUController: Writing to data point: 0x7F 0x2C 0x21 0x99 0x5E 0xEB 0xC5 0x3F 0x57 0x81 0x38 0x89 0x9F 0x8F 0xBB 0xFF 0x32 0x4F 0x47 0x61 size: 0x0000008D, bytesLeft: 0x0000003D, pCRC: 0xF0B23407, cCRC: 0xC3DB5CE3 DFUController: Writing to data point: 0xB3 0x61 0xE8 0xE6 0x66 0x48 0x00 0x52 0x04 0x08 0x01 0x12 0x00 0x10 0x00 0x1A 0x40 0xE7 0x9A 0x13 size: 0x0000008D, bytesLeft: 0x00000029, pCRC: 0xB0DA652D, cCRC: 0xC3DB5CE3 DFUController: Writing to data point: 0x82 0x1D 0xE8 0xA2 0xBD 0x42 0xB8 0xBB 0xF2 0x05 0xAC 0xBE 0x3E 0x0B 0xBA 0x87 0x01 0x76 0x9C 0x01 size: 0x0000008D, bytesLeft: 0x00000015, pCRC: 0x53474700, cCRC: 0xC3DB5CE3 DFUController: Writing to data point: 0xED 0x44 0x21 0x57 0xCD 0x2B 0x3F 0xE4 0x05 0xBF 0xCA 0xFB 0x1D 0xF3 0xD0 0xE7 0x3A 0xBC 0x4E 0xDF size: 0x0000008D, bytesLeft: 0x00000001, pCRC: 0xD8B832C6, cCRC: 0xC3DB5CE3 DFUController: Writing to data point: 0xDA 0x01 0xF7 0x2F 0x88 0x85 0xC4 0x7E 0x87 0xE0 0x93 0x2A 0x76 0x53 0x22 0x29 0x58 0x51 0x70 0x7E size: 0x0000008D, bytesLeft: 0x00000000, pCRC: 0xC3DB5CE3, cCRC: 0xC3DB5CE3 DFUController: Writing to data point: 0x1D DFUController: Writing to control point: 0x03 DFUController: In sendInitData() - success DFUController: In processResponse(): data = 0x60 0x03 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 DFUController: In processInitDataResponse(), offset = 0x00000000, crc = 0x00000000 DFUController: Init packet failure, CRCs do not match
The lines with size, bytesLeft, pCRC (partial CRC) and cCRC (complete CRC) are from the stream holding the .dat file contents. All 141 bytes are wrtten and the CRCs appear to make sense.