node-raspberrypi-usbboot
Advanced tools
Comparing version 1.0.8 to 1.1.0-build-aethernet-allow-custom-sb-assets-900d62a628cac2346f4a3d1ea05466aef3689b64-1
@@ -26,3 +26,4 @@ /// <reference types="node" /> | ||
private attachedDeviceIds; | ||
constructor(); | ||
private extraFolder; | ||
constructor(extraFolder?: string); | ||
start(): void; | ||
@@ -29,0 +30,0 @@ stop(): void; |
@@ -259,3 +259,18 @@ "use strict"; | ||
}; | ||
const getFileBuffer = async (device, filename) => { | ||
const unsafeReadFile = async (filename) => { | ||
try { | ||
return await (0, promises_1.readFile)(filename); | ||
} | ||
catch (e) { | ||
// no data | ||
} | ||
}; | ||
const getFileBuffer = async (device, filename, extraFolder) => { | ||
if (extraFolder) { | ||
const extraBuffer = await unsafeReadFile(Path.join(extraFolder, filename)); | ||
if (extraBuffer !== undefined) { | ||
debug(`Sending buffer from ${extraFolder}/${filename}`); | ||
return extraBuffer; | ||
} | ||
} | ||
const folder = device.deviceDescriptor.idProduct === USB_PRODUCT_ID_BCM2711_BOOT | ||
@@ -360,3 +375,3 @@ ? 'cm4' | ||
class UsbbootScanner extends events_1.EventEmitter { | ||
constructor() { | ||
constructor(extraFolder) { | ||
super(); | ||
@@ -368,2 +383,4 @@ this.usbbootDevices = new Map(); | ||
this.attachedDeviceIds = new Set(); | ||
this.extraFolder = extraFolder; | ||
debug(`Extra folder: ${extraFolder}`); | ||
this.boundAttachDevice = this.attachDevice.bind(this); | ||
@@ -463,4 +480,5 @@ this.boundDetachDevice = this.detachDevice.bind(this); | ||
else { | ||
const extraFolder = this.extraFolder; | ||
debug('Second stage boot server', devicePortId(device)); | ||
await this.fileServer(device, endpoint, 2); | ||
await this.fileServer(device, endpoint, 2, extraFolder); | ||
} | ||
@@ -495,3 +513,3 @@ device.close(); | ||
} | ||
async fileServer(device, endpoint, step) { | ||
async fileServer(device, endpoint, step, extraFolder) { | ||
while (true) { | ||
@@ -517,3 +535,3 @@ let data; | ||
message.command === FileMessageCommand.ReadFile) { | ||
const buffer = await getFileBuffer(device, message.filename); | ||
const buffer = await getFileBuffer(device, message.filename, extraFolder); | ||
if (buffer === undefined) { | ||
@@ -520,0 +538,0 @@ debug(`Couldn't find ${message.filename}`, devicePortId(device)); |
@@ -7,2 +7,7 @@ # Change Log | ||
# v1.1.0 | ||
## (2024-05-09) | ||
* minor: allow passing custom assets to start SB protected CM4 [Edwin Joassart] | ||
# v1.0.8 | ||
@@ -9,0 +14,0 @@ ## (2024-04-12) |
{ | ||
"name": "node-raspberrypi-usbboot", | ||
"version": "1.0.8", | ||
"version": "1.1.0-build-aethernet-allow-custom-sb-assets-900d62a628cac2346f4a3d1ea05466aef3689b64-1", | ||
"description": "Transforms Raspberry Pi Compute Modules and Zeros to mass storage devices.", | ||
@@ -42,4 +42,4 @@ "main": "build/index.js", | ||
"versionist": { | ||
"publishedAt": "2024-04-12T10:09:10.968Z" | ||
"publishedAt": "2024-05-09T16:33:14.678Z" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28088024
604
2