diff --git a/src/cli/flash.js b/src/cli/flash.js index 48744c326..c9eed392c 100644 --- a/src/cli/flash.js +++ b/src/cli/flash.js @@ -41,10 +41,6 @@ module.exports = ({ commandProcessor, root }) => { 'tachyon' : { boolean: true, description: 'Flash Tachyon' - }, - 'verbose' : { - boolean: false, - description: 'Enable logging' } }, handler: (args) => { diff --git a/src/cmd/flash.js b/src/cmd/flash.js index b4bd49998..3e12fb93d 100644 --- a/src/cmd/flash.js +++ b/src/cmd/flash.js @@ -41,8 +41,8 @@ module.exports = class FlashCommand extends CLICommandBase { target, port, yes, - verbose, tachyon, + verbose, 'application-only': applicationOnly }) { if (!tachyon && !device && !binary && !local) { @@ -87,39 +87,18 @@ module.exports = class FlashCommand extends CLICommandBase { unpackToolFolder = path.dirname(files[0]); } - const parsedFiles = await this._analyzeFiles(files); - let linxuFiles = await this._findLinuxExecutableFiles(parsedFiles.files, { directory: unpackToolFolder }); + let linxuFiles = await this._findLinuxExecutableFiles(files, { directory: unpackToolFolder }); linxuFiles = linxuFiles.map(f => path.basename(f)); - const elfFiles = linxuFiles.filter(f => f.startsWith('prog') && f.endsWith('.elf')); const rawProgramFiles = linxuFiles.filter(f => f.startsWith('rawprogram') && f.endsWith('.xml')); const patchFiles = linxuFiles.filter(f => f.startsWith('patch') && f.endsWith('.xml')); - if (!elfFiles.length || !rawProgramFiles.length || !patchFiles.length) { - throw new Error('The directory should contain at least one .elf file, one rawprogram file, and one patch file'); - } - - const sortByNumber = (a, b) => { - const extractNumber = str => parseInt(str.match(/(\d+).xml/)[1]); - return extractNumber(a) - extractNumber(b); - }; - - rawProgramFiles.sort(sortByNumber); - patchFiles.sort(sortByNumber); - - if (rawProgramFiles.length !== patchFiles.length) { - throw new Error('The number of rawprogram files should match the number of patch files'); - } - - let filesToProgram = []; - // interleave the rawprogram files and patch files - for (let i = 0; i < rawProgramFiles.length; i++) { - filesToProgram.push(rawProgramFiles[i]); - filesToProgram.push(patchFiles[i]); + if (!elfFiles.length || !rawProgramFiles.length) { + throw new Error('The directory should contain at least one .elf file, one rawprogram file'); } - filesToProgram.unshift(elfFiles[0]); + let filesToProgram = [elfFiles[0], ...rawProgramFiles, ...patchFiles]; this.ui.write(`Found the following files in the directory:${os.EOL}`); this.ui.write('Loader file:'); @@ -157,7 +136,7 @@ module.exports = class FlashCommand extends CLICommandBase { this.ui.write(`Download complete${os.EOL}`); } } catch (err) { - throw new Error(`Download failed. Try powering up your board in EDL mode and try again.${os.EOL}Error: ${err.message}${os.EOL}`); + throw new Error(`Download failed. Try powering up your board in EDL mode and try again.${os.EOL}${err.message}${os.EOL}`); } // TODO: Handle errors }