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

WIP Ambiq Apollo3 support #2378

Draft
wants to merge 58 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
a7f9e5d
WIP scaffolding
thebentern Mar 24, 2023
516fc5c
Moar
thebentern Mar 28, 2023
1eff8fd
WIP scaffolding
thebentern Mar 24, 2023
681377c
Moar
thebentern Mar 28, 2023
4b053dd
Merge branch 'apollo' of github.com:meshtastic/firmware into apollo
caveman99 Apr 24, 2023
a54ad6b
update apollo platform files and exclude from building other platforms
caveman99 Apr 24, 2023
f826a85
Merge branch 'master' into apollo
caveman99 May 8, 2023
784381b
Merge branch 'master' into apollo
caveman99 May 10, 2023
9a79d34
Merge branch 'master' into apollo
caveman99 Jun 12, 2023
8e088df
Merge branch 'master' into apollo
thebentern Jun 25, 2023
b467ee0
Merge branch 'master' into apollo
caveman99 Jul 1, 2023
1369630
Merge branch 'master' into apollo
caveman99 Jul 24, 2023
ed43274
Merge branch 'master' into apollo
thebentern Jul 30, 2023
72b1fa3
Merge branch 'master' into apollo
caveman99 Jul 31, 2023
b8965d2
Apollo3 WIP
caveman99 Jul 31, 2023
db9cb33
Merge branch 'apollo' of github.com:meshtastic/firmware into apollo
caveman99 Jul 31, 2023
de21b31
Merge branch 'master' into apollo
caveman99 Jul 31, 2023
7e2d729
revert overcommit
caveman99 Jul 31, 2023
5348454
Merge branch 'apollo' of github.com:meshtastic/firmware into apollo
caveman99 Jul 31, 2023
b6b52d8
Merge branch 'master' into apollo
thebentern Jul 31, 2023
c31476d
Merge branch 'master' into apollo
thebentern Aug 8, 2023
2b074e6
Merge branch 'master' into apollo
caveman99 Aug 17, 2023
a7bf7f4
trunk fmt
caveman99 Aug 17, 2023
acbbc95
Merge branch 'master' into apollo
thebentern Aug 31, 2023
71645c0
Merge branch 'master' into apollo
caveman99 Sep 28, 2023
c29b49f
Merge branch 'master' into apollo
caveman99 Oct 31, 2023
47b522f
Merge branch 'master' into apollo
caveman99 Nov 16, 2023
81a7832
Merge branch 'master' into apollo
caveman99 Dec 1, 2023
7d5716d
trunk fmt
caveman99 Dec 1, 2023
dcae45d
Merge remote-tracking branch 'remotes/origin/master' into apollo
caveman99 Dec 4, 2023
55a75d2
Making progress with OSFS, still WIP
caveman99 Dec 8, 2023
b2a3137
Merge branch 'master' into apollo
thebentern Dec 12, 2023
4996e2a
Merge branch 'master' into apollo
caveman99 Feb 23, 2024
a9fc31c
Merge branch 'master' into apollo
caveman99 Mar 5, 2024
a7c0109
trunk fmt
caveman99 Mar 8, 2024
93d7f24
Merge branch 'master' into apollo
caveman99 Mar 18, 2024
9be3b7b
make apollo decent again
caveman99 Mar 18, 2024
72664b0
add FS macro guards
caveman99 Mar 18, 2024
f50f61a
Merge branch 'master' into apollo
caveman99 Mar 28, 2024
011cff2
Merge branch 'master' into apollo
caveman99 Apr 23, 2024
ed9bdf0
Merge branch 'master' into apollo
caveman99 May 17, 2024
7cbf669
Merge branch 'master' into apollo
caveman99 May 18, 2024
f2116a0
Merge branch 'master' into apollo
caveman99 May 27, 2024
688385f
Merge branch 'master' into apollo
caveman99 Jun 13, 2024
652441f
Merge branch 'master' into apollo
caveman99 Jun 16, 2024
3765b9f
Get apollo3 building again (#4141)
al177 Jun 19, 2024
074ccba
Merge branch 'master' into apollo
caveman99 Jun 19, 2024
0e93470
Merge remote-tracking branch 'remotes/origin/master' into apollo
caveman99 Sep 2, 2024
c1a493f
update apollo toolchain
caveman99 Sep 2, 2024
047b8a5
Merge branch 'master' into apollo
caveman99 Sep 4, 2024
f0c97b8
Merge branch 'master' into apollo
caveman99 Oct 8, 2024
19bcb60
woopsie
caveman99 Oct 8, 2024
02e258d
Merge branch 'master' into apollo
caveman99 Oct 16, 2024
7a3f30f
Merge branch 'master' into apollo
caveman99 Oct 26, 2024
7d9b2ef
Merge branch 'master' into apollo
caveman99 Nov 2, 2024
6860717
fix RP2040 builds
caveman99 Nov 3, 2024
b789781
Merge branch 'master' into apollo
caveman99 Nov 11, 2024
b97ca2c
Merge branch 'master' into apollo
caveman99 Nov 24, 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
7 changes: 3 additions & 4 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
"ms-vscode.cpptools",
"platformio.platformio-ide",
"trunk.io"
],
"unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
}
33 changes: 33 additions & 0 deletions arch/apollo3/apollo3.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[apollo3_base]
extends = arduino_base
platform = https://github.com/nigelb/platform-apollo3blue.git#2e8a9895cf82f2836c483885e6f89b3f83d3ade4
platform_packages=framework-arduinoapollo3@https://github.com/sparkfun/Arduino_Apollo3#a0d99c5fc9b1112d46a9d11c1339898d01e586c9
build_type = debug
build_flags =
${arduino_base.build_flags}
-Isrc/platform/apollo3 -g
-I"${platformio.packages_dir}/framework-arduinoapollo3/libraries/SPI/src"
-DRADIOLIB_EEPROM_UNSUPPORTED
-DMESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
build_src_filter =
${arduino_base.build_src_filter}
-<platform/nrf52>
-<platform/esp32/>
-<platform/rp2040>
-<platform/portduino>
-<platform/stm32wl>
-<nimble/>
-<mesh/api/>
-<mesh/http/>
-<mesh/wifi/>
-<modules/esp32>
-<mesh/eth/>
-<input>
-<buzz>
-<modules/Telemetry>
lib_deps =
${env.lib_deps}
charlesbaynham/OSFS@^1.2.3
rweather/Crypto
lib_ignore =
mathertel/OneButton
8 changes: 7 additions & 1 deletion arch/esp32/esp32.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ custom_esp32_kind = esp32
platform = platformio/[email protected]

