lovyan03 / LovyanGFX

SPI LCD graphics library for ESP32 (ESP-IDF/ArduinoESP32) / ESP8266 (ArduinoESP8266) / SAMD51(Seeed ArduinoSAMD51)
Other
1.03k stars 189 forks source link

Add MISO PIN for WT32-SC01 autodetect #294

Closed sukesh-ak closed 1 year ago

sukesh-ak commented 1 year ago

Problem Description ( 問題の内容 )

Please add correct MISO pin here, so that we can use other SPI devices like SD card using LovyanGFX shared SPI option.

https://github.com/lovyan03/LovyanGFX/blob/9de99d25496413f133ce3c057fa3edb60148f523/src/lgfx/v1_autodetect/LGFX_AutoDetect_ESP32.hpp#L1717

Thanks to @dizcza for pointing this out.

tobozo commented 1 year ago

hi,

I don't know what the correct MISO pin is in this context, but if you do please feel free to submit a pull request :+1:

dizcza commented 1 year ago

@tobozo add an option to menuconfig and set -1 by default.

tobozo commented 1 year ago

@dizcza unless there's an official value for this MISO pin, it sounds like those menuconfig values should be project specific rather than driver specific

@sukesh-ak your custom config can be achieved by disabling autodetect and managing the LGFX configuration as seen in the how to use example, just import the LGFX_WT32_SC01 board/bus config values from autodetect and assign your esp-idf MY_CONFIG_MISO_PIN* macro from there.

sukesh-ak commented 1 year ago

@dizcza unless there's an official value for this MISO pin, it sounds like those menuconfig values should be project specific rather than driver specific

@sukesh-ak your custom config can be achieved by disabling autodetect and managing the LGFX configuration as seen in the how to use example, just import the LGFX_WT32_SC01 board/bus config values from autodetect and assign your esp-idf MY_CONFIG_MISO_PIN* macro from there.

Yes sorry guys we can close this. I have created custom config and disabled autodetect.

Here is the updated sample https://github.com/sukesh-ak/WT32-SC01-PLUS-LVGL-IDF

dizcza commented 1 year ago

Such a pity that the users are forced to write up a script to initialize SPI bus, connect a touch I2C periphery, light screen just because of one pin. I'd gladly leave it to autodetect. This will also ensure code maintenance rather than one-stone code.

What if instead, you provide a way to subclass the LGFX class and reinitialize the SPI bus only and leave everything as it is? Would it work @tobozo ?

Currently, these members are private:

    lgfx::Panel_Device* _panel_last = nullptr;
    lgfx::ILight* _light_last = nullptr;
    lgfx::ITouch* _touch_last = nullptr;
    lgfx::Bus_SPI _bus_spi;
tobozo commented 1 year ago

@dizcza only non standard builds (e.g. M5Stack + secondary display) should disable autodetect.

Did you add an extra device not listed in the product specifications?

If so the build is custom and it's up to you to manage your configuration as detailed in the how to use example.

dizcza commented 1 year ago

I do use a device supported by your autodetect - WT32-SC01. As the header of the issue outlines.

I just need to make SPI bus full-duplex. Reinitialize it.

dizcza commented 1 year ago

If so the build is custom and it's up to you to manage your configuration as detailed in the how to use example.

This is precisely what I do not want to do as WT32-SC01 is already supported. That's why I wrote

Such a pity that the users are forced to write up a script to initialize SPI bus, connect a touch I2C periphery, light screen just because of one pin. I'd gladly leave it to autodetect. This will also ensure code maintenance rather than one-stone code.

dizcza commented 1 year ago

What I'm asking is being able to issue

      auto cfg = _bus_spi.config(); // gets the structure for bus settings.
      cfg.pin_miso = 33;
      _bus_spi.config(cfg);              // reflects the setting value on the bus.

in the subclassed constructor.

dizcza commented 1 year ago

3 lines instead of 130 hardcoded commands.

tobozo commented 1 year ago

here's an experimental snippet for you, courtesy of @lovyan03

LGFX display;

