Hello,
My colleague has posted this issue in Github (see https://github.com/NordicSemiconductor/Android-nRF-Connect-Device-Manager/issues/79) , but also want to post it here:
We use this library (1.4.1) in our mobile app to upgrade our BLE Device firmware (DFU, Zephyr, McuBoot). The iOS version of this library works as expected, but we have issues making this upgrade process work with the Android version. The device image used for both cases is the same.
This issue is also in the nRF Connect application (4.26.0) for Android. nRF Connect app for iOS works (2.5.3).
I have included below the code we use for iOS and Android and the messages from the BLE device during the upgrade process with the Android version.
Could you please help? Thanks!
BLE Device Output
BLE Deviceuart:~$ *** Booting Zephyr OS version 2.3.99 ***
[00:00:00.003,601] <inf> mcuboot: Starting bootloader
[00:00:00.009,704] <inf> mcuboot: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
[00:00:00.019,561] <inf> mcuboot: Boot source: none
[00:00:00.024,932] <inf> mcuboot: Swap type: perm
[00:00:08.675,231] <err> mcuboot: Image in the secondary slot is not valid!
[00:00:09.051,116] <inf> mcuboot: Bootloader chainload address offset: 0xe000
[00:00:09.058,654] <inf> mcuboot: Jumping to the first image slot
iOS Code (Swift)
private func startDfu(_ address: String, binary: FlutterStandardTypedData, result: @escaping FlutterResult) {
guard let uuid = UUID(uuidString: address) else {
result(FlutterError(code: "DEVICE_ADDRESS_ERROR", message: "Device address conversion failed.", details: "Device address \(address) conversion failed"))
return
}
guard let imageData = getImageData(binary: binary) else {
result(FlutterError(code: "FIRMWARE_NOT_FOUND", message: "Binary file not valid.", details: nil))
return
}
let bleTransport = McuMgrBleTransport(uuid)
let dfuManager = FirmwareUpgradeManager(transporter: bleTransport, delegate: self)
dfuManager.logDelegate = UIApplication.shared.delegate as? McuMgrLogDelegate
dfuManager.estimatedSwapTime = 20.0
do {
try dfuManager.start(data: imageData)
} catch {
print("Error reading hash: \(error)")
}
}
Android Code (Kotlin)
fun startDfu(binary: ByteArray): Unit {
getBleDevice(address) { device ->
val transport: McuMgrTransport = McuMgrBleTransport(context, device);
val dfuManager = FirmwareUpgradeManager(transport, this)
dfuManager.setEstimatedSwapTime(20000)
dfuManager.setMode(FirmwareUpgradeManager.Mode.CONFIRM_ONLY)
val eraseStorage = false
val imageData = getImageData(binary)
dfuManager.start(imageData, eraseStorage)
}
}