build_src_filter =
${arduino_base.build_src_filter} -<platform/nrf52/> -<platform/stm32wl> -<platform/rp2xx0> -<mesh/eth/> -<mesh/raspihttp>
${arduino_base.build_src_filter}
-<platform/nrf52/>
-<platform/stm32wl>
-<platform/rp2xx0>
-<platform/apollo3>
-<mesh/eth/>
-<mesh/raspihttp>

upload_speed = 921600
debug_init_break = tbreak setup
Expand Down
1 change: 1 addition & 0 deletions arch/esp32/esp32c3.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[esp32c3_base]
extends = esp32_base

custom_esp32_kind = esp32c3

monitor_speed = 115200
Expand Down
2 changes: 1 addition & 1 deletion arch/esp32/esp32s3.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[esp32s3_base]
extends = esp32_base

custom_esp32_kind = esp32s3

monitor_speed = 115200

13 changes: 12 additions & 1 deletion arch/nrf52/nrf52.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,18 @@ build_flags =
-DMAX_NUM_NODES=80

build_src_filter =
${arduino_base.build_src_filter} -<platform/esp32/> -<platform/stm32wl> -<nimble/> -<mesh/wifi/> -<mesh/api/> -<mesh/http/> -<modules/esp32> -<platform/rp2xx0> -<mesh/eth/> -<mesh/raspihttp>
${arduino_base.build_src_filter}
-<platform/esp32/>
-<platform/stm32wl>
-<nimble/>
-<mesh/wifi/>
-<mesh/api/>
-<mesh/http/>
-<modules/esp32>
-<platform/rp2xx0>
-<mesh/eth/>
-<mesh/raspihttp>
-<platform/apollo3>

