Extract checkFirmwareImage()
This commit is contained in:
@@ -1,5 +1,22 @@
|
|||||||
require('shelljs/global');
|
require('shelljs/global');
|
||||||
|
|
||||||
|
function checkFirmwareImage(imagePath, extension) {
|
||||||
|
if (!imagePath) {
|
||||||
|
echo('No firmware image specified');
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!imagePath.endsWith(extension)) {
|
||||||
|
echo(`Firmware image extension is not ${extension}`);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!test('-f', imagePath)) {
|
||||||
|
echo('Firmware image does not exist');
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getBlhostCmd() {
|
function getBlhostCmd() {
|
||||||
let blhostPath;
|
let blhostPath;
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
@@ -37,6 +54,7 @@ function execRetry(command) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const exp = {
|
const exp = {
|
||||||
|
checkFirmwareImage,
|
||||||
getBlhostCmd,
|
getBlhostCmd,
|
||||||
execRetry,
|
execRetry,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,33 +3,20 @@ const program = require('commander');
|
|||||||
require('shelljs/global');
|
require('shelljs/global');
|
||||||
require('./shared')
|
require('./shared')
|
||||||
|
|
||||||
|
const extension = '.bin';
|
||||||
config.fatal = true;
|
config.fatal = true;
|
||||||
|
|
||||||
program
|
program
|
||||||
.usage('update-slave-firmware <firmware-image>')
|
.usage(`update-slave-firmware <firmware-image${extension}>`)
|
||||||
.parse(process.argv)
|
.parse(process.argv)
|
||||||
|
|
||||||
const firmwareImage = program.args[0];
|
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 usbDir = '../../../lib/agent/packages/usb';
|
||||||
const blhostUsb = getBlhostCmd();
|
const blhostUsb = getBlhostCmd();
|
||||||
const blhostBuspal = blhostUsb + ' --buspal i2c,0x10,100k';
|
const blhostBuspal = blhostUsb + ' --buspal i2c,0x10,100k';
|
||||||
|
|
||||||
|
checkFirmwareImage(firmwareImage, extension);
|
||||||
|
|
||||||
config.verbose = true;
|
config.verbose = true;
|
||||||
exec(`${usbDir}/send-kboot-command-to-slave.js ping 0x10`);
|
exec(`${usbDir}/send-kboot-command-to-slave.js ping 0x10`);
|
||||||
exec(`${usbDir}/jump-to-slave-bootloader.js`);
|
exec(`${usbDir}/jump-to-slave-bootloader.js`);
|
||||||
|
|||||||
Reference in New Issue
Block a user