espressif / esp-bsp

Board support components for Espressif development boards
Other
178 stars 94 forks source link

Can't get component esp_lcd_gc9503 to work (IDFGH-13231) (BSP-518) #345

Open dannybackx opened 2 months ago

dannybackx commented 2 months ago

Answers checklist.

General issue report

I am using all the example / advice on https://components.espressif.com/components/espressif/esp_lcd_gc9503/versions/3.0.1?language=en but my display stays blank.

The hardware (ZX3D95CD01S board available from multiple sources on AliExpress) works just fine if you compile stuff with the board support package. However, that is based on old esp-idf versions and this bothers me for other (dependency) reasons.

Board reference https://www.aliexpress.com/item/1005005886057393.html?spm=a2g0o.order_list.order_list_main.23.3afe1802V0TN7o

So I'm trying to get the board to display something with the generic components, and have tried a lot of different scenarios already. The latest and cleanest is a merge between the included sample in the esp_lvgl_port component and the sample code on the esp_lcd_gc9503 page , so replacing the st7789 dependency with gc9503 code.

See https://sourceforge.net/p/esp32-s3-86-box-project-base/code/HEAD/tree/trunk/touchscreen

This should cleanly build with a variety of recent esp-idf distributions, currently using yesterday's 5.3-rc1.

Dependency list is just stuff from the components repo.

The screen lights up a little bit (the backlight is active, I mean) but other than that remains dark. How can I debug further ?

