From 9930bba3f5c65b679449cea5f8b990e7728fa4f1 Mon Sep 17 00:00:00 2001 From: Mictronics Date: Thu, 20 Feb 2025 10:56:34 +0100 Subject: [PATCH 1/3] Add Pico2W variant including Wifi support. (#6062) --- arch/rp2xx0/rp2350.ini | 5 ++- src/mesh/api/ServerAPI.cpp | 4 ++- variants/rpipico2/platformio.ini | 2 +- variants/rpipico2w/platformio.ini | 30 ++++++++++++++++++ variants/rpipico2w/variant.h | 52 +++++++++++++++++++++++++++++++ 5 files changed, 88 insertions(+), 5 deletions(-) create mode 100644 variants/rpipico2w/platformio.ini create mode 100644 variants/rpipico2w/variant.h diff --git a/arch/rp2xx0/rp2350.ini b/arch/rp2xx0/rp2350.ini index ab16e24b4..6f1e4400e 100644 --- a/arch/rp2xx0/rp2350.ini +++ b/arch/rp2xx0/rp2350.ini @@ -1,8 +1,8 @@ ; Common settings for rp2040 Processor based targets [rp2350_base] -platform = https://github.com/maxgerhardt/platform-raspberrypi.git#19e30129fb1428b823be585c787dcb4ac0d9014c ; For arduino-pico >=4.2.1 +platform = https://github.com/maxgerhardt/platform-raspberrypi.git#76ecf3c7e9dd4503af0331154c4ca1cddc4b03e5 ; For arduino-pico >= 4.4.3 extends = arduino_base -platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#6024e9a7e82a72e38dd90f42029ba3748835eb2e ; 4.3.0 with fix MDNS +platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#4.4.3 board_build.core = earlephilhower board_build.filesystem_size = 0.5m @@ -10,7 +10,6 @@ build_flags = ${arduino_base.build_flags} -Wno-unused-variable -Wcast-align -Isrc/platform/rp2xx0 -D__PLAT_RP2350__ -# -D _POSIX_THREADS build_src_filter = ${arduino_base.build_src_filter} - - - - - - - - - - - diff --git a/src/mesh/api/ServerAPI.cpp b/src/mesh/api/ServerAPI.cpp index e28e4c815..1a506421c 100644 --- a/src/mesh/api/ServerAPI.cpp +++ b/src/mesh/api/ServerAPI.cpp @@ -51,6 +51,8 @@ template int32_t APIServerPort::runOnce() #else auto client = U::available(); #endif +#elif defined(ARCH_RP2040) + auto client = U::accept(); #else auto client = U::available(); #endif @@ -78,4 +80,4 @@ template int32_t APIServerPort::runOnce() waitTime = 100; #endif return 100; // only check occasionally for incoming connections -} +} \ No newline at end of file diff --git a/variants/rpipico2/platformio.ini b/variants/rpipico2/platformio.ini index 24714efd5..de4954ea2 100644 --- a/variants/rpipico2/platformio.ini +++ b/variants/rpipico2/platformio.ini @@ -9,7 +9,7 @@ build_flags = ${rp2350_base.build_flags} -Ivariants/rpipico2 -DDEBUG_RP2040_PORT=Serial -DHW_SPI1_DEVICE - -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m0plus" + -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m33" lib_deps = ${rp2350_base.lib_deps} debug_build_flags = ${rp2350_base.build_flags}, -g diff --git a/variants/rpipico2w/platformio.ini b/variants/rpipico2w/platformio.ini new file mode 100644 index 000000000..351774221 --- /dev/null +++ b/variants/rpipico2w/platformio.ini @@ -0,0 +1,30 @@ +[env:pico2w] +extends = rp2350_base +board = rpipico2w +upload_protocol = jlink +# debug settings for external openocd with RP2040 support (custom build) +debug_tool = custom +debug_init_cmds = + target extended-remote localhost:3333 + $INIT_BREAK + monitor reset halt + $LOAD_CMDS + monitor init + monitor reset halt + +# add our variants files to the include and src paths +build_flags = ${rp2350_base.build_flags} + -DRPI_PICO2 + -Ivariants/rpipico2w +# -DDEBUG_RP2040_PORT=Serial + -DHW_SPI1_DEVICE + -DARDUINO_RASPBERRY_PI_PICO_2W + -DARDUINO_ARCH_RP2040 + -DHAS_WIFI=1 + -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m33" + -fexceptions # for exception handling in MQTT +build_src_filter = ${rp2350_base.build_src_filter} + +lib_deps = + ${rp2350_base.lib_deps} + ${networking_base.lib_deps} +debug_build_flags = ${rp2350_base.build_flags}, -g \ No newline at end of file diff --git a/variants/rpipico2w/variant.h b/variants/rpipico2w/variant.h new file mode 100644 index 000000000..c7689048a --- /dev/null +++ b/variants/rpipico2w/variant.h @@ -0,0 +1,52 @@ +// #define RADIOLIB_CUSTOM_ARDUINO 1 +// #define RADIOLIB_TONE_UNSUPPORTED 1 +// #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED 1 + +#define ARDUINO_ARCH_AVR + +#ifndef HAS_WIFI +#define HAS_WIFI 1 +#endif + +// default I2C pins: +// SDA = 4 +// SCL = 5 + +// Recommended pins for SerialModule: +// txd = 8 +// rxd = 9 + +#define EXT_NOTIFY_OUT 22 +#define BUTTON_PIN 17 + +#define BATTERY_PIN 26 +// ratio of voltage divider = 3.0 (R17=200k, R18=100k) +#define ADC_MULTIPLIER 3.1 // 3.0 + a bit for being optimistic +#define BATTERY_SENSE_RESOLUTION_BITS ADC_RESOLUTION + +#define USE_SX1262 + +#undef LORA_SCK +#undef LORA_MISO +#undef LORA_MOSI +#undef LORA_CS + +#define LORA_SCK 10 +#define LORA_MISO 12 +#define LORA_MOSI 11 +#define LORA_CS 3 + +#define LORA_DIO0 RADIOLIB_NC +#define LORA_RESET 15 +#define LORA_DIO1 20 +#define LORA_DIO2 2 +#define LORA_DIO3 RADIOLIB_NC + +#ifdef USE_SX1262 +#define SX126X_CS LORA_CS +#define SX126X_DIO1 LORA_DIO1 +#define SX126X_BUSY LORA_DIO2 +#define SX126X_RESET LORA_RESET +#define SX126X_DIO2_AS_RF_SWITCH +#define SX126X_DIO3_TCXO_VOLTAGE 1.8 +#endif \ No newline at end of file From 994e22aba9e1bee9124a1d7e265de5f0c35d09f3 Mon Sep 17 00:00:00 2001 From: rostekus <34031791+rostekus@users.noreply.github.com> Date: Thu, 20 Feb 2025 14:36:49 +0100 Subject: [PATCH 2/3] feat: added BMP-390 support to the BMP-3xx sensors (#6103) --- src/detect/ScanI2CTwoWire.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/detect/ScanI2CTwoWire.cpp b/src/detect/ScanI2CTwoWire.cpp index 880e5c131..41cfe1517 100644 --- a/src/detect/ScanI2CTwoWire.cpp +++ b/src/detect/ScanI2CTwoWire.cpp @@ -244,6 +244,10 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize) logFoundDevice("BMP-388", (uint8_t)addr.address); type = BMP_3XX; break; + case 0x60: // BMP-390 should be 0x60 + logFoundDevice("BMP-390", (uint8_t)addr.address); + type = BMP_3XX; + break; case 0x58: // BMP-280 should be 0x58 default: logFoundDevice("BMP-280", (uint8_t)addr.address); @@ -521,4 +525,4 @@ void ScanI2CTwoWire::logFoundDevice(const char *device, uint8_t address) { LOG_INFO("%s found at address 0x%x", device, address); } -#endif +#endif \ No newline at end of file From ec0eafedab6b3a49cb26c1017a59e5717cb36a31 Mon Sep 17 00:00:00 2001 From: Tom Fifield Date: Thu, 20 Feb 2025 21:48:37 +0800 Subject: [PATCH 3/3] Move variant-specific lines back to variant (#6044) Last release a change introduced different branching functions in gps.cpp based on the model of a device. This makes the code less readable and introduces the potential for bugs. This patch creates a new variable, GPS_PROBETRIES that can be set in variant.h of devices that will control how many times we will probe for GPS presence. It sets up the T1000-E to use this variable and cleans the code in gps.c --- src/gps/GPS.cpp | 16 ++++++---------- variants/tracker-t1000-e/variant.h | 1 + 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index c2aae0381..f4b07664f 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -437,6 +437,10 @@ static const int serialSpeeds[3] = {9600, 115200, 38400}; static const int rareSerialSpeeds[3] = {4800, 57600, GPS_BAUDRATE}; #endif +#ifndef GPS_PROBETRIES +#define GPS_PROBETRIES 2 +#endif + /** * @brief Setup the GPS based on the model detected. * We detect the GPS by cycling through a set of baud rates, first common then rare. @@ -460,11 +464,7 @@ bool GPS::setup() digitalWrite(PIN_GPS_EN, HIGH); delay(1000); #endif -#ifdef TRACKER_T1000_E - if (probeTries < 5) { -#else - if (probeTries < 2) { -#endif + if (probeTries < GPS_PROBETRIES) { LOG_DEBUG("Probe for GPS at %d", serialSpeeds[speedSelect]); gnssModel = probe(serialSpeeds[speedSelect]); if (gnssModel == GNSS_MODEL_UNKNOWN) { @@ -475,11 +475,7 @@ bool GPS::setup() } } // Rare Serial Speeds -#ifdef TRACKER_T1000_E - if (probeTries == 5) { -#else - if (probeTries == 2) { -#endif + if (probeTries == GPS_PROBETRIES) { LOG_DEBUG("Probe for GPS at %d", rareSerialSpeeds[speedSelect]); gnssModel = probe(rareSerialSpeeds[speedSelect]); if (gnssModel == GNSS_MODEL_UNKNOWN) { diff --git a/variants/tracker-t1000-e/variant.h b/variants/tracker-t1000-e/variant.h index e65f26c93..0d98a3033 100644 --- a/variants/tracker-t1000-e/variant.h +++ b/variants/tracker-t1000-e/variant.h @@ -111,6 +111,7 @@ extern "C" { #define GPS_TX_PIN PIN_SERIAL1_TX #define GPS_BAUDRATE 115200 +#define GPS_PROBETRIES 5 #define PIN_GPS_EN (32 + 11) // P1.11 #define GPS_EN_ACTIVE HIGH