diff --git a/README.md b/README.md index 2d8d6cc..5f4311b 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ $ npm install -g ember-zli $ ember-zli COMMAND running command... $ ember-zli (--version) -ember-zli/2.9.4 win32-x64 node-v22.11.0 +ember-zli/2.10.0 win32-x64 node-v22.11.0 $ ember-zli --help [COMMAND] USAGE $ ember-zli COMMAND @@ -61,7 +61,7 @@ EXAMPLES $ ember-zli bootloader ``` -_See code: [src/commands/bootloader/index.ts](https://github.com/Nerivec/ember-zli/blob/v2.9.4/src/commands/bootloader/index.ts)_ +_See code: [src/commands/bootloader/index.ts](https://github.com/Nerivec/ember-zli/blob/v2.10.0/src/commands/bootloader/index.ts)_ ## `ember-zli help [COMMAND]` @@ -98,7 +98,7 @@ EXAMPLES $ ember-zli monitor ``` -_See code: [src/commands/monitor/index.ts](https://github.com/Nerivec/ember-zli/blob/v2.9.4/src/commands/monitor/index.ts)_ +_See code: [src/commands/monitor/index.ts](https://github.com/Nerivec/ember-zli/blob/v2.10.0/src/commands/monitor/index.ts)_ ## `ember-zli router` @@ -115,7 +115,7 @@ EXAMPLES $ ember-zli router ``` -_See code: [src/commands/router/index.ts](https://github.com/Nerivec/ember-zli/blob/v2.9.4/src/commands/router/index.ts)_ +_See code: [src/commands/router/index.ts](https://github.com/Nerivec/ember-zli/blob/v2.10.0/src/commands/router/index.ts)_ ## `ember-zli sniff` @@ -132,7 +132,7 @@ EXAMPLES $ ember-zli sniff ``` -_See code: [src/commands/sniff/index.ts](https://github.com/Nerivec/ember-zli/blob/v2.9.4/src/commands/sniff/index.ts)_ +_See code: [src/commands/sniff/index.ts](https://github.com/Nerivec/ember-zli/blob/v2.10.0/src/commands/sniff/index.ts)_ ## `ember-zli stack` @@ -149,7 +149,7 @@ EXAMPLES $ ember-zli stack ``` -_See code: [src/commands/stack/index.ts](https://github.com/Nerivec/ember-zli/blob/v2.9.4/src/commands/stack/index.ts)_ +_See code: [src/commands/stack/index.ts](https://github.com/Nerivec/ember-zli/blob/v2.10.0/src/commands/stack/index.ts)_ ## `ember-zli utils` @@ -166,7 +166,7 @@ EXAMPLES $ ember-zli utils ``` -_See code: [src/commands/utils/index.ts](https://github.com/Nerivec/ember-zli/blob/v2.9.4/src/commands/utils/index.ts)_ +_See code: [src/commands/utils/index.ts](https://github.com/Nerivec/ember-zli/blob/v2.10.0/src/commands/utils/index.ts)_ ## `ember-zli version` diff --git a/package-lock.json b/package-lock.json index 9257ec8..826ecd5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ember-zli", - "version": "2.9.2", + "version": "2.10.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ember-zli", - "version": "2.9.2", + "version": "2.10.0", "license": "GPL-3.0-or-later", "dependencies": { "@inquirer/prompts": "^7", @@ -1992,12 +1992,12 @@ } }, "node_modules/@oclif/plugin-not-found": { - "version": "3.2.32", - "resolved": "https://registry.npmjs.org/@oclif/plugin-not-found/-/plugin-not-found-3.2.32.tgz", - "integrity": "sha512-8uyqhwq0I2qkBra6W6Ti0opBqDsBbMywVWplhbt1TkjMr9B8ZA8F1cQYa5Zz14blJD7dSS+OAhSHb/Ikkm1g4Q==", + "version": "3.2.33", + "resolved": "https://registry.npmjs.org/@oclif/plugin-not-found/-/plugin-not-found-3.2.33.tgz", + "integrity": "sha512-1RgvZ0J5KloU8TRemHxCr5MbVtr41ungnz8BBCPJn2yR5L+Eo2Lt+kpOyEeYAohjo4Tml1AHSmipUF4jKThwTw==", "license": "MIT", "dependencies": { - "@inquirer/prompts": "^7.2.0", + "@inquirer/prompts": "^7.2.1", "@oclif/core": "^4", "ansis": "^3.5.2", "fast-levenshtein": "^3.0.0" @@ -2020,14 +2020,14 @@ } }, "node_modules/@oclif/plugin-warn-if-update-available": { - "version": "3.1.28", - "resolved": "https://registry.npmjs.org/@oclif/plugin-warn-if-update-available/-/plugin-warn-if-update-available-3.1.28.tgz", - "integrity": "sha512-15UI0yrzsodQLltntbUOmR7Nyd1tmUWzbcnR7QJvWMgEMuImNjqNdSaeXUFc3UBtaK266YatJYJWL5SCb/MTWw==", + "version": "3.1.29", + "resolved": "https://registry.npmjs.org/@oclif/plugin-warn-if-update-available/-/plugin-warn-if-update-available-3.1.29.tgz", + "integrity": "sha512-NmD6hcyBquo9TV26tnYnsbyR69VzaeMC3kqks0YT2947CSJS7smONMxpkjU2P4kLTH4Tn8/n5w/sjoegNe1jdw==", "dev": true, "license": "MIT", "dependencies": { "@oclif/core": "^4", - "ansis": "^3.4.0", + "ansis": "^3.5.2", "debug": "^4.4.0", "http-call": "^5.2.2", "lodash": "^4.17.21", @@ -2045,13 +2045,13 @@ "license": "MIT" }, "node_modules/@oclif/test": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/@oclif/test/-/test-4.1.4.tgz", - "integrity": "sha512-0gUIkJJVDDpM2BNuo1+vBrf71DO3iVSFjUcLo+kma6co5vVOKG1COfVmxV7mB8XCNTuBWAZ4pJ4vsASxTxE5yg==", + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/@oclif/test/-/test-4.1.5.tgz", + "integrity": "sha512-w4hVfP+Lsz7toaSnj/E3cFH4Y/nHt1k14cCREQXe/nIqnZW7J6xGnjYEmqU9BPk7m0Lsl52AqJ2hGvLarGhfLw==", "dev": true, "license": "MIT", "dependencies": { - "ansis": "^3.4.0", + "ansis": "^3.5.2", "debug": "^4.4.0" }, "engines": { @@ -3111,9 +3111,9 @@ } }, "node_modules/@types/node": { - "version": "20.17.10", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.10.tgz", - "integrity": "sha512-/jrvh5h6NXhEauFFexRin69nA0uHJ5gwk4iDivp/DeoEua3uwCUto6PC86IpRITBOs4+6i2I56K5x5b6WYGXHA==", + "version": "20.17.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.11.tgz", + "integrity": "sha512-Ept5glCK35R8yeyIeYlRIZtX6SLRyqMhOFTgj5SOkMpLTdw3SEHI9fHx60xaUZ+V1aJxQJODE+7/j5ocZydYTg==", "license": "MIT", "dependencies": { "undici-types": "~6.19.2" @@ -3133,17 +3133,17 @@ "license": "MIT" }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.18.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.18.2.tgz", - "integrity": "sha512-adig4SzPLjeQ0Tm+jvsozSGiCliI2ajeURDGHjZ2llnA+A67HihCQ+a3amtPhUakd1GlwHxSRvzOZktbEvhPPg==", + "version": "8.19.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.19.0.tgz", + "integrity": "sha512-NggSaEZCdSrFddbctrVjkVZvFC6KGfKfNK0CU7mNK/iKHGKbzT4Wmgm08dKpcZECBu9f5FypndoMyRHkdqfT1Q==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/regexpp": "^4.10.0", - "@typescript-eslint/scope-manager": "8.18.2", - "@typescript-eslint/type-utils": "8.18.2", - "@typescript-eslint/utils": "8.18.2", - "@typescript-eslint/visitor-keys": "8.18.2", + "@typescript-eslint/scope-manager": "8.19.0", + "@typescript-eslint/type-utils": "8.19.0", + "@typescript-eslint/utils": "8.19.0", + "@typescript-eslint/visitor-keys": "8.19.0", "graphemer": "^1.4.0", "ignore": "^5.3.1", "natural-compare": "^1.4.0", @@ -3163,16 +3163,16 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "8.18.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.18.2.tgz", - "integrity": "sha512-y7tcq4StgxQD4mDr9+Jb26dZ+HTZ/SkfqpXSiqeUXZHxOUyjWDKsmwKhJ0/tApR08DgOhrFAoAhyB80/p3ViuA==", + "version": "8.19.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.19.0.tgz", + "integrity": "sha512-6M8taKyOETY1TKHp0x8ndycipTVgmp4xtg5QpEZzXxDhNvvHOJi5rLRkLr8SK3jTgD5l4fTlvBiRdfsuWydxBw==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/scope-manager": "8.18.2", - "@typescript-eslint/types": "8.18.2", - "@typescript-eslint/typescript-estree": "8.18.2", - "@typescript-eslint/visitor-keys": "8.18.2", + "@typescript-eslint/scope-manager": "8.19.0", + "@typescript-eslint/types": "8.19.0", + "@typescript-eslint/typescript-estree": "8.19.0", + "@typescript-eslint/visitor-keys": "8.19.0", "debug": "^4.3.4" }, "engines": { @@ -3188,14 +3188,14 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "8.18.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.18.2.tgz", - "integrity": "sha512-YJFSfbd0CJjy14r/EvWapYgV4R5CHzptssoag2M7y3Ra7XNta6GPAJPPP5KGB9j14viYXyrzRO5GkX7CRfo8/g==", + "version": "8.19.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.19.0.tgz", + "integrity": "sha512-hkoJiKQS3GQ13TSMEiuNmSCvhz7ujyqD1x3ShbaETATHrck+9RaDdUbt+osXaUuns9OFwrDTTrjtwsU8gJyyRA==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.18.2", - "@typescript-eslint/visitor-keys": "8.18.2" + "@typescript-eslint/types": "8.19.0", + "@typescript-eslint/visitor-keys": "8.19.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -3206,14 +3206,14 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "8.18.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.18.2.tgz", - "integrity": "sha512-AB/Wr1Lz31bzHfGm/jgbFR0VB0SML/hd2P1yxzKDM48YmP7vbyJNHRExUE/wZsQj2wUCvbWH8poNHFuxLqCTnA==", + "version": "8.19.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.19.0.tgz", + "integrity": "sha512-TZs0I0OSbd5Aza4qAMpp1cdCYVnER94IziudE3JU328YUHgWu9gwiwhag+fuLeJ2LkWLXI+F/182TbG+JaBdTg==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/typescript-estree": "8.18.2", - "@typescript-eslint/utils": "8.18.2", + "@typescript-eslint/typescript-estree": "8.19.0", + "@typescript-eslint/utils": "8.19.0", "debug": "^4.3.4", "ts-api-utils": "^1.3.0" }, @@ -3230,9 +3230,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "8.18.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.18.2.tgz", - "integrity": "sha512-Z/zblEPp8cIvmEn6+tPDIHUbRu/0z5lqZ+NvolL5SvXWT5rQy7+Nch83M0++XzO0XrWRFWECgOAyE8bsJTl1GQ==", + "version": "8.19.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.19.0.tgz", + "integrity": "sha512-8XQ4Ss7G9WX8oaYvD4OOLCjIQYgRQxO+qCiR2V2s2GxI9AUpo7riNwo6jDhKtTcaJjT8PY54j2Yb33kWtSJsmA==", "dev": true, "license": "MIT", "engines": { @@ -3244,14 +3244,14 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.18.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.18.2.tgz", - "integrity": "sha512-WXAVt595HjpmlfH4crSdM/1bcsqh+1weFRWIa9XMTx/XHZ9TCKMcr725tLYqWOgzKdeDrqVHxFotrvWcEsk2Tg==", + "version": "8.19.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.19.0.tgz", + "integrity": "sha512-WW9PpDaLIFW9LCbucMSdYUuGeFUz1OkWYS/5fwZwTA+l2RwlWFdJvReQqMUMBw4yJWJOfqd7An9uwut2Oj8sLw==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.18.2", - "@typescript-eslint/visitor-keys": "8.18.2", + "@typescript-eslint/types": "8.19.0", + "@typescript-eslint/visitor-keys": "8.19.0", "debug": "^4.3.4", "fast-glob": "^3.3.2", "is-glob": "^4.0.3", @@ -3271,16 +3271,16 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "8.18.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.18.2.tgz", - "integrity": "sha512-Cr4A0H7DtVIPkauj4sTSXVl+VBWewE9/o40KcF3TV9aqDEOWoXF3/+oRXNby3DYzZeCATvbdksYsGZzplwnK/Q==", + "version": "8.19.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.19.0.tgz", + "integrity": "sha512-PTBG+0oEMPH9jCZlfg07LCB2nYI0I317yyvXGfxnvGvw4SHIOuRnQ3kadyyXY6tGdChusIHIbM5zfIbp4M6tCg==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", - "@typescript-eslint/scope-manager": "8.18.2", - "@typescript-eslint/types": "8.18.2", - "@typescript-eslint/typescript-estree": "8.18.2" + "@typescript-eslint/scope-manager": "8.19.0", + "@typescript-eslint/types": "8.19.0", + "@typescript-eslint/typescript-estree": "8.19.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -3295,13 +3295,13 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.18.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.18.2.tgz", - "integrity": "sha512-zORcwn4C3trOWiCqFQP1x6G3xTRyZ1LYydnj51cRnJ6hxBlr/cKPckk+PKPUw/fXmvfKTcw7bwY3w9izgx5jZw==", + "version": "8.19.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.19.0.tgz", + "integrity": "sha512-mCFtBbFBJDCNCWUl5y6sZSCHXw1DEFEk3c/M3nRK2a4XUB8StGFtmcEMizdjKuBzB6e/smJAAWYug3VrdLMr1w==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.18.2", + "@typescript-eslint/types": "8.19.0", "eslint-visitor-keys": "^4.2.0" }, "engines": { @@ -5628,20 +5628,20 @@ } }, "node_modules/oclif": { - "version": "4.17.4", - "resolved": "https://registry.npmjs.org/oclif/-/oclif-4.17.4.tgz", - "integrity": "sha512-CELZOdxSfpM2Kl3dGP0N4fL4+RReGP18vo6oNklWoSP4ka+pJTBzO3W0o15KHAyrzpes5cui+xur3UPZIGr0LQ==", + "version": "4.17.7", + "resolved": "https://registry.npmjs.org/oclif/-/oclif-4.17.7.tgz", + "integrity": "sha512-RWh3TieJHjs2FqUQUHowEbDhriLvdzI3I7LpMbO/sNaA33MvI0B7gg8bO6ZNmBz1f9aN8hBW6wl9s6PHSO4HAQ==", "dev": true, "license": "MIT", "dependencies": { - "@aws-sdk/client-cloudfront": "^3.699.0", - "@aws-sdk/client-s3": "^3.712.0", + "@aws-sdk/client-cloudfront": "^3.716.0", + "@aws-sdk/client-s3": "^3.717.0", "@inquirer/confirm": "^3.1.22", "@inquirer/input": "^2.2.4", "@inquirer/select": "^2.5.0", "@oclif/core": "^4.2.0", "@oclif/plugin-help": "^6.2.20", - "@oclif/plugin-not-found": "^3.2.31", + "@oclif/plugin-not-found": "^3.2.32", "@oclif/plugin-warn-if-update-available": "^3.1.28", "async-retry": "^1.3.3", "chalk": "^4", @@ -5762,9 +5762,9 @@ } }, "node_modules/oclif/node_modules/@types/node": { - "version": "22.10.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.2.tgz", - "integrity": "sha512-Xxr6BBRCAOQixvonOye19wnzyDiUtTeqldOOmj3CkeblonbccA12PFwlufvRdrpjXxqnmUaeiU5EOA+7s5diUQ==", + "version": "22.10.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.3.tgz", + "integrity": "sha512-DifAyw4BkrufCILvD3ucnuN8eydUfc/C1GlyrnI+LK6543w5/L3VeVgf05o3B4fqSXP1dKYLOZsKfutpxPzZrw==", "dev": true, "license": "MIT", "dependencies": { @@ -6908,15 +6908,15 @@ } }, "node_modules/typescript-eslint": { - "version": "8.18.2", - "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.18.2.tgz", - "integrity": "sha512-KuXezG6jHkvC3MvizeXgupZzaG5wjhU3yE8E7e6viOvAvD9xAWYp8/vy0WULTGe9DYDWcQu7aW03YIV3mSitrQ==", + "version": "8.19.0", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.19.0.tgz", + "integrity": "sha512-Ni8sUkVWYK4KAcTtPjQ/UTiRk6jcsuDhPpxULapUDi8A/l8TSBk+t1GtJA1RsCzIJg0q6+J7bf35AwQigENWRQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/eslint-plugin": "8.18.2", - "@typescript-eslint/parser": "8.18.2", - "@typescript-eslint/utils": "8.18.2" + "@typescript-eslint/eslint-plugin": "8.19.0", + "@typescript-eslint/parser": "8.19.0", + "@typescript-eslint/utils": "8.19.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" diff --git a/package.json b/package.json index 06b22e7..bd6c1b3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ember-zli", "description": "Interact with EmberZNet-based adapters using zigbee-herdsman 'ember' driver", - "version": "2.9.4", + "version": "2.10.0", "author": "Nerivec", "bin": { "ember-zli": "bin/run.js" diff --git a/src/commands/bootloader/index.ts b/src/commands/bootloader/index.ts index d588675..21ba836 100644 --- a/src/commands/bootloader/index.ts +++ b/src/commands/bootloader/index.ts @@ -2,7 +2,7 @@ import type { AdapterModel, FirmwareLinks, FirmwareVariant, SelectChoices } from import { readFileSync } from 'node:fs' -import { input, select } from '@inquirer/prompts' +import { confirm, input, select } from '@inquirer/prompts' import { Command } from '@oclif/core' import { Presets, SingleBar } from 'cli-progress' @@ -13,31 +13,6 @@ import { FirmwareValidation } from '../../utils/enums.js' import { getPortConf } from '../../utils/port.js' import { browseToFile, fetchJson } from '../../utils/utils.js' -const clearNVM3SonoffZBDongleE: () => Buffer = () => { - const start = 'eb17a603080000000000000300000000f40a0af41c00000000000000000000000000000000000000000000000000000000000000fd0303fd0480000000600b00' - const blankChunkStart = '01009ab2010000d0feffff0fffffffff0098' - const blankChunkLength = 8174 - const end = 'fc0404fc040000004b83c4aa' - - return Buffer.concat([ - Buffer.from(start, 'hex'), - Buffer.from(blankChunkStart, 'hex'), - Buffer.alloc(blankChunkLength, 0xff), - Buffer.from(blankChunkStart, 'hex'), - Buffer.alloc(blankChunkLength, 0xff), - Buffer.from(blankChunkStart, 'hex'), - Buffer.alloc(blankChunkLength, 0xff), - Buffer.from(blankChunkStart, 'hex'), - Buffer.alloc(blankChunkLength, 0xff), - Buffer.from(end, 'hex'), - ]) -} - -const CLEAR_NVM3_BUFFERS: Partial Buffer>> = { - 'Sonoff ZBDongle-E': clearNVM3SonoffZBDongleE, - 'ROUTER - Sonoff ZBDongle-E': clearNVM3SonoffZBDongleE, -} - export default class Bootloader extends Command { static override args = {} static override description = 'Interact with the Gecko bootloader in the adapter.' @@ -99,7 +74,16 @@ export default class Bootloader extends Command { choices: [ { name: 'Get info', value: BootloaderMenu.INFO }, { name: 'Update firmware', value: BootloaderMenu.UPLOAD_GBL }, - { name: 'Clear NVM3', value: BootloaderMenu.CLEAR_NVM3, disabled: !this.supportsClearNVM3(gecko.adapterModel) }, + { + name: 'Clear NVM3 (https://github.com/Nerivec/silabs-firmware-recovery?tab=readme-ov-file#nvm3-clear)', + value: BootloaderMenu.CLEAR_NVM3, + disabled: !gecko.adapterModel, + }, + { + name: 'Clear APP (https://github.com/Nerivec/silabs-firmware-recovery?tab=readme-ov-file#app-clear)', + value: BootloaderMenu.CLEAR_APP, + disabled: !gecko.adapterModel, + }, { name: 'Exit bootloader (run firmware)', value: BootloaderMenu.RUN }, { name: 'Force close', value: -1 }, ], @@ -126,8 +110,39 @@ export default class Bootloader extends Command { } } } else if (answer === BootloaderMenu.CLEAR_NVM3) { - // adapterModel is defined here since menu is disabled if not supported, same for the value in the object - firmware = CLEAR_NVM3_BUFFERS[gecko.adapterModel!]!() + const confirmed = await confirm({ + default: false, + message: `Confirm adapter is: ${gecko.adapterModel}?`, + }) + + if (!confirmed) { + logger.warning(`Cancelled NVM3 clearing.`) + return false + } + + const nvm3Size = await select({ + choices: [ + { name: '32768', value: 32768 }, + { name: '40960', value: 40960 }, + ], + message: 'NVM3 Size (https://github.com/Nerivec/silabs-firmware-recovery?tab=readme-ov-file#nvm3-clear)', + }) + const firmwareLinks = await fetchJson(PRE_DEFINED_FIRMWARE_LINKS_URL) + const variant = nvm3Size === 32768 ? `nvm3_32768_clear` : `nvm3_40960_clear` + firmware = await this.downloadFirmware(firmwareLinks[variant][gecko.adapterModel!]!) + } else if (answer === BootloaderMenu.CLEAR_APP) { + const confirmed = await confirm({ + default: false, + message: `Confirm adapter is: ${gecko.adapterModel}?`, + }) + + if (!confirmed) { + logger.warning(`Cancelled APP clearing.`) + return false + } + + const firmwareLinks = await fetchJson(PRE_DEFINED_FIRMWARE_LINKS_URL) + firmware = await this.downloadFirmware(firmwareLinks.app_clear[gecko.adapterModel!]!) } return await gecko.navigate(answer, firmware) @@ -235,18 +250,4 @@ export default class Bootloader extends Command { } } } - - private supportsClearNVM3(adapterModel?: AdapterModel): boolean { - if (!adapterModel) { - return false - } - - for (const key in CLEAR_NVM3_BUFFERS) { - if (key === adapterModel) { - return true - } - } - - return false - } } diff --git a/src/utils/bootloader.ts b/src/utils/bootloader.ts index 565db97..d8dce59 100644 --- a/src/utils/bootloader.ts +++ b/src/utils/bootloader.ts @@ -40,6 +40,7 @@ export enum BootloaderMenu { UPLOAD_GBL = 0x31, RUN = 0x32, INFO = 0x33, + CLEAR_APP = 0xfe, CLEAR_NVM3 = 0xff, } @@ -199,6 +200,28 @@ export class GeckoBootloader extends EventEmitter { return await this.menuGetInfo() } + case BootloaderMenu.CLEAR_APP: { + if (firmware === undefined) { + logger.error(`Navigating to clear APP requires a valid firmware.`, NS) + await this.transport.close(false) // don't emit closed since we're returning true which will close anyway + + return true + } + + const confirmed = await confirm({ + default: false, + message: + 'Confirm APP clearing? (Cannot be undone; will erase the entire firmware (including NVM3). You MUST flash a new one afterwards.)', + }) + + if (!confirmed) { + logger.warning(`Cancelled APP clearing.`, NS) + return false + } + + return await this.menuUploadGBL(firmware) + } + case BootloaderMenu.CLEAR_NVM3: { if (firmware === undefined) { logger.error(`Navigating to clear NVM3 requires a valid firmware.`, NS) diff --git a/src/utils/types.ts b/src/utils/types.ts index c943fa6..64f380f 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -54,7 +54,7 @@ export type PortConf = { export type EmberFullVersion = { ezsp: number; revision: string } & EmberVersion export type ConfigValue = { [key: string]: string } -export type FirmwareVariant = 'official' | 'latest' | 'experimental' +export type FirmwareVariant = 'official' | 'latest' | 'experimental' | 'nvm3_32768_clear' | 'nvm3_40960_clear' | 'app_clear' export type FirmwareVersion = `${number}.${number}.${number}.${number}` export type FirmwareVersionShort = `${number}.${number}.${number}` export type FirmwareFilename = `${string}.gbl` diff --git a/src/utils/update-firmware-links.ts b/src/utils/update-firmware-links.ts index 18f512e..c63b3ac 100644 --- a/src/utils/update-firmware-links.ts +++ b/src/utils/update-firmware-links.ts @@ -31,7 +31,7 @@ async function getLatestGithubRelease(repo: string): Promise } function findFirmware(release: GithubReleaseJson, model: string, include: string | string[]): string | undefined { - const includeArr = Array.isArray(include) ? include : [include]; + const includeArr = Array.isArray(include) ? include : [include] const firmware = release.assets.find((asset) => asset.name.startsWith(model) && includeArr.every((i) => asset.name.includes(i))) return firmware?.browser_download_url