Skip to content

Commit

Permalink
add cm4-secure-boot
Browse files Browse the repository at this point in the history
Change-type: patch
Signed-off-by: Ryan Cooke <[email protected]>
  • Loading branch information
rcooke-warwick committed Jun 13, 2024
1 parent 963e5e4 commit dc1288e
Show file tree
Hide file tree
Showing 4 changed files with 1,378 additions and 1,538 deletions.
6 changes: 6 additions & 0 deletions lib/flashing/devices/raspberrypicm4-ioboard-sb.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "usbboot",
"power": true,
"jumper": true,
"sb": true
}
15 changes: 11 additions & 4 deletions lib/flashing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { delay } from 'bluebird';
import * as Bluebird from 'bluebird';
import * as retry from 'bluebird-retry';
import * as sdk from 'etcher-sdk';
import { fs } from 'mz';
import * as fs from 'fs/promises';
import { BlockDeviceAdapter } from 'etcher-sdk/build/scanner/adapters';
import { Autokit } from '../';

Expand Down Expand Up @@ -240,7 +240,7 @@ async function flashFlasher(filename: string, autoKit: Autokit, jumper: boolean,
await delay(powerOnDelay)
}

async function flashUsbBoot(filename: string, autoKit: Autokit, port: usbPort, power: boolean, jumper: boolean){
async function flashUsbBoot(filename: string, autoKit: Autokit, port: usbPort, power: boolean, jumper: boolean, sb?: boolean){
// this delay is how long to wait after internal flashing before trying to re power the board. For the case where devices have capacitors that
// take time to drain
const powerOnDelay = Number(process.env.CAP_DELAY) || 1000*60;
Expand All @@ -264,14 +264,19 @@ async function flashUsbBoot(filename: string, autoKit: Autokit, port: usbPort, p
}

// etcher-sdk (power on) usboot
// This is the path to the folder containing the cm4 secureboot artifacts on the autokit
const bootImageFolder = (sb) ? (process.env.SB_ARTIFACT || '/data/secure-boot-msd/') : undefined;

console.log(bootImageFolder)

const adapters: sdk.scanner.adapters.Adapter[] = [
new BlockDeviceAdapter({
includeSystemDrives: () => false,
unmountOnSuccess: false,
write: true,
direct: true,
}),
new sdk.scanner.adapters.UsbbootDeviceAdapter(),
new sdk.scanner.adapters.UsbbootDeviceAdapter(bootImageFolder),
];
const deviceScanner = new sdk.scanner.Scanner(adapters);
console.log('Waiting for compute module');
Expand Down Expand Up @@ -331,6 +336,8 @@ async function flashUsbBoot(filename: string, autoKit: Autokit, port: usbPort, p
) {
console.log('Attached compute module.');
clearTimeout(timeout);
drive.oWrite = true;
drive.oDirect = true;
resolve(drive);
deviceScanner.removeListener('attach', onAttach);
}
Expand Down Expand Up @@ -642,7 +649,7 @@ async function flash(filename: string, deviceType: string, autoKit: Autokit, por
if(port === undefined){
throw new Error('No usb port specified!')
}
await flashUsbBoot(filename, autoKit, port, flashProcedure.power, flashProcedure.jumper);
await flashUsbBoot(filename, autoKit, port, flashProcedure.power, flashProcedure.jumper, flashProcedure.sb);
break;
}
case 'flasher': {
Expand Down
Loading

0 comments on commit dc1288e

Please sign in to comment.