From e4757c0bf702ec1ec0b1c13529939a1f796bcdcf Mon Sep 17 00:00:00 2001 From: Daniel Buentello Date: Mon, 22 Aug 2016 14:40:50 -0500 Subject: [PATCH] Fix-bricked-restore (#826) * set enable write * wait for erase to finish before continuing --- lib/tessel/restore.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/tessel/restore.js b/lib/tessel/restore.js index 0f285e57..b98ff3d9 100644 --- a/lib/tessel/restore.js +++ b/lib/tessel/restore.js @@ -142,7 +142,7 @@ exportables.validateDeviceId = function(usb) { // 9.6.3 Bulk Erase (BE 60h or C7h) exportables.bulkEraseFlash = function(usb) { - return exportables.transaction(usb, COMMAND_BE); + return (exportables.transaction(usb, COMMAND_BE)).then(() => exportables.waitTransactionComplete(usb)); }; // NOTE: The following commands do not directly interact with the flash memory registers @@ -220,7 +220,11 @@ exportables.flash = function(tessel, buffers) { buffers.partition = exportables.partition(mac1, mac2); return Promise.resolve().then(() => { - log.info('Bulk Erasing Flash Memory...'); + log.info('Setting WRITE_ENABLED'); + return exportables.enableWrite(usb); + }) + .then(() => { + log.info('Bulk Erasing Flash Memory (this may take a minute)...'); return exportables.bulkEraseFlash(usb); }) .then(() => {