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

Add initial support for ESP32-C3 #2454

Merged
merged 4 commits into from Jan 24, 2022
Merged

Add initial support for ESP32-C3 #2454

merged 4 commits into from Jan 24, 2022

Conversation

misery
Copy link
Contributor

@misery misery commented Dec 27, 2021

This is based on my other pull request for ESP32-S2: #2452
Once it is merged I will rebase this PR as it requires same changes in ESPAsyncWebServer: Aircoookie/ESPAsyncWebServer#4

Also this change requires current master branch version bump of:

TODO

espressif/arduino-esp32#5502

Linking .pio/build/esp32c3/firmware.elf
/home/andre/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld: .pio/build/esp32c3/src/blynk.cpp.o: in function `BlynkApi<BlynkProtocol<BlynkArduinoClientGen<Client> > >::processCmd(void const*, unsigned int)':
/home/andre/git/WLED/wled00/src/dependencies/blynk/Blynk/BlynkApiArduino.h:93: undefined reference to `esp32_adc2gpio'
/home/andre/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld: /home/andre/git/WLED/wled00/src/dependencies/blynk/Blynk/BlynkApiArduino.h:93: undefined reference to `esp32_adc2gpio'
/home/andre/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld: /home/andre/git/WLED/wled00/src/dependencies/blynk/Blynk/BlynkApiArduino.h:95: undefined reference to `esp32_adc2gpio'
/home/andre/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld: /home/andre/git/WLED/wled00/src/dependencies/blynk/Blynk/BlynkApiArduino.h:101: undefined reference to `esp32_adc2gpio'
/home/andre/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld: .pio/build/esp32c3/src/button.cpp.o: in function `isButtonPressed(unsigned char)':
/home/andre/git/WLED/wled00/button.cpp:89: undefined reference to `touchRead'
collect2: error: ld returned 1 exit status
*** [.pio/build/esp32c3/firmware.elf] Error 1

@misery
Copy link
Contributor Author

misery commented Dec 27, 2021

Fixes #1940

@misery
Copy link
Contributor Author

misery commented Dec 28, 2021

Work-Around for espressif/arduino-esp32#5502 in https://github.com/misery/arduino-esp32/commit/7936842c926e3af2819bcf81822d290caa07ccae

Work-Around: Remove it for now... seems the weak symbol is not included in.pio/build/esp32c3/FrameworkArduino/esp32-hal-touch.c.o at the moment.

/home/andre/git/WLED/wled00/button.cpp:89: undefined reference to `touchRead'

@misery misery mentioned this pull request Dec 28, 2021
@Jason2866
Copy link
Contributor

Jason2866 commented Dec 28, 2021

You use the old risc toolchain. Not recommended -> compiler bugs.
Actual used for core 2.0.2 is espressif/toolchain-riscv32-esp @ 8.4.0+2021r2
LittleFS is included in Arduino Core 2.0.2. No need to add as lib

@misery
Copy link
Contributor Author

misery commented Dec 28, 2021

Thanks! I look into it tomorrow. 🙂

LittleFS is not included for S2 and C3.

@misery
Copy link
Contributor Author

misery commented Jan 8, 2022

I got my C3 today. Seems there is something broken.

ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT)
Saved PC:0x40382762
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd6100,len:0x420
load:0x403ce000,len:0x90c
load:0x403d0000,len:0x236c
SHA-256 comparison failed:
Calculated: ccb0d00bac7e84e1d90a12e4f75f4ab6c5f7e71bb209afd5819c4c9557a6db71
Expected: c9cf160580940ec7801c73b16423824e72ad12055c732e83ce66332240af42a7
Attempting to boot anyway...
entry 0x403ce000

---WLED 0.13.0-b6 2112080 INIT---
esp32 v4.4-beta1-189-ga79dc75f0a
heap 238588
Registering usermods ...
Reading config
Reading settings from /wsec.json...
[   302][E][vfs_api.cpp:102] open(): /littlefs/wsec.json does not exist, no permits for creation
JSON buffer released. (3)
Restore settings from EEPROM
EEPROM settings invalid, using defaults...
Writing settings to /wsec.json...
E (329) esp_littlefs_api: failed to read addr 00001000, size 00000080, err 262
E (334) esp_littlefs_api: failed to read addr 00000000, size 00000080, err 262
E (342) esp_littlefs_api: failed to read addr 00001000, size 00000080, err 262
E (351) esp_littlefs_api: failed to read addr 00000000, size 00000080, err 262
[   347][E][vfs_api.cpp:308] VFSFileImpl(): fopen(/littlefs/wsec.json) failed
J
***ERROR*** A stack overflow in task loopTask has been detected.
Core  0 register dump:
MEPC    : 0x40382b20  RA      : 0x40387c88  SP      : 0x3fc9a640  GP      : 0x3fc8f000  
TP      : 0x3fc6b474  T0      : 0x4005890e  T1      : 0x0000000f  T2      : 0x00000001  
S0/FP   : 0x3fc9a664  S1      : 0x3fc9a664  A0      : 0x3fc9a664  A1      : 0x3c1614a8  
A2      : 0x0000000f  A3      : 0x3fc9a692  A4      : 0x00000001  A5      : 0x3fc9e000  
A6      : 0xa0000000  A7      : 0x0000000a  S2      : 0x00001881  S3      : 0x3fc9e714  
S4      : 0x00000016  S5      : 0x00000017  S6      : 0x00000000  S7      : 0x3c135f05  
S8      : 0x00000000  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000001  
T3      : 0x00000000  T4      : 0x00000000  T5      : 0x00000001  T6      : 0xffffffff  
MSTATUS : 0x00001801  MTVEC   : 0x40380001  MCAUSE  : 0x00000007  MTVAL   : 0x00000000  
MHARTID : 0x00000000  

