MoonModules / WLED

Control WS2812B and many more types of digital RGB LEDs with an ESP8266 or ESP32 over WiFi! MoonModules adds features on top of upstream.
https://mm.kno.wled.ge
GNU General Public License v3.0
187 stars 54 forks source link

C6 experiments #138

Open softhack007 opened 1 week ago

softhack007 commented 1 week ago

This is a first, very experimental support for the ESP32-C6 chip. It compiles, but nothing tested on the hardware yet.

Its intended for WLED/MM core developers, to understand better where the differences are. If you don't consider yourself a "core developer", then please ignore this PR and do something meaningful 😛

⚠️ no PWM support yet - so you can't use analog LEDs ⚠️ NeoPixelBus drivers are running in "BitBang" mode, so don't attach more than just a handful of addressable LEDs. ⚠️ Audioreadctive not supported yet, due to massive changes in I2S API

Currently some libraries are not compiling with Arduino Core 3.0.x, so i've forked these and made a few minimal patches to allow compiling. Also I had to make a "no FastLED" version of FastLED, because the clockless RMT driver of fastLED is causing crashes at startup - even when all outputs are managed by NeoPixelBus -> E (423) rmt(legacy): CONFLICT! driver_ng is not allowed to be used with the legacy driver.

softhack007 commented 1 week ago

FastLED bugs out very early.

abort() was called at PC 0x4206c3a1 on core 0
Core  0 register dump:
MEPC    : 0x40803362  RA      : 0x4080770c  SP      : 0x4087e150  GP      : 0x4080cd40  
TP      : 0x00000000  T0      : 0x37363534  T1      : 0x7271706f  T2      : 0x33323130  
S0/FP   : 0x4087e17c  S1      : 0x4087e160  A0      : 0x4087e17c  A1      : 0x4087e15e  
A2      : 0x00000000  A3      : 0x4087e1a9  A4      : 0x00000001  A5      : 0x4081e000  
A6      : 0x00000000  A7      : 0x76757473  S2      : 0x42129000  S3      : 0x40818a74  
S4      : 0x42000000  S5      : 0x40802fcc  S6      : 0x00040020  S7      : 0x000f7b40  
S8      : 0x0002d2e0  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000  
T3      : 0x6e6d6c6b  T4      : 0x6a696867  T5      : 0x66656463  T6      : 0x62613938  
MSTATUS : 0x00001881  MTVEC   : 0x40800001  MCAUSE  : 0x00000007  MTVAL   : 0x00000000  
MHARTID : 0x00000000

Stack memory:
4087e150: 0x00001800 0x0000000c 0x00000000 0x40800030 0x36303234 0x31613363 0x00000000 0x4080f4dc
  #0  0x40800030 in _vector_table at ??:?
  #1  0x4080f4dc in __global_pointer$ at ??:?

4087e170: 0x4087e160 0x4080f4f8 0x4087e15c 0x726f6261 0x20292874 0x20736177 0x6c6c6163 0x61206465
  #0  0x4080f4f8 in __global_pointer$ at ??:?

4087e190: 0x43502074 0x34783020 0x63363032 0x20316133 0x63206e6f 0x2065726f 0x00000030 0x42090000
  #0  0x42090000 in esp_netif_dhcpc_stop_api at esp_netif_lwip.c.obj:?

4087e1b0: 0x42129000 0x4212c55c 0x4212c5ac 0x4206c3a4 0xffff0000 0x00000000 0x00700000 0x42071902
  #0  0x4206c3a4 in check_rmt_legacy_driver_conflict at rmt_legacy.c.obj:?
  #1  0x42071902 in esp_rtc_get_time_us at ??:?

4087e1d0: 0x00040020 0x40802fcc 0x42000000 0x42100000 0x0000004d 0x00000001 0x0000004d 0x40803140
  #0  0x40802fcc in call_start_cpu0 at ??:?
  #1  0x42100000 in _flash_rodata_dummy_start at ??:?
  #2  0x40803140 in call_start_cpu0 at ??:?

4087e1f0: 0xffff0000 0x4212d2ff 0x420f7b5f 0x02625a00 0xffff0000 0x4212d2ff 0x420f7b5f 0x4086f5fc
  #0  0x420f7b5f in intr_handler_set at ??:?
  #1  0x420f7b5f in intr_handler_set at ??:?

