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

Demo tested with esp32-3248S035C ? #43

Open
noeldodd opened this issue Sep 2, 2024 · 14 comments
Open

Demo tested with esp32-3248S035C ? #43

noeldodd opened this issue Sep 2, 2024 · 14 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@noeldodd
Copy link

noeldodd commented Sep 2, 2024

Does the esp32-3248S035C, with it's higher resolution, have sufficient memory to run the demo? Mine hangs at lv_display_set_buffers

I'm not sure if this is a esp32-smartdisplay-demo, an lvgl thing, or if the board can't be used this way. When shipped it had the lvgl demo on it, and the display & cap touch worked fine so I don't think it's bum hardware.

But this demo hangs at lv_display_set_buffers; I added some extra log statements in lvgl to localize it:

rst:0x1 (POWERON_RESET),boot:0x13 (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:2
load:0x3fff0030,len:1184
load:0x40078000,len:13232
load:0x40080400,len:3028
entry 0x400805e4
[     7][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
[  5024][V][esp32-hal-uart.c:330] uartBegin(): UART0 baud(115200) Mode(800001c) rxPin(3) txPin(1)
[  5034][V][esp32-hal-uart.c:416] uartBegin(): UART0 not installed. Starting installation
[  5045][V][esp32-hal-uart.c:463] uartBegin(): UART0 initialization done.
[  5059][I][main.cpp:27] setup(): Board: esp32-3248S035C
[  5064][I][main.cpp:28] setup(): CPU: ESP32-D0WD-V3 rev3, CPU Freq: 240 Mhz, 2 core(s)
[  5072][I][main.cpp:29] setup(): Free heap: 245552 bytes
[  5078][I][main.cpp:30] setup(): Free PSRAM: 0 bytes
[  5082][I][main.cpp:31] setup(): SDK version: v4.4.7-dirty
[  5088][D][esp32_smartdisplay.c:159] smartdisplay_init(): smartdisplay_init
[  5095][D][esp32_smartdisplay.c:110] smartdisplay_led_set_rgb(): R:0, G:0, B:0
[  5103][I][esp32_smartdisplay.c:37] lvgl_log(): [Info] (0.000, +0)      lv_init: begin lv_init.c:160

[  5121][V][lvgl_panel_st7796_spi.c:34] lvgl_lcd_init(): display:0x3ffc2bfc
[  5128][V][lvgl_panel_st7796_spi.c:37] lvgl_lcd_init(): heap_caps_malloc w/ 3 x 38400 = 115200
[  5137][V][lvgl_panel_st7796_spi.c:40] lvgl_lcd_init(): lv_display_set_buffers...

I also tried changing the LV_MEM_SIZE calculation in lv_conf.h; same result:

#if LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN
    /*Size of the memory available for `lv_malloc()` in bytes (>= 2kB)*/
    #define LV_MEM_SIZE (96 * 1024U)          /*[bytes] - was 64x, 128==error */

If it is supposed to work I can chase it down with lvgl.

--- edit ---
My issue is likely caused by the complexity of platformio. I can get the lvgllvgl_arduino demo that prints Hello Arduino, I'm LVGL! to the center of TFT working, so I came back to this lib and started from scratch. At one point I caught sight of a notification that had something about too many ???... pausing updates for 10 minutes which might? be due to libraries being added to all the board defs? So I'm not sure what state the files are in. At any rate, it doesn't even turn on the backlight before hanging in the same place (lvgl_lcd_init).

Interestingly I couldn't just turn on the 'use demo widgets' in the lvgl demo; 'out of memory'. So I'm back to wondering if it's the lack of psram + higher screen resolution on this model.

@rzeldent rzeldent self-assigned this Sep 4, 2024
@rzeldent rzeldent added the bug Something isn't working label Sep 4, 2024
@rzeldent
Copy link
Owner

rzeldent commented Sep 4, 2024

The 3248S035 have no psram so this is probably tricky to get this running.
In LVGL9 the memory allocation has been changed so might be causing runtime problems.

@noeldodd
Copy link
Author

noeldodd commented Sep 7, 2024

I can confirm the unit works with the vanilla lvgl / tft_espi / gt911 packages under platformio, and this config in main.cpp;

#define TFT_HOR_RES   320
#define TFT_VER_RES   480
#define DRAW_BUF_SIZE (TFT_HOR_RES * TFT_VER_RES / 10 * (LV_COLOR_DEPTH / 8))
uint32_t draw_buf[DRAW_BUF_SIZE / 4]; 

I think the only change was operating in portrait mode.

I did a good deal of package/file housekeeping and to get it to compile I had to move around a few of their header files, so I'm betting it will just work when I retest es32-smartdisplay.

@noeldodd
Copy link
Author

noeldodd commented Sep 7, 2024

Also identical are the pin defs in tft_espi's User_Setup.h and the board def in esp32-3248S035C.json (except spi freq of 24000000 vs 27000000 ). It also defines the display in portrait mode, so that wasn't it.

I recreated an almost empty app but I'm still seeing a hang at smartdisplay_init(), which never returns. I have #define LV_USE_LOG 1 in lvgl_conf.h and set to LV_LOG_LEVEL_TRACE but log_v et al won't log anything.

If platformio.ini contains just one of these lines, similar to the guide for esp-smarthome, logging won't be enabled:

-D LV_CONF_PATH="${PROJECT_DIR}/include/lv_conf.h" 
'-D LV_CONF_PATH=${PROJECT_DIR}/include/lv_conf.h' 
'-D LV_CONF_PATH=${platformio.include_dir}/lv_conf.h' 

But add these two lines before, and serial logging is fine:

    '-D BOARD_NAME="${this.board}"'
    '-D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE'
    '-D LV_CONF_PATH=${platformio.include_dir}/lv_conf.h'

So with logging now working ... it still stalls as before:

rst:0x1 (POWERON_RESET),boot:0x13 (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:2
load:0x3fff0030,len:1184
load:0x40078000,len:13232
load:0x40080400,len:3028
entry 0x400805e4
[     7][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
[    24][D][esp32_smartdisplay.c:110] smartdisplay_led_set_rgb(): R:1, G:1, B:1
[    32][I][main.cpp:17] setup(): Board: esp32-3248S035C
[    39][I][main.cpp:18] setup(): CPU: ESP32-D0WD-V3 rev3, CPU Freq: 240 Mhz, 2 core(s)
[    49][I][main.cpp:19] setup(): Free heap: 280396 bytes
[    56][I][main.cpp:20] setup(): Free PSRAM: 0 bytes
[    63][I][main.cpp:21] setup(): SDK version: v4.4.7-dirty
[    71][D][esp32_smartdisplay.c:159] smartdisplay_init(): smartdisplay_init
[    80][D][esp32_smartdisplay.c:110] smartdisplay_led_set_rgb(): R:0, G:0, B:0
[    89][I][esp32_smartdisplay.c:37] lvgl_log(): [Info] (0.000, +0)      lv_init: begin lv_init.c:160

[   109][V][lvgl_panel_st7796_spi.c:34] lvgl_lcd_init(): display:0x3ffc2b74

And main.cpp is:

#include <Arduino.h>
#include <esp32_smartdisplay.h>

void setup() {
  smartdisplay_led_set_rgb( 96,96,96);  // Make the RGB LED blip before it's reset during init()
  log_i("Board: %s", BOARD_NAME);
  log_i("CPU: %s rev%d, CPU Freq: %d Mhz, %d core(s)", ESP.getChipModel(), ESP.getChipRevision(), getCpuFrequencyMhz(), ESP.getChipCores());
  log_i("Free heap: %d bytes", ESP.getFreeHeap());
  log_i("Free PSRAM: %d bytes", ESP.getPsramSize());
  log_i("SDK version: %s", ESP.getSdkVersion());
  smartdisplay_init();
  //auto display = lv_display_get_default();
  log_i("setup() done...");
}

unsigned long lastTickMillis = 0; 

void loop() {
    // Again from https://www.youtube.com/watch?v=s4_fUwhw-dI; suggest a way to ensure no wrap?
    unsigned int tickPeriod = millis() - lastTickMillis;
    lv_tick_inc( tickPeriod );
    lastTickMillis = millis();

    lv_timer_handler(); /* let the GUI do its work */
    delay(5); /* let this time pass */
}

@noeldodd
Copy link
Author

noeldodd commented Sep 7, 2024

May have cracked it; if I divide the buffer size by 4 in lvgl_panel_st7796_spi.c, (line 36-ish)

uint32_t drawBufferSize = sizeof(lv_color_t) * LVGL_BUFFER_PIXELS / 4;

I get a white display (I'm not drawing anything yet), and I can get 500ms debug prints from loop(), so it is no longer hanging. I guessed that 115200 bytes of draw buffer was too large, seeing as the draw buffer in lv_conf, line 108, was only 24k.

Edit: Yahtzee! - With that change to line 36, the demo works!

@rzeldent
Copy link
Owner

rzeldent commented Sep 8, 2024

Hi Noel,

I was looking at this issue and saw that there was already some reduction in the buffersize present:

In the file esp32-3248S035C.json there is already a reduction in the buffer size; only a quarter if the screen is used:

"'-D LVGL_BUFFER_PIXELS=(DISPLAY_WIDTH*DISPLAY_HEIGHT/4)'",

This is probably too optimistic because of the limited memory.

I propose to update the value in the esp32-3248S035C.json to something more workable. Some tweaking is required here.
So could you check out if if you change the line above (and have the original esp32-smartdisplay) to:

"'-D LVGL_BUFFER_PIXELS=(DISPLAY_WIDTH*DISPLAY_HEIGHT/16)'",

It also works? To test this you will have to delete the precompiled files in the .pio directory and rebuild the libraries...

@noeldodd
Copy link
Author

noeldodd commented Sep 9, 2024

Ok, I did this:

  • returned the line I changed in lvgl_panel_st7796_spi.c to NOT divide by 4
  • changed the line in esp32-3248S035C.json to divide by 16 (from your comment above)
  • deleted the build dir, recompiled, uploaded ...

...and it works just fine. Clicking on the 'rotate' button the redrawing is visible and smooth.

For giggles I changed it again to /32 (!) and it STILL works. It might be the smallest amount slower to redraw, but it's hard to tell without maybe recording it with a camera and counting video frames.

At /64 it still works and redrawing is still smooth - but it is slower... 1 second per screen?. So it must be efficient at shuffling those screen buffers around. Perhaps it might be more noticeable with a large-ish bitmap to redraw? I don't know how to turn on the FPS counter (yet).

In any event I think we can safely say it's tested with this hardware, which was my original question... pretty amazing, actually!

BTW, thanks for the effort on this lib; it's nice to have it consolidated like this!

If there are more tests you'd like, let me know. I've just started tinkering with squareline, so it'll be a while before the hardware shuffles off to it's new home. It's a hobby project, so no hard deadlines.

@pilamrocky
Copy link

First off I have been battling the board I bought ( ESP32-3248S035C ) for weeks to get it running. Although most of that time was spent trying to get lv_micropython on it. Finding this repo has been a God send.

I also had a lot of issue trying to get past the screen loading. I started over from scratch and only made the change you suggested by changing the board setting to "'-D LVGL_BUFFER_PIXELS=(DISPLAY_WIDTH*DISPLAY_HEIGHT/16)'" like you instructed. The demo loaded fine.

@pilamrocky
Copy link

While we are talking about this file I also noticed the SRAM is set to 320KB. According the AliExpress page you have linked in this file the SRAM is 520KB.

"maximum_ram_size": 327,680
"maximum_ram_size": 532480

I made this change and so far it is working.

@rzeldent
Copy link
Owner

I look at platformio for the boards definitions. I think they're a bit more reliable than AliExpress...

https://registry.platformio.org/platforms/platformio/espressif32/boards

@pilamrocky
Copy link

Understood. I found a few other sites that also mentioned 520KB, so I reach out to the seller for the product sheet for that specific board (ESP32-3248S035R/C) and this is what it says in the description.

This LCD module uses ESP32-WROOM-32 module as the main control, the main
control is a dual-core MCU, integrated WI-FI and Bluetooth functions, the main
frequency can reach 240MHz, 520KB SRAM, 448KB ROM, Flash size is 4MB.

I also found a post that says maybe 520KB is the total but some of it is for IRAM?

There is 520 KB of available SRAM (320 KB of DRAM and 200 KB of IRAM) on the ESP32.

Anyways I agree that it doesn't make sense that the board would be different then what the chip specifies that it has on it. I guess I will leave it as 320KB for now, I would just hate to miss out on memory that might be available. I don't know how to probe the board to know for sure.

Thanks for responding.

@lostPixels
Copy link

I had the same issue and can confirm that adjusting this line fixed it: "'-D LVGL_BUFFER_PIXELS=(DISPLAY_WIDTH*DISPLAY_HEIGHT/16)'"

@danielbonnells
Copy link

I've edited the aforementioned line and it does show something on the screen, but it only lasts for a few seconds before rebooting. Any ideas?

@rzeldent rzeldent added the help wanted Extra attention is needed label Nov 16, 2024
@rzeldent
Copy link
Owner

Still not working? Can you test with the latest version?

@jwitczak180
Copy link

jwitczak180 commented Dec 28, 2024

Tested with current/latest version. Verified the line above is as recommended (/16). Seems like this might be a new issue (or just with my hardware) - but thought I'd chime in here first.

rst:0xc (SW_CPU_RESET),boot:0x13 (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:2
load:0x3fff0030,len:1184
load:0x40078000,len:13192
load:0x40080400,len:3028
entry 0x400805e4
[  5027][I][main.cpp:27] setup(): Board: esp32-3248S035C
[  5028][I][main.cpp:28] setup(): CPU: ESP32-D0WDQ5 rev3, CPU Freq: 240 Mhz, 2 core(s)
[  5029][I][main.cpp:29] setup(): Free heap: 276700 bytes
[  5034][I][main.cpp:30] setup(): Free PSRAM: 0 bytes
[  5039][I][main.cpp:31] setup(): SDK version: v4.4.4
[  5256][I][esp32-hal-adc.c:235] __analogReadMilliVolts(): ADC1: Characterized using eFuse Vref: 1107

E (5262) spi_master: check_trans_valid(689): txdata transfer > host maximum
E (5263) lcd_panel.io.spi: panel_io_spi_tx_color(380): spi transmit (queue) color failed
[  5282][E][esp_panel_st7796.c:174] st7796_draw_bitmap(): Sending RAMWR failed
ESP_ERROR_CHECK failed: esp_err_t 0x102 (ESP_ERR_INVALID_ARG) at 0x40088b20
file: ".pio/libdeps/esp32-3248S035C/esp32_smartdisplay/src/lvgl_panel_st7796_spi.c" line 29
func: st7796_lv_flush
expression: esp_lcd_panel_draw_bitmap(panel_handle, area->x1, area->y1, area->x2 + 1, area->y2 + 1, px_map)

abort() was called at PC 0x40088b23 on core 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants