diff --git a/platformio.ini b/platformio.ini
index 3d328fbfa..5d01c2876 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -92,7 +92,7 @@ lib_deps =
extends = arduino_base
platform = espressif32@3.5.0
build_src_filter =
- ${arduino_base.build_src_filter} - -
+ ${arduino_base.build_src_filter} - - -
upload_speed = 115200
debug_init_break = tbreak setup
@@ -144,7 +144,7 @@ build_flags =
${arduino_base.build_flags} -Wno-unused-variable
-Isrc/nrf52
build_src_filter =
- ${arduino_base.build_src_filter} - - - - - - -
+ ${arduino_base.build_src_filter} - - - - - - - -
lib_ignore =
BluetoothOTA
@@ -165,3 +165,23 @@ board = nrf52840_dk
[env:feather_nrf52832]
extends = nrf52_base
board = adafruit_feather_nrf52832
+
+; Common settings for rp2040 Processor based targets
+[rp2040_base]
+platform = https://github.com/maxgerhardt/platform-raspberrypi.git
+extends = arduino_base
+board_build.core = earlephilhower
+board_build.filesystem_size = 0.5m
+build_flags =
+ ${arduino_base.build_flags} -Wno-unused-variable
+ -Isrc/rp2040
+ -D__PLAT_RP2040__
+# -D _POSIX_THREADS
+build_src_filter =
+ ${arduino_base.build_src_filter} - - - - - - - -
+lib_ignore =
+ BluetoothOTA
+lib_deps =
+ ${arduino_base.lib_deps}
+ ${environmental_base.lib_deps}
+ https://github.com/kokke/tiny-AES-c.git
\ No newline at end of file
diff --git a/src/FSCommon.cpp b/src/FSCommon.cpp
index 76dc97757..5832a2acb 100644
--- a/src/FSCommon.cpp
+++ b/src/FSCommon.cpp
@@ -44,7 +44,7 @@ bool renameFile(const char* pathFrom, const char* pathTo)
void listDir(const char * dirname, uint8_t levels)
{
#ifdef FSCom
- File root = FSCom.open(dirname);
+ File root = FSCom.open(dirname, FILE_O_READ);
if(!root){
return;
}
@@ -71,7 +71,7 @@ void listDir(const char * dirname, uint8_t levels)
void rmDir(const char * dirname)
{
#ifdef FSCom
- File file = FSCom.open(dirname);
+ File file = FSCom.open(dirname, FILE_O_READ);
if(!file){
return;
}
diff --git a/src/FSCommon.h b/src/FSCommon.h
index 89b2ed10d..5def77ecb 100644
--- a/src/FSCommon.h
+++ b/src/FSCommon.h
@@ -13,6 +13,15 @@
#define FILE_O_READ "r"
#endif
+#if defined(ARCH_RP2040)
+// RP2040
+#include "LittleFS.h"
+#define FSCom LittleFS
+#define FSBegin() FSCom.begin()
+#define FILE_O_WRITE "w"
+#define FILE_O_READ "r"
+#endif
+
#if defined(ARCH_ESP32)
// ESP32 version
#include "LITTLEFS.h"
diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp
index 00e419b3e..f30e21d1e 100644
--- a/src/mesh/NodeDB.cpp
+++ b/src/mesh/NodeDB.cpp
@@ -297,7 +297,7 @@ bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_
#ifdef FSCom
// static DeviceState scratch; We no longer read into a tempbuf because this structure is 15KB of valuable RAM
- auto f = FSCom.open(filename);
+ auto f = FSCom.open(filename, FILE_O_READ);
if (f) {
DEBUG_MSG("Loading %s\n", filename);
diff --git a/src/nrf52/architecture.h b/src/nrf52/architecture.h
index 8a84cde8c..5ef37cc44 100644
--- a/src/nrf52/architecture.h
+++ b/src/nrf52/architecture.h
@@ -40,6 +40,8 @@
#define HW_VENDOR HardwareModel_T_ECHO
#elif defined(NORDIC_PCA10059)
#define HW_VENDOR HardwareModel_NRF52840_PCA10059
+#elif defined(PRIVATE_HW)
+ #define HW_VENDOR HardwareModel_PRIVATE_HW
#else
#define HW_VENDOR HardwareModel_NRF52_UNKNOWN
#endif
diff --git a/src/rp2040/architecture.h b/src/rp2040/architecture.h
new file mode 100644
index 000000000..35d163e4a
--- /dev/null
+++ b/src/rp2040/architecture.h
@@ -0,0 +1,7 @@
+#pragma once
+
+#define ARCH_RP2040
+
+#if defined(PRIVATE_HW)
+ #define HW_VENDOR HardwareModel_PRIVATE_HW
+#endif
\ No newline at end of file
diff --git a/src/rp2040/main-rp2040.cpp b/src/rp2040/main-rp2040.cpp
new file mode 100644
index 000000000..3f785d344
--- /dev/null
+++ b/src/rp2040/main-rp2040.cpp
@@ -0,0 +1,30 @@
+#include "configuration.h"
+#include
+#include
+
+void setBluetoothEnable(bool on)
+{
+ // not needed
+}
+
+void cpuDeepSleep(uint64_t msecs)
+{
+ // not needed
+}
+
+void updateBatteryLevel(uint8_t level)
+{
+ // not needed
+}
+
+void getMacAddr(uint8_t *dmac)
+{
+ pico_unique_board_id_t src;
+ pico_get_unique_board_id(&src);
+ dmac[5] = src.id[0];
+ dmac[4] = src.id[1];
+ dmac[3] = src.id[2];
+ dmac[2] = src.id[3];
+ dmac[1] = src.id[4];
+ dmac[0] = src.id[5];
+}
diff --git a/src/rp2040/rp2040CryptoEngine.cpp b/src/rp2040/rp2040CryptoEngine.cpp
new file mode 100644
index 000000000..bb1c00779
--- /dev/null
+++ b/src/rp2040/rp2040CryptoEngine.cpp
@@ -0,0 +1,36 @@
+#include "configuration.h"
+#include "CryptoEngine.h"
+#include "aes.hpp"
+
+class RP2040CryptoEngine : public CryptoEngine
+{
+ public:
+ RP2040CryptoEngine() {}
+
+ ~RP2040CryptoEngine() {}
+
+ /**
+ * Encrypt a packet
+ *
+ * @param bytes is updated in place
+ */
+ virtual void encrypt(uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes) override
+ {
+ if (key.length > 0) {
+ AES_ctx ctx;
+ initNonce(fromNode, packetNum);
+ AES_init_ctx_iv(&ctx, key.bytes, nonce);
+ AES_CTR_xcrypt_buffer(&ctx, bytes, numBytes);
+ }
+ }
+
+ virtual void decrypt(uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes) override
+ {
+ // For CTR, the implementation is the same
+ encrypt(fromNode, packetNum, numBytes, bytes);
+ }
+
+ private:
+};
+
+CryptoEngine *crypto = new RP2040CryptoEngine();
diff --git a/variants/pico/platformio.ini b/variants/pico/platformio.ini
new file mode 100644
index 000000000..4f238fa14
--- /dev/null
+++ b/variants/pico/platformio.ini
@@ -0,0 +1,17 @@
+[env:pico]
+extends = rp2040_base
+board = pico
+upload_protocol = picotool
+
+# add our variants files to the include and src paths
+build_flags = ${rp2040_base.build_flags}
+ -DPRIVATE_HW
+ -Ivariants/pico
+ -DARDUINO_AVR_NANO_EVERY
+ -DDEBUG_RP2040_WIRE
+ -DDEBUG_RP2040_SPI
+ -DDEBUG_RP2040_CORE
+ -DDEBUG_RP2040_PORT=Serial
+ -DUSE_TINYUSB
+lib_deps =
+ ${rp2040_base.lib_deps}
\ No newline at end of file
diff --git a/variants/pico/variant.h b/variants/pico/variant.h
new file mode 100644
index 000000000..d620a356b
--- /dev/null
+++ b/variants/pico/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
+
+#define CBC 0
+#define CTR 1
+#define ECB 0
+
+#define NO_GPS 1
+#define USE_SH1106 1
+#undef GPS_SERIAL_NUM
+
+// #define I2C_SDA 6
+// #define I2C_SCL 7
+
+#define BUTTON_PIN 17
+#define EXT_NOTIFY_OUT 4
+
+#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 USE_RF95
+#define USE_SX1262
+
+#undef RF95_SCK
+#undef RF95_MISO
+#undef RF95_MOSI
+#undef RF95_NSS
+
+#define RF95_SCK 10
+#define RF95_MISO 12
+#define RF95_MOSI 11
+#define RF95_NSS 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 RF95_NSS
+#define SX126X_DIO1 LORA_DIO1
+#define SX126X_BUSY LORA_DIO2
+#define SX126X_RESET LORA_RESET
+#define SX126X_E22
+#endif
+
+#include
\ No newline at end of file
diff --git a/variants/portduino/platformio.ini b/variants/portduino/platformio.ini
index 1a9dda202..840cbdc3b 100644
--- a/variants/portduino/platformio.ini
+++ b/variants/portduino/platformio.ini
@@ -6,6 +6,7 @@ build_src_filter =
-
-
-
+ -
-
-
-