4087e210: 0x00000000 0x00100000 0x00010020 0x00040020 0x42100020 0x42000020 0x0002d2e0 0x000f7b40
  #0  0x42000020 in atexit at .pio/libdeps/esp32c6dev_8MB/FastLED/src/FastLED.cpp:254

4087e230: 0x00000000 0x00000000 0x00000000 0x40880000 0x00002f08 0x4004b05c 0x0000ffff 0xffffffff
4087e250: 0x00000000 0x4087e3a0 0x00000000 0x4086f85e 0xc2919723 0x00010000 0x00200000 0x00010000
4087e270: 0x300206e9 0x40802fcc 0x000000ee 0x0000000d 0x00ffff00 0x01000000 0x42100020 0x0002d2e0
  #0  0x40802fcc in call_start_cpu0 at ??:?

4087e290: 0x40800000 0x00002d10 0x42000020 0x000f7b40 0x40802d10 0x00009828 0x4080c540 0x000035c0
  #0  0x40800000 in _vector_table at ??:?
  #1  0x42000020 in atexit at .pio/libdeps/esp32c6dev_8MB/FastLED/src/FastLED.cpp:254
  #2  0x40802d10 in spi_flash_os_yield at spi_flash_os_func_app.c.obj:?
  #3  0x4080c540 in ?? at /builds/idf/crosstool-NG/.build/src/newlib-git-ff0b7d93/newlib/libc/include/time.h:138

4087e2b0: 0x50002000 0x00000004 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4087e2d0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4087e2f0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00010020 0x0003d308
4087e310: 0x00040020 0x00137b68 0x00141398 0x00144960 0x00000000 0x00000000 0x00000000 0x00000000
4087e330: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00134990 0x00000000
4087e350: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4087e370: 0x00002f08 0x4004b05c 0x0000ffff 0x40880000 0x00000000 0x0000005a 0x00002f10 0x4086c478
4087e390: 0x9dc8da6f 0xfad63171 0x00000000 0x00000000 0x0000e000 0x00002000 0x00000000 0x00000000
4087e3b0: 0x00000000 0x00000000 0x00010000 0x00200000 0x00210000 0x00200000 0x00000000 0x00000000
4087e3d0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4087e3f0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4087e410: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4087e430: 0x00000000 0x00000000 0x00000002 0x00000000 0x00000000 0x0000005a 0x00002f10 0x4001b1c0
4087e450: 0x5d39474b 0x31656642 0x910381c0 0x00000000 0x92f8f710 0x00000000 0x00010000 0x300203e9
4087e470: 0x4086c410 0x40875728 0x000000f8 0x000000ee 0x0000000d 0x00ffff00 0x01000000 0x42002f10
  #0  0x42002f10 in mode_chase_flash_random() at wled00/FX.cpp:1072

4087e490: 0x7533885e 0x114b9cce 0xfb8ba4e6 0xd8d6a372 0x323b98bb 0x73177650 0xd7144909 0xc1e25a97
4087e4b0: 0xe106aa86 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4087e4d0: 0x00000000 0x4087e5f0 0x00000101 0x00000002 0x114b9cce 0xfb8ba4e6 0xd8d6a372 0x323b98bb
4087e4f0: 0x73177650 0xd7144909 0xc1e25a97 0xe106aa86 0x00000000 0x00000000 0x00000000 0x00000000
4087e510: 0x00000000 0x00000000 0x00000000 0x00000000 0x86ea7240 0x00000140 0x00000000 0x5a000000
softhack007 commented 1 week ago

Update: its still mysterious, however something to do with RMT 🤔

E (423) rmt(legacy): CONFLICT! driver_ng is not allowed to be used with the legacy driver

E (423) rmt(legacy): CONFLICT! driver_ng is not allowed to be used with the legacy driver

