zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
9.74k stars 6k forks source link

ESP32 builds fail when using display drivers SSD1306 or ST7789 #72205

Open zpm1066 opened 2 weeks ago

zpm1066 commented 2 weeks ago

Describe the bug Unable to build successfully ESP32-S3 firmware that uses Display Driver SSD1306 or ST7789. Previously, these built fine under Zephyr 3.6. The same code (with appropriate overlays) works fine for ARM boards.

To Reproduce Steps to reproduce the behavior:

  1. Build display driver sample for SSD1306 or ST7789
  2. Build fails.
  3. See error below in "Logs and consoles output"

Expected behavior Successful build.

Impact Showstopper for firmware that uses ESP32 with SSD1306/ST7789 displays.

Logs and console output Observe the following errors for several ESP32-S3 boards even though Display and SSD1306 drivers are enabled. The same configuration works fine with ARM boards.

warning: SSD1306 (defined at drivers/display/Kconfig.ssd1306:6) was assigned the value 'y' but got
the value 'n'. Check these unsatisfied dependencies: (DT_HAS_SOLOMON_SSD1306FB_ENABLED ||
DT_HAS_SINOWEALTH_SH1106_ENABLED) (=n). See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_SSD1306 and/or look up SSD1306 in the
menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration Values,
and Kconfig - Tips and Best Practices sections of the manual might be helpful too.

...
...

  No SOURCES given to Zephyr library: drivers__display

  Excluding target from build.

Environment:

Additional context The same code and configuration with ARM boards (tested using nRF52840, RP2040, STM42) builds & runs fine when used with SSD1306 or ST7789 displays.

ESP32-S3 boards with SSD1306 or ST7789 work fine with Zephyr 3.5.xx and also worked with initial 3.6.99.

zpm1066 commented 1 week ago

After observing the introduction of qualifiers "esp32s3/procpu" in Zephyr 3.6.xx, in build of xiao_esp32s3 board, I renamed the "xiao_esp32s3.overlay" to "xiao_esp32s3_procpu.overlay".

This has resolved the SSD1306 display devicetree issue but now throws the following errors when creating esp32s3 image.

The code with the same "xiao_esp32s3.overlay" builds & runs fine under Zephyr 3.5.x.

quark11:ssd1306_cfb_custom_fonts_v3.5 quark11$ west build -p -b xiao_esp32s3/esp32s3/procpu -d build_xiao_esp32s3_3.6
-- west build: making build dir /Users/quark11/Documents/2024_zephyr_dev/ssd1306_cfb_custom_fonts_v3.5/build_xiao_esp32s3_3.6 pristine
-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: /Users/quark11/Documents/2024_zephyr_dev/ssd1306_cfb_custom_fonts_v3.5
-- CMake version: 3.29.1
-- Found Python3: /usr/local/opt/python@3.11/bin/python3.11 (found suitable version "3.11.7", minimum required is "3.8") found components: Interpreter
-- Cache files will be written to: /Users/quark11/Library/Caches/zephyr
-- Zephyr version: 3.6.99 (/Users/quark11/zephyrproject360/zephyr)
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
-- Board: xiao_esp32s3, qualifiers: esp32s3/procpu
-- Found host-tools: zephyr 0.16.5 (/opt/zephyr-sdk-0.16.5)
-- Found toolchain: zephyr 0.16.5 (/opt/zephyr-sdk-0.16.5)
-- Found Dtc: /usr/local/bin/dtc (found suitable version "1.7.0", minimum required is "1.4.6")
-- Found BOARD.dts: /Users/quark11/zephyrproject360/zephyr/boards/seeed/xiao_esp32s3/xiao_esp32s3_procpu.dts
-- Found devicetree overlay: /Users/quark11/Documents/2024_zephyr_dev/ssd1306_cfb_custom_fonts_v3.5/boards/xiao_esp32s3_procpu.overlay
-- Generated zephyr.dts: /Users/quark11/Documents/2024_zephyr_dev/ssd1306_cfb_custom_fonts_v3.5/build_xiao_esp32s3_3.6/zephyr/zephyr.dts
-- Generated devicetree_generated.h: /Users/quark11/Documents/2024_zephyr_dev/ssd1306_cfb_custom_fonts_v3.5/build_xiao_esp32s3_3.6/zephyr/include/generated/devicetree_generated.h
-- Including generated dts.cmake file: /Users/quark11/Documents/2024_zephyr_dev/ssd1306_cfb_custom_fonts_v3.5/build_xiao_esp32s3_3.6/zephyr/dts.cmake

