Closed webjay closed 11 months ago
To see how a firmware is built, before the public key for Apple is inserted, it is probably easiest to follow this step: https://github.com/SpaceInvaderTech/openhaystack_moko/tree/actions#compile-via-docker Which produces this output: https://github.com/SpaceInvaderTech/openhaystack_moko/pull/1#issue-2028337592
The problems were:
ecdsa-sha2-nistp256
. So I just had to replace sign(null, ...
with sign('sha256', ...
. https://github.com/SpaceInvaderTech/blu-transmogrifier/blob/0f50ba1af025c0cc6c5da6c9eb49415b9a6279f8/src/crypt.ts#L40-L43dfu.Command.encode(commandMessage).finish()
is prepended with 4 bytes which is presumed to be the length. So I strip those, and it works 🤷 https://github.com/SpaceInvaderTech/blu-transmogrifier/blob/0f50ba1af025c0cc6c5da6c9eb49415b9a6279f8/src/initpacket.ts#L63-L67
Creating a packet for update via DFU works, meaning I can create a zip file and see the content:
Which shows:
A packet created via a OpenHaystack fork looks similar:
The
EA140CF93E0D.zip
can be succesfully transferred to the Moko device. Theblu-transmogrifier/firmware.zip
fails the DFU process with "Invalid object".The halfbaked firmware is baked in a process like this.
The initpacket is made here: https://github.com/SpaceInvaderTech/blu-transmogrifier/blob/main/src/initpacket.ts Based on protocol buffers: https://github.com/SpaceInvaderTech/blu-transmogrifier/blob/main/src/protobuf/dfu.proto
The signature is made in
signData
: https://github.com/SpaceInvaderTech/blu-transmogrifier/blob/main/src/crypt.tsDevice Firmware Update process: https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.0.0/lib_bootloader_dfu_process.html
This seems to be how the device validates: https://github.com/DiUS/nRF5-SDK-15.3.0-reduced/blob/master/components/libraries/bootloader/dfu/nrf_dfu_validation.c#L341-L417
Following this will show each step: https://github.com/SpaceInvaderTech/blu-transmogrifier/blob/main/test/main.test.ts