abort() was called at PC 0x420a3635 on core 0
Core  0 register dump:
MEPC    : 0x40803e0a  RA      : 0x4080975c  SP      : 0x4087e140  GP      : 0x40811ce0  
TP      : 0x00000000  T0      : 0x37363534  T1      : 0x7271706f  T2      : 0x33323130  
S0/FP   : 0x4087e16c  S1      : 0x4087e16c  A0      : 0x4087e178  A1      : 0x4087e15a  
A2      : 0x00000000  A3      : 0x4087e1a5  A4      : 0x00000001  A5      : 0x40823000  
A6      : 0x00000000  A7      : 0x76757473  S2      : 0x421a9000  S3      : 0x4081e194  
S4      : 0x42160000  S5      : 0x42000000  S6      : 0x40803a38  S7      : 0x0015cdb0  
S8      : 0x00074780  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000  
T3      : 0x6e6d6c6b  T4      : 0x6a696867  T5      : 0x66656463  T6      : 0x62613938  
MSTATUS : 0x00001881  MTVEC   : 0x40800001  MCAUSE  : 0x00000007  MTVAL   : 0x00000000  
MHARTID : 0x00000000  

Stack memory:
4087e140: 0x00000000 0x00000000 0x4087e16c 0x4080ea0e 0x40803a38 0x42000000 0x42160030 0x4081498c
  #0  0x4080ea0e in __assert_func at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/newlib/assert.c:34
  #1  0x40803a38 in rv_utils_dbgr_is_attached at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/riscv/include/riscv/rv_utils.h:203
      (inlined by) esp_cpu_dbgr_is_attached at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_hw_support/include/esp_cpu.h:506
      (inlined by) call_start_cpu0 at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/port/cpu_start.c:307
  #2  0x4081498c in __global_pointer$ at ??:?

4087e160: 0x4087e16c 0x408149a8 0x4087e158 0x61303234 0x35333633 0x28010200 0x726f6261 0x20292874
  #0  0x408149a8 in __global_pointer$ at ??:?

4087e180: 0x20736177 0x6c6c6163 0x61206465 0x43502074 0x34783020 0x33613032 0x20353336 0x63206e6f
4087e1a0: 0x2065726f 0x00000030 0x42180000 0x4eb09137 0x20001090 0x421b5ad4 0x421b5b24 0x420a3638
  #0  0x420a3638 in check_rmt_legacy_driver_conflict at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/driver/deprecated/rmt_legacy.c:1380 (discriminator 3)

4087e1c0: 0x421a9000 0x421b5ad4 0x421b5b30 0x420a95f4 0x0000004d 0x00000001 0x0000004d 0x420a8cc2
  #0  0x420a95f4 in do_global_ctors at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/startup.c:203
      (inlined by) start_cpu0_default at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/startup.c:486
  #1  0x420a8cc2 in esp_cache_err_int_init at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/port/soc/esp32c6/cache_err_int.c:39

4087e1e0: 0x0000004d 0x00000001 0x0000004d 0x40803ba6 0x43000000 0x421d479f 0x4215cdcf 0x42000000
  #0  0x40803ba6 in call_start_cpu0 at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/port/cpu_start.c:706
  #1  0x4215cdcf in _flash_rodata_dummy_start at ??:?

4087e200: 0x43000000 0x421d479f 0x4215cdcf 0x4086f834 0x5218a20c 0x00160000 0x00010020 0x00090020
  #0  0x4215cdcf in _flash_rodata_dummy_start at ??:?

4087e220: 0x42160020 0x42000020 0x00074780 0x0015cdb0 0x00010000 0x00200000 0x00000000 0x40880000
  #0  0x42160020 in ?? at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_app_format/esp_app_desc.c:15
  #1  0x42000020 in CRGB::operator+=(CRGB const&) at .pio/libdeps/esp32c6dev_8MB/FastLED/src/pixeltypes.h:268

4087e240: 0x00003958 0x4004b05c 0x0000ffff 0xffffffff 0x00000000 0x4087e3a0 0x00000000 0x4086fae0
4087e260: 0xd293b723 0x00010000 0x00200000 0x00010000 0x300206e9 0x40803a38 0x000000ee 0x0000000d
  #0  0x40803a38 in rv_utils_dbgr_is_attached at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/riscv/include/riscv/rv_utils.h:203
      (inlined by) esp_cpu_dbgr_is_attached at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_hw_support/include/esp_cpu.h:506
      (inlined by) call_start_cpu0 at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/port/cpu_start.c:307

4087e280: 0x00ffff00 0x01000000 0x42160020 0x00074780 0x40800000 0x0000b870 0x42000020 0x0015cdb0
  #0  0x42160020 in ?? at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_app_format/esp_app_desc.c:15
  #1  0x40800000 in _vector_table at ??:?
  #2  0x42000020 in CRGB::operator+=(CRGB const&) at .pio/libdeps/esp32c6dev_8MB/FastLED/src/pixeltypes.h:268
