diff --git a/docs/tth-commands.md b/docs/tth-commands.md index f26a3b5b..ea2e16b1 100644 --- a/docs/tth-commands.md +++ b/docs/tth-commands.md @@ -113,6 +113,7 @@ stall watchdog", "Reboot into the bootloader" and "Why the board last reset". | `blink [n]` / `blink on\|off` | repeater | flash a spare LED (not the BLE or TX one) `n` times (default 6, max 999), or until `blink off` (gives up after 10 min); finds a board on a bench or a node on a mast | | `txpwr [dBm]` | repeater | LoRa output power until reboot, with RadioLib's status (`set tx` saves and says OK even when the radio refused) | | `i2c` | all | scan the I2C bus | +| `get chip` | nRF52 (repeater, room server, sensor) | the silicon (`nRF52840 AAD0`; variant `xxF0` and later = rev3) and `UICR.APPROTECT`: `open` means SWD can read the whole flash, keys included ([locked-bootloader.md](locked-bootloader.md)) | | `dio1` | own build: `PIN_DIAG` | has the SX1262 raise TX_DONE and compares its IRQ register with the level on the DIO1 pin -- which end of a dead IRQ line is broken | | `radiostat` | own build: `RADIO_DIAG` | receiver state, interrupt and RX counters, without touching the radio | | `radiokick rx\|clrirq\|standby\|agc` | own build: `RADIO_DIAG` | one recovery step, gentlest first: re-arm RX, clear latched IRQs, standby + RX, AGC reset; the first that brings `recv` back names the broken layer | diff --git a/src/helpers/CommonCLI.cpp b/src/helpers/CommonCLI.cpp index 5fed38ad..b4822769 100644 --- a/src/helpers/CommonCLI.cpp +++ b/src/helpers/CommonCLI.cpp @@ -936,6 +936,20 @@ void CommonCLI::handleGetCmd(uint32_t sender_timestamp, char* command, char* rep strcpy(reply, "Error: locked build"); return; } +#endif +#if defined(NRF52_PLATFORM) + // CUSTOM (TeTeHacko): which silicon, and whether SWD can read the flash + // (docs/locked-bootloader.md, point 5). Variant xxF0 and later = rev3, where + // the hardware closes the debug port unless the firmware opens it on every + // boot -- ours never does; rev1/rev2 obey UICR.APPROTECT alone (0xFF = open). + if (memcmp(config, "chip", 4) == 0 && config[4] == 0) { + uint32_t v = NRF_FICR->INFO.VARIANT; + uint32_t ap = NRF_UICR->APPROTECT; + sprintf(reply, "> nRF%lx %c%c%c%c, uicr.approtect %08lx (%s)", (unsigned long)NRF_FICR->INFO.PART, + (char)(v >> 24), (char)(v >> 16), (char)(v >> 8), (char)v, (unsigned long)ap, + (ap & 0xFF) == 0xFF ? "open" : "protected"); + return; + } #endif if (memcmp(config, "allow.read.only", 15) == 0) { sprintf(reply, "> %s", _prefs->allow_read_only ? "on" : "off");