Extract checkFirmwareImage()

This commit is contained in:
László Monda
2017-10-29 17:47:24 +01:00
parent f847cc844e
commit a5402e7c6a
2 changed files with 22 additions and 17 deletions

View File

@@ -3,33 +3,20 @@ const program = require('commander');
require('shelljs/global');
require('./shared')
const extension = '.bin';
config.fatal = true;
program
.usage('update-slave-firmware <firmware-image>')
.usage(`update-slave-firmware <firmware-image${extension}>`)
.parse(process.argv)
const firmwareImage = program.args[0];
if (!firmwareImage) {
echo('No firmware image specified');
exit(1);
}
if (!firmwareImage.endsWith('.bin')) {
echo('Firmware image extension is not .bin');
exit(1);
}
if (!test('-f', firmwareImage)) {
echo('Firmware image does not exist');
exit(1);
}
const usbDir = '../../../lib/agent/packages/usb';
const blhostUsb = getBlhostCmd();
const blhostBuspal = blhostUsb + ' --buspal i2c,0x10,100k';
checkFirmwareImage(firmwareImage, extension);
config.verbose = true;
exec(`${usbDir}/send-kboot-command-to-slave.js ping 0x10`);
exec(`${usbDir}/jump-to-slave-bootloader.js`);