Parsing /Users/quark11/zephyrproject360/zephyr/Kconfig
Loaded configuration '/Users/quark11/zephyrproject360/zephyr/boards/seeed/xiao_esp32s3/xiao_esp32s3_procpu_defconfig'
Merged configuration '/Users/quark11/Documents/2024_zephyr_dev/ssd1306_cfb_custom_fonts_v3.5/prj.conf'
Configuration saved to '/Users/quark11/Documents/2024_zephyr_dev/ssd1306_cfb_custom_fonts_v3.5/build_xiao_esp32s3_3.6/zephyr/.config'
Kconfig header saved to '/Users/quark11/Documents/2024_zephyr_dev/ssd1306_cfb_custom_fonts_v3.5/build_xiao_esp32s3_3.6/zephyr/include/generated/autoconf.h'
-- Found GnuLd: /opt/zephyr-sdk-0.16.5/xtensa-espressif_esp32s3_zephyr-elf/xtensa-espressif_esp32s3_zephyr-elf/bin/ld.bfd (found version "2.38")
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- The ASM compiler identification is GNU
-- Found assembler: /opt/zephyr-sdk-0.16.5/xtensa-espressif_esp32s3_zephyr-elf/bin/xtensa-espressif_esp32s3_zephyr-elf-gcc
esptool path: /Users/quark11/zephyrproject360/modules/hal/espressif/tools/esptool_py/esptool.py
-- Using ccache: /usr/local/bin/ccache
-- Configuring done (7.8s)
-- Generating done (0.3s)
-- Build files have been written to: /Users/quark11/Documents/2024_zephyr_dev/ssd1306_cfb_custom_fonts_v3.5/build_xiao_esp32s3_3.6
-- west build: building application
[1/243] Preparing syscall dependency handling

