From fd619b49d10f4b76e4b9e156f76180c1b9b8ca2f Mon Sep 17 00:00:00 2001 From: jessm33 Date: Fri, 22 May 2026 09:18:32 -0400 Subject: [PATCH 01/12] Enable suport for the lr2021 on native --- bin/config.d/lora-lyra-ultra-LoRa2021F33.yaml | 38 +++++++++++++++++++ src/mesh/InterfacesTemplates.cpp | 2 +- src/mesh/LR11x0Interface.cpp | 10 ++--- src/mesh/LR2021Interface.cpp | 2 +- src/mesh/LR20x0Interface.cpp | 7 +++- src/mesh/RadioInterface.cpp | 2 + src/platform/portduino/PortduinoGlue.cpp | 7 +++- src/platform/portduino/PortduinoGlue.h | 7 +++- 8 files changed, 64 insertions(+), 11 deletions(-) create mode 100644 bin/config.d/lora-lyra-ultra-LoRa2021F33.yaml diff --git a/bin/config.d/lora-lyra-ultra-LoRa2021F33.yaml b/bin/config.d/lora-lyra-ultra-LoRa2021F33.yaml new file mode 100644 index 00000000000..3b078e95689 --- /dev/null +++ b/bin/config.d/lora-lyra-ultra-LoRa2021F33.yaml @@ -0,0 +1,38 @@ +# For the NiceRF LoRa2021F33 module, on the LuckFox Ultra boards. +# Pin assignment is based on wehooper4's Luckfox Ultra Hats +# +# Ubuntu use luckfox-config to configure spi0 as: +# CS=10, CLK=8, MOSI=6, MISO=7 Max spi speed: 2000000 +# +# For use with Armbian luckfox-lyra-ultra-w +# Enable overlay 'luckfox-lyra-ultra-w-spi0-cs0-spidev' with armbian-config + +Meta: + name: Luackfox Ultr NiceRF LoRa2021F33 + support: community + compatible: + - luckfox-pico-ultra # Armbian + - luckfox-lyra-ultra # Armbian + +Lora: + Module: lr2021 + DIO3_TCXO_VOLTAGE: 1.8 + # Defaults for LR2021, but can be overridden by user config + # LR2021_MAX_POWER: 22 + # LR2021_MAX_POWER_HF: 22 + # LR2021_IRQ_DIO_NUM: 9 + CS: 10 + IRQ: 5 + Busy: 11 + Reset: 9 + + spidev: spidev0.0 #pins are (CS=10, CLK=8, MOSI=6, MISO=7) + spiSpeed: 2000000 + +rfswitch_table: + pins: [DIO5, DIO6, DIO8] + MODE_STBY: [LOW, LOW, LOW] + MODE_RX: [LOW, LOW, LOW] + MODE_TX: [LOW, HIGH, LOW] + MODE_RX_HF: [HIGH, LOW, LOW] + MODE_TX_HF: [LOW, LOW, HIGH] diff --git a/src/mesh/InterfacesTemplates.cpp b/src/mesh/InterfacesTemplates.cpp index 6f6b2d2a14d..9adf78bb4b4 100644 --- a/src/mesh/InterfacesTemplates.cpp +++ b/src/mesh/InterfacesTemplates.cpp @@ -25,7 +25,7 @@ template class LR11x0Interface; template class LR11x0Interface; template class LR11x0Interface; #endif -#if defined(USE_LR2021) && RADIOLIB_EXCLUDE_LR2021 != 1 +#if RADIOLIB_EXCLUDE_LR2021 != 1 template class LR20x0Interface; #endif #ifdef ARCH_STM32WL diff --git a/src/mesh/LR11x0Interface.cpp b/src/mesh/LR11x0Interface.cpp index 1d1616ed673..4b63187e043 100644 --- a/src/mesh/LR11x0Interface.cpp +++ b/src/mesh/LR11x0Interface.cpp @@ -8,11 +8,11 @@ #include "rfswitch.h" #elif ARCH_PORTDUINO #include "PortduinoGlue.h" -#define rfswitch_dio_pins portduino_config.rfswitch_dio_pins -#define rfswitch_table portduino_config.rfswitch_table +#define lr11x0_rfswitch_dio_pins portduino_config.rfswitch_dio_pins +#define lr11x0_rfswitch_table portduino_config.rfswitch_table #else -static const uint32_t rfswitch_dio_pins[] = {RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC}; -static const Module::RfSwitchMode_t rfswitch_table[] = { +static const uint32_t lr11x0_rfswitch_dio_pins[] = {RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC}; +static const Module::RfSwitchMode_t lr11x0_rfswitch_table[] = { {LR11x0::MODE_STBY, {}}, {LR11x0::MODE_RX, {}}, {LR11x0::MODE_TX, {}}, {LR11x0::MODE_TX_HP, {}}, {LR11x0::MODE_TX_HF, {}}, {LR11x0::MODE_GNSS, {}}, {LR11x0::MODE_WIFI, {}}, END_OF_MODE_TABLE, }; @@ -146,7 +146,7 @@ template bool LR11x0Interface::init() #endif if (dioAsRfSwitch) { - lora.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table); + lora.setRfSwitchTable(lr11x0_rfswitch_dio_pins, lr11x0_rfswitch_table); LOG_DEBUG("Set DIO RF switch"); } diff --git a/src/mesh/LR2021Interface.cpp b/src/mesh/LR2021Interface.cpp index 9aa4d5f1ab0..f0e513302a5 100644 --- a/src/mesh/LR2021Interface.cpp +++ b/src/mesh/LR2021Interface.cpp @@ -1,6 +1,6 @@ #include "configuration.h" -#if defined(USE_LR2021) && RADIOLIB_EXCLUDE_LR2021 != 1 +#if RADIOLIB_EXCLUDE_LR2021 != 1 #include "LR2021Interface.h" #include "error.h" diff --git a/src/mesh/LR20x0Interface.cpp b/src/mesh/LR20x0Interface.cpp index 699663cf032..c077c4c3f2e 100644 --- a/src/mesh/LR20x0Interface.cpp +++ b/src/mesh/LR20x0Interface.cpp @@ -1,6 +1,6 @@ #include "configuration.h" -#if defined(USE_LR2021) && RADIOLIB_EXCLUDE_LR2021 != 1 +#if RADIOLIB_EXCLUDE_LR2021 != 1 #include "LR20x0Interface.h" #include "error.h" #include "mesh/NodeDB.h" @@ -80,7 +80,10 @@ template bool LR20x0Interface::init() RadioLibInterface::init(); -#ifdef LR2021_IRQ_DIO_NUM +#if ARCH_PORTDUINO + lora.irqDioNum = portduino_config.lr2021_irq_dio_num; + LOG_DEBUG("Set irqDioNum %d", lora.irqDioNum); +#elif defined(LR2021_IRQ_DIO_NUM) lora.irqDioNum = LR2021_IRQ_DIO_NUM; LOG_DEBUG("Set irqDioNum %d", lora.irqDioNum); #elif defined(IRQ_DIO_NUM) diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index f4f25f80c9b..98ac0422211 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -279,6 +279,8 @@ std::unique_ptr initLoRa() return std::unique_ptr(new LR1120Interface(hal, cs, irq, rst, busy)); case use_lr1121: return std::unique_ptr(new LR1121Interface(hal, cs, irq, rst, busy)); + case use_lr2021: + return std::unique_ptr(new LR2021Interface(hal, cs, irq, rst, busy)); case use_llcc68: return std::unique_ptr(new LLCC68Interface(hal, cs, irq, rst, busy)); case use_simradio: diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp index 59d9f75260b..1618afd0517 100644 --- a/src/platform/portduino/PortduinoGlue.cpp +++ b/src/platform/portduino/PortduinoGlue.cpp @@ -799,9 +799,14 @@ bool loadConfig(const char *configPath) portduino_config.lr1110_max_power = yamlConfig["Lora"]["LR1110_MAX_POWER"].as(22); if (yamlConfig["Lora"]["LR1120_MAX_POWER"]) portduino_config.lr1120_max_power = yamlConfig["Lora"]["LR1120_MAX_POWER"].as(13); + if (yamlConfig["Lora"]["LR2021_MAX_POWER"]) + portduino_config.lr2021_max_power = yamlConfig["Lora"]["LR2021_MAX_POWER"].as(22); + if (yamlConfig["Lora"]["LR2021_MAX_POWER_HF"]) + portduino_config.lr2021_max_power_hf = yamlConfig["Lora"]["LR2021_MAX_POWER_HF"].as(22); + if (yamlConfig["Lora"]["LR2021_IRQ_DIO_NUM"]) + portduino_config.lr2021_irq_dio_num = yamlConfig["Lora"]["LR2021_IRQ_DIO_NUM"].as(9); if (yamlConfig["Lora"]["RF95_MAX_POWER"]) portduino_config.rf95_max_power = yamlConfig["Lora"]["RF95_MAX_POWER"].as(20); - if (yamlConfig["Lora"]["TX_GAIN_LORA"]) { YAML::Node tx_gain_node = yamlConfig["Lora"]["TX_GAIN_LORA"]; if (tx_gain_node.IsSequence() && tx_gain_node.size() != 0) { diff --git a/src/platform/portduino/PortduinoGlue.h b/src/platform/portduino/PortduinoGlue.h index b38cfca25ee..2db8b653127 100644 --- a/src/platform/portduino/PortduinoGlue.h +++ b/src/platform/portduino/PortduinoGlue.h @@ -42,6 +42,7 @@ enum lora_module_enum { use_lr1110, use_lr1120, use_lr1121, + use_lr2021, use_llcc68 }; @@ -71,7 +72,8 @@ extern struct portduino_config_struct { // Lora std::map loraModules = { {use_simradio, "sim"}, {use_autoconf, "auto"}, {use_rf95, "RF95"}, {use_sx1262, "sx1262"}, {use_sx1268, "sx1268"}, - {use_sx1280, "sx1280"}, {use_lr1110, "lr1110"}, {use_lr1120, "lr1120"}, {use_lr1121, "lr1121"}, {use_llcc68, "LLCC68"}}; + {use_sx1280, "sx1280"}, {use_lr1110, "lr1110"}, {use_lr1120, "lr1120"}, {use_lr1121, "lr1121"}, {use_lr2021, "lr2021"}, + {use_llcc68, "LLCC68"}}; std::map screen_names = {{x11, "X11"}, {fb, "FB"}, {st7789, "ST7789"}, {st7735, "ST7735"}, {st7735s, "ST7735S"}, {st7796, "ST7796"}, @@ -93,6 +95,9 @@ extern struct portduino_config_struct { int sx128x_max_power = 13; int lr1110_max_power = 22; int lr1120_max_power = 13; + int lr2021_max_power = 22; + int lr2021_max_power_hf = 22; + int lr2021_irq_dio_num = 9; int rf95_max_power = 20; bool dio2_as_rf_switch = false; int dio3_tcxo_voltage = 0; From 3281071632146ef6a108ba8ba82738a687c26a22 Mon Sep 17 00:00:00 2001 From: jessm33 Date: Wed, 27 May 2026 18:16:17 -0400 Subject: [PATCH 02/12] add config for usb lr2021 --- bin/config.d/lora-usb-meshtoad2021..yaml | 26 ++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 bin/config.d/lora-usb-meshtoad2021..yaml diff --git a/bin/config.d/lora-usb-meshtoad2021..yaml b/bin/config.d/lora-usb-meshtoad2021..yaml new file mode 100644 index 00000000000..d1f07e9b79d --- /dev/null +++ b/bin/config.d/lora-usb-meshtoad2021..yaml @@ -0,0 +1,26 @@ +Meta: + name: meshtoad2021 + support: maybe + compatible: + - usb + +Lora: + Module: lr2021 + CS: 0 + IRQ: 6 + Reset: 2 + Busy: 4 + DIO3_TCXO_VOLTAGE: 1.8 + spidev: ch341 + USB_PID: 0x5512 + USB_VID: 0x1A86 + # Optional: Set the serial number for multi-radio support + # USB_Serialnum: 13374201 + +rfswitch_table: + pins: [DIO5, DIO6, DIO8] + MODE_STBY: [LOW, LOW, LOW] + MODE_RX: [LOW, LOW, LOW] + MODE_TX: [LOW, HIGH, LOW] + MODE_RX_HF: [HIGH, LOW, LOW] + MODE_TX_HF: [LOW, LOW, HIGH] From fa3227c8765c92261ee552b923c0463347d01b9b Mon Sep 17 00:00:00 2001 From: jessm33 Date: Wed, 27 May 2026 18:29:33 -0400 Subject: [PATCH 03/12] fix filename --- .../{lora-usb-meshtoad2021..yaml => lora-usb-meshtoad2021.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename bin/config.d/{lora-usb-meshtoad2021..yaml => lora-usb-meshtoad2021.yaml} (100%) diff --git a/bin/config.d/lora-usb-meshtoad2021..yaml b/bin/config.d/lora-usb-meshtoad2021.yaml similarity index 100% rename from bin/config.d/lora-usb-meshtoad2021..yaml rename to bin/config.d/lora-usb-meshtoad2021.yaml From cce6d1d419371e06c9d027886fa4120bda40976c Mon Sep 17 00:00:00 2001 From: jessm33 Date: Thu, 28 May 2026 20:13:15 -0400 Subject: [PATCH 04/12] Fix build of lr11x0 variants --- src/mesh/LR11x0Interface.cpp | 2 ++ src/mesh/LR20x0Interface.cpp | 4 ++++ .../diy/nrf52_promicro_diy_tcxo/rfswitch.h | 14 ++++++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/mesh/LR11x0Interface.cpp b/src/mesh/LR11x0Interface.cpp index 4b63187e043..8f8f789b64a 100644 --- a/src/mesh/LR11x0Interface.cpp +++ b/src/mesh/LR11x0Interface.cpp @@ -6,6 +6,8 @@ #include "mesh/NodeDB.h" #ifdef LR11X0_DIO_AS_RF_SWITCH #include "rfswitch.h" +#define lr11x0_rfswitch_dio_pins rfswitch_dio_pins +#define lr11x0_rfswitch_table rfswitch_table #elif ARCH_PORTDUINO #include "PortduinoGlue.h" #define lr11x0_rfswitch_dio_pins portduino_config.rfswitch_dio_pins diff --git a/src/mesh/LR20x0Interface.cpp b/src/mesh/LR20x0Interface.cpp index c077c4c3f2e..c904af35edf 100644 --- a/src/mesh/LR20x0Interface.cpp +++ b/src/mesh/LR20x0Interface.cpp @@ -12,6 +12,10 @@ #ifdef LR2021_DIO_AS_RF_SWITCH #include "rfswitch.h" +#ifndef LR20X0_RFSWITCH_NATIVE +#define lr20x0_rfswitch_dio_pins rfswitch_dio_pins +#define lr20x0_rfswitch_table rfswitch_table +#endif #elif ARCH_PORTDUINO #include "PortduinoGlue.h" #define lr20x0_rfswitch_dio_pins portduino_config.rfswitch_dio_pins diff --git a/variants/nrf52840/diy/nrf52_promicro_diy_tcxo/rfswitch.h b/variants/nrf52840/diy/nrf52_promicro_diy_tcxo/rfswitch.h index 714c58c241f..5f2dfff6286 100644 --- a/variants/nrf52840/diy/nrf52_promicro_diy_tcxo/rfswitch.h +++ b/variants/nrf52840/diy/nrf52_promicro_diy_tcxo/rfswitch.h @@ -1,4 +1,3 @@ -#pragma once #include "RadioLib.h" // Keep LR20x0 naming while RadioLib exposes LR2021 symbols. @@ -6,6 +5,10 @@ #define LR20x0 LR2021 #endif + + +#ifndef RFSWITCH_NRF52TCXO_LR11X0_DEFINED +#define RFSWITCH_NRF52TCXO_LR11X0_DEFINED // This is rewritten to match the requirements of the E80-900M2213S // The E80 does not conform to the reference Semtech switches(!) and therefore needs a custom matrix. // See footnote #3 in "https://www.cdebyte.com/products/E80-900M2213S/2#Pin" @@ -30,13 +33,19 @@ static const Module::RfSwitchMode_t rfswitch_table[] = { END_OF_MODE_TABLE, // clang-format on }; +#endif // LR2021 RF switch matrix following the standard Semtech / Seeed T1000-E reference topology. // DIO5 -> antenna path select (HIGH = sub-GHz LF) // DIO6 -> TX enable / HP PA select // DIO7 -> not connected (no GNSS on LR2021) // DIO8 -> RF front-end power enable - +// +// LR20X0_RFSWITCH_NATIVE tells LR20x0Interface.cpp that lr20x0_rfswitch_* are defined here +// directly, so it should not alias rfswitch_dio_pins (which points to the LR11x0 table above). +#ifndef RFSWITCH_NRF52TCXO_LR20X0_DEFINED +#define RFSWITCH_NRF52TCXO_LR20X0_DEFINED +#define LR20X0_RFSWITCH_NATIVE static const uint32_t lr20x0_rfswitch_dio_pins[] = {RADIOLIB_LR2021_DIO5, RADIOLIB_LR2021_DIO6, RADIOLIB_LR2021_DIO7, RADIOLIB_LR2021_DIO8, RADIOLIB_NC}; @@ -51,3 +60,4 @@ static const Module::RfSwitchMode_t lr20x0_rfswitch_table[] = { END_OF_MODE_TABLE, // clang-format on }; +#endif From 038b8e02e42006839e4f9eda8079e3d601e4cfc2 Mon Sep 17 00:00:00 2001 From: jessm33 Date: Thu, 28 May 2026 20:16:32 -0400 Subject: [PATCH 05/12] Speel good --- bin/config.d/lora-lyra-ultra-LoRa2021F33.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/config.d/lora-lyra-ultra-LoRa2021F33.yaml b/bin/config.d/lora-lyra-ultra-LoRa2021F33.yaml index 3b078e95689..8066f3645c7 100644 --- a/bin/config.d/lora-lyra-ultra-LoRa2021F33.yaml +++ b/bin/config.d/lora-lyra-ultra-LoRa2021F33.yaml @@ -8,7 +8,7 @@ # Enable overlay 'luckfox-lyra-ultra-w-spi0-cs0-spidev' with armbian-config Meta: - name: Luackfox Ultr NiceRF LoRa2021F33 + name: Luackfox Ultra NiceRF LoRa2021F33 support: community compatible: - luckfox-pico-ultra # Armbian From b2cbee8f29493fc0926a0b6aba2d49dd5f055adf Mon Sep 17 00:00:00 2001 From: jessm33 Date: Tue, 2 Jun 2026 12:12:32 -0400 Subject: [PATCH 06/12] config file updates --- bin/config.d/lora-lyra-ultra-LoRa2021F33.yaml | 3 ++- bin/config.d/lora-usb-meshtoad2021.yaml | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/config.d/lora-lyra-ultra-LoRa2021F33.yaml b/bin/config.d/lora-lyra-ultra-LoRa2021F33.yaml index 8066f3645c7..41ae13f305c 100644 --- a/bin/config.d/lora-lyra-ultra-LoRa2021F33.yaml +++ b/bin/config.d/lora-lyra-ultra-LoRa2021F33.yaml @@ -8,7 +8,7 @@ # Enable overlay 'luckfox-lyra-ultra-w-spi0-cs0-spidev' with armbian-config Meta: - name: Luackfox Ultra NiceRF LoRa2021F33 + name: Luckfox Ultra NiceRF LoRa2021F33 support: community compatible: - luckfox-pico-ultra # Armbian @@ -29,6 +29,7 @@ Lora: spidev: spidev0.0 #pins are (CS=10, CLK=8, MOSI=6, MISO=7) spiSpeed: 2000000 +# NiceRF LoRa2021F33 module rfswitch_table: pins: [DIO5, DIO6, DIO8] MODE_STBY: [LOW, LOW, LOW] diff --git a/bin/config.d/lora-usb-meshtoad2021.yaml b/bin/config.d/lora-usb-meshtoad2021.yaml index d1f07e9b79d..89292bc51de 100644 --- a/bin/config.d/lora-usb-meshtoad2021.yaml +++ b/bin/config.d/lora-usb-meshtoad2021.yaml @@ -17,6 +17,7 @@ Lora: # Optional: Set the serial number for multi-radio support # USB_Serialnum: 13374201 +# NiceRF LoRa2021F33 module rfswitch_table: pins: [DIO5, DIO6, DIO8] MODE_STBY: [LOW, LOW, LOW] From ad43637f0a966e6cc6342be31155ed42e0e6333f Mon Sep 17 00:00:00 2001 From: jessm33 Date: Wed, 3 Jun 2026 13:43:25 -0400 Subject: [PATCH 07/12] fix: format rfswitch_table in LoRa configuration files for consistency --- bin/config.d/lora-lyra-ultra-LoRa2021F33.yaml | 16 ++++++++-------- bin/config.d/lora-usb-meshtoad2021.yaml | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/bin/config.d/lora-lyra-ultra-LoRa2021F33.yaml b/bin/config.d/lora-lyra-ultra-LoRa2021F33.yaml index 41ae13f305c..8649ba1b722 100644 --- a/bin/config.d/lora-lyra-ultra-LoRa2021F33.yaml +++ b/bin/config.d/lora-lyra-ultra-LoRa2021F33.yaml @@ -29,11 +29,11 @@ Lora: spidev: spidev0.0 #pins are (CS=10, CLK=8, MOSI=6, MISO=7) spiSpeed: 2000000 -# NiceRF LoRa2021F33 module -rfswitch_table: - pins: [DIO5, DIO6, DIO8] - MODE_STBY: [LOW, LOW, LOW] - MODE_RX: [LOW, LOW, LOW] - MODE_TX: [LOW, HIGH, LOW] - MODE_RX_HF: [HIGH, LOW, LOW] - MODE_TX_HF: [LOW, LOW, HIGH] + # NiceRF LoRa2021F33 module + rfswitch_table: + pins: [DIO5, DIO6, DIO8] + MODE_STBY: [LOW, LOW, LOW] + MODE_RX: [LOW, LOW, LOW] + MODE_TX: [LOW, HIGH, LOW] + MODE_RX_HF: [HIGH, LOW, LOW] + MODE_TX_HF: [LOW, LOW, HIGH] diff --git a/bin/config.d/lora-usb-meshtoad2021.yaml b/bin/config.d/lora-usb-meshtoad2021.yaml index 89292bc51de..83f75aaeef9 100644 --- a/bin/config.d/lora-usb-meshtoad2021.yaml +++ b/bin/config.d/lora-usb-meshtoad2021.yaml @@ -17,11 +17,11 @@ Lora: # Optional: Set the serial number for multi-radio support # USB_Serialnum: 13374201 -# NiceRF LoRa2021F33 module -rfswitch_table: - pins: [DIO5, DIO6, DIO8] - MODE_STBY: [LOW, LOW, LOW] - MODE_RX: [LOW, LOW, LOW] - MODE_TX: [LOW, HIGH, LOW] - MODE_RX_HF: [HIGH, LOW, LOW] - MODE_TX_HF: [LOW, LOW, HIGH] + # NiceRF LoRa2021F33 module + rfswitch_table: + pins: [DIO5, DIO6, DIO8] + MODE_STBY: [LOW, LOW, LOW] + MODE_RX: [LOW, LOW, LOW] + MODE_TX: [LOW, HIGH, LOW] + MODE_RX_HF: [HIGH, LOW, LOW] + MODE_TX_HF: [LOW, LOW, HIGH] From 0aacaf910d14d30576f6b00bb2348199bfb92403 Mon Sep 17 00:00:00 2001 From: jessm33 Date: Tue, 23 Jun 2026 14:27:05 -0400 Subject: [PATCH 08/12] rename meshtoad config file to be clear on what module is on the hardware --- ...ad2021.yaml => lora-usb-meshtoad-nicerflora2021f33.yaml} | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) rename bin/config.d/{lora-usb-meshtoad2021.yaml => lora-usb-meshtoad-nicerflora2021f33.yaml} (75%) diff --git a/bin/config.d/lora-usb-meshtoad2021.yaml b/bin/config.d/lora-usb-meshtoad-nicerflora2021f33.yaml similarity index 75% rename from bin/config.d/lora-usb-meshtoad2021.yaml rename to bin/config.d/lora-usb-meshtoad-nicerflora2021f33.yaml index 83f75aaeef9..b05843e0cf5 100644 --- a/bin/config.d/lora-usb-meshtoad2021.yaml +++ b/bin/config.d/lora-usb-meshtoad-nicerflora2021f33.yaml @@ -1,6 +1,6 @@ Meta: name: meshtoad2021 - support: maybe + support: community compatible: - usb @@ -11,6 +11,10 @@ Lora: Reset: 2 Busy: 4 DIO3_TCXO_VOLTAGE: 1.8 + # Defaults for LR2021, but can be overridden by user config + # LR2021_MAX_POWER: 22 + # LR2021_MAX_POWER_HF: 22 + # LR2021_IRQ_DIO_NUM: 9 spidev: ch341 USB_PID: 0x5512 USB_VID: 0x1A86 From 95f3ad98538255a77ba00de5fac1a2c3344dcd1d Mon Sep 17 00:00:00 2001 From: jessm33 Date: Tue, 23 Jun 2026 14:30:17 -0400 Subject: [PATCH 09/12] remove config for test hardware --- bin/config.d/lora-lyra-ultra-LoRa2021F33.yaml | 39 ------------------- 1 file changed, 39 deletions(-) delete mode 100644 bin/config.d/lora-lyra-ultra-LoRa2021F33.yaml diff --git a/bin/config.d/lora-lyra-ultra-LoRa2021F33.yaml b/bin/config.d/lora-lyra-ultra-LoRa2021F33.yaml deleted file mode 100644 index 8649ba1b722..00000000000 --- a/bin/config.d/lora-lyra-ultra-LoRa2021F33.yaml +++ /dev/null @@ -1,39 +0,0 @@ -# For the NiceRF LoRa2021F33 module, on the LuckFox Ultra boards. -# Pin assignment is based on wehooper4's Luckfox Ultra Hats -# -# Ubuntu use luckfox-config to configure spi0 as: -# CS=10, CLK=8, MOSI=6, MISO=7 Max spi speed: 2000000 -# -# For use with Armbian luckfox-lyra-ultra-w -# Enable overlay 'luckfox-lyra-ultra-w-spi0-cs0-spidev' with armbian-config - -Meta: - name: Luckfox Ultra NiceRF LoRa2021F33 - support: community - compatible: - - luckfox-pico-ultra # Armbian - - luckfox-lyra-ultra # Armbian - -Lora: - Module: lr2021 - DIO3_TCXO_VOLTAGE: 1.8 - # Defaults for LR2021, but can be overridden by user config - # LR2021_MAX_POWER: 22 - # LR2021_MAX_POWER_HF: 22 - # LR2021_IRQ_DIO_NUM: 9 - CS: 10 - IRQ: 5 - Busy: 11 - Reset: 9 - - spidev: spidev0.0 #pins are (CS=10, CLK=8, MOSI=6, MISO=7) - spiSpeed: 2000000 - - # NiceRF LoRa2021F33 module - rfswitch_table: - pins: [DIO5, DIO6, DIO8] - MODE_STBY: [LOW, LOW, LOW] - MODE_RX: [LOW, LOW, LOW] - MODE_TX: [LOW, HIGH, LOW] - MODE_RX_HF: [HIGH, LOW, LOW] - MODE_TX_HF: [LOW, LOW, HIGH] From fac2969937a671dcc5a75d34fa6067c18dd28556 Mon Sep 17 00:00:00 2001 From: jessm33 Date: Wed, 1 Jul 2026 13:22:38 -0400 Subject: [PATCH 10/12] format files --- src/mesh/LR11x0Interface.cpp | 4 ++-- src/mesh/LR20x0Interface.cpp | 4 ++-- src/mesh/RadioInterface.cpp | 4 ++-- src/platform/portduino/PortduinoGlue.cpp | 6 +++--- src/platform/portduino/PortduinoGlue.h | 8 ++++---- variants/nrf52840/diy/nrf52_promicro_diy_tcxo/rfswitch.h | 2 -- 6 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/mesh/LR11x0Interface.cpp b/src/mesh/LR11x0Interface.cpp index af80969a581..abeac57f1ed 100644 --- a/src/mesh/LR11x0Interface.cpp +++ b/src/mesh/LR11x0Interface.cpp @@ -207,7 +207,7 @@ template bool LR11x0Interface::reconfigure() err = lora.setOutputPower(power); assert(err == RADIOLIB_ERR_NONE); - // Apply RX gain mode — valid in STDBY, matches resetAGC() pattern + // Apply RX gain mode - valid in STDBY, matches resetAGC() pattern err = lora.setRxBoostedGainMode(config.lora.sx126x_rx_boosted_gain); if (err != RADIOLIB_ERR_NONE) LOG_WARN("LR11x0 setRxBoostedGainMode %s%d", radioLibErr, err); @@ -328,7 +328,7 @@ template void LR11x0Interface::resetAGC() LOG_DEBUG("LR11x0 AGC reset: warm sleep + Calibrate(0x3F)"); - // 1. Warm sleep — powers down the analog frontend, resetting AGC state + // 1. Warm sleep - powers down the analog frontend, resetting AGC state lora.sleep(true, 0); // 2. Wake to RC standby for stable calibration diff --git a/src/mesh/LR20x0Interface.cpp b/src/mesh/LR20x0Interface.cpp index a07a3cf8a9a..30d69c7f217 100644 --- a/src/mesh/LR20x0Interface.cpp +++ b/src/mesh/LR20x0Interface.cpp @@ -218,7 +218,7 @@ template bool LR20x0Interface::reconfigure() err = lora.setOutputPower(power); assert(err == RADIOLIB_ERR_NONE); - // Apply RX gain mode — valid in STDBY, matches resetAGC() pattern + // Apply RX gain mode - valid in STDBY, matches resetAGC() pattern err = lora.setRxBoostedGainMode(config.lora.sx126x_rx_boosted_gain); if (err != RADIOLIB_ERR_NONE) LOG_WARN("LR20x0 setRxBoostedGainMode %s%d", radioLibErr, err); @@ -339,7 +339,7 @@ template void LR20x0Interface::resetAGC() LOG_DEBUG("LR20x0 AGC reset: warm sleep + Calibrate(0x3F)"); - // 1. Warm sleep — powers down the analog frontend, resetting AGC state + // 1. Warm sleep - powers down the analog frontend, resetting AGC state lora.sleep(true, 0); // 2. Wake to RC standby for stable calibration diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index 38ebcff5202..abff762cd8d 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -174,7 +174,7 @@ const RegionInfo regions[] = { /* https://lora-alliance.org/wp-content/uploads/2020/11/lorawan_regional_parameters_v1.0.3reva_0.pdf https://standard.nbtc.go.th/getattachment/Standards/%E0%B8%A1%E0%B8%B2%E0%B8%95%E0%B8%A3%E0%B8%90%E0%B8%B2%E0%B8%99%E0%B8%97%E0%B8%B2%E0%B8%87%E0%B9%80%E0%B8%97%E0%B8%84%E0%B8%99%E0%B8%B4%E0%B8%84%E0%B8%82%E0%B8%AD%E0%B8%87%E0%B9%80%E0%B8%84%E0%B8%A3%E0%B8%B7%E0%B9%88%E0%B8%AD%E0%B8%87%E0%B9%82%E0%B8%97%E0%B8%A3%E0%B8%84%E0%B8%A1%E0%B8%99%E0%B8%B2%E0%B8%84%E0%B8%A1/1033-2565.pdf.aspx?lang=th-TH - Thailand 920–925 MHz set max TX power to 27 dBm and enforce 10% duty cycle, aligned with NBTC regulations. + Thailand 920-925 MHz set max TX power to 27 dBm and enforce 10% duty cycle, aligned with NBTC regulations. */ RDEF(TH, 920.0f, 925.0f, 10, 27, false, false, PROFILE_STD, PRESET(LONG_FAST), 0), @@ -246,7 +246,7 @@ const RegionInfo regions[] = { /* ITU Region 1 (Europe, Africa, Middle East, former USSR) amateur 2m allocation: 144.000 - 146.000 MHz. - Power limit is the regulatory ceiling (1 W / 30 dBm) — individual hardware will cap below this + Power limit is the regulatory ceiling (1 W / 30 dBm) - individual hardware will cap below this via its own PA curve; the field here is just the legal upper bound. Default slot: 26 (144.510 MHz) diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp index 1e1474683b3..afc2c0e09de 100644 --- a/src/platform/portduino/PortduinoGlue.cpp +++ b/src/platform/portduino/PortduinoGlue.cpp @@ -174,7 +174,7 @@ void getMacAddr(uint8_t *dmac) // the same kind of stable, host-derived identifier that the BlueZ // path provides on Linux. If en0 isn't found or has no MAC, dmac is // left untouched and the caller's "Blank MAC Address not allowed!" - // check will still fire — preserving existing behavior for users + // check will still fire - preserving existing behavior for users // who deliberately rely on --hwid or YAML override. struct ifaddrs *ifap = nullptr; if (getifaddrs(&ifap) == 0) { @@ -548,7 +548,7 @@ void portduinoSetup() // Pass the full buffer size (9 = 8 chars + null) to getSerialString, // not 8. The function treats `len` as buffer size and reserves one // slot for the null terminator, so passing 8 produced a 7-char serial - // and broke the `strlen(serial) == 8` check below — masked on Linux + // and broke the `strlen(serial) == 8` check below - masked on Linux // by the BlueZ HCI MAC fallback in getMacAddr(), but on macOS (where // the BlueZ path is __linux__-guarded) it left mac_address empty and // meshtasticd refused to start. @@ -1175,7 +1175,7 @@ bool MAC_from_string(std::string mac_str, uint8_t *dmac) std::string exec(const char *cmd) { // https://stackoverflow.com/a/478960 #ifdef ARCH_PORTDUINO_WASM - (void)cmd; // no shell/popen in the browser — shell-outs degrade to empty + (void)cmd; // no shell/popen in the browser - shell-outs degrade to empty return ""; #endif std::array buffer; diff --git a/src/platform/portduino/PortduinoGlue.h b/src/platform/portduino/PortduinoGlue.h index eede9b6bc76..38a0d620ad5 100644 --- a/src/platform/portduino/PortduinoGlue.h +++ b/src/platform/portduino/PortduinoGlue.h @@ -77,10 +77,10 @@ std::string exec(const char *cmd); extern struct portduino_config_struct { // Lora - std::map loraModules = { - {use_simradio, "sim"}, {use_autoconf, "auto"}, {use_rf95, "RF95"}, {use_sx1262, "sx1262"}, {use_sx1268, "sx1268"}, - {use_sx1280, "sx1280"}, {use_lr1110, "lr1110"}, {use_lr1120, "lr1120"}, {use_lr1121, "lr1121"}, {use_lr2021, "lr2021"}, - {use_llcc68, "LLCC68"}}; + std::map loraModules = {{use_simradio, "sim"}, {use_autoconf, "auto"}, {use_rf95, "RF95"}, + {use_sx1262, "sx1262"}, {use_sx1268, "sx1268"}, {use_sx1280, "sx1280"}, + {use_lr1110, "lr1110"}, {use_lr1120, "lr1120"}, {use_lr1121, "lr1121"}, + {use_lr2021, "lr2021"}, {use_llcc68, "LLCC68"}}; std::map screen_names = {{x11, "X11"}, {fb, "FB"}, {st7789, "ST7789"}, {st7735, "ST7735"}, {st7735s, "ST7735S"}, {st7796, "ST7796"}, diff --git a/variants/nrf52840/diy/nrf52_promicro_diy_tcxo/rfswitch.h b/variants/nrf52840/diy/nrf52_promicro_diy_tcxo/rfswitch.h index 5f2dfff6286..d105e0fef91 100644 --- a/variants/nrf52840/diy/nrf52_promicro_diy_tcxo/rfswitch.h +++ b/variants/nrf52840/diy/nrf52_promicro_diy_tcxo/rfswitch.h @@ -5,8 +5,6 @@ #define LR20x0 LR2021 #endif - - #ifndef RFSWITCH_NRF52TCXO_LR11X0_DEFINED #define RFSWITCH_NRF52TCXO_LR11X0_DEFINED // This is rewritten to match the requirements of the E80-900M2213S From ead1ba4862c87ec6b8474724d3cabfde51beb4bc Mon Sep 17 00:00:00 2001 From: jessm33 Date: Wed, 1 Jul 2026 15:33:33 -0400 Subject: [PATCH 11/12] adreess coderabbit issues --- src/platform/portduino/PortduinoGlue.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp index afc2c0e09de..cea55bce231 100644 --- a/src/platform/portduino/PortduinoGlue.cpp +++ b/src/platform/portduino/PortduinoGlue.cpp @@ -933,6 +933,8 @@ bool loadConfig(const char *configPath) portduino_config.rfswitch_table[2].values[i] = HIGH; if (yamlConfig["Lora"]["rfswitch_table"]["MODE_TX_HP"][i].as("") == "HIGH") portduino_config.rfswitch_table[3].values[i] = HIGH; + if (yamlConfig["Lora"]["rfswitch_table"]["MODE_RX_HF"][i].as("") == "HIGH") + portduino_config.rfswitch_table[3].values[i] = HIGH; if (yamlConfig["Lora"]["rfswitch_table"]["MODE_TX_HF"][i].as("") == "HIGH") portduino_config.rfswitch_table[4].values[i] = HIGH; if (yamlConfig["Lora"]["rfswitch_table"]["MODE_GNSS"][i].as("") == "HIGH") From 068a557c7741a031229be1dcf7629916cb22c2b4 Mon Sep 17 00:00:00 2001 From: jessm33 Date: Sun, 26 Jul 2026 22:23:26 -0400 Subject: [PATCH 12/12] fix(portduino): resolve enum value conflict for LR2021 and LR11x0 modes --- src/platform/portduino/PortduinoGlue.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/platform/portduino/PortduinoGlue.h b/src/platform/portduino/PortduinoGlue.h index 627d565affc..7baa00575ed 100644 --- a/src/platform/portduino/PortduinoGlue.h +++ b/src/platform/portduino/PortduinoGlue.h @@ -355,7 +355,8 @@ extern struct portduino_config_struct { out << YAML::Key << "MODE_TX"; break; case 3: - out << YAML::Key << "MODE_TX_HP"; + // LR2021::MODE_RX_HF and LR11x0::MODE_TX_HP share the same enum value; pick the chip's name + out << YAML::Key << (lora_module == use_lr2021 ? "MODE_RX_HF" : "MODE_TX_HP"); break; case 4: out << YAML::Key << "MODE_TX_HF";