Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make STM compile again and update toolchain. #2960

Merged
merged 45 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
550a10d
Make STM compile again and update toolchain. The binary is too big fo…
caveman99 Nov 23, 2023
8399ef6
Merge branch 'master' into stm32wl
thebentern Nov 25, 2023
c7fa4fc
Merge branch 'master' into stm32wl
thebentern Nov 29, 2023
b0587a9
Merge branch 'master' into stm32wl
thebentern Dec 2, 2023
0ab0a07
Merge remote-tracking branch 'remotes/origin/master' into stm32wl
caveman99 Dec 3, 2023
c4f10fc
Merge branch 'stm32wl' of github.com:meshtastic/firmware into stm32wl
caveman99 Dec 4, 2023
67b5e00
Merge remote-tracking branch 'remotes/origin/master' into stm32wl
caveman99 Dec 4, 2023
03ee820
Merge branch 'master' into stm32wl
thebentern Dec 7, 2023
444b1d8
Merge branch 'master' into stm32wl
thebentern Dec 7, 2023
264bd49
Merge branch 'stm32wl' of github.com:meshtastic/firmware into stm32wl
caveman99 Dec 8, 2023
2c6e2bb
Making progress with OSFS, still WIP
caveman99 Dec 8, 2023
41cbf30
Merge branch 'master' into stm32wl
thebentern Dec 13, 2023
fe90751
more progress, still too big. Adding RAK3172 to the equasion
caveman99 Dec 13, 2023
75e19a1
Merge branch 'master' into stm32wl
thebentern Dec 14, 2023
a8544f8
Merge branch 'master' into stm32wl
thebentern Dec 27, 2023
2805bbb
Make STM compile again and update toolchain. The binary is too big fo…
caveman99 Nov 23, 2023
35fa14e
Making progress with OSFS, still WIP
caveman99 Dec 8, 2023
00662be
more progress, still too big. Adding RAK3172 to the equasion
caveman99 Dec 13, 2023
9dd7db5
Merge branch 'master' into stm32wl
caveman99 Mar 18, 2024
c5ffc37
Merge branch 'stm32wl' of github.com:meshtastic/firmware into stm32wl
caveman99 Mar 18, 2024
cf3e9a9
still too big
caveman99 Mar 18, 2024
4508522
Merge branch 'master' into stm32wl
caveman99 Mar 28, 2024
e9bccec
Merge branch 'master' into stm32wl
caveman99 Apr 23, 2024
8f66b15
minimize build
caveman99 May 4, 2024
a3d882c
Merge remote-tracking branch 'remotes/origin/master' into stm32wl
caveman99 May 9, 2024
24d77a3
trunk fmt
caveman99 May 9, 2024
2bbdc6d
fix a couple of symbol clashes
caveman99 May 9, 2024
c768744
Merge branch 'master' into stm32wl
caveman99 May 11, 2024
903d51b
trunk fmt
caveman99 May 11, 2024
123b64d
down to 101% with a release vs. debug build and omitting the flash st…
caveman99 May 11, 2024
6613979
fix compilation
caveman99 May 11, 2024
79aa3cb
fix compilation once more
caveman99 May 11, 2024
0ee12a2
Merge branch 'master' into stm32wl
caveman99 May 12, 2024
bc68fc4
update protobufs linkage
caveman99 May 19, 2024
6e434bf
Merge branch 'master' into stm32wl
caveman99 May 19, 2024
4972438
- Toolchain updated
caveman99 May 19, 2024
b9786d9
silence compiler warning
caveman99 May 19, 2024
89a8358
Merge branch 'master' into stm32wl
caveman99 May 27, 2024
1dd076e
Merge branch 'master' into stm32wl
thebentern Jun 4, 2024
71f9a2c
Merge branch 'master' into stm32wl
caveman99 Jun 13, 2024
809b976
Merge branch 'master' into stm32wl
caveman99 Jun 16, 2024
1ea5363
new toolkit and fix Power.cpp
caveman99 Jun 16, 2024
9f96c06
Merge branch 'master' into stm32wl
caveman99 Jul 22, 2024
14a69d1
Merge branch 'master' into stm32wl
thebentern Jul 25, 2024
42a4008
STM32WL make it fit (#4330)
thebentern Jul 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions arch/stm32/stm32.ini
Original file line number Diff line number Diff line change
@@ -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} -<platform/esp32/> -<nimble/> -<mesh/api/> -<mesh/wifi/> -<mesh/http/> -<modules/esp32> -<mesh/eth/> -<input> -<buzz> -<modules/Telemetry> -<platform/nrf52> -<platform/portduino> -<platform/rp2040> -<mesh/raspihttp>

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
28 changes: 0 additions & 28 deletions arch/stm32/stm32wl5e.ini

