From 076becb70f23851dd12a16d5ae69a9f3fba95b24 Mon Sep 17 00:00:00 2001 From: liquidraver <504870+liquidraver@users.noreply.github.com> Date: Tue, 14 Apr 2026 08:55:11 +0200 Subject: [PATCH] RAK4631 - enable display support --- _meshcore_arduino | 1 + zephcore/boards/nrf52840/rak4631/board.conf | 52 ++-- .../boards/nrf52840/rak4631/board.overlay | 236 ++++++++++-------- 3 files changed, 156 insertions(+), 133 deletions(-) create mode 160000 _meshcore_arduino diff --git a/_meshcore_arduino b/_meshcore_arduino new file mode 160000 index 0000000..9f680d1 --- /dev/null +++ b/_meshcore_arduino @@ -0,0 +1 @@ +Subproject commit 9f680d1744dbba2e61476071dbf00c4efb277633 diff --git a/zephcore/boards/nrf52840/rak4631/board.conf b/zephcore/boards/nrf52840/rak4631/board.conf index 8853a8f..2c65373 100644 --- a/zephcore/boards/nrf52840/rak4631/board.conf +++ b/zephcore/boards/nrf52840/rak4631/board.conf @@ -1,24 +1,28 @@ -# RAK4631 (nRF52840 + SX1262) -# Board-specific configuration - pins and unique features only -# -# SoftDevice: s140 v6.1.1 (app@0x26000, bootloader@0xF4000) -# Arduino linker: nrf52840_s140_v6.ld -# -# Hardware: -# - SX1262 LoRa on SPI0 (built into RAK4631 module) -# - RAK1910 GPS on UART0 (Slot A) - u-blox MAX-7Q at 9600 baud -# - Battery ADC on AIN3 (P0.05) -# - I2C0 for WisBlock sensors (auto-detected): -# - RAK1901 (SHTC3) at 0x70 -# - RAK1902 (LPS22HB) at 0x5C -# - RAK1906 (BME680) at 0x76 - -# Board identification (matches Arduino variant name) -CONFIG_ZEPHCORE_BOARD_NAME="RAK 4631" - -# Device Information Service model name -CONFIG_BT_DIS_MODEL_NUMBER_STR="RAK4631" - -# SoftDevice firmware ID (s140 v6.1.1) -CONFIG_ZEPHCORE_SD_FWID=0x00B6 - +# RAK4631 (nRF52840 + SX1262) +# Board-specific configuration - pins and unique features only +# +# SoftDevice: s140 v6.1.1 (app@0x26000, bootloader@0xF4000) +# Arduino linker: nrf52840_s140_v6.ld +# +# Hardware: +# - SX1262 LoRa on SPI0 (built into RAK4631 module) +# - RAK1910 GPS on UART0 (Slot A) - u-blox MAX-7Q at 9600 baud +# - Battery ADC on AIN3 (P0.05) +# - I2C0 for WisBlock sensors (auto-detected): +# - RAK1901 (SHTC3) at 0x70 +# - RAK1902 (LPS22HB) at 0x5C +# - RAK1906 (BME680) at 0x76 +# - Optional SSD1306 128x64 OLED @ 0x3C (P0.13 SDA, P0.14 SCL), same as MeshCore Arduino + +# Board identification (matches Arduino variant name) +CONFIG_ZEPHCORE_BOARD_NAME="RAK 4631" + +# Device Information Service model name +CONFIG_BT_DIS_MODEL_NUMBER_STR="RAK4631" + +# SoftDevice firmware ID (s140 v6.1.1) +CONFIG_ZEPHCORE_SD_FWID=0x00B6 + +# Display: compile in UI display stack; panel is optional at runtime (probe/init). +CONFIG_ZEPHCORE_UI_DISPLAY=y + diff --git a/zephcore/boards/nrf52840/rak4631/board.overlay b/zephcore/boards/nrf52840/rak4631/board.overlay index 0514762..6f5da42 100644 --- a/zephcore/boards/nrf52840/rak4631/board.overlay +++ b/zephcore/boards/nrf52840/rak4631/board.overlay @@ -1,109 +1,127 @@ -/* - * RAK4631 overlay for SoftDevice + UF2 bootloader. - * App at 0x26000, storage at 0xD4000, bootloader at 0xF4000. - * Uses SoftDevice s140 v6.1.1 (ends at 0x26000). - * Console: USB CDC ACM. - * Battery: AIN3 = P0.05 (Arduino pin 5), voltage divider per RAK4631 schematic. - * - * QSPI Flash: Optional external flash on WisBlock Base boards. - * Supports: P25Q16H, MX25R1635F, W25Q16, GD25Q16, IS25LP080, ZD25WQ16 - * If no QSPI flash present, falls back to internal flash only. - * - * GPS: RAK1910 (u-blox MAX-7Q) on UART0 at 9600 baud (Slot A) - * Sensors: Auto-detected on I2C0 - supports: - * - RAK1901 (SHTC3) at 0x70 - * - RAK1902 (LPS22HB) at 0x5C - * - RAK1906 (BME680) at 0x76 - */ - -#include - -/delete-node/ &boot_partition; -/delete-node/ &slot0_partition; -/delete-node/ &slot1_partition; -/delete-node/ &storage_partition; - -/ { - aliases { - led1 = &green_led; - }; - chosen { - zephyr,code-partition = &code_partition; - zephyr,console = &cdc_acm_uart; - zephyr,shell-uart = &cdc_acm_uart; - }; -}; - -/* Battery ADC - AIN3 on P0.05 with voltage divider */ -/ { - zephyr,user { - io-channels = <&adc 3>; - vbat-mv-multiplier = <6161>; /* Arduino: (3 * 1.73 * 1.187 * 1000) ≈ 6161, GAIN_1_6 + 0.6V ref */ - }; -}; - -&adc { - #address-cells = <1>; - #size-cells = <0>; - channel@3 { - reg = <3>; - zephyr,gain = "ADC_GAIN_1_6"; - zephyr,reference = "ADC_REF_INTERNAL"; - zephyr,acquisition-time = ; - zephyr,input-positive = ; - zephyr,resolution = <12>; - }; -}; - -&zephyr_udc0 { - cdc_acm_uart: cdc_acm_uart { - compatible = "zephyr,cdc-acm-uart"; - }; -}; - -&lora { - dio1-gpios = <&gpio1 15 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>; - rx-boosted; -}; - -/* - * GPS on UART0 - RAK1910 (u-blox MAX-7Q) at 9600 baud - * Connect to Slot A (UART pins P0.19 RX, P0.20 TX) - */ -&uart0 { - current-speed = <9600>; - gnss: gnss-nmea-generic { - compatible = "gnss-nmea-generic"; - }; -}; - -/* - * Environment & power sensors on I2C0 - * All supported sensors pre-defined — auto-detected at runtime. - * WisBlock modules: RAK1901 (SHTC3), RAK1902 (LPS22HB), RAK1906 (BME680) - */ -&i2c0 { - #include "../../common/sensors-i2c.dtsi" -}; - -/* RAK4631 has BME680, not BME280 — override the common DTSI default */ -/delete-node/ &bme280; -&i2c0 { - bme680: bme680@76 { - compatible = "bosch,bme680"; - reg = <0x76>; - }; -}; - -/* - * QSPI Flash — disabled. - * RAK19003 Mini Base Board has no QSPI flash. The upstream DTS enables &qspi, - * which hangs at boot if no chip is present. Disable it explicitly. - * For base boards with QSPI (RAK19007, RAK5005-O), create a separate variant. - */ -&qspi { - status = "disabled"; -}; - -/* Arduino MeshCore compatible partition layout (SoftDevice v6) */ -#include "../../common/nrf52_partitions_sdv6.dtsi" +/* + * RAK4631 overlay for SoftDevice + UF2 bootloader. + * App at 0x26000, storage at 0xD4000, bootloader at 0xF4000. + * Uses SoftDevice s140 v6.1.1 (ends at 0x26000). + * Console: USB CDC ACM. + * Battery: AIN3 = P0.05 (Arduino pin 5), voltage divider per RAK4631 schematic. + * + * QSPI Flash: Optional external flash on WisBlock Base boards. + * Supports: P25Q16H, MX25R1635F, W25Q16, GD25Q16, IS25LP080, ZD25WQ16 + * If no QSPI flash present, falls back to internal flash only. + * + * GPS: RAK1910 (u-blox MAX-7Q) on UART0 at 9600 baud (Slot A) + * Sensors: Auto-detected on I2C0 - supports: + * - RAK1901 (SHTC3) at 0x70 + * - RAK1902 (LPS22HB) at 0x5C + * - RAK1906 (BME680) at 0x76 + * + * Optional WisBlock OLED (MeshCore Arduino: SSD1306 128x64 @ 0x3C on I2C0 + * P0.13/P0.14, no reset GPIO). If the panel is absent, display init may fail + * at runtime; UI continues without OLED. + */ + +#include + +/delete-node/ &boot_partition; +/delete-node/ &slot0_partition; +/delete-node/ &slot1_partition; +/delete-node/ &storage_partition; + +/ { + aliases { + led1 = &green_led; + }; + chosen { + zephyr,code-partition = &code_partition; + zephyr,console = &cdc_acm_uart; + zephyr,shell-uart = &cdc_acm_uart; + zephyr,display = &ssd1306; + }; +}; + +/* Battery ADC - AIN3 on P0.05 with voltage divider */ +/ { + zephyr,user { + io-channels = <&adc 3>; + vbat-mv-multiplier = <6161>; /* Arduino: (3 * 1.73 * 1.187 * 1000) ≈ 6161, GAIN_1_6 + 0.6V ref */ + }; +}; + +&adc { + #address-cells = <1>; + #size-cells = <0>; + channel@3 { + reg = <3>; + zephyr,gain = "ADC_GAIN_1_6"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,input-positive = ; + zephyr,resolution = <12>; + }; +}; + +&zephyr_udc0 { + cdc_acm_uart: cdc_acm_uart { + compatible = "zephyr,cdc-acm-uart"; + }; +}; + +&lora { + dio1-gpios = <&gpio1 15 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>; + rx-boosted; +}; + +/* + * GPS on UART0 - RAK1910 (u-blox MAX-7Q) at 9600 baud + * Connect to Slot A (UART pins P0.19 RX, P0.20 TX) + */ +&uart0 { + current-speed = <9600>; + gnss: gnss-nmea-generic { + compatible = "gnss-nmea-generic"; + }; +}; + +/* + * I2C0: optional SSD1306 OLED + environment sensors (same bus as MeshCore RAK4631). + */ +&i2c0 { + ssd1306: ssd1306@3c { + compatible = "solomon,ssd1306"; + reg = <0x3c>; + width = <128>; + height = <64>; + segment-offset = <0>; + page-offset = <0>; + display-offset = <0>; + multiplex-ratio = <63>; + segment-remap; + com-invdir; + inversion-on; + prechargep = <0x22>; + }; + + #include "../../common/sensors-i2c.dtsi" +}; + +/* RAK4631 has BME680, not BME280 — override the common DTSI default */ +/delete-node/ &bme280; +&i2c0 { + bme680: bme680@76 { + compatible = "bosch,bme680"; + reg = <0x76>; + }; +}; + +/* + * QSPI Flash — disabled. + * RAK19003 Mini Base Board has no QSPI flash. The upstream DTS enables &qspi, + * which hangs at boot if no chip is present. Disable it explicitly. + * For base boards with QSPI (RAK19007, RAK5005-O), create a separate variant. + */ +&qspi { + status = "disabled"; +}; + +/* Arduino MeshCore compatible partition layout (SoftDevice v6) */ +#include "../../common/nrf52_partitions_sdv6.dtsi"