Make update-slave-firmware expect a module slot name, too.

This commit is contained in:
László Monda
2017-11-08 03:47:51 +01:00
parent ac5d6ba32a
commit 9a5862b57c
2 changed files with 25 additions and 8 deletions

View File

@@ -98,6 +98,11 @@ exports = module.exports = moduleExports = {
ping: 1,
reset: 2,
},
moduleSlotToI2cAddress: {
leftHalf: 0x10,
leftAddon: 0x20,
rightAddon: 0x30,
},
leftLedDriverAddress: 0b1110100,
rightLedDriverAddress: 0b1110111,
sendLog: sendLog,

View File

@@ -1,4 +1,5 @@
#!/usr/bin/env node
const uhk = require('./uhk');
const program = require('commander');
require('shelljs/global');
require('./shared')
@@ -7,18 +8,29 @@ const extension = '.bin';
config.fatal = true;
program
.usage(`update-slave-firmware <firmware-image${extension}>`)
.usage(`update-slave-firmware <module-slot> <firmware-image${extension}>`)
.parse(process.argv)
const firmwareImage = program.args[0];
const usbDir = `${__dirname}`;
const blhostUsb = getBlhostCmd(0x6121);
const blhostBuspal = `${blhostUsb} --buspal i2c,0x10,100k`;
let moduleSlot = program.args[0];
let i2cAddress = uhk.moduleSlotToI2cAddress[moduleSlot];
if (!i2cAddress) {
echo(`Invalid module slot specified.`);
echo(`Valid slots are: ${Object.keys(uhk.moduleSlotToI2cAddress).join(', ')}.`);
exit(1);
}
i2cAddress = `0x${i2cAddress.toString(16)}`;
const firmwareImage = program.args[1];
checkFirmwareImage(firmwareImage, extension);
const usbDir = `${__dirname}`;
const blhostUsb = getBlhostCmd(0x6121);
const blhostBuspal = `${blhostUsb} --buspal i2c,${i2cAddress},100k`;
config.verbose = true;
exec(`${usbDir}/send-kboot-command-to-slave.js ping 0x10`);
exec(`${usbDir}/send-kboot-command-to-slave.js ping ${i2cAddress}`);
exec(`${usbDir}/jump-to-slave-bootloader.js`);
exec(`${usbDir}/reenumerate.js buspal`);
execRetry(`${blhostBuspal} get-property 1`);
@@ -26,7 +38,7 @@ exec(`${blhostBuspal} flash-erase-all-unsecure`);
exec(`${blhostBuspal} write-memory 0x0 ${firmwareImage}`);
exec(`${blhostUsb} reset`);
exec(`${usbDir}/reenumerate.js normalKeyboard`);
execRetry(`${usbDir}/send-kboot-command-to-slave.js reset 0x10`);
execRetry(`${usbDir}/send-kboot-command-to-slave.js reset ${i2cAddress}`);
config.verbose = false;
echo('Firmware updated successfully');
echo('Firmware updated successfully.');