Move update-{master,slave}-firmware.js and shared.js into the Agent repo and reference those scripts.

This commit is contained in:
László Monda
2017-11-08 01:27:49 +01:00
parent fb39d700e0
commit 49a94d82b0
6 changed files with 3 additions and 126 deletions

View File

@@ -19,7 +19,7 @@
<booleanAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN" value="true"/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_ARGUMENTS" value="uhk60-right_debug/uhk-right.hex"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="../../scripts/update-master-firmware.js"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="../../lib/agent/packages/usb/update-master-firmware.js"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="uhk-right"/>
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="ilg.gnuarmeclipse.managedbuild.cross.config.elf.release.1939339834.1692217331.1297236062"/>

View File

@@ -19,7 +19,7 @@
<booleanAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN" value="true"/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_ARGUMENTS" value="uhk60-right_release/uhk-right.hex"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="../../scripts/update-master-firmware.js"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="../../lib/agent/packages/usb/update-master-firmware.js"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="uhk-right"/>
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="ilg.gnuarmeclipse.managedbuild.cross.config.elf.release.1939339834.1692217331"/>

View File

@@ -1,64 +0,0 @@
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(pid) {
let blhostPath;
switch (process.platform) {
case 'linux':
blhostPath = 'linux/amd64/blhost';
break;
case 'darwin':
blhostPath = 'mac/blhost';
break;
case 'win32':
blhostPath = 'win/blhost.exe';
break;
default:
echo('Your operating system is not supported');
exit(1);
break;
}
return `${__dirname}/../lib/bootloader/bin/Tools/blhost/${blhostPath} --usb 0x1d50,${pid}`;
}
function execRetry(command) {
let firstRun = true;
let remainingRetries = 3;
let code;
do {
if (!firstRun) {
console.log(`Retrying ${command}`)
}
config.fatal = !remainingRetries;
code = exec(command).code;
config.fatal = true;
firstRun = false;
} while(code && --remainingRetries);
}
const exp = {
checkFirmwareImage,
getBlhostCmd,
execRetry,
}
Object.keys(exp).forEach(function (cmd) {
global[cmd] = exp[cmd];
});

View File

@@ -1,27 +0,0 @@
#!/usr/bin/env node
const program = require('commander');
require('shelljs/global');
require('./shared')
const extension = '.hex';
config.fatal = true;
program
.usage(`update-master-firmware <firmware-image${extension}>`)
.parse(process.argv)
const firmwareImage = program.args[0];
const usbDir = `${__dirname}/../lib/agent/packages/usb`;
const blhost = getBlhostCmd(0x6120);
checkFirmwareImage(firmwareImage, extension);
config.verbose = true;
exec(`${usbDir}/reenumerate.js bootloader`);
exec(`${blhost} flash-security-disable 0403020108070605`);
exec(`${blhost} flash-erase-region 0xc000 475136`);
exec(`${blhost} flash-image ${firmwareImage}`);
exec(`${blhost} reset`);
config.verbose = false;
echo('Firmware updated successfully');

View File

@@ -1,32 +0,0 @@
#!/usr/bin/env node
const program = require('commander');
require('shelljs/global');
require('./shared')
const extension = '.bin';
config.fatal = true;
program
.usage(`update-slave-firmware <firmware-image${extension}>`)
.parse(process.argv)
const firmwareImage = program.args[0];
const usbDir = `${__dirname}/../lib/agent/packages/usb`;
const blhostUsb = getBlhostCmd(0x6121);
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`);
exec(`${usbDir}/reenumerate.js buspal`);
execRetry(`${blhostBuspal} get-property 1`);
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`);
config.verbose = false;
echo('Firmware updated successfully');