From 9237cf90128fa7c999168de8658fbb9a6778b20f Mon Sep 17 00:00:00 2001 From: kevin Date: Sun, 19 Jul 2026 03:10:02 +0800 Subject: [PATCH] =?UTF-8?q?moonshine:=20=E5=8A=A0=E5=85=85=E7=94=B5?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=20P0.16=20+=20=E6=95=B4=E7=90=86=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E7=83=A7=E5=BD=95=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit variant.h: 新增 EXT_CHRG_DETECT (P0.16, 高电平=充电中), Power.cpp 据此驱动 isCharging() 和充电状态 LED 行为。 readme: 引脚表加 CHARGE_DET 行;合并 Build/Flash 章节为 'Build & Flash',分首次烧录(recover+SD+app)和增量烧录(app only) 两个命令块,便于复用。 --- .../nrf52840/diy/moonshine_NRF52/readme.md | 30 +++++++++++-------- .../nrf52840/diy/moonshine_NRF52/variant.h | 4 +++ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/variants/nrf52840/diy/moonshine_NRF52/readme.md b/variants/nrf52840/diy/moonshine_NRF52/readme.md index d97e6dd9e..b2397b73f 100644 --- a/variants/nrf52840/diy/moonshine_NRF52/readme.md +++ b/variants/nrf52840/diy/moonshine_NRF52/readme.md @@ -17,6 +17,7 @@ DIY Meshtastic node variant based on the RF-BM-ND05 nRF52840 module. | Function | Pin | Notes | | ------------- | ----- | -------------------------------------- | | LED | P0.30 | Active high (`LED_STATE_ON = 1`) | +| CHARGE_DET | P0.16 | Active high (charging) | | BUTTON | P0.27 | User button | | BUZZER | P0.26 | PWM buzzer | | BATTERY_ADC | P0.05 | 0.5 divider | @@ -46,7 +47,9 @@ Note: P0.12/P0.13 are physically wired as RTS/CTS, but the Adafruit nRF52 core's hardware flow control is not enabled by firmware. These pins are unused unless the core is patched. -## Build +## Build & Flash + +### Build ```sh pio run -e moonshine_NRF52_node @@ -60,7 +63,7 @@ start at `0x27000` and requires the S140 SoftDevice v7.x to be present on the chip at `0x0`-`0x26FFF`. The build output (`firmware-*.hex` / `.uf2`) contains **only the application**, not the SoftDevice. -## Flash (first time on a bare RF-BM-ND05) +### Flash (first time on a bare RF-BM-ND05) A factory-fresh RF-BM-ND05 module has **no SoftDevice and no bootloader**. The SoftDevice must be flashed once via SWD before the application; otherwise @@ -74,7 +77,7 @@ the nRF52 CTRL-AP and clears APPROTECT, so it is the recommended first step on a fresh module (ebyte/Raytac modules ship with APPROTECT engaged). ```sh -# Single-command flow: recover (erase all + unlock) -> SoftDevice -> app -> reset +# Full flow: recover (erase all + unlock) -> SoftDevice -> app -> reset C:/openocd/bin/openocd.exe -s C:/openocd/share/openocd/scripts \ -f interface/cmsis-dap.cfg -f target/nrf52.cfg \ -c "init; nrf52_recover; \ @@ -83,8 +86,11 @@ C:/openocd/bin/openocd.exe -s C:/openocd/share/openocd/scripts \ reset run; exit" ``` -If the chip is already unlocked and you only need to re-flash the application -(SoftDevice already present), skip `nrf52_recover` and the SoftDevice line: +### Flash (app only, SoftDevice already present) + +When the SoftDevice is already on the chip and only the application changed +(e.g. after editing the variant and rebuilding), skip `nrf52_recover` and the +SoftDevice line: ```sh C:/openocd/bin/openocd.exe -s C:/openocd/share/openocd/scripts \ @@ -94,16 +100,16 @@ C:/openocd/bin/openocd.exe -s C:/openocd/share/openocd/scripts \ reset run; exit" ``` -Notes: +### Notes + - The firmware hex filename contains a commit hash (e.g. `2.8.0.421838f`); use the actual file produced by `pio run` or a shell glob. - The SoftDevice hex occupies `0x0`-`0x26498` (~156 KB) and does **not** write UICR, so `nrf52_recover` is safe (UICR resets to defaults). - Swap `interface/cmsis-dap.cfg` for `interface/jlink.cfg` or `interface/stlink.cfg` if using a different SWD probe. - -No UF2 bootloader is installed in this flow, so subsequent updates must go -through BLE DFU (secure DFU service) or SWD again. To enable UF2 drag-and-drop -updates, flash an Adafruit nRF52 UF2 bootloader -(https://github.com/adafruit/Adafruit_nRF52_Bootloader) at `0x0` in place of the -bare SoftDevice - the bootloader bundles its own SoftDevice. +- No UF2 bootloader is installed in this flow, so subsequent updates must go + through BLE DFU (secure DFU service) or SWD again. To enable UF2 drag-and-drop + updates, flash an Adafruit nRF52 UF2 bootloader + (https://github.com/adafruit/Adafruit_nRF52_Bootloader) at `0x0` in place of + the bare SoftDevice - the bootloader bundles its own SoftDevice. diff --git a/variants/nrf52840/diy/moonshine_NRF52/variant.h b/variants/nrf52840/diy/moonshine_NRF52/variant.h index 1abb2f7b3..ab5e53e8a 100644 --- a/variants/nrf52840/diy/moonshine_NRF52/variant.h +++ b/variants/nrf52840/diy/moonshine_NRF52/variant.h @@ -73,6 +73,10 @@ MOONSHINE NRF52 PIN ASSIGNMENT (RF-BM-ND05) #define LED_BLUE PIN_LED1 #define LED_STATE_ON 1 // State when LED is lit (active high) +// Charge detection (P0.16, active high = charging) +#define EXT_CHRG_DETECT (0 + 16) +#define EXT_CHRG_DETECT_VALUE HIGH + // Buzzer #define PIN_BUZZER (0 + 26) // P0.26