Closed keeramis closed 1 year ago
Just a quick update regarding the progress on the DFU upload functionality. I've encountered some challenges when implementing the upload feature on nodeusb perhaps/apparently due to differences in how webdfu and nodeusb handle the upload process. It might take some time to look at it so to avoid delaying the release of the current functionality, I'll proceed with creating this PR without the upload feature. Rest assured, I'll continue working on the upload functionality in a separate PR, but for the upcoming RC, it's not an essential requirement.
Tested with argon:
I'm getting an sos
issue after flashing system-part
and user-part
I'll try again tomorrow. I'm assuming my implementation is broken hehe
Update: It was my device hehe 😅
Description
This pull request introduces new functionality to enable firmware download to a module using the Device Firmware Update (DFU) mechanism. The
flashWithDfu
method is designed to enable the flashing of any USB device in DFU mode.To utilize this functionality, users are required to provide the following required arguments:
binary-version-reader
doManifestation : true
ornoErase : true
How to test
Flash system parts and user parts
async function main() { const devices = await usb.getDevices(); if (devices.length === 0) { throw new Error('No devices found'); } const device = devices[0]; console.log('Device : ', device); await device.open(); await device.enterDfuMode();
const buf = await fs.readFile('/path/to/binaries/5.4.0/p2/p2-system-part1@5.4.0.bin'); const reader = new HalModuleParser(); const parsed = await reader.parseBuffer({ fileBuffer: buf }); const addr = parseInt(parsed.prefixInfo.moduleStartAddy, 16); await device.writeOverDfu(0, parsed.fileBuffer, addr, {}); // the
0
is obtained from particle-cliconst bufTinker = await fs.readFile('/path/to/binaries/5.4.0/p2/p2-tinker@5.4.0.bin'); const parsedTinker = await reader.parseBuffer({ fileBuffer: bufTinker }); const addrTinker = parseInt(parsedTinker.prefixInfo.moduleStartAddy, 16); await device.writeOverDfu(0, parsedTinker.fileBuffer, addrTinker, { doManifestation: true }); }
main().catch((error) => { console.error('Error:', error.message); });
const usb = require('/path/to/local/particle-usb'); const fs = require('fs-extra'); const { HalModuleParser } = require('binary-version-reader');
async function main() { const devices = await usb.getDevices(); if (devices.length === 0) { throw new Error('No devices found'); } const device = devices[0]; console.log('Device : ', device); await device.open(); await device.enterDfuMode();
const keysStr = await fs.readFile('/path/to/module/key', 'binary'); const keysBuf = Buffer.from(keysStr, 'binary'); await device.flashWithDfu(1, keysBuf, 3106, { doManifestation: true }); }
main().catch((error) => { console.error('Error:', error.message); });