lib_deps=
${arduino_base.lib_deps}
Expand Down
3 changes: 2 additions & 1 deletion arch/portduino/portduino.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ build_src_filter =
-<platform/nrf52/>
-<platform/stm32wl/>
-<platform/rp2xx0>
-<platform/apollo3>
-<mesh/wifi/>
-<mesh/http/>
+<mesh/raspihttp/>
Expand All @@ -36,4 +37,4 @@ build_flags =
-lstdc++fs
-lbluetooth
-lgpiod
-lyaml-cpp
-lyaml-cpp
2 changes: 1 addition & 1 deletion arch/rp2xx0/rp2040.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ build_flags =
-D__PLAT_RP2040__
# -D _POSIX_THREADS
build_src_filter =
${arduino_base.build_src_filter} -<platform/esp32/> -<nimble/> -<modules/esp32> -<platform/nrf52/> -<platform/stm32wl> -<mesh/eth/> -<mesh/wifi/> -<mesh/http/> -<mesh/raspihttp>
${arduino_base.build_src_filter} -<platform/esp32/> -<nimble/> -<modules/esp32> -<platform/nrf52/> -<platform/apollo3> -<platform/stm32wl> -<mesh/eth/> -<mesh/wifi/> -<mesh/http/> -<mesh/raspihttp>

lib_ignore =
BluetoothOTA
Expand Down
12 changes: 11 additions & 1 deletion arch/rp2xx0/rp2350.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@ build_flags =
-D__PLAT_RP2040__
# -D _POSIX_THREADS
build_src_filter =
${arduino_base.build_src_filter} -<platform/esp32/> -<nimble/> -<modules/esp32> -<platform/nrf52/> -<platform/stm32wl> -<mesh/eth/> -<mesh/wifi/> -<mesh/http/> -<mesh/raspihttp>
${arduino_base.build_src_filter}
-<platform/esp32/>
-<nimble/>
-<modules/esp32>
-<platform/nrf52/>
-<platform/stm32wl>
-<mesh/eth/>
-<mesh/wifi/>
-<mesh/http/>
-<platform/apollo3>
-<mesh/raspihttp>

lib_ignore =
BluetoothOTA
Expand Down
2 changes: 1 addition & 1 deletion arch/stm32/stm32.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ build_flags =
-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/RemoteHardwareModule.cpp> -<platform/nrf52> -<platform/portduino> -<platform/rp2xx0> -<mesh/raspihttp>
${arduino_base.build_src_filter} -<platform/esp32/> -<nimble/> -<mesh/api/> -<mesh/wifi/> -<mesh/http/> -<modules/esp32> -<mesh/eth/> -<input> -<buzz> -<modules/RemoteHardwareModule.cpp> -<platform/nrf52> -<platform/portduino> -<platform/rp2xx0> -<platform/apollo3> -<mesh/raspihttp>

board_upload.offset_address = 0x08000000
upload_protocol = stlink
Expand Down
45 changes: 45 additions & 0 deletions boards/wiscore_rak11720.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"build": {
"cpu": "cortex-m4",
"f_cpu": "48000000L",
"mcu": "AMA3B1KK",
"part": "apollo3",
"fabi": "hard",
"specs": "nosys.specs",
"framework": {
"arduino": {
"v1": {
"variant": "artemis",
"extra_flags": "-DSFE_ARTEMIS"
},
"v2": {
"variant": "rak11720",
"extra_flags": "-DARDUINO_RAK_11720_MODULE"
}
},
"ambiqsdk-sfe": {
"variant": ["boards_sfe", "artemis_module"],
"extra_flags": "",
"variant_lib_src_filter": ""
}
}
},
"debug": {
"jlink_device": "AMA3B1KK-KBR",
"svd_path": "apollo3.svd",
"swo_freq": 12000000,
"init": {
"break": "tbreak setup"
}
},
"frameworks": ["arduino", "ambiqsdk-sfe"],
"name": "WisCore RAK11720 Board",
"upload": {
"maximum_ram_size": 393216,
"maximum_size": 983040,
"protocol": "svl",
"protocols": ["svl", "asb", "jlink"]
},
"url": "https://www.rakwireless.com",
"vendor": "RAKwireless"
}
11 changes: 8 additions & 3 deletions src/FSCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@ SPIClass SPI1(HSPI);

