feat: kboot package (#894)
* feat: kboot package * feat: kboot package * fix: wait 1 sec after device is available * test: fix unit test * refactor: clean unused codes * doc: improve readme.md * doc: improve readme.md * test: fix unit test * chore: fix lint settings * style: fix linting issues
This commit is contained in:
committed by
László Monda
parent
bfc08edfce
commit
3964698cf7
@@ -0,0 +1,33 @@
|
||||
import { execSync } from 'child_process';
|
||||
import { join } from 'path';
|
||||
import { readFileSync } from 'fs';
|
||||
import * as MemoryMap from 'nrf-intel-hex';
|
||||
|
||||
export enum UhkReenumerationModes {
|
||||
Bootloader = 'bootloader',
|
||||
Buspal = 'buspal',
|
||||
NormalKeyboard = 'normalKeyboard',
|
||||
CompatibleKeyboard = 'compatibleKeyboard'
|
||||
}
|
||||
|
||||
const USB_SCRIPTS_DIR = join(__dirname, '../../../usb');
|
||||
export const reenumerate = (mode: UhkReenumerationModes): void => {
|
||||
const reenumerateScriptFile = join(USB_SCRIPTS_DIR, 'reenumerate.js');
|
||||
const command = [reenumerateScriptFile, mode.toString()].join(' ');
|
||||
|
||||
execSync(
|
||||
command,
|
||||
{
|
||||
cwd: USB_SCRIPTS_DIR,
|
||||
stdio: [0, 1, 2]
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export const readBootloaderFirmwareFromHexFile = (): Map<any, any> => {
|
||||
const hexFilePath = join(__dirname, '../../../../tmp/packages/firmware/devices/uhk60-right/firmware.hex');
|
||||
const fileContent = readFileSync(hexFilePath, { encoding: 'utf8' });
|
||||
const memoryMap = MemoryMap.fromHex(fileContent);
|
||||
|
||||
return memoryMap;
|
||||
};
|
||||
Reference in New Issue
Block a user