void setup()
{
  display.init();
  auto bus = (lgfx::Bus_SPI*)(display.panel()->bus());
  autp cfg = bus->config();
  cfg.pin_miso = 33;
  bus->config(cfg);
  bus->init();
}
dizcza commented 1 year ago

It works with a minor and yet important change: you need to deinitialize a previously initialized SPI bus prior to initialing it for the second time. I wonder why I didn't get any spi bus init error at line bus->init() - do you hide these logs somehow?

Here is the complete code that works.

        lcd.init();
        auto bus = (lgfx::Bus_SPI*)(lcd.panel()->bus());
        bus->release();
        auto cfg = bus->config();
        cfg.pin_miso = 33;
        bus->config(cfg);
        bus->init();

But guys! I see a large change on develop branch. With the latest changes, the project used to work fails to build.

/home/dizcza/Projects/Embedded/eclipse-workspace/other/LVGL8-WT32-SC01-IDF/components/LovyanGFX/src/lgfx/v1_autodetect/LGFX_AutoDetect_ESP32_all.hpp:3114:1: error: format '%d' expects argument of type 'int', but argument 6 has type 'uint32_t' {aka 'long unsigned int'} [-Werror=format=]
 3114 |   ESP_LOGE("LGFX","pkg:%d", pkg_ver);
      |                             ~
      |                             |
      |                             uint32_t {aka long unsigned int}
/home/dizcza/tools/esp-idf/components/log/include/esp_log.h:282:59: note: in definition of macro 'LOG_FORMAT'
  282 | #define LOG_FORMAT(letter, format)  LOG_COLOR_ ## letter #letter " (%" PRIu32 ") %s: " format LOG_RESET_COLOR "\n"
      |                                                           ^~~~~~
