Extract uhk.jumpToModuleBootloader() and use it.

This commit is contained in:
László Monda
2018-01-31 01:17:28 +01:00
parent 4f8a0247d3
commit df14e2d569
3 changed files with 8 additions and 2 deletions

View File

@@ -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);
})();

View File

@@ -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,

View File

@@ -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');