I (27) boot: ESP-IDF v5.3-rc1 2nd stage bootloader
I (27) boot: compile time Jul 11 2024 10:05:52
I (27) boot: Multicore bootloader
I (30) boot: chip revision: v0.2
I (34) boot.esp32s3: Boot SPI Speed : 80MHz
I (39) boot.esp32s3: SPI Mode       : DIO
I (43) boot.esp32s3: SPI Flash Size : 2MB
I (48) boot: Enabling RNG early entropy source...
I (54) boot: Partition Table:
I (57) boot: ## Label            Usage          Type ST Offset   Length
I (64) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (72) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (79) boot:  2 factory          factory app      00 00 00010000 00100000
I (87) boot: End of partition table
I (91) esp_image: segment 0: paddr=00010020 vaddr=3c050020 size=196bch (104124) map
I (118) esp_image: segment 1: paddr=000296e4 vaddr=3fc93300 size=03418h ( 13336) load
I (121) esp_image: segment 2: paddr=0002cb04 vaddr=40374000 size=03514h ( 13588) load
I (127) esp_image: segment 3: paddr=00030020 vaddr=42000020 size=4eb08h (322312) map
I (190) esp_image: segment 4: paddr=0007eb30 vaddr=40377514 size=0bdd0h ( 48592) load
I (207) boot: Loaded app from partition at offset 0x10000
I (208) boot: Disabling RNG early entropy source...
I (219) octal_psram: vendor id    : 0x0d (AP)
I (220) octal_psram: dev id       : 0x02 (generation 3)
I (220) octal_psram: density      : 0x03 (64 Mbit)
I (225) octal_psram: good-die     : 0x01 (Pass)
I (230) octal_psram: Latency      : 0x01 (Fixed)
I (235) octal_psram: VCC          : 0x01 (3V)
I (240) octal_psram: SRF          : 0x01 (Fast Refresh)
I (246) octal_psram: BurstType    : 0x01 (Hybrid Wrap)
I (252) octal_psram: BurstLen     : 0x01 (32 Byte)
I (257) octal_psram: Readlatency  : 0x02 (10 cycles@Fixed)
I (263) octal_psram: DriveStrength: 0x00 (1/1)
I (269) MSPI Timing: PSRAM timing tuning index: 5
I (274) esp_psram: Found 8MB PSRAM device
I (279) esp_psram: Speed: 80MHz
I (296) mmu_psram: Read only data copied and mapped to SPIRAM
I (330) mmu_psram: Instructions copied and mapped to SPIRAM
I (330) cpu_start: Multicore app
I (721) esp_psram: SPI SRAM memory test OK
I (729) cpu_start: Pro cpu start user code
I (729) cpu_start: cpu freq: 240000000 Hz
I (729) app_init: Application information:
I (732) app_init: Project name:     touchscreen
I (737) app_init: App version:      1
I (742) app_init: Compile time:     Jul 11 2024 11:34:23
I (748) app_init: ELF file SHA256:  34dbbf3b3...
I (753) app_init: ESP-IDF:          v5.3-rc1
I (758) efuse_init: Min chip rev:     v0.0
I (763) efuse_init: Max chip rev:     v0.99 
I (768) efuse_init: Chip rev:         v0.2
I (772) heap_init: Initializing. RAM available for dynamic allocation:
I (780) heap_init: At 3FC9F218 len 0004A4F8 (297 KiB): RAM
I (786) heap_init: At 3FCE9710 len 00005724 (21 KiB): RAM
I (792) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (798) heap_init: At 600FE100 len 00001EE8 (7 KiB): RTCRAM
I (804) esp_psram: Adding pool of 7744K of PSRAM memory to heap allocator
I (812) spi_flash: detected chip: generic
I (816) spi_flash: flash io: dio
W (820) spi_flash: Detected size(16384k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (834) sleep: Configure to isolate all GPIO pins in sleep state
I (840) sleep: Enable automatic switching of GPIO sleep configuration
I (00:00:00.118) main_task: Started on CPU0
I (858) esp_psram: Reserving pool of 32K of internal memory for DMA/internal allocations
I (00:00:00.132) main_task: Calling app_main()
I (00:00:00.137) gc9503.c: app_lcd_init
I (00:00:00.141) gc9503.c: Install 3-wire SPI panel IO
I (00:00:00.147) gpio: GPIO[38]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (00:00:00.157) gpio: GPIO[45]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (00:00:00.167) gpio: GPIO[48]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (00:00:00.177) lcd_panel.io.3wire_spi: Panel IO create success, version: 1.0.1
I (00:00:00.185) gc9503.c: Install GC9503 panel driver
I (00:00:00.190) gpio: GPIO[41]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
D (00:00:00.227) lcd_panel.rgb: new rgb panel(0) @0x3fcabd04, num_fbs=2, fb_size=460800, bb0 @0x0, bb1 @0x0, bb_size=0
D (00:00:00.228) lcd_panel.rgb: fb[0] @0x3c070900
D (00:00:00.232) lcd_panel.rgb: fb[1] @0x3c0e1120
I (00:00:00.236) gc9503: LCD panel create success, version: 3.0.1
D (00:00:00.532) lcd_panel.rgb: rgb panel(0) start, pclk=15000000Hz
I (00:00:00.532) gpio: GPIO[5]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (00:00:00.537) gc9503.c: backlight: backlight set to 1
I (00:00:00.543) gc9503.c: app_lcd_init done
I (00:00:00.548) gc9503.c: app_touch_init done
I (00:00:00.553) EXAMPLE: LVGL version 9.1.0
I (00:00:00.558) LVGL: Starting LVGL task
E (00:00:00.564) lcd_panel.io.3wire_spi: Register event callbacks is not supported
espzav commented 1 month ago

Hi @dannybackx, I have looked to your code fast and it seems, there is problem in function lvgl_port_add_disp. You are using RGB LCD display and you should use function lvgl_port_add_disp_rgb like here: https://github.com/espressif/esp-bsp/blob/5d33575499110ccf0f9ff1eb58e4b17cf9b4da2b/bsp/esp32_s3_lcd_ev_board/src/esp32_s3_lcd_ev_board.c#L383C12-L383C34

dannybackx commented 3 weeks ago

Thanks for pointing to that. It doesn't change the result I'm currently getting : the backlight is the only visible thing, the display doesn't work. Touch does work.

I suspect the SPI code to configure the display isn't working.

The BSP does things like this :

void qmsd_rgb_spi_init() {
  spi_bus_config_t buscfg = {
    .sclk_io_num = LCD_SPI_CLK,
    .mosi_io_num = LCD_SPI_DATA0,
    .miso_io_num = -1,
    .quadwp_io_num = -1,
    .quadhd_io_num = -1,
    .max_transfer_sz = 10 * 1024,
  };
  ESP_ERROR_CHECK(spi_bus_initialize(SPI2_HOST, &buscfg, SPI_DMA_CH_AUTO));

  spi_device_interface_config_t devcfg = {
    .clock_speed_hz = SPI_MASTER_FREQ_10M,   //Clock out at 10 MHz
    .mode = 0,                               //SPI mode 0
    .spics_io_num = LCD_SPI_CS,              //CS pin
    .queue_size = 7,                         //We want to be able to queue 7 transactions at a time
  };

  ESP_ERROR_CHECK(spi_bus_add_device(SPI2_HOST, &devcfg, &g_screen_spi));
  rgb_driver_init();

while my code starts like this :

  /*
   * See https://docs.espressif.com/projects/esp-iot-solution/en/latest/display/lcd/rgb_lcd.html
   * This says use 3-wire via io_additions .
   * On the https://components.espressif.com/components/espressif/esp_lcd_panel_io_additions page
   * there's an init example. But a more complete one is on
   * https://components.espressif.com/components/espressif/esp_lcd_gc9503/versions/3.0.1 
   *
   * Additional sample https://github.com/espressif/esp-bsp/blob/master/components/lcd/esp_lcd_gc9503/README.md
   */
  ESP_LOGI(tag, "Install 3-wire SPI panel IO");
  spi_line_config_t line_config = {
    .cs_io_type         = IO_TYPE_GPIO,                 // Set to `IO_TYPE_EXPANDER` if using IO expander
    .cs_gpio_num        = LCD_SPI_CS,
    .scl_io_type        = IO_TYPE_GPIO,
    .scl_gpio_num       = LCD_SPI_CLK,
    .sda_io_type        = IO_TYPE_GPIO,
    .sda_gpio_num       = LCD_SPI_DATA0,
    .io_expander        = NULL,                        // Set to device handle if using IO expander
  };

ideas ?

dannybackx commented 3 days ago

This is getting really frustrating.

The BSP from the board vendor is based on old esp-idf versions and they claim you guys move too fast. But it used esp-idf's components/esp_driver_spi/src/gpspi/spi_master.c .

The esp-bsp stuff for gc9503 doesn't seem to work, and it uses own SPI functions in managed_components/espressif__esp_lcd_panel_io_additions/esp_lcd_panel_io_3wire_spi.c .

I'm not sure what to do here. Except maybe give up on esp-idf's managed components.

tore-espressif commented 2 days ago

Hi @dannybackx , Unfortunately I could not find schematic of your board, without this information it is very difficult to check that everything is setup correctly. The GC9503 uses RGB interface for color data. This interface is usually a lot more difficult to configure compared to SPI. From my experience with similar displays, most of the issues come from incorrect RGB interface configuration and timing. Each display requires different timings, you can find this information in the display's datasheet and the configure the driver accordingly here https://github.com/espressif/esp-idf/blob/master/components/esp_lcd/rgb/include/esp_lcd_panel_rgb.h#L128

If this doesn't help, you can check your schematic whether you need to do HW reset of the display and whether SPI is sending the data as you intend

dannybackx commented 2 days ago

http://en.smartpanle.com/product-item-20.html

Lzw655 commented 17 hours ago

Hi @dannybackx, Since the link is inaccessible, I can't view your code. However, after reviewing the product manual, I found that LCD_SCLK and LCD_MOSI share the same GPIOs as RGB_D0 and RGB_D1 on the LCD.

image

Therefore, please ensure that when using gc9503_vendor_config_t, you set .flags.auto_del_panel_io = 1 && .flags.mirror_by_cmd = 0.

    gc9503_vendor_config_t vendor_config = {
        .rgb_config = &rgb_config,
        // .init_cmds = lcd_init_cmds,      // Uncomment these line if use custom initialization commands
        // .init_cmds_size = sizeof(lcd_init_cmds) / sizeof(gc9503_lcd_init_cmd_t),
        .flags = {
            .mirror_by_cmd = 0,             // Only work when `auto_del_panel_io` is set to 0
            .auto_del_panel_io = 1,         /**
                                             * Set to 1 if panel IO is no longer needed after LCD initialization.
                                             * If the panel IO pins are sharing other pins of the RGB interface to save GPIOs,
                                             * Please set it to 1 to release the pins.
                                             */
        },
    };
dannybackx commented 6 hours ago

Responding to the "inaccessible" remark, do you refer to the subversion url in my message ? If yes, I don't understand. I just checked if I could use https://sourceforge.net/p/esp32-s3-86-box-project-base/code/HEAD/tree/trunk/touchscreen/main/gc9503.c with an anonymous browser session, and with curl. Both worked.