Stack memory:
3fc9a640: 0x00000000 0x00000000 0x00000000 0x4038aac0 0x00000000 0x00000000 0x3c16146c 0x3fca57ec
3fc9a660: 0x3c161494 0x452a2a2a 0x524f5252 0x202a2a2a 0x74732041 0x206b6361 0x7265766f 0x776f6c66
3fc9a680: 0x206e6920 0x6b736174 0x6f6f6c20 0x73615470 0x6168206b 0x65622073 0x64206e65 0x63657465
3fc9a6a0: 0x2e646574 0x00000000 0x00000000 0x3c000000 0x400481b0 0x3fc9e6e0 0x3fca5f70 0x403898e8
3fc9a6c0: 0x03ffffff 0x3fc9e6dc 0x00000000 0x40387df6 0x00000000 0x00000000 0x00000000 0x3c135f05
3fc9a6e0: 0x00000000 0x00000017 0x00000016 0x00000001 0x00001881 0x80000004 0x3fca5f70 0x40387d04
3fc9a700: 0x403801b8 0x80000007 0x3fca5f70 0x4038019c 0x00000001 0x3fc9a718 0xffffffff 0x3fca2708
3fc9a720: 0x3fca2708 0x00000000 0x3fc9a72c 0xffffffff 0x3fc9a72c 0x3fc9a72c 0x00000000 0x3fc9a740
3fc9a740: 0xffffffff 0x3fc9a740 0x3fc9a740 0x00000000 0x3fc9a754 0xffffffff 0x3fc9a754 0x3fc9a754
3fc9a760: 0x00000000 0x3fc9a768 0xffffffff 0x3fc9a768 0x3fc9a768 0x00000000 0x3fc9a77c 0xffffffff
3fc9a780: 0x3fc9a77c 0x3fc9a77c 0x00000000 0x3fc9a790 0xffffffff 0x3fc9a790 0x3fc9a790 0x00000000
3fc9a7a0: 0x3fc9a7a4 0xffffffff 0x3fc9a7a4 0x3fc9a7a4 0x00000000 0x3fc9a7b8 0xffffffff 0x3fc9a7b8
3fc9a7c0: 0x3fc9a7b8 0x00000000 0x3fc9a7cc 0xffffffff 0x3fc9a7cc 0x3fc9a7cc 0x00000000 0x3fc9a7e0
3fc9a7e0: 0xffffffff 0x3fc9a7e0 0x3fc9a7e0 0x00000000 0x3fc9a7f4 0xffffffff 0x3fc9a7f4 0x3fc9a7f4
3fc9a800: 0x00000000 0x3fc9a808 0xffffffff 0x3fc9a808 0x3fc9a808 0x00000000 0x3fc9a81c 0xffffffff
3fc9a820: 0x3fc9a81c 0x3fc9a81c 0x00000000 0x3fc9a830 0xffffffff 0x3fc9a830 0x3fc9a830 0x00000000
3fc9a840: 0x3fc9a844 0xffffffff 0x3fc9a844 0x3fc9a844 0x00000000 0x3fc9a858 0xffffffff 0x3fc9a858
3fc9a860: 0x3fc9a858 0x00000000 0x3fc9a86c 0xffffffff 0x3fc9a86c 0x3fc9a86c 0x00000000 0x3fc9a880
3fc9a880: 0xffffffff 0x3fc9a880 0x3fc9a880 0x00000000 0x3fc9a894 0xffffffff 0x3fc9a894 0x3fc9a894
3fc9a8a0: 0x00000000 0x3fc9a8a8 0xffffffff 0x3fc9a8a8 0x3fc9a8a8 0x00000000 0x3fc9a8bc 0xffffffff
3fc9a8c0: 0x3fc9a8bc 0x3fc9a8bc 0x00000000 0x3fc9a8d0 0xffffffff 0x3fc9a8d0 0x3fc9a8d0 0x00000000
3fc9a8e0: 0x3fc9a8e4 0xffffffff 0x3fc9a8e4 0x3fc9a8e4 0x00000000 0x3fc9a8f8 0xffffffff 0x3fc9a8f8
3fc9a900: 0x3fc9a8f8 0x00000000 0x3fc9a90c 0xffffffff 0x3fc9a90c 0x3fc9a90c 0x00000000 0x3fc9a920
3fc9a920: 0xffffffff 0x3fc9a920 0x3fc9a920 0x00000000 0x3fc9a934 0xffffffff 0x3fc9a934 0x3fc9a934
3fc9a940: 0x00000002 0x3fc9a948 0xffffffff 0x3fca1330 0x3fca57bc 0x00000000 0x3fc9a95c 0xffffffff
3fc9a960: 0x3fc9a95c 0x3fc9a95c 0x00000000 0x3fc9a968 0x00000000 0x00000000 0x00000000 0x3fc9a980
3fc9a980: 0xffffffff 0x3fc9a980 0x3fc9a980 0x00000000 0x3fc9a994 0xffffffff 0x3fc9a994 0x3fc9a994
3fc9a9a0: 0x00000001 0x00000001 0x00000000 0x0001ffff 0x00000000 0xb33fffff 0x00000000 0x00000000
3fc9a9c0: 0x3fc9a9bc 0x00000000 0x00000000 0x00000000 0x3fc9a9d4 0xffffffff 0x3fc9a9d4 0x3fc9a9d4
3fc9a9e0: 0x00000000 0x3fc9a9e8 0xffffffff 0x3fc9a9e8 0x3fc9a9e8 0x00000001 0x00000001 0x00000000
3fc9aa00: 0x0001ffff 0x00000000 0xb33fffff 0x00000000 0x00000000 0x3fc9f8fc 0x3fc9f964 0x3fc9f9cc
3fc9aa20: 0x00000000 0x00000000 0x00000001 0x00000000 0x00000000 0x00000000 0x42118724 0x00000000



