thsq-device-flasher
Advanced tools
Comparing version 1.0.8 to 1.0.9
{ | ||
"name": "thsq-device-flasher", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"author": "Thingsquare <support@thingsquare.com>", | ||
@@ -5,0 +5,0 @@ "description": "Thingsquare device flash utility", |
@@ -373,3 +373,3 @@ #!/usr/bin/env node | ||
var path = require('path'); | ||
if (options.C) { | ||
@@ -470,4 +470,6 @@ return options.C; | ||
var NVSTORAGE_SIGNATURE = 'ed55ceac'; /* uint32_t 'acce55ed' */ | ||
var BOOTLOADERPARAMS_OFFSET; | ||
if(getFilesizeInBytes(binfile) === 128*1024) { | ||
NVSTORAGE_OFFSET = 0x1f000; /* 0x1f000 Nvstorage: 124-128 */ | ||
BOOTLOADERPARAMS_OFFSET = 4064; /* see platform Makefile */ | ||
} else if(getFilesizeInBytes(binfile) === 512*1024) { | ||
@@ -480,4 +482,6 @@ NVSTORAGE_OFFSET = 0x27f000 - 0x200000; | ||
} | ||
BOOTLOADERPARAMS_OFFSET = 2619348; /* see platform Makefile */ | ||
} else if(getFilesizeInBytes(binfile) === 352*1024) { | ||
NVSTORAGE_OFFSET = 352*1024 - 8*1024; | ||
BOOTLOADERPARAMS_OFFSET = 8160; /* see platform Makefile */ | ||
} else { | ||
@@ -638,2 +642,9 @@ errorusage('Unsupported binfile size: ' + binfile + ': ' + getFilesizeInBytes(binfile)); | ||
} | ||
/* bootloader params: AES key: + 6 bytes offset in struct */ | ||
var bootloaderKey = crypto.randomBytes(16); | ||
for(var i = 0; i < bootloaderKey.length; i++) { | ||
filedata[BOOTLOADERPARAMS_OFFSET + 6 + i] = bootloaderKey[i]; | ||
} | ||
fs.writeFileSync(filename, filedata); | ||
@@ -894,2 +905,4 @@ | ||
meta = updatemetaarg(meta, 'flashed', new Date().getTime()); | ||
meta = updatemetaarg(meta, 'aes', true); | ||
thsq.setVariable(device.meta.unique.value, 's', 'id', 'platform:' + platform + ',eui:' + eui); | ||
@@ -1250,3 +1263,3 @@ | ||
} | ||
} | ||
@@ -1321,3 +1334,3 @@ /*---------------------------------------------------------------------------*/ | ||
output('OK: logged in as user ' + user.login); | ||
if(createunbondedthenexit) { | ||
@@ -1341,3 +1354,3 @@ thsq.getDevicelist(function(existing) { | ||
} | ||
if(reflashthenexit) { | ||
@@ -1397,3 +1410,3 @@ var existingidx = 0; | ||
} | ||
if (typeof rlhelp === 'function') { | ||
@@ -1400,0 +1413,0 @@ rlhelp(); |
105409
1284