From 2158772e3b979c4bb2a186f757c1f19e00242ebd Mon Sep 17 00:00:00 2001 From: Alexis Svinartchouk Date: Tue, 13 Nov 2018 14:55:45 +0100 Subject: [PATCH 1/2] lint: don't run codespell on svg files Change-type: patch --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7632db9fb3..aa23c7041c 100644 --- a/Makefile +++ b/Makefile @@ -201,7 +201,7 @@ lint-spell: codespell \ --dictionary - \ --dictionary dictionary.txt \ - --skip *.gz,*.bz2,*.xz,*.zip,*.img,*.dmg,*.iso,*.rpi-sdcard,.DS_Store,*.dtb,*.dtbo,*.dat,*.elf,*.bin,*.foo,xz-without-extension \ + --skip *.svg *.gz,*.bz2,*.xz,*.zip,*.img,*.dmg,*.iso,*.rpi-sdcard,.DS_Store,*.dtb,*.dtbo,*.dat,*.elf,*.bin,*.foo,xz-without-extension \ lib tests docs scripts Makefile *.md LICENSE lint: lint-js lint-sass lint-cpp lint-html lint-spell From 7fb382bee0239d4fdc34a29867c0088a172b38ed Mon Sep 17 00:00:00 2001 From: Alexis Svinartchouk Date: Tue, 13 Nov 2018 14:57:42 +0100 Subject: [PATCH 2/2] fix(usbboot): Limit usbboot transfers to 1MiB Change-type: patch --- lib/sdk/adapters/usbboot/protocol.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/sdk/adapters/usbboot/protocol.js b/lib/sdk/adapters/usbboot/protocol.js index 607e46d1f9..12b8fdaaa4 100644 --- a/lib/sdk/adapters/usbboot/protocol.js +++ b/lib/sdk/adapters/usbboot/protocol.js @@ -30,6 +30,8 @@ const usb = require('./usb') const NULL_BUFFER_SIZE = 0 const NULL_BUFFER = Buffer.alloc(NULL_BUFFER_SIZE) +const ONE_MEGABYTE = 1048576 + /** * @summary The size of the boot message bootcode length section * @type {Number} @@ -206,6 +208,12 @@ exports.sendBufferSize = (device, size) => { }) } +const chunks = function *(buffer, size) { + for (let start = 0; start < buffer.length; start += size) { + yield buffer.slice(start, start + size) + } +} + /** * @summary Write a buffer to an OUT endpoint * @function @@ -231,9 +239,11 @@ exports.write = (device, endpoint, buffer) => { .delay(USB_REQUEST_DELAY_MS) .then(() => { - return Bluebird.fromCallback((callback) => { - endpoint.timeout = USB_BULK_TRANSFER_TIMEOUT_MS - endpoint.transfer(buffer, callback) + endpoint.timeout = USB_BULK_TRANSFER_TIMEOUT_MS + return Bluebird.each(chunks(buffer, ONE_MEGABYTE), (chunk) => { + return Bluebird.fromCallback((callback) => { + endpoint.transfer(chunk, callback) + }) }) }) }