/home/dizcza/tools/esp-idf/components/log/include/esp_log.h:432:41: note: in expansion of macro 'ESP_LOG_LEVEL'
  432 |         if ( LOG_LOCAL_LEVEL >= level ) ESP_LOG_LEVEL(level, tag, format, ##__VA_ARGS__); \
      |                                         ^~~~~~~~~~~~~
/home/dizcza/tools/esp-idf/components/log/include/esp_log.h:334:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL'
  334 | #define ESP_LOGE( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_ERROR,   tag, format __VA_OPT__(,) __VA_ARGS__)
      |                                      ^~~~~~~~~~~~~~~~~~~
/home/dizcza/Projects/Embedded/eclipse-workspace/other/LVGL8-WT32-SC01-IDF/components/LovyanGFX/src/lgfx/v1_autodetect/LGFX_AutoDetect_ESP32_all.hpp:3114:3: note: in expansion of macro 'ESP_LOGE'
 3114 |   ESP_LOGE("LGFX","pkg:%d", pkg_ver);
      |   ^~~~~~~~

To resolve the issues, I added a hotfix to the project cmake file:

idf_component_get_property(lib main COMPONENT_LIB)
target_compile_options(${lib} PRIVATE -Wno-error=format)

I hope it's temporary and you'll fix this soon.

BTW, why did you mark the package version log as an error? It looks scary in the logs.

tobozo commented 1 year ago

BTW, why did you mark the package version log as an error? It looks scary in the logs.

some leftovers from halloween maybe ? :rofl:

dizcza commented 1 year ago

I have another issue that might be spelled on a separate page but in favor of our cozy chatting I'm posting it here.

The problem

On abort() and subsequent kernel reset autodetect doesn't find the right board. First attempt: success. Second: failure. It might be due to RAM keeping old values between resets or I don't know.

Script

Borrowed from https://github.com/sukesh-ak/LVGL8-WT32-SC01-IDF/blob/master/main/main.cpp.

Just add abort() at the end.

void app_main(void)
    {
        lcd.init(); // Initialize LovyanGFX

        lv_init();  // Initialize lvgl

        // Setting display to landscape
        if (lcd.width() < lcd.height())
            lcd.setRotation(lcd.getRotation() ^ 1);

        /* LVGL : Setting up buffer to use for display */
        lv_disp_draw_buf_init(&draw_buf, buf, NULL, screenWidth * 10);

        /*** LVGL : Setup & Initialize the display device driver ***/
        static lv_disp_drv_t disp_drv;
        lv_disp_drv_init(&disp_drv);
        disp_drv.hor_res = screenWidth;
        disp_drv.ver_res = screenHeight;
        disp_drv.flush_cb = display_flush;
        disp_drv.draw_buf = &draw_buf;
        lv_disp_drv_register(&disp_drv);

        /*** LVGL : Setup & Initialize the input device driver ***/
        static lv_indev_drv_t indev_drv;
        lv_indev_drv_init(&indev_drv);
        indev_drv.type = LV_INDEV_TYPE_POINTER;
        indev_drv.read_cb = touchpad_read;
        lv_indev_drv_register(&indev_drv);

        /* Create and start a periodic timer interrupt to call lv_tick_inc */
        const esp_timer_create_args_t periodic_timer_args = {
            .callback = &lv_tick_task,
            .name = "periodic_gui"};
        esp_timer_handle_t periodic_timer;
        ESP_ERROR_CHECK(esp_timer_create(&periodic_timer_args, &periodic_timer));
        ESP_ERROR_CHECK(esp_timer_start_periodic(periodic_timer, LV_TICK_PERIOD_MS * 1000));

        /*** Create simple label and show LVGL version ***/

        sprintf(txt, "WT32-SC01 with LVGL v%d.%d.%d", lv_version_major(), lv_version_minor(), lv_version_patch());

        lv_obj_t *label = lv_label_create(lv_scr_act()); // full screen as the parent
        lv_label_set_text(label, txt);                   // set label text
        lv_obj_align(label, LV_ALIGN_TOP_MID, 0, 20);    // Center but 20 from the top

        tlabel = lv_label_create(lv_scr_act());         // full screen as the parent
        lv_label_set_text(tlabel, "Touch:(000,000)");   // set label text
        lv_obj_align(tlabel, LV_ALIGN_TOP_RIGHT, 0, 0); // Center but 20 from the top

        lv_button_demo(); // lvl buttons

        while (1)
        {
            lv_timer_handler(); /* let the GUI do its work */
            vTaskDelay(1);
            abort();
        }
    }

Logs

I (0) cpu_start: App cpu up.
I (304) cpu_start: Pro cpu start user code
I (304) cpu_start: cpu freq: 240000000 Hz
I (304) cpu_start: Application information:
I (309) cpu_start: Project name:     lvgl-wt32-sc01
I (315) cpu_start: App version:      730fce4-dirty
I (320) cpu_start: Compile time:     Oct 23 2022 20:56:10
I (326) cpu_start: ELF file SHA256:  0a9ed23c2d3f7a5f...
I (332) cpu_start: ESP-IDF:          v5.1-dev-1146-g1308ff3d21
I (339) heap_init: Initializing. RAM available for dynamic allocation:
I (346) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (352) heap_init: At 3FFBDE10 len 000221F0 (136 KiB): DRAM
I (358) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (365) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (371) heap_init: At 4008CB6C len 00013494 (77 KiB): IRAM
I (378) spi_flash: detected chip: generic
I (382) spi_flash: flash io: dio
I (387) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (397) gpio: GPIO[15]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (407) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (417) gpio: GPIO[22]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (447) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (447) gpio: GPIO[15]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (447) gpio: GPIO[15]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (457) gpio: GPIO[15]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (467) gpio: GPIO[13]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (477) gpio: GPIO[14]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (487) gpio: GPIO[21]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (497) gpio: GPIO[13]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (507) gpio: GPIO[14]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (517) LovyanGFX: [Autodetect] WT32_SC01
I (517) gpio: GPIO[15]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (527) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (537) gpio: GPIO[22]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (547) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (1047) gpio: GPIO[39]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (1047) gpio: GPIO[19]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (1047) gpio: GPIO[18]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 

abort() was called at PC 0x400d827b on core 0
0x400d827b: app_main at /home/dizcza/Projects/Embedded/eclipse-workspace/other/LVGL8-WT32-SC01-IDF/main/main.cpp:114

Backtrace: 0x40081e2e:0x3ffc0430 0x400862e5:0x3ffc0450 0x4008b726:0x3ffc0470 0x400d827b:0x3ffc04e0 0x4011f557:0x3ffc0520
0x40081e2e: panic_abort at /home/dizcza/tools/esp-idf/components/esp_system/panic.c:417

0x400862e5: esp_system_abort at /home/dizcza/tools/esp-idf/components/esp_system/esp_system.c:135

0x4008b726: abort at /home/dizcza/tools/esp-idf/components/newlib/abort.c:38

0x400d827b: app_main at /home/dizcza/Projects/Embedded/eclipse-workspace/other/LVGL8-WT32-SC01-IDF/main/main.cpp:114

0x4011f557: main_task at /home/dizcza/tools/esp-idf/components/freertos/FreeRTOS-Kernel/portable/port_common.c:131 (discriminator 2)

ELF file SHA256: 0a9ed23c2d3f7a5f

Rebooting...
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:7024
load:0x40078000,len:15380
ho 0 tail 12 room 4
load:0x40080400,len:3816
0x40080400: _init at ??:?

entry 0x40080648
I (29) boot: ESP-IDF v5.1-dev-1146-g1308ff3d21 2nd stage bootloader
I (29) boot: compile time Oct 21 2022 22:19:18
I (31) boot: chip revision: V100
I (35) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (42) boot.esp32: SPI Speed      : 80MHz
I (46) boot.esp32: SPI Mode       : DIO
I (51) boot.esp32: SPI Flash Size : 4MB
I (55) boot: Enabling RNG early entropy source...
I (61) boot: Partition Table:
I (64) boot: ## Label            Usage          Type ST Offset   Length
I (72) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (79) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (87) boot:  2 factory          factory app      00 00 00010000 00100000
I (94) boot: End of partition table
I (98) boot_comm: chip revision: 1, min. application chip revision: 0
I (105) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=10840h ( 67648) map
I (134) esp_image: segment 1: paddr=00020868 vaddr=3ffb0000 size=026d8h (  9944) load
I (138) esp_image: segment 2: paddr=00022f48 vaddr=40080000 size=0cb6ch ( 52076) load
I (158) esp_image: segment 3: paddr=0002fabc vaddr=50000000 size=00010h (    16) load
I (159) esp_image: segment 4: paddr=0002fad4 vaddr=00000000 size=00544h (  1348) 
I (164) esp_image: segment 5: paddr=00030020 vaddr=400d0020 size=4f700h (325376) map
I (277) boot: Loaded app from partition at offset 0x10000
I (277) boot: Disabling RNG early entropy source...
I (289) cpu_start: Pro cpu up.
I (289) cpu_start: Starting app cpu, entry point is 0x400812b4
0x400812b4: call_start_cpu1 at /home/dizcza/tools/esp-idf/components/esp_system/port/cpu_start.c:146

I (275) cpu_start: App cpu up.
I (305) cpu_start: Pro cpu start user code
I (305) cpu_start: cpu freq: 240000000 Hz
I (305) cpu_start: Application information:
I (310) cpu_start: Project name:     lvgl-wt32-sc01
I (316) cpu_start: App version:      730fce4-dirty
I (321) cpu_start: Compile time:     Oct 23 2022 20:56:10
I (327) cpu_start: ELF file SHA256:  0a9ed23c2d3f7a5f...
I (333) cpu_start: ESP-IDF:          v5.1-dev-1146-g1308ff3d21
I (340) heap_init: Initializing. RAM available for dynamic allocation:
I (347) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (353) heap_init: At 3FFBDE10 len 000221F0 (136 KiB): DRAM
I (359) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (366) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (372) heap_init: At 4008CB6C len 00013494 (77 KiB): IRAM
I (379) spi_flash: detected chip: generic
I (383) spi_flash: flash io: dio
I (388) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (398) gpio: GPIO[15]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (408) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (418) gpio: GPIO[22]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (448) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (448) gpio: GPIO[15]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (448) gpio: GPIO[15]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (458) gpio: GPIO[15]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (468) gpio: GPIO[13]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (478) gpio: GPIO[14]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (488) gpio: GPIO[21]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (498) gpio: GPIO[13]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (508) gpio: GPIO[14]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (518) gpio: GPIO[15]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (528) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (538) gpio: GPIO[22]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (568) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (568) gpio: GPIO[15]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (568) gpio: GPIO[15]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (578) gpio: GPIO[15]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (588) gpio: GPIO[13]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (598) gpio: GPIO[14]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (608) gpio: GPIO[21]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (618) gpio: GPIO[13]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (628) gpio: GPIO[14]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (638) gpio: GPIO[15]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (648) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (658) gpio: GPIO[22]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (688) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (688) gpio: GPIO[15]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (688) gpio: GPIO[15]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (698) gpio: GPIO[15]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (708) gpio: GPIO[13]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (718) gpio: GPIO[14]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (728) gpio: GPIO[21]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (738) gpio: GPIO[13]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (748) gpio: GPIO[14]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (758) gpio: GPIO[15]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (768) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (778) gpio: GPIO[22]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (808) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (808) gpio: GPIO[15]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (808) gpio: GPIO[15]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (818) gpio: GPIO[15]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (828) gpio: GPIO[13]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (838) gpio: GPIO[14]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (848) gpio: GPIO[21]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (858) gpio: GPIO[13]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (868) gpio: GPIO[14]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (878) gpio: GPIO[15]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (888) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (898) gpio: GPIO[22]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (928) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (928) gpio: GPIO[15]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (928) gpio: GPIO[15]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (938) gpio: GPIO[15]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (948) gpio: GPIO[13]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (958) gpio: GPIO[14]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (968) gpio: GPIO[21]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (978) gpio: GPIO[13]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (988) gpio: GPIO[14]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 

abort() was called at PC 0x400d827b on core 0
0x400d827b: app_main at /home/dizcza/Projects/Embedded/eclipse-workspace/other/LVGL8-WT32-SC01-IDF/main/main.cpp:114

Backtrace: 0x40081e2e:0x3ffc0430 0x400862e5:0x3ffc0450 0x4008b726:0x3ffc0470 0x400d827b:0x3ffc04e0 0x4011f557:0x3ffc0520
0x40081e2e: panic_abort at /home/dizcza/tools/esp-idf/components/esp_system/panic.c:417

0x400862e5: esp_system_abort at /home/dizcza/tools/esp-idf/components/esp_system/esp_system.c:135

0x4008b726: abort at /home/dizcza/tools/esp-idf/components/newlib/abort.c:38

0x400d827b: app_main at /home/dizcza/Projects/Embedded/eclipse-workspace/other/LVGL8-WT32-SC01-IDF/main/main.cpp:114

0x4011f557: main_task at /home/dizcza/tools/esp-idf/components/freertos/FreeRTOS-Kernel/portable/port_common.c:131 (discriminator 2)

As you see, the first attempt succeeds - WT32-SC01 has been correctly detected - but not the following (all others fail).

dizcza commented 1 year ago

Keeping simple & same behavior:

    void app_main(void)
    {
        lcd.init(); // Initialize LovyanGFX

        while (1)
        {
            vTaskDelay(1);
            abort();
        }
    }
tobozo commented 1 year ago

unless the MISO pin of this original thread is involved, I suggest you create a new issue for that

meanwhile here some thoughts about the issue:

esp32-arduino packkage had an issue with similar symptoms involving SPI and SD Card, where SD.begin() would only work once per power cycle and fail across resets.

it turned out to fail 7 times in a row, then work once, then fail 7 times again... some bit shifting was occuring and affecting CS pin handling, causing timeouts and other side effects such as preventing the next init to respond normally.

it was fixed with the appearance of a new esp-idf config flag that affected SPI behaviour, it came with esp-idf 4.4

wild suggestion: make this a feature, detect when a reset has occured, and skip the init :-)

if( rtc_get_reset_reason(0)!=12 /* SW_CPU_RESET */ ) 
{
  lcd.init();
}