Skip to content

Lua integration: esp32-c3 is okay, but esp32-s3 is fail #97226

@dmkuzmin

Description

@dmkuzmin

Describe the bug

I want to integrate the Lua engine https://github.com/lromeraj/lua-zephyr-module to Zephyr. On the esp32c3_devkitm board, it compiles and runs without errors. But on the esp32s3_devkitm board, there is a problem during compile and errors occur during startup.

Regression

  • This is a regression.

Steps to reproduce

  1. in my workspace, in the west.yml file, I added lua-zephyr-module:
  remotes:
    - name: zephyrproject-rtos
      url-base: https://github.com/zephyrproject-rtos
    - name: lromeraj
      url-base: https://github.com/lromeraj

  projects:
    - name: zephyr
      remote: zephyrproject-rtos
      revision: v4.2.0
      import: true
    - name: lua-zephyr-module
      remote: lromeraj
      revision: 0fb91faf28e0cc8488f0b273a5cc182cbbfcb72e
      path: modules/lua
      west-commands: scripts/west-commands.yml
  1. called the west update command

3a. I compiled the modules/lua/samples/app example west build -p always -b esp32c3_devkitm ..\modules\lua\samples\app and ran it on the esp32c3_devkitm board. Everything is working.

configuration is default (with newlibc):

# If picolibc is used, CONFIG_POSIX_API is required since
# the toolchain and also the module build only tinystdio module
# which relies on POSIX API 
#CONFIG_PICOLIBC=y
#CONFIG_POSIX_API=y

# for newlib C
CONFIG_NEWLIB_LIBC=y

3b. esp32c3_devkitm board is working
configuration with picolibc:

# If picolibc is used, CONFIG_POSIX_API is required since
# the toolchain and also the module build only tinystdio module
# which relies on POSIX API 
CONFIG_PICOLIBC=y
CONFIG_POSIX_API=y

# for newlib C
#CONFIG_NEWLIB_LIBC=y

3c. esp32s3_devkitm board is not compiled
configuration is default (with newlibc):

# If picolibc is used, CONFIG_POSIX_API is required since
# the toolchain and also the module build only tinystdio module
# which relies on POSIX API 
#CONFIG_PICOLIBC=y
#CONFIG_POSIX_API=y

# for newlib C
CONFIG_NEWLIB_LIBC=y

build output:

FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map C:/Users/dmkuzmin/zephyr/zephyr_workspace/rb-zephyr-workspace/build/zephyr/zephyr_pre0.map
C:\WINDOWS\system32\cmd.exe /C "cd . && ccache D:\zephyr-sdk-0.17.4\xtensa-espressif_esp32s3_zephyr-elf\bin\xtensa-espressif_esp32s3_zephyr-elf-gcc.exe  -gdwarf-4 zephyr/CMakeFiles/zephyr_pre0.dir/misc/empty_file.c.obj -o zephyr\zephyr_pre0.elf  zephyr/CMakeFiles/offsets.dir/./arch/xtensa/core/offsets/offsets.c.obj  -T  zephyr/linker_zephyr_pre0.cmd  -Wl,-Map,C:/Users/dmkuzmin/zephyr/zephyr_workspace/rb-zephyr-workspace/build/zephyr/zephyr_pre0.map  -Wl,--whole-archive  app/libapp.a  zephyr/libzephyr.a  zephyr/arch/common/libarch__common.a  zephyr/arch/arch/xtensa/core/libarch__xtensa__core.a  zephyr/lib/libc/newlib/liblib__libc__newlib.a  zephyr/lib/libc/common/liblib__libc__common.a  zephyr/drivers/interrupt_controller/libdrivers__interrupt_controller.a  zephyr/drivers/clock_control/libdrivers__clock_control.a  zephyr/drivers/console/libdrivers__console.a  zephyr/drivers/gpio/libdrivers__gpio.a  zephyr/drivers/pinctrl/libdrivers__pinctrl.a  zephyr/drivers/serial/libdrivers__serial.a  zephyr/drivers/timer/libdrivers__timer.a  modules/lua/lib/liblua.a  -Wl,--no-whole-archive  zephyr/kernel/libkernel.a  -LC:/Users/dmkuzmin/zephyr/zephyr_workspace/rb-zephyr-workspace/build/zephyr  zephyr/arch/common/libisr_tables.a  -fuse-ld=bfd  -Wl,--gc-sections  -Wl,--build-id=none  -Wl,--sort-common=descending  -Wl,--sort-section=alignment  -Wl,-u,_OffsetAbsSyms  -Wl,-u,_ConfigAbsSyms  -nostdlib  -static  -Wl,-X  -Wl,-N  -Wl,--orphan-handling=warn  -Wl,-no-pie  -L"D:/zephyr-sdk-0.17.4/xtensa-espressif_esp32s3_zephyr-elf/xtensa-espressif_esp32s3_zephyr-elf"/lib/.  -u_printf_float  -lgcc  -TC:/Users/dmkuzmin/zephyr/zephyr_workspace/modules/hal/espressif/zephyr/esp32s3/src/linker/esp32s3.rom.alias.ld  -TC:/Users/dmkuzmin/zephyr/zephyr_workspace/modules/hal/espressif/zephyr/esp32s3/../../components/esp_rom/esp32s3/ld/esp32s3.rom.ld  -TC:/Users/dmkuzmin/zephyr/zephyr_workspace/modules/hal/espressif/zephyr/esp32s3/../../components/esp_rom/esp32s3/ld/esp32s3.rom.api.ld  -TC:/Users/dmkuzmin/zephyr/zephyr_workspace/modules/hal/espressif/zephyr/esp32s3/../../components/esp_rom/esp32s3/ld/esp32s3.rom.libgcc.ld  -TC:/Users/dmkuzmin/zephyr/zephyr_workspace/modules/hal/espressif/zephyr/esp32s3/../../components/esp_rom/esp32s3/ld/esp32s3.rom.newlib.ld  -TC:/Users/dmkuzmin/zephyr/zephyr_workspace/modules/hal/espressif/zephyr/esp32s3/../../components/esp_rom/esp32s3/ld/esp32s3.rom.version.ld  -TC:/Users/dmkuzmin/zephyr/zephyr_workspace/modules/hal/espressif/zephyr/esp32s3/../../components/soc/esp32s3/ld/esp32s3.peripherals.ld  -Wl,--wrap=longjmp  -lc -L"d:/zephyr-sdk-0.17.4/xtensa-espressif_esp32s3_zephyr-elf/bin/../lib/gcc/xtensa-espressif_esp32s3_zephyr-elf/12.2.0" -lm -lc -lgcc -lc && C:\WINDOWS\system32\cmd.exe /C "cd /D C:\Users\dmkuzmin\zephyr\zephyr_workspace\rb-zephyr-workspace\build\zephyr && "C:\Program Files\CMake\bin\cmake.exe" -E true""
d:/zephyr-sdk-0.17.4/xtensa-espressif_esp32s3_zephyr-elf/bin/../lib/gcc/xtensa-espressif_esp32s3_zephyr-elf/12.2.0/../../../../xtensa-espressif_esp32s3_zephyr-elf/bin/ld.bfd.exe: D:/zephyr-sdk-0.17.4/xtensa-espressif_esp32s3_zephyr-elf/xtensa-espressif_esp32s3_zephyr-elf/lib/.\libc.a(lib_a-clock.o):(.literal.clock+0x0): undefined reference to `_times_r'
d:/zephyr-sdk-0.17.4/xtensa-espressif_esp32s3_zephyr-elf/bin/../lib/gcc/xtensa-espressif_esp32s3_zephyr-elf/12.2.0/../../../../xtensa-espressif_esp32s3_zephyr-elf/bin/ld.bfd.exe: D:/zephyr-sdk-0.17.4/xtensa-espressif_esp32s3_zephyr-elf/xtensa-espressif_esp32s3_zephyr-elf/lib/.\libc.a(lib_a-clock.o): in function `clock':
clock.c:(.text.clock+0xa): undefined reference to `_times_r'
d:/zephyr-sdk-0.17.4/xtensa-espressif_esp32s3_zephyr-elf/bin/../lib/gcc/xtensa-espressif_esp32s3_zephyr-elf/12.2.0/../../../../xtensa-espressif_esp32s3_zephyr-elf/bin/ld.bfd.exe: D:/zephyr-sdk-0.17.4/xtensa-espressif_esp32s3_zephyr-elf/xtensa-espressif_esp32s3_zephyr-elf/lib/.\libc.a(lib_a-remove.o):(.literal._remove_r+0x0): undefined reference to `_unlink_r'
d:/zephyr-sdk-0.17.4/xtensa-espressif_esp32s3_zephyr-elf/bin/../lib/gcc/xtensa-espressif_esp32s3_zephyr-elf/12.2.0/../../../../xtensa-espressif_esp32s3_zephyr-elf/bin/ld.bfd.exe: D:/zephyr-sdk-0.17.4/xtensa-espressif_esp32s3_zephyr-elf/xtensa-espressif_esp32s3_zephyr-elf/lib/.\libc.a(lib_a-remove.o): in function `_remove_r':
remove.c:(.text._remove_r+0x7): undefined reference to `_unlink_r'
d:/zephyr-sdk-0.17.4/xtensa-espressif_esp32s3_zephyr-elf/bin/../lib/gcc/xtensa-espressif_esp32s3_zephyr-elf/12.2.0/../../../../xtensa-espressif_esp32s3_zephyr-elf/bin/ld.bfd.exe: D:/zephyr-sdk-0.17.4/xtensa-espressif_esp32s3_zephyr-elf/xtensa-espressif_esp32s3_zephyr-elf/lib/.\libc.a(lib_a-remove.o): in function `remove':
remove.c:(.text.remove+0xc): undefined reference to `_unlink_r'
d:/zephyr-sdk-0.17.4/xtensa-espressif_esp32s3_zephyr-elf/bin/../lib/gcc/xtensa-espressif_esp32s3_zephyr-elf/12.2.0/../../../../xtensa-espressif_esp32s3_zephyr-elf/bin/ld.bfd.exe: D:/zephyr-sdk-0.17.4/xtensa-espressif_esp32s3_zephyr-elf/xtensa-espressif_esp32s3_zephyr-elf/lib/.\libc.a(lib_a-rename.o):(.literal.rename+0x0): undefined reference to `_rename_r'
d:/zephyr-sdk-0.17.4/xtensa-espressif_esp32s3_zephyr-elf/bin/../lib/gcc/xtensa-espressif_esp32s3_zephyr-elf/12.2.0/../../../../xtensa-espressif_esp32s3_zephyr-elf/bin/ld.bfd.exe: D:/zephyr-sdk-0.17.4/xtensa-espressif_esp32s3_zephyr-elf/xtensa-espressif_esp32s3_zephyr-elf/lib/.\libc.a(lib_a-rename.o): in function `rename':
rename.c:(.text.rename+0xc): undefined reference to `_rename_r'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

3d. esp32s3_devkitm board is compiled but not working
configuration with picolibc:

# If picolibc is used, CONFIG_POSIX_API is required since
# the toolchain and also the module build only tinystdio module
# which relies on POSIX API 
CONFIG_PICOLIBC=y
CONFIG_POSIX_API=y

# for newlib C
#CONFIG_NEWLIB_LIBC=y

log output:

I (96) boot: IRAM: lma 0x00032028 vma 0x00000000 len 0xdfd0   (5ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x15 (USB_UART_CHIP_RESET),boot:0x2b (SPI_FAST_FLASH_BOOT)
Saved PC:0x40375ea8
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fc8ed50,len:0x2124
load:0x40374000,len:0xad38
SHA-256 comparison failed:
Calculated: 73b86475dccbf9c32c7dd6547ad3433a2f56b328e0b06b65e662ca394083646c
Expected: 0000000060310000000000000000000000000000000000000000000000000000
Attempting to boot anyway...
entry 0x40379b78
I (57) soc_init: ESP Simple boot
I (57) soc_init: compile time Oct  9 2025 00:36:51
W (58) soc_init: Unicore bootloader
I (58) soc_init: chip revision: v0.2
I (60) flash_init: Boot SPI Speed : 80MHz
I (64) flash_init: SPI Mode       : DIO
I (67) flash_init: SPI Flash Size : 8MB
I (71) boot: DRAM: lma 0x00000020 vma 0x3fc8ed50 len 0x2124   (8484)
I (77) boot: IRAM: lma 0x0000214c vma 0x40374000 len 0xad38   (44344)
I (83) boot: IRAM: lma 0x0000ce98 vma 0x00000000 len 0x3160   (12640)
I (89) boot: IMAP: lma 0x00010000 vma 0x42000000 len 0x22020  (139296)
I (96) boot: IRAM: lma 0x00032028 vma 0x00000000 len 0xdfd0   (57296)
I (102) boot: DMAP: lma 0x00040000 vma 0x3c030000 len 0x6358   (25432)
I (108) boot: Image with 6 segments
I (111) boot: IROM segment: paddr=00010000h, vaddr=42000000h, size=2201Eh (139294) map
I (119) boot: DROM segment: paddr=00040000h, vaddr=3c030000h, size=06360h ( 25440) map
I (126) boot: libc heap size 81 kB.
I (130) spi_flash: detected chip: generic
I (133) spi_flash: flash io: dio
*** Booting Zephyr OS build v4.2.0 ***
[00000162] <err> os:  ** SYSCALL PS 0x60e20 PC 0x4002e243
[00000162] <err> os:  **  A0 0x820067a4  SP 0x3fc93d30  A2 0  A3 0x3fc93d90
[00000162] <err> os:  **  A4 0x3fc93d44  A5 0  A6 0x3fc93cb0  A7 0
[00000162] <err> os:  **  A8 0x82001eae  A9 0x3fc93d40 A10 0x1 A11 0
[00000162] <err> os:  ** A12 0x9c40 A13 0x196c A14 0xfffffff8 A15 0
[00000162] <err> os:  ** LBEG 0x400570e8 LEND 0x400570f3 LCOUNT 0
[00000162] <err> os:  ** SAR 0x12
[00000162] <err> os:  **  THREADPTR 0x3fc93d10
[00000201] <err> os:  ** SYSCALL PS 0x60a20 PC 0x4002e243
[00000201] <err> os:  **  A0 0x820067a4  SP 0x3fc93cc0  A2 0  A3 0x3fcd5720
[00000201] <err> os:  **  A4 0x3fc93cd4  A5 0x3c032294  A6 0x3fcd5578  A7 0xff000000
[00000201] <err> os:  **  A8 0x8200cafc  A9 0x3fc93cb0 A10 0x45 A11 0x3fcd5720
[00000201] <err> os:  ** A12 0x3fcd5580 A13 0x3fcd5578 A14 0x3fcd8638 A15 0x10
[00000201] <err> os:  ** LBEG 0x40056f5c LEND 0x40056f72 LCOUNT 0xffffffff
[00000201] <err> os:  ** SAR 0x1a
[00000201] <err> os:  **  THREADPTR 0
[00000238] <err> os:  ** SYSCALL PS 0x60a20 PC 0x4002e243
[00000238] <err> os:  **  A0 0x820067a4  SP 0x3fc93d30  A2 0  A3 0
[00000238] <err> os:  **  A4 0x3fc93d44  A5 0  A6 0x3fcd5298  A7 0x7d0
[00000238] <err> os:  **  A8 0x8200686c  A9 0x3fc93d20 A10 0 A11 0
[00000238] <err> os:  ** A12 0 A13 0 A14 0 A15 0x1
[00000239] <err> os:  ** LBEG 0x40056fc5 LEND 0x40056fe7 LCOUNT 0xffffffff
[00000239] <err> os:  ** SAR 0x13
[00000239] <err> os:  **  THREADPTR 0x3fc93d80
Welcome to the Lua demo application
----------------------------------
Countdown: 5

Countdown: 4
Countdown: 3
Countdown: 2
Countdown: 1
Done
[00005283] <err> os:  ** SYSCALL PS 0x60f20 PC 0x4002e243
[00005283] <err> os:  **  A0 0x820067a4  SP 0x3fc93d20  A2 0  A3 0x3fcd5578
[00005283] <err> os:  **  A4 0x3fc93d34  A5 0  A6 0  A7 0x1
[00005283] <err> os:  **  A8 0x8200bcde  A9 0x3fc93ce0 A10 0x3fcd5224 A11 0x10000
[00005283] <err> os:  ** A12 0 A13 0x10001 A14 0xc7 A15 0x1
[00005283] <err> os:  ** LBEG 0x40056f08 LEND 0x40056f12 LCOUNT 0
[00005283] <err> os:  ** SAR 0x4
[00005283] <err> os:  **  THREADPTR 0x3fc93d00
[00005323] <err> os:  ** SYSCALL PS 0x60320 PC 0x4002e243
[00005323] <err> os:  **  A0 0x820067a4  SP 0x3fc93cd0  A2 0  A3 0x3fcd5571
[00005323] <err> os:  **  A4 0x3fc93ce4  A5 0x3fc8f184  A6 0x3fcd4ba0  A7 0x1
[00005323] <err> os:  **  A8 0x4c6f0440  A9 0x3e7 A10 0x57619f1 A11 0
[00005323] <err> os:  ** A12 0x60123 A13 0x48e040 A14 0xffff2b5d A15 0x1
[00005323] <err> os:  ** LBEG 0x40056f08 LEND 0x40056f12 LCOUNT 0
[00005323] <err> os:  ** SAR 0x1d
[00005323] <err> os:  **  THREADPTR 0x40056f72
[00005365] <err> os:  ** SYSCALL PS 0x60520 PC 0x4002e243
[00005365] <err> os:  **  A0 0x820067a4  SP 0x3fc93cd0  A2 0  A3 0
[00005365] <err> os:  **  A4 0x3fc93ce4  A5 0x3fc93d50  A6 0x3fc93d04  A7 0x3fc93d50
[00005365] <err> os:  **  A8 0x8200bd36  A9 0x3fc93ca0 A10 0x3fcd5224 A11 0x3fcd5578
[00005365] <err> os:  ** A12 0 A13 0x48e040 A14 0xffff2b5d A15 0x1
[00005365] <err> os:  ** LBEG 0x40056fc5 LEND 0x40056fe7 LCOUNT 0
[00005365] <err> os:  ** SAR 0x1d
[00005365] <err> os:  **  THREADPTR 0x10001
[00005403] <err> os:  ** SYSCALL PS 0x60520 PC 0x4002e243
[00005403] <err> os:  **  A0 0x820067a4  SP 0x3fc93cd0  A2 0  A3 0
[00005403] <err> os:  **  A4 0x3fc93ce4  A5 0x3fc93d50  A6 0x3fc93d04  A7 0x3fc93d50
[00005403] <err> os:  **  A8 0x8200bd36  A9 0x3fc93ca0 A10 0x3fcd5224 A11 0x3fcd5578
[00005403] <err> os:  ** A12 0 A13 0x48e040 A14 0xffff2b5d A15 0x1
[00005403] <err> os:  ** LBEG 0x40055499 LEND 0x400554a9 LCOUNT 0xffffffe4
[00005403] <err> os:  ** SAR 0x1d
[00005403] <err> os:  **  THREADPTR 0x10001
[00005442] <err> os:  ** SYSCALL PS 0x60520 PC 0x4002e243
[00005442] <err> os:  **  A0 0x820067a4  SP 0x3fc93cd0  A2 0  A3 0
[00005442] <err> os:  **  A4 0x3fc93ce4  A5 0x3fc93d50  A6 0x3fc93d04  A7 0x3fc93d50
[00005442] <err> os:  **  A8 0x8200bd36  A9 0x3fc93ca0 A10 0x3fcd5224 A11 0x3fcd5578
[00005442] <err> os:  ** A12 0 A13 0x48e040 A14 0xffff2b5d A15 0x1
[00005442] <err> os:  ** LBEG 0x40055499 LEND 0x400554a9 LCOUNT 0xffffffe4
[00005442] <err> os:  ** SAR 0x20
[00005442] <err> os:  **  THREADPTR 0x10001

Relevant log output

Impact

Annoyance – Minor irritation; no significant impact on usability or functionality.

Environment

  • Windows 10
  • Zephyr SDK 0.17.4
  • esp32c3_devkitm and esp32s3_devkitm boards
  • Zephyr 4.2.0

Additional Context

No response

Metadata

Metadata

Assignees

Labels

bugThe issue is a bug, or the PR is fixing a bugplatform: ESP32Espressif ESP32

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions