zephyr: Lora sender sample build error for esp32

Describe the bug When building a project with the esp32 , I get build errors for example: -- Generating done -- Build files have been written to: C:/Users/houssine/zephyrproject/zephyr/build [70/139] Building C object zephyr/lib/posix/CMakeFiles/lib__posix.dir/pthread_common.c.obj FAILED: zephyr/lib/posix/CMakeFiles/lib__posix.dir/pthread_common.c.obj C:\Users\houssine\.espressif\tools\xtensa-esp32-elf\esp-2020r3-8.4.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-gcc.exe -DKERNEL -D_FORTIFY_SOURCE=2 -D__LINUX_ERRNO_EXTENSIONS__ -D__ZEPHYR__=1 -I../kernel/include -I../arch/xtensa/include -I../include -Izephyr/include/generated -I../soc/xtensa/esp32 -I../soc/xtensa/esp32/include -I../lib/libc/newlib/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/adapter/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/adapter/include/crypto -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/adapter/include/wifi -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/esp_common/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/esp_rom/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/esp32/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/soc/esp32/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/xtensa/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/xtensa/esp32/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/soc/soc/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/soc/soc/esp32/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/soc/soc/esp32/private_include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/soc/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/soc/src/esp32/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/driver/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/soc/soc/esp32 -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/esp_wifi/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/efuse/esp32/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/efuse/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/esp_system/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/esp_wifi/esp32/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/esp_timer/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/esp_timer/private_include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/esp_netif/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/esp_event/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/log/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/wpa_supplicant/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/wpa_supplicant/port/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/wpa_supplicant/src -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/wpa_supplicant/include/esp_supplicant -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/wpa_supplicant/src/crypto -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/spi_flash/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/spi_flash/private_include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/bootloader_support/include -Os -imacros C:/Users/houssine/zephyrproject/zephyr/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -imacros C:/Users/houssine/zephyrproject/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=C:/Users/houssine/zephyrproject/zephyr/samples/drivers/lora/send=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/Users/houssine/zephyrproject/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/Users/houssine/zephyrproject=WEST_TOPDIR -ffunction-sections -fdata-sections -mlongcalls -std=c99 -MD -MT zephyr/lib/posix/CMakeFiles/lib__posix.dir/pthread_common.c.obj -MF zephyr\lib\posix\CMakeFiles\lib__posix.dir\pthread_common.c.obj.d -o zephyr/lib/posix/CMakeFiles/lib__posix.dir/pthread_common.c.obj -c C:/Users/houssine/zephyrproject/zephyr/lib/posix/pthread_common.c In file included from C:/Users/houssine/zephyrproject/zephyr/lib/posix/pthread_common.c:10: ../include/posix/time.h:90:15: error: static declaration of 'clock_gettime' follows non-static declaration __syscall int clock_gettime(clockid_t clock_id, struct timespec *ts); ^~~~~~~~~~~~~ In file included from ../include/posix/time.h:12, from C:/Users/houssine/zephyrproject/zephyr/lib/posix/pthread_common.c:10: c:\users\houssine\.espressif\tools\xtensa-esp32-elf\esp-2020r3-8.4.0\xtensa-esp32-elf\xtensa-esp32-elf\sys-include\time.h:187:5: note: previous declaration of 'clock_gettime' was here int clock_gettime (clockid_t clock_id, struct timespec *tp); ^~~~~~~~~~~~~ In file included from C:/Users/houssine/zephyrproject/zephyr/lib/posix/pthread_common.c:10: ../include/posix/time.h:94:5: error: conflicting types for 'timer_create' int timer_create(clockid_t clockId, struct sigevent *evp, timer_t *timerid); ^~~~~~~~~~~~ In file included from ../include/posix/time.h:12, from C:/Users/houssine/zephyrproject/zephyr/lib/posix/pthread_common.c:10: c:\users\houssine\.espressif\tools\xtensa-esp32-elf\esp-2020r3-8.4.0\xtensa-esp32-elf\xtensa-esp32-elf\sys-include\time.h:192:5: note: previous declaration of 'timer_create' was here int timer_create (clockid_t clock_id, ^~~~~~~~~~~~ [71/139] Building C object zephyr/lib/posix/CMakeFiles/lib__posix.dir/nanosleep.c.obj FAILED: zephyr/lib/posix/CMakeFiles/lib__posix.dir/nanosleep.c.obj C:\Users\houssine\.espressif\tools\xtensa-esp32-elf\esp-2020r3-8.4.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-gcc.exe -DKERNEL -D_FORTIFY_SOURCE=2 -D__LINUX_ERRNO_EXTENSIONS__ -D__ZEPHYR__=1 -I../kernel/include -I../arch/xtensa/include -I../include -Izephyr/include/generated -I../soc/xtensa/esp32 -I../soc/xtensa/esp32/include -I../lib/libc/newlib/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/adapter/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/adapter/include/crypto -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/adapter/include/wifi -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/esp_common/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/esp_rom/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/esp32/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/soc/esp32/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/xtensa/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/xtensa/esp32/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/soc/soc/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/soc/soc/esp32/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/soc/soc/esp32/private_include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/soc/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/soc/src/esp32/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/driver/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/soc/soc/esp32 -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/esp_wifi/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/efuse/esp32/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/efuse/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/esp_system/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/esp_wifi/esp32/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/esp_timer/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/esp_timer/private_include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/esp_netif/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/esp_event/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/log/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/wpa_supplicant/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/wpa_supplicant/port/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/wpa_supplicant/src -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/wpa_supplicant/include/esp_supplicant -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/wpa_supplicant/src/crypto -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/spi_flash/include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/spi_flash/private_include -IC:/Users/houssine/zephyrproject/modules/hal/espressif/zephyr/../components/bootloader_support/include -Os -imacros C:/Users/houssine/zephyrproject/zephyr/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -imacros C:/Users/houssine/zephyrproject/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=C:/Users/houssine/zephyrproject/zephyr/samples/drivers/lora/send=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/Users/houssine/zephyrproject/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/Users/houssine/zephyrproject=WEST_TOPDIR -ffunction-sections -fdata-sections -mlongcalls -std=c99 -MD -MT zephyr/lib/posix/CMakeFiles/lib__posix.dir/nanosleep.c.obj -MF zephyr\lib\posix\CMakeFiles\lib__posix.dir\nanosleep.c.obj.d -o zephyr/lib/posix/CMakeFiles/lib__posix.dir/nanosleep.c.obj -c C:/Users/houssine/zephyrproject/zephyr/lib/posix/nanosleep.c In file included from C:/Users/houssine/zephyrproject/zephyr/lib/posix/nanosleep.c:12: ../include/posix/time.h:90:15: error: static declaration of 'clock_gettime' follows non-static declaration __syscall int clock_gettime(clockid_t clock_id, struct timespec *ts); ^~~~~~~~~~~~~ In file included from ../include/posix/time.h:12, from C:/Users/houssine/zephyrproject/zephyr/lib/posix/nanosleep.c:12: c:\users\houssine\.espressif\tools\xtensa-esp32-elf\esp-2020r3-8.4.0\xtensa-esp32-elf\xtensa-esp32-elf\sys-include\time.h:187:5: note: previous declaration of 'clock_gettime' was here int clock_gettime (clockid_t clock_id, struct timespec *tp); ^~~~~~~~~~~~~ In file included from C:/Users/houssine/zephyrproject/zephyr/lib/posix/nanosleep.c:12: ../include/posix/time.h:94:5: error: conflicting types for 'timer_create' int timer_create(clockid_t clockId, struct sigevent *evp, timer_t *timerid); ^~~~~~~~~~~~ In file included from ../include/posix/time.h:12, from C:/Users/houssine/zephyrproject/zephyr/lib/posix/nanosleep.c:12: c:\users\houssine\.espressif\tools\xtensa-esp32-elf\esp-2020r3-8.4.0\xtensa-esp32-elf\xtensa-esp32-elf\sys-include\time.h:192:5: note: previous declaration of 'timer_create' was here int timer_create (clockid_t clock_id, ^~~~~~~~~~~~ [75/139] Building C object zephyr/drivers/i2c/CMakeFiles/drivers__i2c.dir/i2c_esp32.c.obj ninja: build stopped: subcommand failed. FATAL ERROR: command exited with status 1: 'C:\Program Files\CMake\bin\cmake.EXE' --build 'C:\Users\houssine\zephyrproject\zephyr\build' To Reproduce Steps to reproduce the behavior:

  1. Build using west build -b esp32 samples\drivers\lora\send

Expected behavior send a message with lora.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 38 (11 by maintainers)

Most upvoted comments

Hi, please, update Zephyr to latest main, run west update then west espressif update.
Notice that now ESP32 uses Zephyr-SDK 0.14.1. Please, also run export ZEPHYR_TOOLCHAIN_VARIANT="zephyr" so that it uses the SDK as expected.
In case you have issues running west update regarding hal_espressif, try deleting hal_espressif folder and run west update again.

If this is still an issue preventing lora to be used on ESP32 maybe we can keep this open to track the missing feature?

Oh, thank you so much!

It works since I switched to spi2, and I fixed the gpio1 bank for GPIO35 and GPIO34, and I used a single group only!

All in all, all you told me to change.

&pinctrl {
    spim2_default: spim2_default {
        group1 {
            pinmux = < SPIM2_MISO_GPIO19 >,
                     < SPIM2_MOSI_GPIO27 >,
                     < SPIM2_SCLK_GPIO5 >;
	   };
    };
};
/ {
    aliases {
        lora0 = &rfm95;
    };
};

&spi2 {
    #address-cells = <1>;
    #size-cells = <0>;
    status = "okay";
    pinctrl-0 = <&spim2_default>;
    pinctrl-names = "default";
    cs-gpios = <&gpio0 18 GPIO_ACTIVE_LOW>;

    rfm95: sx1276@0 {
        compatible = "semtech,sx1276";
        reg = < 0 >;
        reset-gpios = < &gpio0 14 GPIO_ACTIVE_LOW >;
        dio-gpios = < &gpio0 26 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH) >,
                    < &gpio1 3 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH) >,
                    < &gpio1 2 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH) >;
        spi-max-frequency = <1000000>;
        power-amplifier-output = "pa-boost";
    };
};

I struggled with this recently. Chip version 0x00 is exactly what I was getting, before I had the SPI correctly setup.

I don’t know if its the cause of your issue, but I think your pin assignment for DIO D1 & D2 needs to change. On the ESP32, pins above GPIO31 are on port &gpio1 not &gpio0. See here for more details.

Hi @sylvioalves It is working now. The issue was that I was working with an all version of Zephyr code. I notice that west update updates all the sub-repositories of zephyr project but doesn’t update the main repository. Thus, I needed to do a git pull in the root of zephyr project and a new west update afterwards. Then, the modules were updated (specially the hal_espressif) and everyhting works now fine. I think that we can close the issue. Thank very much!