diff --git a/arch/stm32/stm32.ini b/arch/stm32/stm32.ini
new file mode 100644
index 0000000000..2cea4bbc58
--- /dev/null
+++ b/arch/stm32/stm32.ini
@@ -0,0 +1,36 @@
+[stm32_base]
+extends = arduino_base
+platform = ststm32
+platform_packages = platformio/framework-arduinoststm32@https://github.com/stm32duino/Arduino_Core_STM32.git#361a7fdb67e2a7104e99b4f42a802469eef8b129
+
+build_type = release
+
+;board_build.flash_offset = 0x08000000
+
+build_flags =
+ ${arduino_base.build_flags}
+ -flto
+ -Isrc/platform/stm32wl -g
+ -DMESHTASTIC_MINIMIZE_BUILD
+ -DDEBUG_MUTE
+; -DVECT_TAB_OFFSET=0x08000000
+ -DconfigUSE_CMSIS_RTOS_V2=1
+; -DSPI_MODE_0=SPI_MODE0
+ -fmerge-all-constants
+ -ffunction-sections
+ -fdata-sections
+
+build_src_filter =
+ ${arduino_base.build_src_filter} - - - - - - - - - - - - - -
+
+board_upload.offset_address = 0x08000000
+upload_protocol = stlink
+
+lib_deps =
+ ${env.lib_deps}
+ charlesbaynham/OSFS@^1.2.3
+ https://github.com/caveman99/Crypto.git#f61ae26a53f7a2d0ba5511625b8bf8eff3a35d5e
+
+lib_ignore =
+ mathertel/OneButton
+ Wire
\ No newline at end of file
diff --git a/arch/stm32/stm32wl5e.ini b/arch/stm32/stm32wl5e.ini
deleted file mode 100644
index 4d74ade8fb..0000000000
--- a/arch/stm32/stm32wl5e.ini
+++ /dev/null
@@ -1,28 +0,0 @@
-[stm32wl5e_base]
-platform_packages = platformio/framework-arduinoststm32 @ https://github.com/stm32duino/Arduino_Core_STM32.git#6e3f9910d0122e82a6c3438507dfac3d2fd80a39
-platform = ststm32
-board = generic_wl5e
-framework = arduino
-
-build_type = debug
-
-build_flags =
- ${arduino_base.build_flags}
- -Isrc/platform/stm32wl -g
- -DconfigUSE_CMSIS_RTOS_V2=1
- -DVECT_TAB_OFFSET=0x08000000
-
-build_src_filter =
- ${arduino_base.build_src_filter} - - - - - - - - - - - - - -
-
-board_upload.offset_address = 0x08000000
-upload_protocol = stlink
-
-lib_deps =
- ${env.lib_deps}
- https://github.com/kokke/tiny-AES-c.git#f06ac37fc31dfdaca2e0d9bec83f90d5663c319b
- https://github.com/littlefs-project/littlefs.git#v2.5.1
- https://github.com/stm32duino/STM32FreeRTOS.git#10.3.1
-
-lib_ignore =
- mathertel/OneButton
\ No newline at end of file
diff --git a/boards/generic_wl5e.json b/boards/wiscore_rak3172.json
similarity index 91%
rename from boards/generic_wl5e.json
rename to boards/wiscore_rak3172.json
index 5c4bc24a75..714e09115e 100644
--- a/boards/generic_wl5e.json
+++ b/boards/wiscore_rak3172.json
@@ -1,5 +1,8 @@
{
"build": {
+ "arduino": {
+ "variant_h": "variant_RAK3172_MODULE.h"
+ },
"core": "stm32",
"cpu": "cortex-m4",
"extra_flags": "-DSTM32WLxx -DSTM32WLE5xx -DARDUINO_GENERIC_WLE5CCUX",
diff --git a/src/FSCommon.cpp b/src/FSCommon.cpp
index 7d3788c4d9..3017ec085c 100644
--- a/src/FSCommon.cpp
+++ b/src/FSCommon.cpp
@@ -24,6 +24,30 @@ SPIClass SPI1(HSPI);
#endif // HAS_SDCARD
+#if defined(ARCH_STM32WL)
+
+uint16_t OSFS::startOfEEPROM = 1;
+uint16_t OSFS::endOfEEPROM = 2048;
+
+// 3) How do I read from the medium?
+void OSFS::readNBytes(uint16_t address, unsigned int num, byte *output)
+{
+ for (uint16_t i = address; i < address + num; i++) {
+ *output = EEPROM.read(i);
+ output++;
+ }
+}
+
+// 4) How to I write to the medium?
+void OSFS::writeNBytes(uint16_t address, unsigned int num, const byte *input)
+{
+ for (uint16_t i = address; i < address + num; i++) {
+ EEPROM.update(i, *input);
+ input++;
+ }
+}
+#endif
+
/**
* @brief Copies a file from one location to another.
*
@@ -33,7 +57,33 @@ SPIClass SPI1(HSPI);
*/
bool copyFile(const char *from, const char *to)
{
-#ifdef FSCom
+#ifdef ARCH_STM32WL
+ unsigned char cbuffer[2048];
+
+ // Var to hold the result of actions
+ OSFS::result r;
+
+ r = OSFS::getFile(from, cbuffer);
+
+ if (r == notfound) {
+ LOG_ERROR("Failed to open source file %s\n", from);
+ return false;
+ } else if (r == noerr) {
+ r = OSFS::newFile(to, cbuffer, true);
+ if (r == noerr) {
+ return true;
+ } else {
+ LOG_ERROR("OSFS Error %d\n", r);
+ return false;
+ }
+
+ } else {
+ LOG_ERROR("OSFS Error %d\n", r);
+ return false;
+ }
+ return true;
+
+#elif defined(FSCom)
unsigned char cbuffer[16];
File f1 = FSCom.open(from, FILE_O_READ);
@@ -70,7 +120,13 @@ bool copyFile(const char *from, const char *to)
*/
bool renameFile(const char *pathFrom, const char *pathTo)
{
-#ifdef FSCom
+#ifdef ARCH_STM32WL
+ if (copyFile(pathFrom, pathTo) && (OSFS::deleteFile(pathFrom) == OSFS::result::NO_ERROR)) {
+ return true;
+ } else {
+ return false;
+ }
+#elif defined(FSCom)
#ifdef ARCH_ESP32
// rename was fixed for ESP32 IDF LittleFS in April
return FSCom.rename(pathFrom, pathTo);
diff --git a/src/FSCommon.h b/src/FSCommon.h
index 8fbabd9526..3d485d1b1d 100644
--- a/src/FSCommon.h
+++ b/src/FSCommon.h
@@ -15,10 +15,13 @@
#endif
#if defined(ARCH_STM32WL)
-#include "platform/stm32wl/InternalFileSystem.h" // STM32WL version
-#define FSCom InternalFS
-#define FSBegin() FSCom.begin()
-using namespace LittleFS_Namespace;
+// STM32WL series 2 Kbytes (8 rows of 256 bytes)
+#include
+#include
+
+// Useful consts
+const OSFS::result noerr = OSFS::result::NO_ERROR;
+const OSFS::result notfound = OSFS::result::FILE_NOT_FOUND;
#endif
#if defined(ARCH_RP2040)
diff --git a/src/Power.cpp b/src/Power.cpp
index 19c5c99375..138b06e719 100644
--- a/src/Power.cpp
+++ b/src/Power.cpp
@@ -200,7 +200,8 @@ class AnalogBatteryLevel : public HasBatteryLevel
}
#endif
-#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO) && !defined(HAS_PMU) && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
+#if HAS_TELEMETRY && !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !defined(HAS_PMU) && \
+ !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
if (hasINA()) {
LOG_DEBUG("Using INA on I2C addr 0x%x for device battery voltage\n", config.power.device_battery_ina_address);
return getINAVoltage();
@@ -420,7 +421,7 @@ class AnalogBatteryLevel : public HasBatteryLevel
}
#endif
-#if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && !defined(ARCH_PORTDUINO)
+#if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
uint16_t getINAVoltage()
{
if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA219].first == config.power.device_battery_ina_address) {
diff --git a/src/configuration.h b/src/configuration.h
index 6351c35b18..b298d54243 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -259,6 +259,7 @@ along with this program. If not, see .
#define MESHTASTIC_EXCLUDE_SCREEN 1
#define MESHTASTIC_EXCLUDE_MQTT 1
#define MESHTASTIC_EXCLUDE_POWERMON 1
+#define MESHTASTIC_EXCLUDE_I2C 1
#endif
// Turn off all optional modules
diff --git a/src/detect/ScanI2CTwoWire.cpp b/src/detect/ScanI2CTwoWire.cpp
index 8738e2722d..b831b0e719 100644
--- a/src/detect/ScanI2CTwoWire.cpp
+++ b/src/detect/ScanI2CTwoWire.cpp
@@ -1,7 +1,8 @@
#include "ScanI2CTwoWire.h"
+#if !MESHTASTIC_EXCLUDE_I2C
+
#include "concurrency/LockGuard.h"
-#include "configuration.h"
#if defined(ARCH_PORTDUINO)
#include "linux/LinuxHardwareI2C.h"
#endif
@@ -403,3 +404,4 @@ size_t ScanI2CTwoWire::countDevices() const
{
return foundDevices.size();
}
+#endif
\ No newline at end of file
diff --git a/src/detect/ScanI2CTwoWire.h b/src/detect/ScanI2CTwoWire.h
index 82b48f6b47..c8dd96469a 100644
--- a/src/detect/ScanI2CTwoWire.h
+++ b/src/detect/ScanI2CTwoWire.h
@@ -1,5 +1,8 @@
#pragma once
+#include "configuration.h"
+#if !MESHTASTIC_EXCLUDE_I2C
+
#include