From fe44cb432634b2cd97b9a470d3f4ca7bd6b4b269 Mon Sep 17 00:00:00 2001 From: Kevin Le Date: Sat, 17 Oct 2026 12:04:21 +0700 Subject: [PATCH] Custom GPS, Added BME680_BSEC and Keep time across reset for RAK3401 --- variants/rak3401/fix_bsec_lib.py | 15 +++++++++++++++ variants/rak3401/platformio.ini | 19 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 variants/rak3401/fix_bsec_lib.py diff --git a/variants/rak3401/fix_bsec_lib.py b/variants/rak3401/fix_bsec_lib.py new file mode 100644 index 000000000..605ff1187 --- /dev/null +++ b/variants/rak3401/fix_bsec_lib.py @@ -0,0 +1,15 @@ +Import('env') +import os + +# Bosch has a goof in their PlatformIO packaging making linking fail. +# The BSEC library's extra_script.py selects cortex-m4/libalgobsec.a (soft-float ABI). +# nRF52840 compiles with -mfloat-abi=hard, requiring the fpv4-sp-d16-hard blob. +# Workaround to prepend the hard-float path so the linker finds it before the +# soft-float one. +bsec_hard = os.path.join( + env.subst('$PROJECT_DIR'), + '.pio', 'libdeps', env.subst('$PIOENV'), + 'BSEC Software Library', 'src', + 'cortex-m4', 'fpv4-sp-d16-hard' +) +env.Prepend(LIBPATH=[bsec_hard]) \ No newline at end of file diff --git a/variants/rak3401/platformio.ini b/variants/rak3401/platformio.ini index d157e4b1d..eddadd031 100644 --- a/variants/rak3401/platformio.ini +++ b/variants/rak3401/platformio.ini @@ -2,6 +2,9 @@ extends = nrf52_base board = rak3401 board_check = true +board_build.ldscript = boards/nrf52840_s140_v6.ld +extra_scripts = ${nrf52_base.extra_scripts} + post:variants/rak3401/fix_bsec_lib.py build_flags = ${nrf52_base.build_flags} ${sensor_base.build_flags} -I variants/rak3401 @@ -13,6 +16,11 @@ build_flags = ${nrf52_base.build_flags} -D SX126X_CURRENT_LIMIT=140 -D SX126X_RX_BOOSTED_GAIN=1 -D SX126X_REGISTER_PATCH=1 ; Patch register 0x8B5 for improved RX with SKY66122 FEM + -D FORCE_GPS_ALIVE ; on RAK3401, gpsResetPin ends up = WB_IO2 (kills 3V3_S rail) or + ; pin 4 (= SX126X_RESET, holds radio in reset). stop_gps() must not run. + -D PIN_GPS_EN=-1 ; -1 = no dedicated GPS enable pin (power is the shared 3V3_S rail), same as rak4631 + -UENV_INCLUDE_BME680 + -D ENV_INCLUDE_BME680_BSEC=1 build_src_filter = ${nrf52_base.build_src_filter} +<../variants/rak3401> + @@ -40,6 +48,17 @@ build_src_filter = ${rak3401.build_src_filter} + +<../examples/simple_repeater> +[env:RAK_3401_repeater_bridge_rs232_serial1] +extends = env:RAK_3401_repeater +build_flags = + ${env:RAK_3401_repeater.build_flags} + -D ADVERT_NAME='"RAK3401 1W RS232 Bridge"' + -D WITH_RS232_BRIDGE=Serial1 + -D WITH_RS232_BRIDGE_RX=PIN_SERIAL1_RX + -D WITH_RS232_BRIDGE_TX=PIN_SERIAL1_TX +build_src_filter = ${env:RAK_3401_repeater.build_src_filter} + + + [env:RAK_3401_room_server] extends = rak3401 build_flags =