Extract uhk.jumpToModuleBootloader() and use it.
This commit is contained in:
@@ -11,5 +11,5 @@ const moduleSlotId = uhk.checkModuleSlot(moduleSlot, uhk.moduleSlotToId);
|
||||
const device = uhk.getUhkDevice();
|
||||
|
||||
(async function() {
|
||||
await uhk.writeDevice(device, [uhk.usbCommands.jumpToModuleBootloader, moduleSlotId]);
|
||||
await uhk.jumpToModuleBootloader(device, moduleSlotId);
|
||||
})();
|
||||
|
||||
@@ -200,6 +200,10 @@ async function sendKbootCommandToModule(device, kbootCommandId, i2cAddress) {
|
||||
return await uhk.writeDevice(device, [uhk.usbCommands.sendKbootCommandToModule, kbootCommandId, parseInt(i2cAddress)])
|
||||
};
|
||||
|
||||
async function jumpToModuleBootloader(device, moduleSlotId) {
|
||||
await uhk.writeDevice(device, [uhk.usbCommands.jumpToModuleBootloader, moduleSlotId]);
|
||||
};
|
||||
|
||||
uhk = exports = module.exports = moduleExports = {
|
||||
bufferToString,
|
||||
getUint16,
|
||||
@@ -216,6 +220,7 @@ uhk = exports = module.exports = moduleExports = {
|
||||
updateDeviceFirmware,
|
||||
reenumerate,
|
||||
sendKbootCommandToModule,
|
||||
jumpToModuleBootloader,
|
||||
usbCommands: {
|
||||
getDeviceProperty : 0x00,
|
||||
reenumerate : 0x01,
|
||||
|
||||
@@ -11,6 +11,7 @@ program
|
||||
.parse(process.argv)
|
||||
|
||||
let moduleSlot = program.args[0];
|
||||
const moduleSlotId = uhk.checkModuleSlot(moduleSlot, uhk.moduleSlotToId);
|
||||
const i2cAddress = uhk.checkModuleSlot(moduleSlot, uhk.moduleSlotToI2cAddress);
|
||||
|
||||
const firmwareImage = program.args[1];
|
||||
@@ -24,8 +25,8 @@ const blhostBuspal = `${blhostUsb} --buspal i2c,${i2cAddress}`;
|
||||
config.verbose = true;
|
||||
let device = uhk.getUhkDevice();
|
||||
await uhk.sendKbootCommandToModule(device, uhk.kbootCommands.ping, i2cAddress);
|
||||
await uhk.jumpToModuleBootloader(device, moduleSlotId);
|
||||
device.close();
|
||||
exec(`${usbDir}/jump-to-module-bootloader.js ${moduleSlot}`);
|
||||
exec(`${usbDir}/wait-for-kboot-idle.js`);
|
||||
|
||||
await uhk.reenumerate('buspal');
|
||||
|
||||
Reference in New Issue
Block a user