#endif // HAS_SDCARD

#if defined(ARCH_STM32WL)
#if defined(ARCH_APOLLO3)
// Apollo series 2 Kbytes (8 rows of 256 bytes)

uint16_t OSFS::startOfEEPROM = 1;
uint16_t OSFS::endOfEEPROM = 2048;

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

// 3) How do I read from the medium?
void OSFS::readNBytes(uint16_t address, unsigned int num, byte *output)
{
Expand Down Expand Up @@ -66,7 +71,7 @@ extern "C" void lfs_assert(const char *reason)
*/
bool copyFile(const char *from, const char *to)
{
#ifdef ARCH_STM32WL
#if defined(ARCH_STM32WL) || defined(ARCH_APOLLO3)
unsigned char cbuffer[2048];

// Var to hold the result of actions
Expand Down Expand Up @@ -129,7 +134,7 @@ bool copyFile(const char *from, const char *to)
*/
bool renameFile(const char *pathFrom, const char *pathTo)
{
#ifdef ARCH_STM32WL
#if defined(ARCH_STM32WL) || defined(ARCH_APOLLO3)
if (copyFile(pathFrom, pathTo) && (OSFS::deleteFile(pathFrom) == OSFS::result::NO_ERROR)) {
return true;
} else {
Expand Down
19 changes: 19 additions & 0 deletions src/FSCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,25 @@ const OSFS::result noerr = OSFS::result::NO_ERROR;
const OSFS::result notfound = OSFS::result::FILE_NOT_FOUND;
#endif

#if defined(ARCH_APOLLO3)
// Apollo series 2 Kbytes (8 rows of 256 bytes)
#include <EEPROM.h>
#include <OSFS.h>

extern uint16_t OSFS::startOfEEPROM;
extern uint16_t OSFS::endOfEEPROM;

// Useful consts
extern const OSFS::result noerr;
extern const OSFS::result notfound;

// 3) How do I read from the medium?
void OSFS::readNBytes(uint16_t address, unsigned int num, byte *output);

// 4) How to I write to the medium?
void OSFS::writeNBytes(uint16_t address, unsigned int num, const byte *input);
#endif

#if defined(ARCH_RP2040)
// RP2040
#include "LittleFS.h"
Expand Down
2 changes: 1 addition & 1 deletion src/RedirectablePrint.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "RedirectablePrint.h"
#include "NodeDB.h"
#include "RTC.h"
#include "concurrency/OSThread.h"
#include "configuration.h"
#include "gps/RTC.h"
#include "main.h"
#include "mesh/generated/meshtastic/mesh.pb.h"
#include <assert.h>
Expand Down
4 changes: 2 additions & 2 deletions src/detect/ScanI2CTwoWire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ ScanI2C::DeviceType ScanI2CTwoWire::probeOLED(ScanI2C::DeviceAddress addr) const
}
void ScanI2CTwoWire::printATECCInfo() const
{
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !defined(ARCH_APOLLO3)
atecc.readConfigZone(false);

std::string atecc_numbers = "ATECC608B Serial Number: ";
Expand Down Expand Up @@ -206,7 +206,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
type = probeOLED(addr);
break;

#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !defined(ARCH_APOLLO3)
case ATECC608B_ADDR:
#ifdef RP2040_SLOW_CLOCK
if (atecc.begin(addr.address, Wire, Serial2) == true)
Expand Down
2 changes: 1 addition & 1 deletion src/gps/GPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ const char *DETECTED_MESSAGE = "%s detected, using %s Module";

GnssModel_t GPS::probe(int serialSpeed)
{
#if defined(ARCH_NRF52) || defined(ARCH_PORTDUINO) || defined(ARCH_STM32WL)
#if defined(ARCH_NRF52) || defined(ARCH_PORTDUINO) || defined(ARCH_STM32WL) || defined(ARCH_APOLLO3)
_serial_gps->end();
_serial_gps->begin(serialSpeed);
#elif defined(ARCH_RP2040)
Expand Down
11 changes: 6 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,21 @@

#include "FSCommon.h"
#include "Led.h"
#include "RTC.h"
#include "SPILock.h"
#include "Throttle.h"
#include "concurrency/OSThread.h"
#include "concurrency/Periodic.h"
#include "detect/ScanI2C.h"
#include "error.h"
#include "gps/RTC.h"
#include "power.h"

#if !MESHTASTIC_EXCLUDE_I2C
#include "detect/ScanI2CTwoWire.h"
#include <Wire.h>
#endif
#include "detect/einkScan.h"
#include "gps/RTC.h"
#include "graphics/RAKled.h"
#include "graphics/Screen.h"
#include "main.h"
Expand Down Expand Up @@ -103,7 +104,7 @@ NRF52Bluetooth *nrf52Bluetooth = nullptr;
#include "AmbientLightingThread.h"
#include "PowerFSMThread.h"

#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_I2C
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_I2C && !defined(ARCH_APOLLO3)
#include "motion/AccelerometerThread.h"
AccelerometerThread *accelerometerThread = nullptr;
#endif
Expand Down Expand Up @@ -150,7 +151,7 @@ ScanI2C::DeviceAddress accelerometer_found = ScanI2C::ADDRESS_NONE;
// The I2C address of the RGB LED (if found)
ScanI2C::FoundDevice rgb_found = ScanI2C::FoundDevice(ScanI2C::DeviceType::NONE, ScanI2C::ADDRESS_NONE);

#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !defined(ARCH_APOLLO3)
ATECCX08A atecc;
#endif

Expand Down Expand Up @@ -690,15 +691,15 @@ void setup()
#endif

#if !MESHTASTIC_EXCLUDE_I2C
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !defined(ARCH_APOLLO3)
if (acc_info.type != ScanI2C::DeviceType::NONE) {
accelerometerThread = new AccelerometerThread(acc_info.type);
}
#endif

#if defined(HAS_NEOPIXEL) || defined(UNPHONE) || defined(RGBLED_RED)
ambientLightingThread = new AmbientLightingThread(ScanI2C::DeviceType::NONE);
#elif !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
#elif !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !defined(ARCH_APOLLO3)
if (rgb_found.type != ScanI2C::DeviceType::NONE) {
ambientLightingThread = new AmbientLightingThread(rgb_found.type);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "mesh/generated/meshtastic/telemetry.pb.h"
#include <SPI.h>
#include <map>
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !defined(ARCH_APOLLO3)
#include <SparkFun_ATECCX08a_Arduino_Library.h>
#endif
#if defined(ARCH_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32S2)
Expand Down Expand Up @@ -39,7 +39,7 @@ extern bool pmu_found;
extern bool isCharging;
extern bool isUSBPowered;

#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !defined(ARCH_APOLLO3)
extern ATECCX08A atecc;
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/mesh/MeshService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include "MeshService.h"
#include "NodeDB.h"
#include "PowerFSM.h"
#include "RTC.h"
#include "TypeConversions.h"
#include "gps/RTC.h"
#include "main.h"
#include "mesh-pb-constants.h"
#include "meshUtils.h"
Expand Down
2 changes: 1 addition & 1 deletion src/mesh/NodeDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
#include "NodeDB.h"
#include "PacketHistory.h"
#include "PowerFSM.h"
#include "RTC.h"
#include "Router.h"
#include "SafeFile.h"
#include "TypeConversions.h"
#include "error.h"
#include "gps/RTC.h"
#include "main.h"
#include "mesh-pb-constants.h"
#include "meshUtils.h"
Expand Down
Loading