This file was deleted.

3 changes: 3 additions & 0 deletions boards/generic_wl5e.json → boards/wiscore_rak3172.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"build": {
"arduino": {
"variant_h": "variant_RAK3172_MODULE.h"
},
"core": "stm32",
"cpu": "cortex-m4",
"extra_flags": "-DSTM32WLxx -DSTM32WLE5xx -DARDUINO_GENERIC_WLE5CCUX",
Expand Down
60 changes: 58 additions & 2 deletions src/FSCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
11 changes: 7 additions & 4 deletions src/FSCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <EEPROM.h>
#include <OSFS.h>

// Useful consts
const OSFS::result noerr = OSFS::result::NO_ERROR;
const OSFS::result notfound = OSFS::result::FILE_NOT_FOUND;
#endif

#if defined(ARCH_RP2040)
Expand Down
5 changes: 3 additions & 2 deletions src/Power.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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
Expand Down
4 changes: 3 additions & 1 deletion src/detect/ScanI2CTwoWire.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -403,3 +404,4 @@ size_t ScanI2CTwoWire::countDevices() const
{
return foundDevices.size();
}
#endif
6 changes: 5 additions & 1 deletion src/detect/ScanI2CTwoWire.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#pragma once

#include "configuration.h"
#if !MESHTASTIC_EXCLUDE_I2C

#include <map>
#include <memory>
#include <stddef.h>
Expand Down Expand Up @@ -55,4 +58,5 @@ class ScanI2CTwoWire : public ScanI2C
uint16_t getRegisterValue(const RegisterLocation &, ResponseWidth) const;

DeviceType probeOLED(ScanI2C::DeviceAddress) const;
};
};
#endif
2 changes: 1 addition & 1 deletion src/freertosinc.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <freertos/task.h>
#endif

#if defined(ARDUINO_NRF52_ADAFRUIT) || defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_RP2040)
#if defined(ARDUINO_NRF52_ADAFRUIT) || defined(ARDUINO_ARCH_RP2040)
#define HAS_FREE_RTOS

#include <FreeRTOS.h>
Expand Down
4 changes: 2 additions & 2 deletions src/gps/GPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ int GPS::prepareDeepSleep(void *unused)

