Move updateDeviceFirmware() from update-device-firmware.js to uhk.js
This commit is contained in:
@@ -127,6 +127,23 @@ let eepromOperations = {
|
|||||||
write: 1,
|
write: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
async function updateDeviceFirmware(firmwareImage, extension) {
|
||||||
|
const usbDir = `${__dirname}`;
|
||||||
|
const blhost = uhk.getBlhostCmd(uhk.enumerationNameToProductId.bootloader);
|
||||||
|
|
||||||
|
uhk.checkFirmwareImage(firmwareImage, extension);
|
||||||
|
config.verbose = true;
|
||||||
|
|
||||||
|
await uhk.reenumerate('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.');
|
||||||
|
};
|
||||||
|
|
||||||
// USB commands
|
// USB commands
|
||||||
|
|
||||||
function reenumerate(enumerationMode) {
|
function reenumerate(enumerationMode) {
|
||||||
@@ -179,7 +196,7 @@ function reenumerate(enumerationMode) {
|
|||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
exports = module.exports = moduleExports = {
|
uhk = exports = module.exports = moduleExports = {
|
||||||
bufferToString,
|
bufferToString,
|
||||||
getUint16,
|
getUint16,
|
||||||
getUint32,
|
getUint32,
|
||||||
@@ -192,6 +209,7 @@ exports = module.exports = moduleExports = {
|
|||||||
checkFirmwareImage,
|
checkFirmwareImage,
|
||||||
getBlhostCmd,
|
getBlhostCmd,
|
||||||
execRetry,
|
execRetry,
|
||||||
|
updateDeviceFirmware,
|
||||||
reenumerate,
|
reenumerate,
|
||||||
usbCommands: {
|
usbCommands: {
|
||||||
getDeviceProperty : 0x00,
|
getDeviceProperty : 0x00,
|
||||||
|
|||||||
@@ -11,22 +11,4 @@ program
|
|||||||
.parse(process.argv)
|
.parse(process.argv)
|
||||||
|
|
||||||
const firmwareImage = program.args[0];
|
const firmwareImage = program.args[0];
|
||||||
|
uhk.updateDeviceFirmware(firmwareImage, extension);
|
||||||
async function updateDeviceFirmware(firmwareImage, extension) {
|
|
||||||
const usbDir = `${__dirname}`;
|
|
||||||
const blhost = uhk.getBlhostCmd(uhk.enumerationNameToProductId.bootloader);
|
|
||||||
|
|
||||||
uhk.checkFirmwareImage(firmwareImage, extension);
|
|
||||||
config.verbose = true;
|
|
||||||
|
|
||||||
await uhk.reenumerate('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.');
|
|
||||||
};
|
|
||||||
|
|
||||||
updateDeviceFirmware(firmwareImage, extension);
|
|
||||||
|
|||||||
Reference in New Issue
Block a user