diff --git a/.vscode/settings.json b/.vscode/settings.json
index e6f1d49e1..9b72a2a2f 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -48,7 +48,8 @@
"optional": "cpp",
"string_view": "cpp",
"cassert": "cpp",
- "iterator": "cpp"
+ "iterator": "cpp",
+ "shared_mutex": "cpp"
},
"cSpell.words": [
"Blox",
diff --git a/platformio.ini b/platformio.ini
index 80115757c..60808a56d 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -62,6 +62,7 @@ lib_deps =
https://github.com/meshtastic/TinyGPSPlus.git
https://github.com/meshtastic/AXP202X_Library.git#8404abb6d4b486748636bc6ad72d2a47baaf5460
Wire ; explicitly needed here because the AXP202 library forgets to add it
+ SPI
; Common settings for Ardino targets
[arduino_base]
@@ -70,7 +71,6 @@ framework = arduino
lib_deps =
${env.lib_deps}
- SPI
; Common settings for ESP targes, mixin with extends = esp32_base
[esp32_base]
@@ -248,7 +248,7 @@ lib_deps =
[env:linux]
platform = https://github.com/geeksville/platform-portduino.git
-src_filter = ${env.src_filter} +<../../Portduino/src> - -
-build_flags = ${env.build_flags} -I../Portduino/src -I../Portduino/cores/arduino/api
+src_filter = ${env.src_filter} - -
+build_flags = ${env.build_flags} -DRADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
framework = arduino
board = linux_x86_64
diff --git a/src/concurrency/BaseNotifiedWorkerThread.h b/src/concurrency/BaseNotifiedWorkerThread.h
new file mode 100644
index 000000000..6d5db0ba5
--- /dev/null
+++ b/src/concurrency/BaseNotifiedWorkerThread.h
@@ -0,0 +1,37 @@
+#pragma once
+
+#include "WorkerThread.h"
+
+namespace concurrency {
+
+/**
+ * @brief A worker thread that waits on a freertos notification
+ */
+class BaseNotifiedWorkerThread : public WorkerThread
+{
+ public:
+ /**
+ * Notify this thread so it can run
+ */
+ virtual void notify(uint32_t v = 0, eNotifyAction action = eNoAction) = 0;
+
+ protected:
+ /**
+ * The notification that was most recently used to wake the thread. Read from loop()
+ */
+ uint32_t notification = 0;
+
+ /**
+ * What notification bits should be cleared just after we read and return them in notification?
+ *
+ * Defaults to clear all of them.
+ */
+ uint32_t clearOnRead = UINT32_MAX;
+
+ /**
+ * A method that should block execution - either waiting ona queue/mutex or a "task notification"
+ */
+ virtual void block() = 0;
+};
+
+} // namespace concurrency
diff --git a/src/concurrency/NotifiedWorkerThread.cpp b/src/concurrency/FreeRtosNotifiedWorkerThread.cpp
similarity index 70%
rename from src/concurrency/NotifiedWorkerThread.cpp
rename to src/concurrency/FreeRtosNotifiedWorkerThread.cpp
index 7785ecf8c..8fec432dc 100644
--- a/src/concurrency/NotifiedWorkerThread.cpp
+++ b/src/concurrency/FreeRtosNotifiedWorkerThread.cpp
@@ -1,19 +1,23 @@
#include "NotifiedWorkerThread.h"
+#ifdef HAS_FREE_RTOS
+
namespace concurrency {
/**
* Notify this thread so it can run
*/
-void NotifiedWorkerThread::notify(uint32_t v, eNotifyAction action)
+void FreeRtosNotifiedWorkerThread::notify(uint32_t v, eNotifyAction action)
{
xTaskNotify(taskHandle, v, action);
}
-void NotifiedWorkerThread::block()
+void FreeRtosNotifiedWorkerThread::block()
{
xTaskNotifyWait(0, // don't clear notification on entry
clearOnRead, ¬ification, portMAX_DELAY); // Wait forever
}
} // namespace concurrency
+
+#endif
\ No newline at end of file
diff --git a/src/concurrency/FreeRtosNotifiedWorkerThread.h b/src/concurrency/FreeRtosNotifiedWorkerThread.h
new file mode 100644
index 000000000..c18009e43
--- /dev/null
+++ b/src/concurrency/FreeRtosNotifiedWorkerThread.h
@@ -0,0 +1,40 @@
+#pragma once
+
+#include "BaseNotifiedWorkerThread.h"
+
+#ifdef HAS_FREE_RTOS
+
+namespace concurrency {
+
+/**
+ * @brief A worker thread that waits on a freertos notification
+ */
+class FreeRtosNotifiedWorkerThread : public BaseNotifiedWorkerThread
+{
+ public:
+ /**
+ * Notify this thread so it can run
+ */
+ void notify(uint32_t v = 0, eNotifyAction action = eNoAction);
+
+ /**
+ * Notify from an ISR
+ *
+ * This must be inline or IRAM_ATTR on ESP32
+ */
+ inline void notifyFromISR(BaseType_t *highPriWoken, uint32_t v = 0, eNotifyAction action = eNoAction)
+ {
+ xTaskNotifyFromISR(taskHandle, v, action, highPriWoken);
+ }
+
+ protected:
+
+ /**
+ * A method that should block execution - either waiting ona queue/mutex or a "task notification"
+ */
+ virtual void block();
+};
+
+} // namespace concurrency
+
+#endif
\ No newline at end of file
diff --git a/src/concurrency/NotifiedWorkerThread.h b/src/concurrency/NotifiedWorkerThread.h
index 5ab5a58e7..dee92eb8a 100644
--- a/src/concurrency/NotifiedWorkerThread.h
+++ b/src/concurrency/NotifiedWorkerThread.h
@@ -1,47 +1,17 @@
#pragma once
-#include "WorkerThread.h"
+#include "FreeRtosNotifiedWorkerThread.h"
+#include "PosixNotifiedWorkerThread.h"
-namespace concurrency {
-
-/**
- * @brief A worker thread that waits on a freertos notification
- */
-class NotifiedWorkerThread : public WorkerThread
+namespace concurrency
{
- public:
- /**
- * Notify this thread so it can run
- */
- void notify(uint32_t v = 0, eNotifyAction action = eNoAction);
- /**
- * Notify from an ISR
- *
- * This must be inline or IRAM_ATTR on ESP32
- */
- inline void notifyFromISR(BaseType_t *highPriWoken, uint32_t v = 0, eNotifyAction action = eNoAction)
- {
- xTaskNotifyFromISR(taskHandle, v, action, highPriWoken);
- }
+#ifdef HAS_FREE_RTOS
+typedef FreeRtosNotifiedWorkerThread NotifiedWorkerThread;
+#endif
- protected:
- /**
- * The notification that was most recently used to wake the thread. Read from loop()
- */
- uint32_t notification = 0;
-
- /**
- * What notification bits should be cleared just after we read and return them in notification?
- *
- * Defaults to clear all of them.
- */
- uint32_t clearOnRead = UINT32_MAX;
-
- /**
- * A method that should block execution - either waiting ona queue/mutex or a "task notification"
- */
- virtual void block();
-};
+#ifdef __unix__
+typedef PosixNotifiedWorkerThread NotifiedWorkerThread;
+#endif
} // namespace concurrency
diff --git a/src/concurrency/PosixNotifiedWorkerThread.h b/src/concurrency/PosixNotifiedWorkerThread.h
new file mode 100644
index 000000000..d75b74dd8
--- /dev/null
+++ b/src/concurrency/PosixNotifiedWorkerThread.h
@@ -0,0 +1,26 @@
+#pragma once
+
+#include "BaseNotifiedWorkerThread.h"
+
+namespace concurrency {
+
+/**
+ * @brief A worker thread that waits on a freertos notification
+ */
+class PosixNotifiedWorkerThread : public BaseNotifiedWorkerThread
+{
+ public:
+ /**
+ * Notify this thread so it can run
+ */
+ void notify(uint32_t v = 0, eNotifyAction action = eNoAction);
+
+ protected:
+
+ /**
+ * A method that should block execution - either waiting ona queue/mutex or a "task notification"
+ */
+ virtual void block();
+};
+
+} // namespace concurrency
diff --git a/src/configuration.h b/src/configuration.h
index d127c4781..713aa9509 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -59,7 +59,7 @@ along with this program. If not, see .
#define NO_ESP32 // Don't use ESP32 libs (mainly bluetooth)
-#elif NRF52_SERIES // All of the NRF52 targets are configured using variant.h, so this section shouldn't need to be
+#elif defined(NRF52_SERIES) // All of the NRF52 targets are configured using variant.h, so this section shouldn't need to be
// board specific
//
@@ -103,17 +103,6 @@ along with this program. If not, see .
#define GPS_TX_PIN 12
#endif
-//
-// Standard definitions for !ESP32 targets
-//
-
-#ifdef NO_ESP32
-// Nop definition for these attributes - not used on NRF52
-#define EXT_RAM_ATTR
-#define IRAM_ATTR
-#define RTC_DATA_ATTR
-#endif
-
// -----------------------------------------------------------------------------
// LoRa SPI
// -----------------------------------------------------------------------------
@@ -128,6 +117,17 @@ along with this program. If not, see .
#endif
+//
+// Standard definitions for !ESP32 targets
+//
+
+#ifdef NO_ESP32
+// Nop definition for these attributes - not used on NRF52
+#define EXT_RAM_ATTR
+#define IRAM_ATTR
+#define RTC_DATA_ATTR
+#endif
+
// -----------------------------------------------------------------------------
// OLED
// -----------------------------------------------------------------------------
diff --git a/src/freertosinc.h b/src/freertosinc.h
index 8d4465077..798cf6410 100644
--- a/src/freertosinc.h
+++ b/src/freertosinc.h
@@ -37,5 +37,13 @@ typedef uint32_t BaseType_t;
#define portMAX_DELAY UINT32_MAX
#define tskIDLE_PRIORITY 0
+#define configMAX_PRIORITIES 10 // Highest priority level
+
+// Don't do anything on non free rtos platforms when done with the ISR
+#define portYIELD_FROM_ISR(x)
+
+enum eNotifyAction {
+ eNoAction
+};
#endif
diff --git a/src/main.cpp b/src/main.cpp
index 53780f6fb..49ade89f4 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -223,7 +223,7 @@ void setup()
// Init our SPI controller (must be before screen and lora)
initSPI();
-#ifdef NRF52_SERIES
+#ifdef NO_ESP32
SPI.begin();
#else
// ESP32
diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp
index 93d0787d3..e162c55ec 100644
--- a/src/mesh/NodeDB.cpp
+++ b/src/mesh/NodeDB.cpp
@@ -32,7 +32,14 @@ DeviceState versions used to be defined in the .proto file but really only this
#define DEVICESTATE_CUR_VER 11
#define DEVICESTATE_MIN_VER DEVICESTATE_CUR_VER
-#ifndef NO_ESP32
+#ifdef PORTDUINO
+// Portduino version
+#include "PortduinoFS.h"
+#define FS PortduinoFS
+#define FSBegin() FS.begin(true)
+#define FILE_O_WRITE "w"
+#define FILE_O_READ "r"
+#elif !defined(NO_ESP32)
// ESP32 version
#include "SPIFFS.h"
#define FS SPIFFS