4087e2a0: 0x4080b870 0x00005c68 0x408114e0 0x00003d10 0x50000000 0x00000004 0x00000000 0x00000000
  #0  0x4080b870 in xTaskPriorityInherit at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/FreeRTOS-Kernel/tasks.c:5221
  #1  0x50000000 in ?? at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_hw_support/sleep_modes.c:247

4087e2c0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4087e2e0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4087e300: 0x00000000 0x00000000 0x00010020 0x000847a8 0x00090020 0x001ecdd8 0x001f2a48 0x001f6760
4087e320: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4087e340: 0x00000000 0x00000000 0x001e6790 0x151bebf1 0x818fb06d 0xadd2df6e 0x98db8280 0x5218a20c
4087e360: 0xc2d7f6c1 0x7c26ddbe 0x325cbccd 0x00000000 0xffffffff 0x00000010 0x0000000a 0x40880000
4087e380: 0x00000000 0x000000cf 0x00003960 0x4086c476 0x8d88da2f 0xfa563071 0x00000000 0x00000000
4087e3a0: 0x0000e000 0x00002000 0x00000000 0x00000000 0x00000000 0x00000000 0x00010000 0x00200000
4087e3c0: 0x00210000 0x00200000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4087e3e0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4087e400: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4087e420: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000002 0x00000000
4087e440: 0x60002000 0x00000100 0x00000020 0x4001b1c0 0x5939474b 0x31e5e6ca 0x910381c0 0x00000000
4087e460: 0x9278f710 0x00000000 0x00010000 0x300203e9 0x4086c410 0x40875728 0x00000594 0x000000ee
4087e480: 0x0000000d 0x00ffff00 0x01000000 0x42003960 0x7533885e 0x88a0ebf5 0xb4069687 0x84dc75ea
  #0  0x42003960 in std::vector<Segment, std::allocator<Segment> >::operator[](unsigned int) at c:\tools\pio_pkg\toolchain-riscv32-esp\riscv32-esp-elf\include\c++\12.2.0\bits/stl_vector.h:1124
      (inlined by) mode_random_chase() at wled00/FX.cpp:1791

4087e4a0: 0xe59e24f9 0x758a850e 0x6a0a0365 0x49a7c3ac 0x01d3171d 0x00000000 0x00000000 0x00000000
4087e4c0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x4087e5f0 0x00000101 0x00000002
4087e4e0: 0x88a0ebf5 0xb4069687 0x84dc75ea 0xe59e24f9 0x758a850e 0x6a0a0365 0x49a7c3ac 0x01d3171d
4087e500: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4087e520: 0x69676572 0x775f6332 0x65746972 0x73616d5f 0x6d695f6b 0x00006c70 0x00000000 0xcf000000

ELF file SHA256: 5fd475acd8a7ccfc

Rebooting...


Edit: in practice any firmware that still uses the "old" RMT driver might crash, because arduino-esp32 v3.0.x itself links in the new RMT driver -> legacy driver conflict. Looks like a workaround - in some cases - is to make sure that RGB_BUILTIN is not defined.

softhack007 commented 1 week ago

its booting into WLED 🥳 🚀 Seems that FastLED was causing all the troubles -> -DFASTLED_NO_FASTLED did the trick.

=========== Before Setup Start ===========
Chip Info:
------------------------------------------
  Model             : ESP32-C6
  Package           : 0       
  Revision          : 0       
  Cores             : 1       
  Frequency         : 160 MHz 
  Embedded Flash    : No      
  Embedded PSRAM    : No      
  2.4GHz WiFi       : Yes     
  Classic BT        : No      
  BT Low Energy     : Yes     
  IEEE 802.15.4     : Yes
------------------------------------------  
INTERNAL Memory Info:
------------------------------------------  
  Total Size        :   393304 B ( 384.1 KB)
  Free Bytes        :   357732 B ( 349.3 KB)
  Allocated Bytes   :    29148 B (  28.5 KB)
  Minimum Free Bytes:   357568 B ( 349.2 KB)
  Largest Free Block:   335860 B ( 328.0 KB)
------------------------------------------  
Flash Info:
------------------------------------------  
  Chip Size         :  8388608 B (8 MB)     
  Block Size        :    65536 B (  64.0 KB)
  Sector Size       :     4096 B (   4.0 KB)
  Page Size         :      256 B (   0.2 KB)
  Bus Speed         : 40 MHz
  Bus Mode          : QIO
