From 1720caf27526ae4dc9ccc6dc63963ca5ec85370d Mon Sep 17 00:00:00 2001 From: Wessel Nieboer Date: Tue, 3 Mar 2026 00:01:26 +0100 Subject: [PATCH] diag build --- variants/rak4631/RAK4631Board.cpp | 34 ++++++++++++++++++++++++++++++- variants/rak4631/platformio.ini | 17 ++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/variants/rak4631/RAK4631Board.cpp b/variants/rak4631/RAK4631Board.cpp index 21fcbce25..39550bfa4 100644 --- a/variants/rak4631/RAK4631Board.cpp +++ b/variants/rak4631/RAK4631Board.cpp @@ -16,6 +16,22 @@ static void __attribute__((constructor(102))) rak4631_early_poe_power() { } #endif +#ifdef BOOT_DIAG +// Diagnostic LED blink: N short blinks on green LED to indicate boot stage +static void diag_blink(uint8_t count) { + pinMode(PIN_LED1, OUTPUT); + for (uint8_t i = 0; i < count; i++) { + digitalWrite(PIN_LED1, HIGH); + delay(100); + digitalWrite(PIN_LED1, LOW); + delay(150); + } + delay(300); +} +#else +#define diag_blink(n) ((void)0) +#endif + #ifdef NRF52_POWER_MANAGEMENT // Static configuration for power management // Values set in variant.h defines @@ -41,7 +57,16 @@ void RAK4631Board::initiateShutdown(uint8_t reason) { #endif // NRF52_POWER_MANAGEMENT void RAK4631Board::begin() { + diag_blink(1); // Stage 1: entering begin() + +#ifdef DISABLE_DCDC + NRF52Board::begin(); +#else NRF52BoardDCDC::begin(); +#endif + + diag_blink(2); // Stage 2: board base init done + pinMode(PIN_VBAT_READ, INPUT); #ifdef PIN_USER_BTN pinMode(PIN_USER_BTN, INPUT_PULLUP); @@ -58,12 +83,19 @@ void RAK4631Board::begin() { Wire.begin(); + diag_blink(3); // Stage 3: I2C done, about to configure LoRa power + pinMode(SX126X_POWER_EN, OUTPUT); -#ifdef NRF52_POWER_MANAGEMENT +#if defined(NRF52_POWER_MANAGEMENT) && !defined(DISABLE_BOOT_PROTECTION) // Boot voltage protection check (may not return if voltage too low) // We need to call this after we configure SX126X_POWER_EN as output but before we pull high checkBootVoltage(&power_config); #endif + + diag_blink(4); // Stage 4: power check passed + digitalWrite(SX126X_POWER_EN, HIGH); delay(10); // give sx1262 some time to power up + + diag_blink(5); // Stage 5: board.begin() complete } \ No newline at end of file diff --git a/variants/rak4631/platformio.ini b/variants/rak4631/platformio.ini index 31b507b4c..06b79b46f 100644 --- a/variants/rak4631/platformio.ini +++ b/variants/rak4631/platformio.ini @@ -72,6 +72,23 @@ lib_deps = ${rak4631.lib_deps} https://github.com/RAKWireless/RAK13800-W5100S/archive/1.0.2.zip +; Diagnostic build: LED blinks at boot stages + boot protection disabled +[env:RAK_4631_repeater_diag] +extends = env:RAK_4631_repeater +build_flags = + ${env:RAK_4631_repeater.build_flags} + -D BOOT_DIAG + -D DISABLE_BOOT_PROTECTION + +; Diagnostic build: LED blinks + boot protection disabled + DC/DC disabled +[env:RAK_4631_repeater_diag_no_dcdc] +extends = env:RAK_4631_repeater +build_flags = + ${env:RAK_4631_repeater.build_flags} + -D BOOT_DIAG + -D DISABLE_BOOT_PROTECTION + -D DISABLE_DCDC + [env:RAK_4631_repeater_bridge_rs232_serial1] extends = rak4631 build_flags =