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