[3/243] Generating include/generated/version.h
-- Zephyr version: 3.6.99 (/Users/quark11/zephyrproject360/zephyr), build: v3.6.0-3135-g69c5c6d5117f
[243/243] Linking C executable zephyr/zephyr.elf
FAILED: zephyr/zephyr.elf zephyr/zephyr.map zephyr/zephyr.bin zephyr/zephyr.stat /Users/quark11/Documents/2024_zephyr_dev/ssd1306_cfb_custom_fonts_v3.5/build_xiao_esp32s3_3.6/zephyr/zephyr.map /Users/quark11/Documents/2024_zephyr_dev/ssd1306_cfb_custom_fonts_v3.5/build_xiao_esp32s3_3.6/zephyr/zephyr.bin /Users/quark11/Documents/2024_zephyr_dev/ssd1306_cfb_custom_fonts_v3.5/build_xiao_esp32s3_3.6/zephyr/zephyr.stat 
: && ccache /opt/zephyr-sdk-0.16.5/xtensa-espressif_esp32s3_zephyr-elf/bin/xtensa-espressif_esp32s3_zephyr-elf-gcc  -gdwarf-4 zephyr/CMakeFiles/zephyr_final.dir/misc/empty_file.c.obj zephyr/CMakeFiles/zephyr_final.dir/isr_tables.c.obj -o zephyr/zephyr.elf  zephyr/CMakeFiles/offsets.dir/./arch/xtensa/core/offsets/offsets.c.obj  -fuse-ld=bfd  -T  zephyr/linker.cmd  -Wl,-Map=/Users/quark11/Documents/2024_zephyr_dev/ssd1306_cfb_custom_fonts_v3.5/build_xiao_esp32s3_3.6/zephyr/zephyr_final.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/picolibc/liblib__libc__picolibc.a  zephyr/lib/libc/common/liblib__libc__common.a  zephyr/lib/posix/options/liblib__posix__options.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/display/libdrivers__display.a  zephyr/drivers/gpio/libdrivers__gpio.a  zephyr/drivers/i2c/libdrivers__i2c.a  zephyr/drivers/pinctrl/libdrivers__pinctrl.a  zephyr/drivers/serial/libdrivers__serial.a  zephyr/drivers/timer/libdrivers__timer.a  -Wl,--no-whole-archive  zephyr/kernel/libkernel.a  -L"/opt/zephyr-sdk-0.16.5/xtensa-espressif_esp32s3_zephyr-elf/bin/../lib/gcc/xtensa-espressif_esp32s3_zephyr-elf/12.2.0"  -L/Users/quark11/Documents/2024_zephyr_dev/ssd1306_cfb_custom_fonts_v3.5/build_xiao_esp32s3_3.6/zephyr  -lgcc  -Wl,--print-memory-usage  zephyr/arch/common/libisr_tables.a  -lgcc  -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  -DPICOLIBC_LONG_LONG_PRINTF_SCANF  -T/Users/quark11/zephyrproject360/modules/hal/espressif/zephyr/esp32s3/src/linker/esp32s3.rom.alias.ld  -T/Users/quark11/zephyrproject360/modules/hal/espressif/zephyr/esp32s3/../../components/esp_rom/esp32s3/ld/esp32s3.rom.ld  -T/Users/quark11/zephyrproject360/modules/hal/espressif/zephyr/esp32s3/../../components/esp_rom/esp32s3/ld/esp32s3.rom.api.ld  -T/Users/quark11/zephyrproject360/modules/hal/espressif/zephyr/esp32s3/../../components/esp_rom/esp32s3/ld/esp32s3.rom.libgcc.ld  -T/Users/quark11/zephyrproject360/modules/hal/espressif/zephyr/esp32s3/../../components/esp_rom/esp32s3/ld/esp32s3.rom.newlib.ld  -T/Users/quark11/zephyrproject360/modules/hal/espressif/zephyr/esp32s3/../../components/esp_rom/esp32s3/ld/esp32s3.rom.version.ld  -T/Users/quark11/zephyrproject360/modules/hal/espressif/zephyr/esp32s3/../../components/soc/esp32s3/ld/esp32s3.peripherals.ld  -Wl,--wrap=longjmp  --specs=picolibc.specs  -lc  -lgcc && cd /Users/quark11/Documents/2024_zephyr_dev/ssd1306_cfb_custom_fonts_v3.5/build_xiao_esp32s3_3.6/zephyr && /usr/local/Cellar/cmake/3.29.1/bin/cmake -E echo Generating\ files\ from\ /Users/quark11/Documents/2024_zephyr_dev/ssd1306_cfb_custom_fonts_v3.5/build_xiao_esp32s3_3.6/zephyr/zephyr.elf\ for\ board:\ xiao_esp32s3 && /usr/local/Cellar/cmake/3.29.1/bin/cmake -E copy zephyr_final.map zephyr.map && /opt/zephyr-sdk-0.16.5/xtensa-espressif_esp32s3_zephyr-elf/bin/xtensa-espressif_esp32s3_zephyr-elf-objcopy --gap-fill 0xff --output-target=binary --remove-section=.comment --remove-section=COMMON --remove-section=.eh_frame zephyr.elf zephyr.bin && /opt/zephyr-sdk-0.16.5/xtensa-espressif_esp32s3_zephyr-elf/bin/xtensa-espressif_esp32s3_zephyr-elf-readelf -e zephyr.elf > zephyr.stat && /usr/local/opt/python@3.11/bin/python3.11 /Users/quark11/zephyrproject360/zephyr/scripts/build/check_init_priorities.py --elf-file=/Users/quark11/Documents/2024_zephyr_dev/ssd1306_cfb_custom_fonts_v3.5/build_xiao_esp32s3_3.6/zephyr/zephyr.elf && /usr/local/opt/python@3.11/bin/python3.11 /Users/quark11/zephyrproject360/modules/hal/espressif/tools/esptool_py/esptool.py --chip esp32s3 elf2image --ram-only-header --flash_mode dio --flash_freq 40m --flash_size 8MB -o /Users/quark11/Documents/2024_zephyr_dev/ssd1306_cfb_custom_fonts_v3.5/build_xiao_esp32s3_3.6/zephyr/zephyr.bin /Users/quark11/Documents/2024_zephyr_dev/ssd1306_cfb_custom_fonts_v3.5/build_xiao_esp32s3_3.6/zephyr/zephyr.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:      144588 B    8388352 B      1.72%
     iram0_0_seg:       50152 B     343552 B     14.60%
     dram0_0_seg:       74264 B     327168 B     22.70%
     irom0_0_seg:       41038 B         8 MB      0.49%
     drom0_0_seg:       79056 B         8 MB      0.94%
    rtc_iram_seg:          0 GB         8 KB      0.00%
    rtc_data_seg:          0 GB         8 KB      0.00%
    rtc_slow_seg:          0 GB         8 KB      0.00%
        IDT_LIST:          0 GB         8 KB      0.00%
Generating files from /Users/quark11/Documents/2024_zephyr_dev/ssd1306_cfb_custom_fonts_v3.5/build_xiao_esp32s3_3.6/zephyr/zephyr.elf for board: xiao_esp32s3
esptool.py v4.7.0
Creating esp32s3 image...
ROM segments hidden - only RAM segments are visible to the ROM loader!
Info: inserting 4 bytes padding between device_area and _static_thread_data_area
Merged 17 ELF sections

