node-raspberrypi-usbboot
Advanced tools
Comparing version 0.2.10 to 0.3.0-cm4-33a3daf7fe4a2f5cd69438c61b86efb02f062607
@@ -105,2 +105,3 @@ "use strict"; | ||
const USB_PRODUCT_ID_BCM2710_BOOT = 0x2764; | ||
const USB_PRODUCT_ID_BCM2711_BOOT = 0x2711; | ||
// When the pi reboots in mass storage mode, it has this product id | ||
@@ -166,3 +167,4 @@ const USB_VENDOR_ID_NETCHIP_TECHNOLOGY = 0x0525; | ||
(idProduct === USB_PRODUCT_ID_BCM2708_BOOT || | ||
idProduct === USB_PRODUCT_ID_BCM2710_BOOT)); | ||
idProduct === USB_PRODUCT_ID_BCM2710_BOOT || | ||
idProduct === USB_PRODUCT_ID_BCM2711_BOOT)); | ||
}; | ||
@@ -254,6 +256,9 @@ exports.isUsbBootCapableUSBDevice = isUsbBootCapableUSBDevice; | ||
}; | ||
const getFileBuffer = async (filename) => { | ||
const getFileBuffer = async (device, filename) => { | ||
let buffer = await safeReadFile(filename); | ||
if (buffer === undefined) { | ||
buffer = await safeReadFile(Path.join('raspberrypi', filename)); | ||
const folder = device.deviceDescriptor.idProduct === USB_PRODUCT_ID_BCM2711_BOOT | ||
? 'cm4' | ||
: 'raspberrypi'; | ||
buffer = await safeReadFile(Path.join(folder, filename)); | ||
} | ||
@@ -292,3 +297,3 @@ if (buffer === undefined) { | ||
const secondStageBoot = async (device, endpoint) => { | ||
const bootcodeBuffer = await getFileBuffer('bootcode.bin'); | ||
const bootcodeBuffer = await getFileBuffer(device, 'bootcode.bin'); | ||
if (bootcodeBuffer === undefined) { | ||
@@ -414,3 +419,5 @@ throw new Error("Can't find bootcode.bin"); | ||
const { endpoint } = initializeDevice(device); | ||
if (device.deviceDescriptor.iSerialNumber === 0) { | ||
// cm: 0; cm4: 3 | ||
if (device.deviceDescriptor.iSerialNumber === 0 || | ||
device.deviceDescriptor.iSerialNumber === 3) { | ||
debug('Sending bootcode.bin', devicePortId(device)); | ||
@@ -472,3 +479,3 @@ this.step(device, 0); | ||
message.command === FileMessageCommand.ReadFile) { | ||
const buffer = await getFileBuffer(message.filename); | ||
const buffer = await getFileBuffer(device, message.filename); | ||
if (buffer === undefined) { | ||
@@ -475,0 +482,0 @@ debug(`Couldn't find ${message.filename}`, devicePortId(device)); |
@@ -7,2 +7,7 @@ # Change Log | ||
# v0.3.0 | ||
## (2020-12-09) | ||
* Add support for compute module 4 [Alexis Svinartchouk] | ||
# v0.2.10 | ||
@@ -9,0 +14,0 @@ ## (2020-11-30) |
{ | ||
"name": "node-raspberrypi-usbboot", | ||
"version": "0.2.10", | ||
"version": "0.3.0-cm4-33a3daf7fe4a2f5cd69438c61b86efb02f062607", | ||
"description": "Transforms Raspberry Pi Compute Modules and Zeros to mass storage devices.", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
Sorry, the diff of this file is not supported yet
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
28222735
25
540
16