-
-
Notifications
You must be signed in to change notification settings - Fork 28
Support ESP32-C3 #1217
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
Comments
Got mine yesterday and have it working in Arduino IDE using https://github.com/espressif/arduino-esp32#master Thankyou. |
@stintel I created a PR (esphome/esphome#1433) to support my ESP32-S2 for 1.18.0. https://github.com/espressif/arduino-esp32/releases/tag/2.0.0-alpha1 supports both now. So maybe it should work, too. Could you try this? Does it work?
I don't have a C3 yet. So please post the compile errors here. :-) |
Still waiting for mine, and the estimated shipment date changed today: But thanks in advance, and I'll definitely try it out once I get my C3s. |
Hi, I tried your suggestion and got the following with an error of failed. Running Esphome v1.19.0-dev. INFO Reading configuration /config/esphome/esp32-c.yaml...
|
Hi, thanks.... I tried to compile it myself now. Found in platformio/platform-espressif32#497 that someone added the toolchain for it.
I have some compile errors now. I will look into it later. |
Fixed some compile errors. Please check if this helps to run a simple test. I dont' have any C3 here to execute the binary. ESPAsyncWebServer
Can be fixed like this until it is merged.
Another TODO with GPIO usage:
|
Hi, Regards, Tool Manager: Installing toolchain-riscv32 @ ~1.80400.0 |
It will be installed automatically. Seems linux_aarch64 is not supported at the moment. I used Linux x86_64 here. |
tried this out (my esp32c-c3 arrived today) with this config and got a whole bunch of errors like this
did you manage to get a binary? |
See my referenced pull requests. This should fix this. But maybe leads to a linker error at the moment. Yes, I have a simple binary. But no C3 to test it. |
@misery I was able to build a binary after applying your PRs. Unfortunately I'm unable to flash it, as esphome-flasher also doesn't support C3 yet. I'm working on adding support here: https://github.com/stintel/esphome-flasher/tree/esp32c3. |
Flashed firmware.bin with esptool at the offset of the ota_0 partition, now getting an error about unable to set CPU clock:
|
Try to change 240 MHz to 160 MHz. C3 has 160 MHz only. |
Thanks for the suggestion. I was trying to find where this is set already, but today is the first time I look at any of the esphome related code so it's not going very fast. Is there maybe an IRC channel where I could ask things like this? |
I can look into it later if I have more than a Smartphone. 😉 Esphome has a discord: https://discord.gg/KhAMKrd |
Alright found it. Your example uses board nodemcu-32s, which runs at 240MHz. The only board supported by platform-espressif32 that runs at 160MHz is bpi-bit; using that makes the CPU clock error disappear. I guess I'll be forking platform-espressif32 and add some more changes. |
So I forked platform-espressif32, and am using this config now:
This seems to trigger a watchdog timeout:
|
After enabling debug, it seems the watchdog message is not fatal, my ESP32-C3 connects to my WiFi and a GPIO motion sensor seems to be working fine. My current changes to esphome: diff --git a/esphome/components/debug/debug_component.cpp b/esphome/components/debug/debug_component.cpp
index 4ffc034d..e1715fc9 100644
--- a/esphome/components/debug/debug_component.cpp
+++ b/esphome/components/debug/debug_component.cpp
@@ -5,8 +5,12 @@
#include "esphome/core/version.h"
#ifdef ARDUINO_ARCH_ESP32
+#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 4, 0)
+#include <esp32/rom/rtc.h>
+#else
#include <rom/rtc.h>
#endif
+#endif
namespace esphome {
namespace debug {
diff --git a/esphome/pins.py b/esphome/pins.py
index fef77f39..b90edbcc 100644
--- a/esphome/pins.py
+++ b/esphome/pins.py
@@ -348,6 +348,7 @@ ESP32_BOARD_PINS = {
"SS": 15,
},
"esp-wrover-kit": {},
+ "esp32-c3-dev": {},
"esp32-devkitlipo": {},
"esp32-evb": {
"BUTTON": 34, |
Enabling the Home Assistant API causes a compile error:
Can be solved by this change: diff --git a/esphome/components/api/user_services.cpp b/esphome/components/api/user_services.cpp
index 39e42bcc..e4fc4899 100644
--- a/esphome/components/api/user_services.cpp
+++ b/esphome/components/api/user_services.cpp
@@ -15,9 +15,16 @@ template<> std::string get_execute_arg_value<std::string>(const ExecuteServiceAr
template<> std::vector<bool> get_execute_arg_value<std::vector<bool>>(const ExecuteServiceArgument &arg) {
return arg.bool_array;
}
+
+#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4, 4, 0)
template<> std::vector<int> get_execute_arg_value<std::vector<int>>(const ExecuteServiceArgument &arg) {
return arg.int_array;
}
+#else
+template<> std::vector<long int> get_execute_arg_value<std::vector<long int>>(const ExecuteServiceArgument &arg) {
+ return arg.int_array;
+}
+#endif
template<> std::vector<float> get_execute_arg_value<std::vector<float>>(const ExecuteServiceArgument &arg) {
return arg.float_array;
} |
I'll double check if my changes are correct, and will submit a PR for them in the coming days, but I welcome any feedback before that. |
I was getting "Error: Unknown board ID" with a custom board I'm developing. This seems to be working, still testing. esphome: |
I successfully flashed a ESP32-C3 using the changes and yaml from this pull-request: The GPIO fix is mostly adopted from @misery's PR. I can successfully connect to WiFi and connect to it using Home Assistant. Haven't tested more than that currently :) |
Great, I flashed a ESP32-C3 with the new DEV ESPhome, and used 4 GPIOs as switches ok, and 1 as a GPIO binary sensor
When I get some more time I've got some PWM led board that I was going to try the C3 on. |
@jeggleston1981 thanks for testing and this summary.
|
@agners thanks for picking this up. Due to travel to my home country for the first time since the start of the pandemic, and an unexpected new job, I haven't found the time to continue on this. Seems esp32-c3 support made it in platform-espressif32 v3.3.0. Unfortunately, support for the arduino framework was left out of the board file. Ive submitted platformio/platform-espressif32#590 to fix this. For now, you can keep pulling it from my fork. |
@stintel that isn't the whole change necessary, the Currently the platform.io repository don't carry a newer version than 1.0.6 for But there are more 🐌 : It seems that the latest Arduino ESP32 v2.0.0-rc1 release uses a new toolchain. At least with the current toolchain pulled in by
Using the latest
Where That isn't taking care of ESPAsyncWebSever fixes yet, but they are under way. Things should become simpler soon :) |
You clearly know more about this than me :-) Though for me it builds fine with the yaml I posted here. I have actually 4 C3s running with that already. |
Hard earned the last two days or so :)
You are using master for
Cool! I have no C3 in "production" yet, but I am testing with the two dev boards I have. I am running an ESP32 with Arduino 2.0.0-rc1 to see how it behaves, looks good so far. |
Actually Jason8266 in @stintel's platformio/platform-espressif32#590 PR brought up a good point: There is already support for the latest Arduino framework version in the This simplifies the above config to: esphome:
name: esp32-c3-test
platform: ESP32
board: esp32-c3-devkitm-1
platformio_options:
platform: https://github.com/platformio/platform-espressif32#feature/arduino-idf-master Still fixes for ESPAsyncWebSever and esphome/esphome#2062 needed. But I think I'll be able to get this sorted soon. Update: Fixed the config above. Also the ESPAsyncWebSever is merged, so from today's (2021-07-29) nightly on building for ESP32-C3 works with just the above config 🎉 |
Fails to compile with that code. Platform Manager: Installing git+https://github.com/platformio/platform-espressif32/tree/feature/arduino-idf-master |
@digiblur whoops there's a typo. Fixed it in the config above. |
Getting closer ;) Linking .pioenvs/esp32c3ble/firmware.elf |
@digiblur hm, it seems an old toolchain still getting used. Can you remove |
I did get it to compile a day or two ago but it doesn't seem to boot. [07:29:13]SPIWP:0xee |
Hi, deep_sleep: Regards, src/esphome/components/deep_sleep/deep_sleep_component.cpp: In member function 'void esphome::deep_sleep::DeepSleepComponent::begin_sleep(bool)': |
@markusg1234 haven't tested sleeping modes so far, interesting find. Can you open a new issue? |
In general, as basic support for ESP32-C3 is in, I think it make sense to track further issues/missing pieces via issue tracker. Feel free to tag me in those issues. |
@digiblur I do get this now too, try this option:
I am pretty sure that Platform.IO's board configuration used QIO from the beginning, and it did work at one point. It seems that some change in Arduino/Platform.IO in late July/early August broke QIO support. |
@agners Here's my config:
When I try to compile, I get this error:
|
Note: This setup for using ESP32-C3 will not be supported in the future. Specifically, using Arduino as the base framework. Instead, ESP32-C3 should be used through esp-idf. In the future that will be like so: esp32:
board: esp32-c3-devkitm-1
framework:
type: esp-idf
# currently needed, but not in the future
variant: ESP32C3 |
Support ESP32-C3
The ESP32-C3 is a RISC-V based ESP. It would be nice if esphome supported this.
ESP32-C3-DevKitM-1 can be ordered from e.g. Mouser. Estimated shipping date for mine is 17/05. I'm willing to donate 1 or 2 if needed.
The text was updated successfully, but these errors were encountered: