Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flickers when using double-buffered i8080 lcd on ESP32-S3 while Wi-Fi performs time-consuming tasks (IDFGH-6569) #8212

Closed
2 tasks done
wangyz1997 opened this issue Jan 9, 2022 · 5 comments
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally

Comments

@wangyz1997
Copy link
Contributor

wangyz1997 commented Jan 9, 2022

Environment

  • Development Kit: Custom ESP32-S3 board.
  • Module or chip used: ESP32-S3-WROOM-1 (D3N8R2).
  • IDF version (run git describe --tags to find it): v4.4-beta1-284-gd83021a6e8
  • Build System: idf.py
  • Compiler version (run xtensa-esp32-elf-gcc --version to find it):
xtensa-esp32-elf-gcc.exe (crosstool-NG esp-2021r2) 8.4.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  • Operating System: Windows10 21H2.
  • (Windows only) environment type: PowerShell.
  • Using an IDE?: No, VS Code as editor.
  • Power Supply: USB

Problem Description

Hi. I am using the lateet ESP32-S3 to drive a Intel 8080 LCD Panel. Everything seems quite normal when I port the driver without enabling Wi-Fi, with or without lvgl. But after I enable Wi-Fi, I can see flickers on screen frequently when Wi-Fi performs time-consuming tasks (connecting, https request, etc). The display buffer is correctly flushed to screen, but on the wrong place (which can be seen in images below).

Lower the PCLK helps reducing the frequency of the bug, but it still happens.

I guess this is due to interrupt not handled timely. Wi-Fi functions have many critical sections, and the LCD DMA uses interrupt to notify the driver when transfer is done. When Wi-Fi stack enters critical section, if LCD DMA generates an interrupt, the interrupt will not be handled timely. This may cause mistakes in command transferring, so the buffer is flushed to the wrong place.

Expected Behavior

The LCD displays correct content.

Actual Behavior

With LVGL:
IMG_1433

IMG_1434

With the code provided:

IMG_1438.mp4

Steps to reproduce

  1. Write a screen refreshing task on core 1, which flushes 8 colored blocks to screen. Each block is transferred with seprate transaction. Double buffer is used.
  2. Write a Wi-Fi task on core 0, and the Wi-Fi stack is also on core 0. Connect to a wrong Wi-Fi to simulate time-consuming tasks.
  3. The bug occurs.

Code to reproduce this issue

Minimal code to reproduce this issue is uploaded below.

https://gist.github.com/wangyz1997/a0fde61e4a212d72dcd964ec9346a9fc

Debug Logs

ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd0108,len:0x16e4
load:0x403b6000,len:0xb7c
load:0x403ba000,len:0x2f90
entry 0x403b6248
I (24) boot: ESP-IDF v5.0-dev-1082-g9f303290d8-dirty 2nd stage bootloader
I (25) boot: compile time 20:31:04
I (25) boot: chip revision: 0
I (28) boot.esp32s3: Boot SPI Speed : 80MHz
I (33) boot.esp32s3: SPI Mode       : DIO
I (38) boot.esp32s3: SPI Flash Size : 2MB
I (43) boot: Enabling RNG early entropy source...
I (48) boot: Partition Table:
I (52) boot: ## Label            Usage          Type ST Offset   Length
I (59) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (66) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (74) boot:  2 factory          factory app      00 00 00010000 00100000
I (81) boot: End of partition table
I (86) esp_image: segment 0: paddr=00010020 vaddr=3c070020 size=14164h ( 82276) map
I (109) esp_image: segment 1: paddr=0002418c vaddr=3fc94340 size=041e0h ( 16864) load
I (113) esp_image: segment 2: paddr=00028374 vaddr=40374000 size=07ca4h ( 31908) load
I (122) esp_image: segment 3: paddr=00030020 vaddr=42000020 size=6ab68h (437096) map
I (201) esp_image: segment 4: paddr=0009ab90 vaddr=4037bca4 size=08690h ( 34448) load
I (209) esp_image: segment 5: paddr=000a3228 vaddr=50000000 size=00010h (    16) load
I (216) boot: Loaded app from partition at offset 0x10000
I (216) boot: Disabling RNG early entropy source...
I (230) cpu_start: Pro cpu up.
I (230) cpu_start: Starting app cpu, entry point is 0x403751fc
0x403751fc: call_start_cpu1 at D:/Programs/esp-idf-beta/components/esp_system/port/cpu_start.c:152

I (0) cpu_start: App cpu up.
I (244) cpu_start: Pro cpu start user code
I (244) cpu_start: cpu freq: 160000000 Hz
I (244) cpu_start: Application information:
I (247) cpu_start: Project name:     esp32s3-8080lcd-bugreport
I (254) cpu_start: App version:      1
I (258) cpu_start: Compile time:     Jan  9 2022 20:30:57
I (264) cpu_start: ELF file SHA256:  92892265312d3492...
I (270) cpu_start: ESP-IDF:          v5.0-dev-1082-g9f303290d8-dirty
I (277) heap_init: Initializing. RAM available for dynamic allocation:
I (284) heap_init: At 3FC9BFC8 len 00044038 (272 KiB): D/IRAM
I (291) heap_init: At 3FCE0000 len 0000EE34 (59 KiB): STACK/DRAM
I (298) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (304) heap_init: At 600FE000 len 00002000 (8 KiB): RTCRAM
I (311) spi_flash: detected chip: gd
I (314) spi_flash: flash io: dio
W (318) spi_flash: Detected size(8192k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (332) sleep: Configure to isolate all GPIO pins in sleep state
I (338) sleep: Enable automatic switching of GPIO sleep configuration
I (346) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (20) pp: pp rom version: e7ae62f
I (30) net80211: net80211 rom version: e7ae62f
I (426) wifi:wifi driver task: 3fce78ac, prio:23, stack:6656, core=0
I (426) system_api: Base MAC address is not set
I (426) system_api: read default base MAC address from EFUSE
I (426) wifi:wifi firmware version: c279458
I (436) wifi:wifi certification version: v7.0
I (436) wifi:config NVS flash: enabled
I (436) wifi:config nano formating: disabled
I (446) wifi:Init data frame dynamic rx buffer num: 32
I (446) wifi:Init management frame dynamic rx buffer num: 32
I (456) wifi:Init management short buffer num: 32
I (456) wifi:Init dynamic tx buffer num: 32
I (466) wifi:Init static tx FG buffer num: 2
I (466) wifi:Init static rx buffer size: 1600
I (466) wifi:Init static rx buffer num: 10
I (476) wifi:Init dynamic rx buffer num: 32
I (476) wifi_init: rx ba win: 6
I (486) wifi_init: tcpip mbox: 32
I (486) wifi_init: udp mbox: 6
I (486) wifi_init: tcp mbox: 6
I (496) wifi_init: tcp tx win: 5744
I (496) wifi_init: tcp rx win: 5744
I (506) wifi_init: tcp mss: 1440
I (506) wifi_init: WiFi IRAM OP enabled
I (506) wifi_init: WiFi RX IRAM OP enabled
I (516) example_connect: Connecting to myssid...
I (516) phy_init: phy_version 302,291a31f,Oct 22 2021,19:22:08
I (576) wifi:mode : sta (7c:df:a1:e0:65:24)
I (576) wifi:enable tsf
I (576) example_connect: Waiting for IP(s)
I (2626) example_connect: Wi-Fi disconnected, trying to reconnect...
I (4676) example_connect: Wi-Fi disconnected, trying to reconnect...
I (6726) example_connect: Wi-Fi disconnected, trying to reconnect...
I (8766) example_connect: Wi-Fi disconnected, trying to reconnect...
I (10816) example_connect: Wi-Fi disconnected, trying to reconnect...
I (12866) example_connect: Wi-Fi disconnected, trying to reconnect...
I (14906) example_connect: Wi-Fi disconnected, trying to reconnect...
I (16956) example_connect: Wi-Fi disconnected, trying to reconnect...
I (19006) example_connect: Wi-Fi disconnected, trying to reconnect...
I (21056) example_connect: Wi-Fi disconnected, trying to reconnect...
I (23106) example_connect: Wi-Fi disconnected, trying to reconnect...
I (25156) example_connect: Wi-Fi disconnected, trying to reconnect...
I (27206) example_connect: Wi-Fi disconnected, trying to reconnect...
I (29256) example_connect: Wi-Fi disconnected, trying to reconnect...
I (31296) example_connect: Wi-Fi disconnected, trying to reconnect...
I (33346) example_connect: Wi-Fi disconnected, trying to reconnect...
I (35396) example_connect: Wi-Fi disconnected, trying to reconnect...
I (37446) example_connect: Wi-Fi disconnected, trying to reconnect...
I (39496) example_connect: Wi-Fi disconnected, trying to reconnect...
I (41536) example_connect: Wi-Fi disconnected, trying to reconnect...
I (43586) example_connect: Wi-Fi disconnected, trying to reconnect...
I (45636) example_connect: Wi-Fi disconnected, trying to reconnect...
I (47686) example_connect: Wi-Fi disconnected, trying to reconnect...
I (49726) example_connect: Wi-Fi disconnected, trying to reconnect...
I (51776) example_connect: Wi-Fi disconnected, trying to reconnect...
I (53826) example_connect: Wi-Fi disconnected, trying to reconnect...
I (55876) example_connect: Wi-Fi disconnected, trying to reconnect...
I (57926) example_connect: Wi-Fi disconnected, trying to reconnect...
I (59966) example_connect: Wi-Fi disconnected, trying to reconnect...
I (62016) example_connect: Wi-Fi disconnected, trying to reconnect...
I (64066) example_connect: Wi-Fi disconnected, trying to reconnect...

Other items if possible

  • sdkconfig file (attach the sdkconfig file from your project folder)
    everything is left default, and wifi ssid and password is set to a wrong one.
  • elf file in the build folder (note this may contain all the code details and symbols of your project.)
    esp32s3-8080lcd-bugreport.elf.zip
@espressif-bot espressif-bot added the Status: Opened Issue is new label Jan 9, 2022
@github-actions github-actions bot changed the title Flickers when using double-buffered i8080 lcd on ESP32-S3 while Wi-Fi performs time-consuming tasks Flickers when using double-buffered i8080 lcd on ESP32-S3 while Wi-Fi performs time-consuming tasks (IDFGH-6569) Jan 9, 2022
@suda-morris
Copy link
Collaborator

The esp_lcd_panel_io_tx_color is an async API, which in internal will set up a transaction and send it to a task queue, and then that function will return immediately. So before that transaction got transmitted finally, you have to ensure the associated frame buffer won't be overwritten.

@wangyz1997
Copy link
Contributor Author

Yes, I have noticed that already. But everything works fine when Wi-Fi is not turn on. This transmission issue only happens when Wi-Fi is performing time-consuming jobs, which is confusing.

@wangyz1997
Copy link
Contributor Author

I patched the code with mutex. The same issue still happen. https://gist.github.com/wangyz1997/0cc05904443d0bd7f16321044d1d42e0

@suda-morris
Copy link
Collaborator

@wangyz1997 Hi, sorry for the late response, we can reproduce this issue now. Thanks for your detailed report and your code that helps us a lot.
For now, a quick fix could be adding a esp_rom_delay_us(1) after this line

The issue is that, after we start the DMA engine, DMA speed can't match the peripheral requirement, thus it can't fill itself with transfer data immediately, so the peripheral's FIFO might contain garbage data. This is also explained why slowing down the PCLK frequency can somehow do the help.

@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Opened Issue is new labels Mar 10, 2022
@wangyz1997
Copy link
Contributor Author

wangyz1997 commented Mar 11, 2022

Thank you for your detailed explaination. Issue fixed with provided method.

@espressif-bot espressif-bot added Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Resolution: Done Issue is done internally and removed Status: In Progress Work is in progress Resolution: NA Issue resolution is unavailable labels Mar 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally
Projects
None yet
Development

No branches or pull requests

3 participants