------------------------------------------
Partitions Info:
------------------------------------------
                nvs : addr: 0x00009000, size:    20.0 KB, type: DATA, subtype: NVS
            otadata : addr: 0x0000E000, size:     8.0 KB, type: DATA, subtype: OTA
               app0 : addr: 0x00010000, size:  2048.0 KB, type:  APP, subtype: OTA_0
               app1 : addr: 0x00210000, size:  2048.0 KB, type:  APP, subtype: OTA_1
             spiffs : addr: 0x00410000, size:  3968.0 KB, type: DATA, subtype: SPIFFS
           coredump : addr: 0x007F0000, size:    64.0 KB, type: DATA, subtype: COREDUMP
------------------------------------------
Software Info:
------------------------------------------
  Compile Date/Time : Jun 14 2024 13:30:20
  ESP-IDF Version   : v5.1.4-51-g442a798083-dirty
  Arduino Version   : 3.0.1
------------------------------------------
Board Info:
------------------------------------------
  Arduino Board     : Espressif ESP32-C6-DevKitC-1
  Arduino Variant   : esp32c6
  Core Debug Level  : 4
  Arduino Runs Core : 0
  Arduino Events on : 0
  Arduino USB Mode  : 1
  CDC On Boot       : 0
============ Before Setup End ============

---WLED 0.14.1-b31.38 2405241 INIT---
 WLEDMM_0.14.1-b31.38 1-C6_8MB, build 2405241.
CPU:   ESP32-C6 rev.0, 1 core(s), 160MHz.
CPU    Restart due to power-on event (code 1). Core#0 power-on (1).
FLASH: 8MB, Mode 0, speed 80MHz.

Mounting FS ...
Mount FS succeeded.
done Mounting FS; 3956 kB free.

(BitBang) Successfully inited strip 0 (len 30) with type 22 and pin 2 (itype 21)

Usermods setup ...

Ada

GPIO    | Assigned to           | Info
--------|-----------------------|------------
i/o   0   Button
i/o   1   ./.
i/o   2   LEDs (digital)          (default) LED pin
i/o   3   ./.
i/o   4   ./.
i/o   5   ./.
i/o   6   ./.
i/o   7   ./.
i/o   8   ./.
i/o   9   ./.
i/o  10   ./.
i/o  11   ./.
i/o  14   ./.
i/o  15   ./.
i/o  16   ./.                     Serial TX
i/o  17   ./.                     Serial RX
i/o  18   ./.
i/o  19   ./.
i/o  20   ./.
i/o  21   ./.
i/o  22   ./.
i/o  23   ./.
WLED initialization done.

Ada

=========== After Setup Start ============
INTERNAL Memory Info:
------------------------------------------
  Total Size        :   393304 B ( 384.1 KB)
  Free Bytes        :   353280 B ( 345.0 KB)
  Allocated Bytes   :    32064 B (  31.3 KB)
  Minimum Free Bytes:   353176 B ( 344.9 KB)
  Largest Free Block:   335860 B ( 328.0 KB)
------------------------------------------
GPIO Info:
------------------------------------------
  GPIO : BUS_TYPE[bus/unit][chan]
  --------------------------------------  
     0 : GPIO
     2 : GPIO
    16 : UART_TX[0]
    17 : UART_RX[0]
============ After Setup End =============
softhack007 commented 1 week ago

ESPHome seem to have their own version of AsynTCP and AsyncWebServer, maintained regularly. Might be worth to give them a try on -C6.

ewoudwijma commented 1 week ago

@softhack007 , didn’t WLED AC updated their version of espasyncwebserved recently ? Maybe the same as esphime uses?

softhack007 commented 2 days ago

Espressif has declared commonly used network API's as "deprecated" - WiFiClient, WiFiServer, WiFiUdp and WiFiClientSecure There are replacements, however with more differences than just new names 😢 https://github.com/espressif/arduino-esp32/commit/ad1de0b37c8208aab4d0fee60d13c3330a3fd789

another area where lots of rework will be needed, just to keep existing features working on new chips like -C6. I'm not amused.

softhack007 commented 2 days ago

Known problem: IP address is always shown as "0.0.0.0" in info page -> might also cause some connection problems in WS or Web UI.