ELF file SHA256: 0000000000000000

Rebooting...

@Jason2866
Copy link
Contributor

Jason2866 commented Jan 8, 2022

The C3 does boot when i use this settings. The env for the S2 is not optimal.

[env:esp32s2_saola]
board = esp32-s2-saola-1
board_build.mcu = esp32s2
platform = https://github.com/tasmota/platform-espressif32/releases/download/v2.0.2/platform-tasmota-espressif32-2.0.2.zip
platform_packages =
framework = arduino
board_build.partitions = tools/WLED_ESP32_4MB_1MB_FS.csv
upload_speed = 460800
build_unflags = ${common.build_unflags}
lib_deps = ${esp32s2.lib_deps}

[env:esp32c3]
board = esp32-c3-devkitm-1
platform = https://github.com/tasmota/platform-espressif32/releases/download/v2.0.2/platform-tasmota-espressif32-2.0.2.zip
platform_packages = framework-arduinoespressif32 @ https://github.com/misery/arduino-esp32.git#esp32_adc2gpio
framework = arduino
board_build.partitions = tools/WLED_ESP32_4MB_1MB_FS.csv
upload_port = /dev/cu.usbserial-11340
upload_speed = 460800
build_unflags = ${common.build_unflags}
lib_deps = ${esp32c3.lib_deps}
mode:DOUT, clock div:1
load:0x3fcd6100,len:0x38c
load:0x403ce000,len:0x6a8
load:0x403d0000,len:0x236c
SHA-256 comparison failed:
Calculated: 17d2a8f618ee550ef57d330dbea7faa9a623bc54de0b6dbc92de48eee7ac5698
Expected: 14e81a57243feb4140f9b1b04dd7b025cf8ce73076948dee6a7502002f2730f5
Attempting to boot anyway...
entry 0x403ce000
[   327][E][vfs_api.cpp:102] open(): /littlefs/ledmap.json does not exist, no permits for creation
Ada

Bildschirmfoto 2022-01-08 um 20 10 30

@Jason2866
Copy link
Contributor

Jason2866 commented Jan 21, 2022

@misery Did a complete platform build. Latest IDF4.4 and Arduino ESP32 from today.
(Includes your C3 fix too). Supports ESP32, ESP32-S2 and ESP32-C3

platform = https://github.com/tasmota/platform-espressif32/releases/download/v2.0.2.1/platform-tasmota-espressif32-2.0.2.1.zip

uses newest espressif toolchains 8.4.0 2021r2 patch2

@misery misery changed the title WIP Add initial support for ESP32-C3 Add initial support for ESP32-C3 Jan 21, 2022
@misery misery marked this pull request as ready for review January 21, 2022 18:52
@misery
Copy link
Contributor Author

misery commented Jan 21, 2022

@Jason2866 Thank you very much! It works great! Even my C3 starts now and I can remove the work-arounds. So we can start a review now. :-)

@Aircoookie
Copy link
Owner

Merging now. I don't have a C3 unit to test yet though.

@Aircoookie Aircoookie merged commit eca980d into Aircoookie:master Jan 24, 2022
@misery misery deleted the c3 branch January 24, 2022 11:07
@AskAlice
Copy link

does this still work on the latest master? i'm getting littlefs errors

@Linjieqiang
Copy link

Is it ready to support esp32-c3?

@softhack007 softhack007 added the board request PR adding support for a specific board. label Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
board request PR adding support for a specific board.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants