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

Adding XIAO ESP32C6 with BLE support #5421

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
60303b0
Add XIAO ESP32C6
alexbegoon Nov 13, 2024
e4c5de7
Merge remote-tracking branch 'upstream/master' into xiao_esp32c6_with…
alexbegoon Nov 22, 2024
497217b
WIP
alexbegoon Nov 22, 2024
be021cc
Merge branch 'master' into xiao_esp32c6_with_ble
caveman99 Nov 23, 2024
79e9702
reset protobufs
alexbegoon Nov 23, 2024
e65e39a
Improve condition for app_main define
alexbegoon Nov 23, 2024
499316b
Merge branch 'master' into xiao_esp32c6_with_ble
caveman99 Nov 24, 2024
b6c4353
Rework extra_scripts (add missing buildflags)
alexbegoon Nov 25, 2024
6fafd0a
Merge remote-tracking branch 'upstream/master' into xiao_esp32c6_with…
alexbegoon Nov 25, 2024
1e00ed8
Merge branch 'xiao_esp32c6_with_ble' of github.com:alexbegoon/firmwar…
alexbegoon Nov 25, 2024
0d52de3
Merge branch 'master' into xiao_esp32c6_with_ble
caveman99 Nov 26, 2024
62f9c35
Merge remote-tracking branch 'upstream/master' into xiao_esp32c6_with…
alexbegoon Dec 29, 2024
0e304bb
Bump a NimBLE version
alexbegoon Dec 29, 2024
765b7c0
Merge branch 'xiao_esp32c6_with_ble' of github.com:alexbegoon/firmwar…
alexbegoon Dec 29, 2024
b17cead
Bump a pioarduino version
alexbegoon Dec 29, 2024
a4453cf
Bump a NimBLE version
alexbegoon Dec 29, 2024
b2a8e7d
Bump NimBLE version
alexbegoon Dec 29, 2024
11ed799
Bridging Arduino and ESP IDF framework
alexbegoon Dec 30, 2024
9517e08
Bridging Arduino and ESP IDF framework
alexbegoon Dec 30, 2024
013d9ca
Merge branch 'master' into xiao_esp32c6_with_ble
fifieldt Dec 30, 2024
084fa5c
Merge branch 'master' into xiao_esp32c6_with_ble
alexbegoon Jan 1, 2025
a64d91b
Merge remote-tracking branch 'upstream/master' into xiao_esp32c6_with…
alexbegoon Jan 2, 2025
6209ba9
Bridging Arduino and ESP IDF framework
alexbegoon Jan 2, 2025
d64bd3d
Merge remote-tracking branch 'origin/xiao_esp32c6_with_ble' into xiao…
alexbegoon Jan 2, 2025
c86aa23
Merge remote-tracking branch 'upstream/master' into xiao_esp32c6_with…
alexbegoon Jan 2, 2025
11d27df
Merge remote-tracking branch 'upstream/master' into xiao_esp32c6_with…
alexbegoon Jan 3, 2025
e76c036
Bump meshtastic/esp8266-oled-ssd1306
alexbegoon Jan 3, 2025
3c6304f
Merge branch 'master' into xiao_esp32c6_with_ble
caveman99 Jan 4, 2025
e2e5822
Add comments to clarify the use of CMake :)
alexbegoon Jan 4, 2025
428ddd7
Merge remote-tracking branch 'origin/xiao_esp32c6_with_ble' into xiao…
alexbegoon Jan 4, 2025
69d9325
on Windows, PIO finds the wrong RTC.h
caveman99 Jan 4, 2025
934096e
Merge branch 'xiao_esp32c6_with_ble' of https://github.com/alexbegoon…
caveman99 Jan 4, 2025
9ffd0af
Merge remote-tracking branch 'upstream/master' into xiao_esp32c6_with…
alexbegoon Jan 8, 2025
07ff8a9
Merge remote-tracking branch 'upstream/master' into xiao_esp32c6_with…
alexbegoon Jan 10, 2025
0224b6a
Add external antenna support to XIAO ESP32C6
alexbegoon Jan 10, 2025
03973d3
Merge remote-tracking branch 'upstream/master' into xiao_esp32c6_with…
alexbegoon Jan 14, 2025
13b2f1d
Merge branch 'master' into xiao_esp32c6_with_ble
thebentern Jan 16, 2025
2e6a896
Merge branch 'master' into xiao_esp32c6_with_ble
caveman99 Jan 19, 2025
579ecd1
Merge remote-tracking branch 'upstream/master' into xiao_esp32c6_with…
alexbegoon Jan 20, 2025
0da30eb
Change GPIO log level to WARN for esp32
alexbegoon Jan 20, 2025
c684afc
Merge branch 'xiao_esp32c6_with_ble' of github.com:alexbegoon/firmwar…
alexbegoon Jan 20, 2025
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
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,12 @@ release/
.vscode/extensions.json
/compile_commands.json
src/mesh/raspihttp/certificate.pem
src/mesh/raspihttp/private_key.pem
src/mesh/raspihttp/private_key.pem

managed_components
dependencies.lock

log_*
sdkconfig
sdkconfig.*
!sdkconfig.defaults
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file supports the ESP-IDF framework only.
# Specifically, it targets the ESP32-C6 due to limited support in PlatformIO (see: https://github.com/platformio/platform-espressif32/issues/1225).
# Currently, we need to compile NimBLE CPP manually to enable BLE, and possibly WiFi, for ESP32-C6 targets.
cmake_minimum_required(VERSION 3.16.0)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(firmware)
2 changes: 1 addition & 1 deletion arch/esp32/esp32.ini
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ lib_deps =
${environmental_base.lib_deps}
${radiolib_base.lib_deps}
https://github.com/meshtastic/esp32_https_server.git#23665b3adc080a311dcbb586ed5941b5f94d6ea2
h2zero/NimBLE-Arduino@^1.4.2
h2zero/NimBLE-Arduino@^2.1.0
https://github.com/dbinfrago/libpax.git#3cdc0371c375676a97967547f4065607d4c53fd1
lewisxhe/XPowersLib@^0.2.6
https://github.com/meshtastic/ESP32_Codec2.git#633326c78ac251c059ab3a8c430fcdf25b41672f
Expand Down
21 changes: 15 additions & 6 deletions bin/platformio-custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,17 @@ def esp32_create_combined_bin(source, target, env):
env.VerboseAction(f"{sys.executable} ./bin/uf2conv.py $BUILD_DIR/firmware.hex -c -f 0xADA52840 -o $BUILD_DIR/firmware.uf2",
"Generating UF2 file"))

Import("projenv")
verPropFile = "version.properties"

try:
# See: https://github.com/platformio/platform-espressif32/issues/953
Import("projenv")
prefsLoc = projenv["PROJECT_DIR"] + "/" + verPropFile
except Exception as e:
print(f"Warning: Unable to import 'projenv'. Falling back. Error: {e}")
projenv = None
prefsLoc = "./" + verPropFile # Fallback location

prefsLoc = projenv["PROJECT_DIR"] + "/version.properties"
verObj = readProps(prefsLoc)
print("Using meshtastic platformio-custom.py, firmware version " + verObj["long"] + " on " + env.get("PIOENV"))

Expand Down Expand Up @@ -122,7 +130,8 @@ def esp32_create_combined_bin(source, target, env):
print ("Using flags:")
for flag in flags:
print(flag)

projenv.Append(
CCFLAGS=flags,
)

if projenv:
projenv.Append(CCFLAGS=flags)

env.Append(CCFLAGS=flags)
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ build_flags = -Wno-missing-field-initializers
monitor_speed = 115200
monitor_filters = direct
lib_deps =
https://github.com/meshtastic/esp8266-oled-ssd1306.git#e16cee124fe26490cb14880c679321ad8ac89c95
https://github.com/meshtastic/esp8266-oled-ssd1306.git#3e9fce851952aa78ef6ce44e892ec9bcf31e1c0b
mathertel/[email protected]
https://github.com/meshtastic/arduino-fsm.git#7db3702bf0cfe97b783d6c72595e3f38e0b19159
https://github.com/meshtastic/TinyGPSPlus.git#71a82db35f3b973440044c476d4bcdc673b104f4
Expand Down
34 changes: 34 additions & 0 deletions sdkconfig.defaults
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# CONFIG_AUTOSTART_ARDUINO is not set
# CONFIG_WS2812_LED_ENABLE is not set
CONFIG_FREERTOS_HZ=1000
CONFIG_MBEDTLS_PSK_MODES=y
CONFIG_MBEDTLS_KEY_EXCHANGE_PSK=y
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE=y

# Override some defaults so BT stack is enabled
# in this example
#
# BT config
#
CONFIG_BT_ENABLED=y
CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y
CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=n
CONFIG_BTDM_CTRL_MODE_BTDM=n
CONFIG_BT_BLUEDROID_ENABLED=n
CONFIG_BT_NIMBLE_ENABLED=y

#
# Arduino Configuration
#
#
# Disable all Arduino included BLE libraries
#
CONFIG_ARDUINO_SELECTIVE_COMPILATION=y
# CONFIG_ARDUINO_SELECTIVE_WiFiProv is not set
# CONFIG_ARDUINO_SELECTIVE_BLE is not set
# CONFIG_ARDUINO_SELECTIVE_BluetoothSerial is not set
# CONFIG_ARDUINO_SELECTIVE_SimpleBLE is not set
# end of Arduino Configuration
14 changes: 14 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file supports the ESP-IDF framework only.
# Specifically, it targets the ESP32-C6 due to limited support in PlatformIO (see: https://github.com/platformio/platform-espressif32/issues/1225).
# Currently, we need to compile NimBLE CPP manually to enable BLE, and possibly WiFi, for ESP32-C6 targets.
FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*.*)
FILE(GLOB_RECURSE platform_sources ${CMAKE_SOURCE_DIR}/src/platform/**/*.*)
list(REMOVE_ITEM app_sources ${platform_sources})
FILE(GLOB_RECURSE esp32_sources ${CMAKE_SOURCE_DIR}/src/platform/esp32/*.*)
list(APPEND app_sources ${esp32_sources})
FILE(GLOB_RECURSE esp32_sources ${CMAKE_SOURCE_DIR}/src/platform/esp32/**/*.*)
list(APPEND app_sources ${esp32_sources})
list(REMOVE_ITEM app_sources ${CMAKE_SOURCE_DIR}/src/mesh/eth/ethClient.cpp)

# Register the component with ESP-IDF
idf_component_register(SRCS ${app_sources} INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/src)
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
2 changes: 1 addition & 1 deletion src/gps/GPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include "GpioLogic.h"
#include "NodeDB.h"
#include "PowerMon.h"
#include "RTC.h"
#include "Throttle.h"
#include "buzz.h"
#include "gps/RTC.h"
#include "meshUtils.h"

#include "main.h" // pmu_found
Expand Down
2 changes: 1 addition & 1 deletion src/gps/NMEAWPL.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#if !MESHTASTIC_EXCLUDE_GPS
#include "NMEAWPL.h"
#include "GeoCoord.h"
#include "RTC.h"
#include "gps/RTC.h"
#include <time.h>

/* -------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/gps/RTC.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "RTC.h"
#include "gps/RTC.h"
#include "configuration.h"
#include "detect/ScanI2C.h"
#include "main.h"
Expand Down
13 changes: 12 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

#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
Expand Down Expand Up @@ -1222,3 +1222,14 @@ void loop()
}
}
#endif
#if !defined(CONFIG_AUTOSTART_ARDUINO) && (ESP_IDF_VERSION_MAJOR * 100 + ESP_IDF_VERSION_MINOR * 10 + ESP_IDF_VERSION_PATCH) > 514
// Define app_main to bridge Arduino and ESP-IDF
extern "C" void app_main(void)
{
setup();
while (1) {
loop();
vTaskDelay(1); // Allows FreeRTOS to manage tasks
}
}
#endif
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 @@ -11,12 +11,12 @@
#include "NodeDB.h"
#include "PacketHistory.h"
#include "PowerFSM.h"
#include "RTC.h"
#include "Router.h"
#include "SPILock.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
2 changes: 1 addition & 1 deletion src/mesh/PhoneAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "mqtt/MQTT.h"
#endif
#include "Throttle.h"
#include <RTC.h>
#include "gps/RTC.h"

PhoneAPI::PhoneAPI()
{
Expand Down
2 changes: 1 addition & 1 deletion src/mesh/Router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#include "MeshRadio.h"
#include "MeshService.h"
#include "NodeDB.h"
#include "RTC.h"
#include "configuration.h"
#include "detect/LoRaRadioType.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/StreamAPI.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "StreamAPI.h"
#include "PowerFSM.h"
#include "RTC.h"
#include "Throttle.h"
#include "configuration.h"
#include "gps/RTC.h"

#define START1 0x94
#define START2 0xc3
Expand Down
2 changes: 1 addition & 1 deletion src/mesh/eth/ethClient.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "mesh/eth/ethClient.h"
#include "NodeDB.h"
#include "RTC.h"
#include "concurrency/Periodic.h"
#include "configuration.h"
#include "gps/RTC.h"
#include "main.h"
#include "mesh/api/ethServerAPI.h"
#if !MESHTASTIC_EXCLUDE_MQTT
Expand Down
12 changes: 5 additions & 7 deletions src/mesh/http/ContentHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
// #include <Arduino.h>
// #include "main.h"

void replaceAll(std::string &str, const std::string &from, const std::string &to)
void replaceAll(String &str, const String &from, const String &to)
{
if (from.empty())
return;
size_t start_pos = 0;
while ((start_pos = str.find(from, start_pos)) != std::string::npos) {
str.replace(start_pos, from.length(), to);
start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with 'yx'
int start_pos = 0;
while ((start_pos = str.indexOf(from, start_pos)) != -1) {
str.replace(from, to);
start_pos += to.length();
}
}
2 changes: 1 addition & 1 deletion src/mesh/http/ContentHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

#define BoolToString(x) ((x) ? "true" : "false")

void replaceAll(std::string &str, const std::string &from, const std::string &to);
void replaceAll(String &str, const String &from, const String &to);
2 changes: 1 addition & 1 deletion src/mesh/wifi/WiFiAPClient.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "configuration.h"
#if HAS_WIFI
#include "NodeDB.h"
#include "RTC.h"
#include "concurrency/Periodic.h"
#include "gps/RTC.h"
#include "mesh/wifi/WiFiAPClient.h"

#include "main.h"
Expand Down
2 changes: 1 addition & 1 deletion src/modules/AdminModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include "MeshService.h"
#include "NodeDB.h"
#include "PowerFSM.h"
#include "RTC.h"
#include "SPILock.h"
#include "gps/RTC.h"
#include "meshUtils.h"
#include <FSCommon.h>
#if defined(ARCH_ESP32) && !MESHTASTIC_EXCLUDE_BLUETOOTH
Expand Down
2 changes: 1 addition & 1 deletion src/modules/ExternalNotificationModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
#include "ExternalNotificationModule.h"
#include "MeshService.h"
#include "NodeDB.h"
#include "RTC.h"
#include "Router.h"
#include "buzz/buzz.h"
#include "configuration.h"
#include "gps/RTC.h"
#include "main.h"
#include "mesh/generated/meshtastic/rtttl.pb.h"
#include <Arduino.h>
Expand Down
2 changes: 1 addition & 1 deletion src/modules/NeighborInfoModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "Default.h"
#include "MeshService.h"
#include "NodeDB.h"
#include "RTC.h"
#include "gps/RTC.h"
#include <Throttle.h>

NeighborInfoModule *neighborInfoModule;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/NodeInfoModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#include "Default.h"
#include "MeshService.h"
#include "NodeDB.h"
#include "RTC.h"
#include "Router.h"
#include "configuration.h"
#include "gps/RTC.h"
#include "main.h"
#include <Throttle.h>

Expand Down
2 changes: 1 addition & 1 deletion src/modules/PositionModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
#include "GPS.h"
#include "MeshService.h"
#include "NodeDB.h"
#include "RTC.h"
#include "Router.h"
#include "TypeConversions.h"
#include "airtime.h"
#include "configuration.h"
#include "gps/GeoCoord.h"
#include "gps/RTC.h"
#include "main.h"
#include "mesh/compression/unishox2.h"
#include "meshUtils.h"
Expand Down
2 changes: 1 addition & 1 deletion src/modules/PowerStressModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include "MeshService.h"
#include "NodeDB.h"
#include "PowerMon.h"
#include "RTC.h"
#include "Router.h"
#include "configuration.h"
#include "gps/RTC.h"
#include "main.h"
#include "sleep.h"
#include "target_specific.h"
Expand Down
2 changes: 1 addition & 1 deletion src/modules/RangeTestModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
#include "MeshService.h"
#include "NodeDB.h"
#include "PowerFSM.h"
#include "RTC.h"
#include "Router.h"
#include "SPILock.h"
#include "airtime.h"
#include "configuration.h"
#include "gps/GeoCoord.h"
#include "gps/RTC.h"
#include <Arduino.h>
#include <Throttle.h>

Expand Down
2 changes: 1 addition & 1 deletion src/modules/RemoteHardwareModule.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "RemoteHardwareModule.h"
#include "MeshService.h"
#include "NodeDB.h"
#include "RTC.h"
#include "Router.h"
#include "configuration.h"
#include "gps/RTC.h"
#include "main.h"
#include <Throttle.h>

Expand Down
2 changes: 1 addition & 1 deletion src/modules/SerialModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include "MeshService.h"
#include "NMEAWPL.h"
#include "NodeDB.h"
#include "RTC.h"
#include "Router.h"
#include "configuration.h"
#include "gps/RTC.h"
#include <Arduino.h>
#include <Throttle.h>

Expand Down
Loading
Loading