usbboot: Add more logging

Change-type: patch
Signed-off-by: Juan Cruz Viotti <juan@balena.io>
This commit is contained in:
Juan Cruz Viotti 2019-03-17 14:55:58 +00:00
parent 7c4eb19748
commit 389e9b14e4
No known key found for this signature in database
GPG Key ID: D01B10083038B3E8
3 changed files with 13 additions and 0 deletions

View File

@ -419,6 +419,7 @@ class USBBootAdapter extends EventEmitter {
const endpoint = deviceInterface.endpoint(addresses.endpoint)
if (serialNumberIndex === USB_DESCRIPTOR_NULL_INDEX) {
debug('Writing boot code')
return this.queryBlobFromCache(USBBOOT_BOOTCODE_FILE_NAME).then((bootcode) => {
return USBBootAdapter.writeBootCode(device, endpoint, bootcode)
})
@ -441,6 +442,7 @@ class USBBootAdapter extends EventEmitter {
setProgress((step * (PERCENTAGE_TOTAL - PERCENTAGE_START) / STEPS_TOTAL) + PERCENTAGE_START)
}
}).tap(() => {
debug('File server started')
setProgress(utils.PERCENTAGE_MAXIMUM)
})
}).return(device).catch({

View File

@ -232,16 +232,22 @@ const chunks = function *(buffer, size) {
* })
*/
exports.write = (device, endpoint, buffer) => {
console.log(`SEND BUFFER SIZE: ${buffer.length}`)
return exports.sendBufferSize(device, buffer.length)
.then(() => {
console.log(`BUFFER SIZE SENT: ${buffer.length}`)
})
// We get LIBUSB_TRANSFER_STALL sometimes
// in future bulk transfers without this
.delay(USB_REQUEST_DELAY_MS)
.then(() => {
console.log(`SENDING CHUNKS: ${buffer.length} (max ${ONE_MEGABYTE})`)
endpoint.timeout = USB_BULK_TRANSFER_TIMEOUT_MS
return Bluebird.each(chunks(buffer, ONE_MEGABYTE), (chunk) => {
return Bluebird.fromCallback((callback) => {
console.log(`SENDING CHUNK: ${chunk.length}`)
endpoint.transfer(chunk, callback)
})
})

View File

@ -74,6 +74,11 @@ exports.listDevices = () => {
return device
})
console.log(devices.map((device) => {
const descriptor = device.deviceDescriptor
return `${descriptor.idVendor.toString(16)}:${descriptor.idProduct.toString(16)}`
}))
// Include driverless devices into the list of USB devices.
if (process.platform === 'win32') {
// NOTE: Temporarily ignore errors when loading winusb-driver-generator,