Skip to content

feat(idf-v6, board, lua): IDF v6.0.1 compat + WT32-SC01 Plus board + CAN bus Lua driver#86

Closed
ayyaris wants to merge 1 commit into
espressif:masterfrom
ayyaris:master
Closed

feat(idf-v6, board, lua): IDF v6.0.1 compat + WT32-SC01 Plus board + CAN bus Lua driver#86
ayyaris wants to merge 1 commit into
espressif:masterfrom
ayyaris:master

Conversation

@ayyaris

@ayyaris ayyaris commented May 17, 2026

Copy link
Copy Markdown

Summary

Three independent contributions bundled in one branch:

1. ESP-IDF v6.0.1 compatibility

  • driver component split — replace REQUIRES driver with the specific esp_driver_* sub-component in 22 CMakeLists.txt files across claw_capabilities/, claw_modules/, and lua_modules/. IDF v6 removed the monolithic driver umbrella; builds fail with fatal error: driver/gpio.h: No such file or directory.
  • SOC_PCNT_CHANNELS_PER_UNIT removed — add #ifndef fallback in lua_driver_pcnt/src/lua_driver_pcnt.c (value is 2 for all supported chips).
  • MALLOC_CAP_EXEC gated — wrap with #ifdef MALLOC_CAP_EXEC in lua_module_system/src/lua_module_system.c; the macro is only defined when CONFIG_HEAP_HAS_EXEC_HEAP=y in IDF v6.
  • cap_im_wechat.c — minor IDF v6 API compat fix.

2. New board: Wireless Tag WT32-SC01 Plus

application/edge_agent/boards/Wireless-Tag/esp32s3_wt32_sc01_plus/

File Purpose
board_peripherals.yaml I2C (FT6336U touch), SPI (SD card), LEDC (backlight)
board_devices.yaml ST7796 LCD (custom I80), FT6336U touch, SD card, backlight, CAN bus
setup_device.c ST7796 via native ESP32-S3 I80 bus; shared GPIO4 reset for LCD+touch; lcd_touch_factory_entry_t calling esp_lcd_touch_new_i2c_ft5x06
sdkconfig.defaults.board 16 MB QIO flash, 2 MB Quad PSRAM, XIP-from-PSRAM disabled (too small), SPIRAM_MALLOC_ALWAYSINTERNAL=65536 + FREERTOS_TASK_CREATE_ALLOW_EXT_MEM=n to prevent PSRAM-stack panics on flash reads

Touch fix: migrated from deprecated lcd_touch_i2c to lcd_touch + sub_type: i2c. The deprecated type has a YAML-mapping bug where i2c_addr[] probe array is never populated, leaving dev_addr=0x00 and causing ESP_ERR_INVALID_RESPONSE → reboot loop. The new type reads the address from peripherals[0].i2c_addr: [0x70] (8-bit format) correctly.

PSRAM stack panic fix: global sdkconfig.defaults sets SPIRAM_MALLOC_ALWAYSINTERNAL=0 + FREERTOS_TASK_CREATE_ALLOW_EXT_MEM=y which is correct when SPIRAM_XIP_FROM_PSRAM=y. On a 2 MB PSRAM board where XIP must be disabled, task stacks land in PSRAM (0x3c2xxxxx) and any flash read triggers assert failed: esp_task_stack_is_sane_cache_disabled. Board defaults override both settings.

3. New Lua module: lua_driver_canbus

components/lua_modules/lua_driver_canbus/

Wraps the IDF v6 esp_driver_twai node API:

  • canbus.new(tx, rx, bitrate [, {listen_only, loopback}]) — creates a TWAI node
  • node:enable() / node:disable()
  • node:send(id, data [, extended [, rtr]])
  • node:receive([timeout_ms]){id, data, extended, rtr} or nil
  • node:status(){state, tx_errors, rx_errors, tx_queue_remaining, bus_errors}
  • node:recover() — bus-off recovery
  • node:close() + __gc

RX is ISR-driven via twai_node_receive_from_isr() into a FreeRTOS queue (depth 32). Registered via APP_CLAW_LUA_DRIVER_CANBUS Kconfig (default y when SOC_TWAI_SUPPORTED).

Test plan

  • Build edge_agent for esp32s3_wt32_sc01_plus with IDF v6.0.1 — no errors
  • Flash and confirm LCD + touch initialise without reboot loop
  • Lua script canbus.new(10,11,500000):enable() on a WT32-SC01 Plus with a CAN transceiver attached

🤖 Generated with Claude Code

…s driver

IDF v6 compatibility
- Replace monolithic `driver` component with `esp_driver_gpio`, `esp_driver_spi`,
  `esp_driver_i2c`, etc. in 22 CMakeLists.txt files
- Add `#ifndef SOC_PCNT_CHANNELS_PER_UNIT` fallback (macro removed in IDF v6)
- Guard `MALLOC_CAP_EXEC` with `#ifdef` (not available in all IDF v6 heap configs)
- Fix IDF v6 compat in cap_im_wechat.c

New board: Wireless Tag WT32-SC01 Plus (ESP32-S3, ST7796 I80, FT6336U, 16 MB flash)
- boards/Wireless-Tag/esp32s3_wt32_sc01_plus/ with full board_peripherals/devices YAML,
  setup_device.c (ST7796 via native I80 bus), sdkconfig.defaults.board
- Migrate lcd_touch from deprecated lcd_touch_i2c to lcd_touch + sub_type:i2c with
  correct 8-bit I2C address [0x70] to fix address-0x00 probe bug / reboot loop
- Disable SPIRAM_XIP_FROM_PSRAM (2 MB Quad PSRAM too small for instruction cache)
- Add SPIRAM_MALLOC_ALWAYSINTERNAL=65536 + FREERTOS_TASK_CREATE_ALLOW_EXT_MEM=n
  to keep task stacks in internal DRAM when XIP-from-PSRAM is off
  (prevents "esp_task_stack_is_sane_cache_disabled" panic on flash reads)

New Lua module: lua_driver_canbus (TWAI / CAN bus)
- Wraps ESP-IDF v6 esp_driver_twai node API with ISR-driven RX queue (depth 32)
- Exposes canbus.new(), enable/disable/send/receive/status/recover/close to Lua
- Registered via Kconfig APP_CLAW_LUA_DRIVER_CANBUS (default y when SOC_TWAI_SUPPORTED)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Alessio Ayyari seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@laride

laride commented May 19, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the PR and for the contribution!

This PR currently contains several independent changes, including the ESP-IDF v6.0 upgrade, new development board support, and TWAI support. To make the review process easier, could you please split them into separate PRs?

For the ESP-IDF v6.0 upgrade, we are also working on this internally. We may refer to your changes to speed up the process, but we probably will not merge this part of the PR directly.

The new development board support looks suitable to be reviewed and merged separately, so please split that part into an individual PR.

For the TWAI support, please rename the related code from CAN/CAN bus to TWAI module, so that it is consistent with the terminology used in the ESP-IDF Programming Guide.

Also, please sign the CLA before we can proceed with the review/merge process.

Thanks again for your work!

@ayyaris

ayyaris commented May 19, 2026

Copy link
Copy Markdown
Author

Closing in favour of two focused PRs as requested:

The IDF v6 compatibility changes are omitted per the maintainer's note that Espressif is handling them internally. The relevant root-cause issues have been filed separately (#89#94) for tracking.

@ayyaris ayyaris closed this May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants