修复 moonshine NRF52 启动: LFRC + S140 v7 + 禁用 I2C
RF-BM-ND05 无 32.768kHz 晶振,USE_LFXO 导致 SoftDevice 卡在 RTC1_IRQHandler,BLE 静默失败。改用 USE_LFRC。 P0.09/P0.10 是 NFC 引脚,被模块内部电路拉低,TWIM endTransmission 无限等待。禁用 I2C 及依赖功能(环境传感器/输入代理/加速度计/磁力计)。 linker 改用 nrf52840_s140_v7.ld 匹配仓库打包的 S140 v7.3.0 SoftDevice(app @ 0x27000)。readme 补充 OpenOCD SWD 烧录流程。
This commit is contained in:
@@ -2,8 +2,15 @@
|
|||||||
[env:moonshine_NRF52_node]
|
[env:moonshine_NRF52_node]
|
||||||
extends = nrf52840_base
|
extends = nrf52840_base
|
||||||
board = adafruit_feather_nrf52840
|
board = adafruit_feather_nrf52840
|
||||||
|
board_build.ldscript = src/platform/nrf52/nrf52840_s140_v7.ld
|
||||||
build_flags = ${nrf52840_base.build_flags}
|
build_flags = ${nrf52840_base.build_flags}
|
||||||
-I variants/nrf52840/diy/moonshine_NRF52
|
-I variants/nrf52840/diy/moonshine_NRF52
|
||||||
-D PRIVATE_HW
|
-D PRIVATE_HW
|
||||||
|
-D USE_SEGGER
|
||||||
|
-D MESHTASTIC_EXCLUDE_I2C=1
|
||||||
|
-D MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR=1
|
||||||
|
-D MESHTASTIC_EXCLUDE_INPUTBROKER=1
|
||||||
|
-D MESHTASTIC_EXCLUDE_ACCELEROMETER=1
|
||||||
|
-D MESHTASTIC_EXCLUDE_MAGNETOMETER=1
|
||||||
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nrf52840/diy/moonshine_NRF52>
|
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nrf52840/diy/moonshine_NRF52>
|
||||||
debug_tool = jlink
|
debug_tool = jlink
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ DIY Meshtastic node variant based on the RF-BM-ND05 nRF52840 module.
|
|||||||
## Hardware
|
## Hardware
|
||||||
|
|
||||||
- **MCU module**: RF-BM-ND05 (nRF52840, 512 KB flash / 128 KB RAM)
|
- **MCU module**: RF-BM-ND05 (nRF52840, 512 KB flash / 128 KB RAM)
|
||||||
- **LF clock**: 32.768 kHz crystal (`USE_LFXO`)
|
- **LF clock**: internal RC (`USE_LFRC`) - RF-BM-ND05 has no 32.768 kHz crystal; using
|
||||||
|
`USE_LFXO` without a crystal makes SoftDevice hang in `RTC1_IRQHandler` waiting
|
||||||
|
for LFCLK, causing LED-stuck-on and silent BLE failure.
|
||||||
- **LoRa**: multi-module compatible (SX1262 / SX1268 / RF95 / LLCC68 / LR1121 / LR2021) with TCXO
|
- **LoRa**: multi-module compatible (SX1262 / SX1268 / RF95 / LLCC68 / LR1121 / LR2021) with TCXO
|
||||||
- **GPS**: u-blox (no EN pin)
|
- **GPS**: u-blox (no EN pin)
|
||||||
- **Battery ADC**: 0.5 voltage divider (equal resistors)
|
- **Battery ADC**: 0.5 voltage divider (equal resistors)
|
||||||
@@ -51,4 +53,57 @@ pio run -e moonshine_NRF52_node
|
|||||||
```
|
```
|
||||||
|
|
||||||
Uses `PRIVATE_HW` (HardwareModel 255) - no protobuf or `architecture.h` changes
|
Uses `PRIVATE_HW` (HardwareModel 255) - no protobuf or `architecture.h` changes
|
||||||
required. Flash via SWD (`debug_tool = jlink`).
|
required.
|
||||||
|
|
||||||
|
The build links against `nrf52840_s140_v7.ld`, so the application is linked to
|
||||||
|
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)
|
||||||
|
|
||||||
|
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
|
||||||
|
`Bluefruit.begin()` fails, `sd_flash_*` calls (LittleFS, NodeDB, config
|
||||||
|
persistence) return errors, and the node appears dead.
|
||||||
|
|
||||||
|
The S140 v7.3.0 SoftDevice hex is shipped in this repo at
|
||||||
|
`bin/s140_nrf52_7.3.0_softdevice.hex`. Flash via SWD with OpenOCD (CMSIS-DAP /
|
||||||
|
J-Link / ST-Link). The `nrf52_recover` command does a chip-wide ERASEALL through
|
||||||
|
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
|
||||||
|
C:/openocd/bin/openocd.exe -s C:/openocd/share/openocd/scripts \
|
||||||
|
-f interface/cmsis-dap.cfg -f target/nrf52.cfg \
|
||||||
|
-c "init; nrf52_recover; \
|
||||||
|
program bin/s140_nrf52_7.3.0_softdevice.hex verify; \
|
||||||
|
program .pio/build/moonshine_NRF52_node/firmware-moonshine_NRF52_node-*.hex verify; \
|
||||||
|
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:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
C:/openocd/bin/openocd.exe -s C:/openocd/share/openocd/scripts \
|
||||||
|
-f interface/cmsis-dap.cfg -f target/nrf52.cfg \
|
||||||
|
-c "init; \
|
||||||
|
program .pio/build/moonshine_NRF52_node/firmware-moonshine_NRF52_node-*.hex verify; \
|
||||||
|
reset run; exit"
|
||||||
|
```
|
||||||
|
|
||||||
|
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.
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
/** Master clock frequency */
|
/** Master clock frequency */
|
||||||
#define VARIANT_MCK (64000000ul)
|
#define VARIANT_MCK (64000000ul)
|
||||||
|
|
||||||
#define USE_LFXO // Board uses 32khz crystal for LF
|
// #define USE_LFXO // Board uses 32khz crystal for LF
|
||||||
|
#define USE_LFRC // RF-BM-ND05 has no LFXO crystal - use internal RC
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------
|
/*----------------------------------------------------------------------------
|
||||||
* Headers
|
* Headers
|
||||||
|
|||||||
Reference in New Issue
Block a user