GnssModel_t GPS::probe(int serialSpeed)
{
#if defined(ARCH_NRF52) || defined(ARCH_PORTDUINO) || defined(ARCH_RP2040)
#if defined(ARCH_NRF52) || defined(ARCH_PORTDUINO) || defined(ARCH_RP2040) || defined(ARCH_STM32WL)
_serial_gps->end();
_serial_gps->begin(serialSpeed);
#else
Expand Down Expand Up @@ -1270,7 +1270,7 @@ GnssModel_t GPS::probe(int serialSpeed)
_serial_gps->write(_message_prt, sizeof(_message_prt));
delay(500);
serialSpeed = 9600;
#if defined(ARCH_NRF52) || defined(ARCH_PORTDUINO) || defined(ARCH_RP2040)
#if defined(ARCH_NRF52) || defined(ARCH_PORTDUINO) || defined(ARCH_RP2040) || defined(ARCH_STM32WL)
_serial_gps->end();
_serial_gps->begin(serialSpeed);
#else
Expand Down
4 changes: 2 additions & 2 deletions src/gps/GeoCoord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ std::shared_ptr<GeoCoord> GeoCoord::pointAtDistance(double bearing, double range
* The bearing in string format
* @return Bearing in degrees
*/
uint GeoCoord::bearingToDegrees(const char *bearing)
unsigned int GeoCoord::bearingToDegrees(const char *bearing)
{
if (strcmp(bearing, "N") == 0)
return 0;
Expand Down Expand Up @@ -537,7 +537,7 @@ uint GeoCoord::bearingToDegrees(const char *bearing)
* The bearing in degrees
* @return Bearing in string format
*/
const char *GeoCoord::degreesToBearing(uint degrees)
const char *GeoCoord::degreesToBearing(unsigned int degrees)
{
if (degrees >= 348 || degrees < 11)
return "N";
Expand Down
4 changes: 2 additions & 2 deletions src/gps/GeoCoord.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ class GeoCoord
static float bearing(double lat1, double lon1, double lat2, double lon2);
static float rangeRadiansToMeters(double range_radians);
static float rangeMetersToRadians(double range_meters);
static uint bearingToDegrees(const char *bearing);
static const char *degreesToBearing(uint degrees);
static unsigned int bearingToDegrees(const char *bearing);
static const char *degreesToBearing(unsigned int degrees);

// Point to point conversions
int32_t distanceTo(const GeoCoord &pointB);
Expand Down
15 changes: 14 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
#include "concurrency/OSThread.h"
#include "concurrency/Periodic.h"
#include "detect/ScanI2C.h"

#if !MESHTASTIC_EXCLUDE_I2C
#include "detect/ScanI2CTwoWire.h"
#include <Wire.h>
#endif
#include "detect/axpDebug.h"
#include "detect/einkScan.h"
#include "graphics/RAKled.h"
Expand All @@ -31,7 +35,6 @@
#include "shutdown.h"
#include "sleep.h"
#include "target_specific.h"
#include <Wire.h>
#include <memory>
#include <utility>
// #include <driver/rtc_io.h>
Expand Down Expand Up @@ -159,8 +162,10 @@ bool pauseBluetoothLogging = false;

bool pmu_found;

#if !MESHTASTIC_EXCLUDE_I2C
// Array map of sensor types with i2c address and wire as we'll find in the i2c scan
std::pair<uint8_t, TwoWire *> nodeTelemetrySensorsMap[_meshtastic_TelemetrySensorType_MAX + 1] = {};
#endif

Router *router = NULL; // Users of router don't care what sort of subclass implements that API

Expand Down Expand Up @@ -349,6 +354,7 @@ void setup()

#endif

#if !MESHTASTIC_EXCLUDE_I2C
#if defined(I2C_SDA1) && defined(ARCH_RP2040)
Wire1.setSDA(I2C_SDA1);
Wire1.setSCL(I2C_SCL1);
Expand All @@ -373,6 +379,7 @@ void setup()
#elif HAS_WIRE
Wire.begin();
#endif
#endif

#ifdef PIN_LCD_RESET
// FIXME - move this someplace better, LCD is at address 0x3F
Expand Down Expand Up @@ -405,6 +412,7 @@ void setup()
powerStatus->observe(&power->newStatus);
power->setup(); // Must be after status handler is installed, so that handler gets notified of the initial configuration

#if !MESHTASTIC_EXCLUDE_I2C
// We need to scan here to decide if we have a screen for nodeDB.init() and because power has been applied to
// accessories
auto i2cScanner = std::unique_ptr<ScanI2CTwoWire>(new ScanI2CTwoWire());
Expand Down Expand Up @@ -560,6 +568,7 @@ void setup()
SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::DFROBOT_LARK, meshtastic_TelemetrySensorType_DFROBOT_LARK)

i2cScanner.reset();
#endif

#ifdef HAS_SDCARD
setupSDCard();
Expand Down Expand Up @@ -620,6 +629,7 @@ void setup()
screen_model = meshtastic_Config_DisplayConfig_OledType_OLED_SH1107; // keep dimension of 128x64
#endif

#if !MESHTASTIC_EXCLUDE_I2C
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
if (acc_info.type != ScanI2C::DeviceType::NONE) {
config.display.wake_on_tap_or_motion = true;
Expand All @@ -635,6 +645,7 @@ void setup()
ambientLightingThread = new AmbientLightingThread(rgb_found.type);
}
#endif
#endif

#ifdef T_WATCH_S3
drv.begin();
Expand Down Expand Up @@ -721,6 +732,7 @@ void setup()
RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_NO_AXP192); // Record a hardware fault for missing hardware
#endif

#if !MESHTASTIC_EXCLUDE_I2C
// Don't call screen setup until after nodedb is setup (because we need
// the current region name)
#if defined(ST7735_CS) || defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7789_CS) || defined(HX8357_CS) || \
Expand All @@ -733,6 +745,7 @@ void setup()
#else
if (screen_found.port != ScanI2C::I2CPort::NO_I2C)
screen->setup();
#endif
#endif

screen->print("Started...\n");
Expand Down
Loading
Loading