diff --git a/lib/gui/assets/warning.svg b/lib/gui/assets/warning.svg new file mode 100644 index 00000000..e97b105b --- /dev/null +++ b/lib/gui/assets/warning.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/lib/shared/sdk/usbboot/index.js b/lib/shared/sdk/usbboot/index.js index 8b75e496..584a347f 100644 --- a/lib/shared/sdk/usbboot/index.js +++ b/lib/shared/sdk/usbboot/index.js @@ -117,6 +117,16 @@ const USBBOOT_CAPABLE_USB_DEVICES = [ ] +/** + * @summary Compute module descriptions + * @type {Object} + * @constant + */ +const COMPUTE_MODULE_DESCRIPTIONS = { + [USB_PRODUCT_ID_BCM2708_BOOT]: 'Compute Module 1', + [USB_PRODUCT_ID_BCM2710_BOOT]: 'Compute Module 3' +} + /** * @summary Estimated device reboot delay * @type {Number} @@ -251,6 +261,23 @@ class USBBootAdapter extends EventEmitter { usb.listDevices().filter(isUsbBootCapableUSBDevice).map((device) => { /* eslint-enable lodash/prefer-lodash-method */ + const description = COMPUTE_MODULE_DESCRIPTIONS[device.deviceDescriptor.idProduct] || 'Compute Module' + + if (!device.accessible) { + return { + device: `${usbIdToString(device.deviceDescriptor.idVendor)}:${usbIdToString(device.deviceDescriptor.idProduct)}`, + displayName: 'Missing drivers', + description, + mountpoints: [], + protected: false, + system: false, + disabled: true, + icon: 'warning', + size: null, + adaptor: USBBootAdapter.id + } + } + // This is the only way we can unique identify devices device.raw = `${device.busNumber}:${device.deviceAddress}` @@ -258,7 +285,11 @@ class USBBootAdapter extends EventEmitter { device: device.raw, raw: device.raw, displayName: 'Initializing device', + + // At this point we can't differentiate between CMs any more, so + // we can't use the description that changes depending on the PID. description: 'Compute Module', + size: null, mountpoints: [], protected: false, @@ -267,7 +298,7 @@ class USBBootAdapter extends EventEmitter { icon: 'loading', vendor: usbIdToString(device.deviceDescriptor.idVendor), product: usbIdToString(device.deviceDescriptor.idProduct), - adaptor: exports.name + adaptor: USBBootAdapter.id } if (_.isNil(this.progress[result.raw])) { diff --git a/lib/shared/sdk/usbboot/usb.js b/lib/shared/sdk/usbboot/usb.js index 5f09f2a4..d0e2d98f 100644 --- a/lib/shared/sdk/usbboot/usb.js +++ b/lib/shared/sdk/usbboot/usb.js @@ -67,7 +67,26 @@ const USB_CONTROL_TRANSFER_TIMEOUT_MS = 0 * }) */ exports.listDevices = () => { - return Bluebird.resolve(usb.getDeviceList()) + const devices = _.map(usb.getDeviceList(), (device) => { + device.accessible = true + return device + }) + + // Include driverless devices into the list of USB devices. + if (process.platform === 'win32') { + const winusbDriverGenerator = require('winusb-driver-generator') + for (const device of winusbDriverGenerator.listDriverlessDevices()) { + devices.push({ + accessible: false, + deviceDescriptor: { + idVendor: device.vid, + idProduct: device.pid + } + }) + } + } + + return Bluebird.resolve(devices) } /** diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 58df4e85..7d6edbee 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -10215,6 +10215,23 @@ "from": "window-size@>=0.2.0 <0.3.0", "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.2.0.tgz" }, + "winusb-driver-generator": { + "version": "1.1.1", + "from": "winusb-driver-generator@latest", + "resolved": "https://registry.npmjs.org/winusb-driver-generator/-/winusb-driver-generator-1.1.1.tgz", + "dependencies": { + "bindings": { + "version": "1.3.0", + "from": "bindings@>=1.3.0 <2.0.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.3.0.tgz" + }, + "nan": { + "version": "2.8.0", + "from": "nan@>=2.7.0 <3.0.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.8.0.tgz" + } + } + }, "wordwrap": { "version": "1.0.0", "from": "wordwrap@>=1.0.0 <1.1.0", diff --git a/package.json b/package.json index b76912b9..ea088829 100644 --- a/package.json +++ b/package.json @@ -90,6 +90,7 @@ "unbzip2-stream": "github:resin-io-modules/unbzip2-stream#core-streams", "usb": "github:tessel/node-usb#1.3.0", "uuid": "3.0.1", + "winusb-driver-generator": "1.1.1", "xml2js": "0.4.17", "yargs": "4.7.1", "yauzl": "2.6.0"