From fcdd982273a16a0dfdf8bd1d16170a24f5552864 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 83c450297..c30b189bb 100644 --- a/variants/rak4631/RAK4631Board.cpp +++ b/variants/rak4631/RAK4631Board.cpp @@ -3,6 +3,22 @@ #include "RAK4631Board.h" +#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 @@ -28,7 +44,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); @@ -44,12 +69,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 2bbba3146..3fec07fac 100644 --- a/variants/rak4631/platformio.ini +++ b/variants/rak4631/platformio.ini @@ -53,6 +53,23 @@ build_src_filter = ${rak4631.build_src_filter} + +<../examples/simple_repeater> +; 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 =