Skip to content

Commit 7dbb114

Browse files
committed
[STM32WL55] micro-SD card use case
1 parent 1ecae13 commit 7dbb114

File tree

6 files changed

+128
-7
lines changed

6 files changed

+128
-7
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ Academy|[Nanjing Qinheng Microelectronics](https://www.wch-ic.com/)<br>[CH32V307
136136
1&nbsp;[**Standalone**](https://github.com/lyusupov/SoftRF/wiki/Standalone-Edition)&nbsp;**upgrade**![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/new-icon.jpg)<br>2&nbsp;[**Lyra**](https://github.com/lyusupov/SoftRF/wiki/Lyra-Edition)&nbsp;![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/new-icon.jpg)|[Rockchip](https://en.wikipedia.org/wiki/Rockchip)<br>RK3506|Q3 2025|![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/icon_may_need_imp.png)|
137137
**Academy**|[Espressif<br>ESP32-P4](https://en.wikipedia.org/wiki/ESP32#ESP32-P4)|Q3 2025|![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/icon_may_need_imp.png)|
138138
**Academy**|[Espressif<br>ESP32-C5](https://en.wikipedia.org/wiki/ESP32#ESP32-C5)|Q3 2025|![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/icon_may_need_imp.png)|
139+
**Labubu**|[STMicroelectronics](https://en.wikipedia.org/wiki/STMicroelectronics)<br>[STM32**WL55**](https://www.st.com/en/microcontrollers-microprocessors/stm32wl55cc.html)|Q4 2025|![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/icon_in_progress.png)|
139140

140141
## By sub-1 GHz radio
141142
Radio|Model(s)|First appearance|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Status&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|Notes

software/firmware/source/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ You will need to have an ST-LINK/V2 USB adapter connected in order to put the fi
221221
1. Follow [these official instructions](https://github.com/stm32duino/wiki/wiki/Getting-Started)
222222
to install Arduino IDE and **certain version** of Arduino STM32 Core -<!-- [latest **stable** Arduino STM32 Core](https://github.com/stm32duino/Arduino_Core_STM32/releases/tag/1.9.0) (1.9.0) --><br>
223223
For **S76G**:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[**1.9.0**](https://github.com/stm32duino/Arduino_Core_STM32/releases/tag/1.9.0)<br>
224-
For **STM32WLE5**:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[**2.4.0**](https://github.com/stm32duino/Arduino_Core_STM32/releases/tag/2.4.0)<br>
224+
For **STM32WLE5**:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[**2.4.0**](https://github.com/stm32duino/Arduino_Core_STM32/releases/tag/2.4.0)<br>
225+
For **STM32WL55**:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[**2.4.0**](https://github.com/stm32duino/Arduino_Core_STM32/releases/tag/2.4.0)<br>
225226
For **STM32F103C8** "Blue Pill":&nbsp;&nbsp;&nbsp;[**2.4.0**](https://github.com/stm32duino/Arduino_Core_STM32/releases/tag/2.4.0)<br>
226227
2. open ``<My Documents>`` (Windows) , ``<Home>`` (Linux) or ``<Documents>`` (MacOS) directory
227228
3. create **Arduino** sub-directory
@@ -242,6 +243,10 @@ You will need to have an ST-LINK/V2 USB adapter connected in order to put the fi
242243
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Select _Tools_ -> _Board_ -> _Generic_ _STM32WL_ _series_<br>
243244
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Select _Tools_ -> _Board_ _part_ _number_ -> _Generic_ _WLE5CCUx_<br>
244245
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Select _Tools_ -> _U(S)ART_ _support_ -> _Enabled_ _(generic_ _'Serial')_<br>
246+
For **STM32WL55**:<br>
247+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Select _Tools_ -> _Board_ -> _Generic_ _STM32WL_ _series_<br>
248+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Select _Tools_ -> _Board_ _part_ _number_ -> _Generic_ _WL55CCUx_<br>
249+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Select _Tools_ -> _U(S)ART_ _support_ -> _Enabled_ _(generic_ _'Serial')_<br>
245250
For **STM32F103C8** "Blue Pill":<br>
246251
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Select _Tools_ -> _Board_ -> _Generic_ _STM32F1_ _series_<br>
247252
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Select _Tools_ -> _Board_ _part_ _number_ -> _BluePill_ _F103CB_ _(or_ _C8_ _with_ _128k)_<br>
@@ -256,6 +261,9 @@ You will need to have an ST-LINK/V2 USB adapter connected in order to put the fi
256261
For **STM32WLE5**:<br>
257262
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Select _Tools_ -> _Upload_ _method_ -> _STM32CubeProgrammer_ _(SWD)_<br>
258263
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Select _Tools_ -> _Port_ -> ``<your ST-LINK/V2 port device name>``<br>
264+
For **STM32WL55**:<br>
265+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Select _Tools_ -> _Upload_ _method_ -> _STM32CubeProgrammer_ _(Serial)_<br>
266+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Select _Tools_ -> _Port_ -> ``<your Serial port device name>``<br>
259267
For **S76G "SkyWatch"** or **STM32F103C8** "Blue Pill":<br>
260268
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Select _Tools_ -> _Upload_ _method_ -> _STM32CubeProgrammer_ _(SWD)_<br>
261269
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Select _Tools_ -> _Port_ -> ``<your ST-LINK/V2 port device name>``<br>

software/firmware/source/SoftRF/src/platform/STM32.cpp

Lines changed: 109 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "../protocol/data/NMEA.h"
3737
#include "../protocol/data/GDL90.h"
3838
#include "../protocol/data/D1090.h"
39+
#include "../protocol/data/JSON.h"
3940

4041
#if !defined(ARDUINO_WisDuo_RAK3172_Evaluation_Board)
4142
#include <STM32LowPower.h>
@@ -103,6 +104,21 @@ void HAL_SUBGHZ_MspInit(SUBGHZ_HandleTypeDef * hsubghz)
103104
}
104105
#endif /* HAL_SUBGHZ_MODULE_ENABLED */
105106

107+
#if defined(ARDUINO_GENERIC_WL55CCUX)
108+
#include <SdFat_Adafruit_Fork.h>
109+
110+
#define SD_CONFIG SdSpiConfig(uSD_SS_pin, SHARED_SPI, SD_SCK_MHZ(8), &SPI)
111+
112+
SdFat uSD;
113+
114+
static bool uSD_is_attached = false;
115+
static bool FATFS_is_mounted = false;
116+
117+
#define STM32_JSON_BUFFER_SIZE 1024
118+
119+
StaticJsonBuffer<STM32_JSON_BUFFER_SIZE> STM32_jsonBuffer;
120+
#endif /* ARDUINO_GENERIC_WL55CCUX */
121+
106122
#elif defined(ARDUINO_WisDuo_RAK3172_Evaluation_Board)
107123

108124
char *dtostrf_workaround(double number, signed char width, unsigned char prec, char *s) {
@@ -392,6 +408,26 @@ static void STM32_setup()
392408
stm32_board = STM32_LILYGO_T3_1_0;
393409
hw_info.model = SOFTRF_MODEL_LABUBU;
394410

411+
{
412+
int uSD_SS_pin = SOC_GPIO_PIN_SD_SS;
413+
414+
/* micro-SD SPI is shared with OLED SPI */
415+
SPI.setMISO(SOC_GPIO_PIN_MISO);
416+
SPI.setMOSI(SOC_GPIO_PIN_MOSI);
417+
SPI.setSCLK(SOC_GPIO_PIN_SCK);
418+
419+
digitalWrite(uSD_SS_pin, HIGH);
420+
pinMode(uSD_SS_pin, OUTPUT);
421+
422+
uSD_is_attached = uSD.cardBegin(SD_CONFIG);
423+
424+
if (uSD_is_attached && uSD.card()->cardSize() > 0) {
425+
hw_info.storage = STORAGE_CARD;
426+
427+
FATFS_is_mounted = uSD.volumeBegin();
428+
}
429+
}
430+
395431
#elif defined(ARDUINO_WisDuo_RAK3172_Evaluation_Board)
396432

397433
/* TBD */
@@ -536,7 +572,7 @@ static void STM32_setup()
536572

537573
lmic_pins.rxe = SOC_GPIO_ANT_RX;
538574
lmic_pins.txe = SOC_GPIO_ANT_TX;
539-
STM32_has_TCXO = false; /* TBD */
575+
STM32_has_TCXO = false; /* LilyGO T3-STM32 V1.0 25-10-13 */
540576

541577
if (STM32_has_TCXO) {
542578
lmic_pins.tcxo = SOC_GPIO_TCXO;
@@ -659,6 +695,36 @@ static void STM32_post_init()
659695
Serial.println(F("Power-on Self Test is complete."));
660696
Serial.println();
661697
Serial.flush();
698+
699+
if (!uSD_is_attached) {
700+
Serial.println(F("WARNING: unable to attach micro-SD card."));
701+
} else {
702+
// The number of 512 byte sectors in the card
703+
// or zero if an error occurs.
704+
size_t cardSize = uSD.card()->cardSize();
705+
706+
if (cardSize == 0) {
707+
Serial.println(F("WARNING: invalid micro-SD card size."));
708+
} else {
709+
uint8_t cardType = uSD.card()->type();
710+
711+
Serial.print(F("SD Card Type: "));
712+
if(cardType == SD_CARD_TYPE_SD1){
713+
Serial.println(F("V1"));
714+
} else if(cardType == SD_CARD_TYPE_SD2){
715+
Serial.println(F("V2"));
716+
} else if(cardType == SD_CARD_TYPE_SDHC){
717+
Serial.println(F("SDHC"));
718+
} else {
719+
Serial.println(F("UNKNOWN"));
720+
}
721+
722+
Serial.print("SD Card Size: ");
723+
Serial.print(cardSize / (2 * 1024));
724+
Serial.println(" MB");
725+
}
726+
}
727+
Serial.println();
662728
}
663729
#endif /* NUCLEO_L073RZ || GENERIC_WLE5CCUX || GENERIC_WL55CCUX */
664730

@@ -892,6 +958,48 @@ static bool STM32_EEPROM_begin(size_t size)
892958
static void STM32_EEPROM_extension(int cmd)
893959
{
894960
if (cmd == EEPROM_EXT_LOAD) {
961+
#if defined(ARDUINO_GENERIC_WL55CCUX)
962+
if ( uSD_is_attached && FATFS_is_mounted ) {
963+
File32 file = uSD.open(SETTINGS_JSON_PATH, FILE_READ);
964+
965+
if (file) {
966+
// StaticJsonBuffer<STM32_JSON_BUFFER_SIZE> STM32_jsonBuffer;
967+
968+
JsonObject &root = STM32_jsonBuffer.parseObject(file);
969+
970+
if (root.success()) {
971+
JsonVariant msg_class = root["class"];
972+
973+
if (msg_class.success()) {
974+
const char *msg_class_s = msg_class.as<char*>();
975+
976+
if (!strcmp(msg_class_s,"SOFTRF")) {
977+
parseSettings (root);
978+
979+
#if defined(ENABLE_PROL)
980+
JsonVariant fromcall = root["fromcall"];
981+
if (fromcall.success()) {
982+
const char * fromcall_s = fromcall.as<char*>();
983+
if (strlen(fromcall_s) < sizeof(APRS_FromCall)) {
984+
strncpy(APRS_FromCall, fromcall_s, sizeof(APRS_FromCall));
985+
}
986+
}
987+
JsonVariant tocall = root["tocall"];
988+
if (tocall.success()) {
989+
const char * tocall_s = tocall.as<char*>();
990+
if (strlen(tocall_s) < sizeof(APRS_ToCall)) {
991+
strncpy(APRS_ToCall, tocall_s, sizeof(APRS_ToCall));
992+
}
993+
}
994+
#endif /* ENABLE_PROL */
995+
}
996+
}
997+
}
998+
file.close();
999+
}
1000+
}
1001+
#endif /* ARDUINO_GENERIC_WL55CCUX */
1002+
8951003
if (settings->mode != SOFTRF_MODE_NORMAL
8961004
#if !defined(EXCLUDE_TEST_MODE)
8971005
&&

software/firmware/source/SoftRF/src/platform/STM32.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ enum stm32_board_id {
8787
STM32_SEEED_E5, /* RFO_HP, 32 MHz TCXO */
8888
STM32_ACSIP_ST50H, /* a.k.a. "RAK3172-SiP", RFO_HP, 32 MHz TCXO */
8989
STM32_RAK_3172_EB, /* RFO_HP, 32 MHz XTAL (10 ppm) */
90-
STM32_LILYGO_T3_1_0,
90+
STM32_LILYGO_T3_1_0, /* RFO_HP, 32 MHz XTAL - V1.0 25-10-13 */
9191
};
9292

9393
enum stm32_boot_action {
@@ -384,6 +384,8 @@ typedef struct stm32_backup_struct {
384384
#define USE_TIME_SLOTS
385385
#define USE_OGN_ENCRYPTION
386386

387+
//#define ENABLE_RECORDER
388+
387389
/* Experimental */
388390
#define ENABLE_ADSL
389391
#define ENABLE_PROL

software/firmware/source/SoftRF/src/protocol/data/JSON.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919
#if defined(RASPBERRY_PI) || defined(ARDUINO_ARCH_NRF52) || \
2020
defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_ARCH_RP2350) || \
21-
defined(ARDUINO_ARCH_ESP32) || defined(LUCKFOX_LYRA)
21+
defined(ARDUINO_ARCH_ESP32) || defined(LUCKFOX_LYRA) || \
22+
defined(ARDUINO_ARCH_STM32)
2223

2324
#include "../../system/SoC.h"
2425
#include <TinyGPS++.h>
@@ -672,7 +673,8 @@ void parseUISettings(JsonObject& root)
672673

673674
#if defined(RASPBERRY_PI) || defined(ARDUINO_ARCH_NRF52) || \
674675
defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_ARCH_RP2350) || \
675-
defined(ARDUINO_ARCH_ESP32) || defined(LUCKFOX_LYRA)
676+
defined(ARDUINO_ARCH_ESP32) || defined(LUCKFOX_LYRA) || \
677+
defined(ARDUINO_ARCH_STM32)
676678

677679
void parseSettings(JsonObject& root)
678680
{

software/firmware/source/libraries/FlightRecorder/src/FlightRecorder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ log_interval=5
4444
*/
4545

4646
#if !defined(ARDUINO_ARCH_ESP32) && !defined(ARDUINO_ARCH_NRF52) && \
47-
!defined(ARDUINO_ARCH_CH32)
47+
!defined(ARDUINO_ARCH_CH32) && !defined(ARDUINO_ARCH_STM32)
4848
typedef struct __attribute__((__packed__))
4949
#else
5050
typedef struct
51-
#endif /* ARDUINO_ARCH_ESP32 || ARDUINO_ARCH_NRF52 || ARDUINO_ARCH_CH32 */
51+
#endif /* ARCH_ESP32 || ARCH_NRF52 || ARCH_CH32 || ARCH_STM32 */
5252
{
5353
char pilot[80];
5454
char copilot[80];

0 commit comments

Comments
 (0)