A fatal error occurred: Segment loaded at 0x3c0134b8 lands in same 64KB flash mapping as segment loaded at 0x3c010000. Can't generate binary. Suggest changing linker script or ELF to merge sections.
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /usr/local/bin/cmake --build /Users/quark11/Documents/2024_zephyr_dev/ssd1306_cfb_custom_fonts_v3.5/build_xiao_esp32s3_3.6
fgihl commented 1 week ago

Try adding --sysbuild to build command. That help me, when I had the same issue.

zpm1066 commented 1 week ago

@fgihl Thanks. Unfortunately, "--sybuild" didn't help. I tried a "git pull" and "west update", no change.

sylvioalves commented 1 week ago

@fgihl CAn you share both .conf and .overlay files?

fgihl commented 1 week ago

@sylvioalves

Will it help you if you looked at my sample program? west init -m git@github.com:fgihl/tenderizer.git --mr fgihl/esp32c3-sample west build -p -b esp32c3_devkitm tenderize

This compiles fine on Zephyr v3.6.0, but failes with Zephyr-main with the link error A fatal error occurred: Segment loaded at 0x3c0134b8 lands in same 64KB flash mapping as segment loaded at 0x3c010000. Can't generate binary. Suggest changing linker script or ELF to merge sections. ninja: build stopped: subcommand failed.

If I compile latest zephyr with the command west build -p -b esp32c3_devkitm --sysbuild tenderizer

With risk of hijacking the issue with other problems (Should I report this separately?) But when starting I get the following runtime errors: W (370) tsens: legacy driver is deprecated, please migrate to driver/temperature_sensor.h W (378) ADC: legacy driver is deprecated, please migrate to esp_adc/adc_oneshot.h And neither ADC or internal tempsensor works.

zpm1066 commented 1 week ago

@sylvioalves

Here are the configuration and overlay being used with target xiao_esp3s3 and Zephyr 3.6.99. The same configuration/overlay work fine with Zephyr 3.5. Also worked fine with Zephyr 3.6.0.

There are no compilation errors and the SSD1306 OLED works as expected.

prj.proj:

CONFIG_HEAP_MEM_POOL_SIZE=16384
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_LOG=y
CONFIG_DISPLAY=y

CONFIG_GPIO=y
CONFIG_PRINTK=y
CONFIG_LOG_PRINTK=y

CONFIG_I2C=y
CONFIG_SSD1306=y

CONFIG_DISPLAY_LOG_LEVEL_ERR=y
CONFIG_STDOUT_CONSOLE=y

CONFIG_CFB_LOG_LEVEL_DBG=y
CONFIG_CHARACTER_FRAMEBUFFER=y
CONFIG_CHARACTER_FRAMEBUFFER_USE_DEFAULT_FONTS=n

# Preferred SHELL options
CONFIG_SHELL=y
#CONFIG_MCUMGR_CMD_SHELL_MGMT=y
CONFIG_BOOT_BANNER=y
CONFIG_DATE_SHELL=y
CONFIG_POSIX_CLOCK=y
CONFIG_DEVICE_SHELL=y
CONFIG_INIT_STACKS=y
CONFIG_KERNEL_SHELL=y
CONFIG_SHELL_STATS=n

# Enable RTT to replace UART
# set CONFIG_UART_CONSOLE=n in particle_xenon_defconfig
# error setting twice if below uncommented
# uncomment to enable uart console
# CONFIG_UART_CONSOLE=y
CONFIG_USE_SEGGER_RTT=n
CONFIG_SHELL_BACKEND_RTT=n

xiao_esp32s3_procpu.overlay:

 / {
    chosen {
        zephyr,display = &ssd1306;
    };

};

&pinctrl {
    i2c0_default: i2c0_default {
        group1 {
            pinmux = <I2C0_SDA_GPIO41>,
                 <I2C0_SCL_GPIO40>;
            bias-pull-up;
            drive-open-drain;
            output-high;
        };
    };
};

&i2c0 {
    pinctrl-names = "default";
    status = "okay";
    clock-frequency = <I2C_BITRATE_FAST>;
    ssd1306: ssd1306@3c {
        compatible = "solomon,ssd1306fb";
        reg = <0x3c>;
        width = <128>;
        height = <64>;
        segment-offset = <0>;
        page-offset = <0>;
        display-offset = <0>;
        multiplex-ratio = <63>;
        segment-remap;
        com-invdir;
        prechargep = <0x22>;
    };
};