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

esp_lvgl_port random restart; (BSP-573) #422

Open
1 task done
semenishchev opened this issue Oct 27, 2024 · 0 comments
Open
1 task done

esp_lvgl_port random restart; (BSP-573) #422

semenishchev opened this issue Oct 27, 2024 · 0 comments
Labels

Comments

@semenishchev
Copy link

Board

ESP32S3-DevkitC N16R8

Hardware Description

ST7789 attached to SPI2 (35, 36, 37)

IDE Name

VSCODE

Operating System

MacOS Sonoma

Description

I have this

printf("Loading display handle\n");
disp_handle = lvgl_port_add_disp(&disp_cfg);
printf("HANDLE LOADED\n");

and ESP goes into the boot loop without reaching HANDLE LOADED and printing out literally anything. It just restarts

Here are logs with verbose level logging: https://pastebin.com/vnQhgQsj

Sketch

/*
 * SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD
 *
 * SPDX-License-Identifier: CC0-1.0
 */

#include <stdio.h>
#include <inttypes.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_chip_info.h"
#include "esp_flash.h"
#include "esp_system.h"
#include "lvgl.h"
#include "esp_lvgl_port.h"
#include "esp_lvgl_port_disp.h"
#include "esp_lcd_panel_io.h"
#include "esp_lcd_panel_vendor.h"
#include "driver/gpio.h"
#include "driver/spi_master.h"
#include "esp_system.h"
#include "esp_log.h"

#define DISP_WIDTH 320
#define DISP_HEIGHT 240

void app_main(void)
{
    printf("Hello world!\n");

    /* Print chip information */
    esp_chip_info_t chip_info;
    uint32_t flash_size;
    esp_chip_info(&chip_info);
    printf("This is %s chip with %d CPU core(s), %s%s%s%s, ",
           CONFIG_IDF_TARGET,
           chip_info.cores,
           (chip_info.features & CHIP_FEATURE_WIFI_BGN) ? "WiFi/" : "",
           (chip_info.features & CHIP_FEATURE_BT) ? "BT" : "",
           (chip_info.features & CHIP_FEATURE_BLE) ? "BLE" : "",
           (chip_info.features & CHIP_FEATURE_IEEE802154) ? ", 802.15.4 (Zigbee/Thread)" : "");

    unsigned major_rev = chip_info.revision / 100;
    unsigned minor_rev = chip_info.revision % 100;
    printf("silicon revision v%d.%d, ", major_rev, minor_rev);
    if(esp_flash_get_size(NULL, &flash_size) != ESP_OK) {
        printf("Get flash size failed");
        return;
    }

    printf("%" PRIu32 "MB %s flash\n", flash_size / (uint32_t)(1024 * 1024),
           (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");

    printf("Minimum free heap size: %" PRIu32 " bytes\n", esp_get_minimum_free_heap_size());
    gpio_set_direction(GPIO_NUM_13, GPIO_MODE_OUTPUT);
    gpio_set_level(GPIO_NUM_13, 1);
    // vTaskDelay(3000 / portTICK_PERIOD_MS);
    spi_bus_config_t buscfg = {
        .mosi_io_num = 35,
        .miso_io_num = 37,
        .sclk_io_num = 36,
        .max_transfer_sz = 4096
    };
    esp_err_t err = spi_bus_initialize(2, &buscfg, SPI_DMA_CH_AUTO);
    if(err != ESP_OK) {
        printf("Error occured: %s:%d\n", __FILE__, __LINE__);
        vTaskDelay(5000 / portTICK_PERIOD_MS);
        esp_restart();
        return;
    }
    const lvgl_port_cfg_t lvgl_cfg = ESP_LVGL_PORT_INIT_CONFIG();
    err = lvgl_port_init(&lvgl_cfg);
    static lv_disp_t * disp_handle;

    /* LCD IO */
    esp_lcd_panel_io_spi_config_t io_config = {
        .dc_gpio_num = GPIO_NUM_20,  // Set to your actual GPIO number for DC pin
        .cs_gpio_num = GPIO_NUM_19,  // Set to your actual GPIO number for CS pin
        .pclk_hz = 40 * 1000 * 1000, // 40MHz clock speed
        .spi_mode = 0,               // SPI mode (can vary based on your setup)
        .trans_queue_depth = 10,     // Queue depth for transactions
        .lcd_cmd_bits = 8,           // Command bit length
        .lcd_param_bits = 8,         // Parameter bit length
    };
    esp_lcd_panel_io_handle_t io_handle = NULL;
    // spi_host_ini
    err = esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t) 2, &io_config, &io_handle);
    if(err != ESP_OK) {
        printf("Error occured: %s:%d\n", __FILE__, __LINE__);
        vTaskDelay(5000 / portTICK_PERIOD_MS);
        esp_restart();
        return;
    }
    // ESP_ERROR_CHECK();
    esp_lcd_panel_dev_config_t panel_config = {
        .reset_gpio_num = -1,   // Set to your actual GPIO number for RESET pin
        .color_space = ESP_LCD_COLOR_SPACE_RGB, // Color format
        .bits_per_pixel = 16,            // Bits per pixel (RGB565)
    
        .flags = {
            .reset_active_high = true,  // Set based on your wiring
        }
    };
    /* LCD driver initialization */
    esp_lcd_panel_handle_t lcd_panel_handle;
    err = esp_lcd_new_panel_st7789(io_handle, &panel_config, &lcd_panel_handle);
    if(err != ESP_OK) {
        printf("Error occured: %s:%d\n", __FILE__, __LINE__);
        vTaskDelay(5000 / portTICK_PERIOD_MS);
        esp_restart();
        return;
    }
    /* Add LCD screen */
    const lvgl_port_display_cfg_t disp_cfg = {
        .io_handle = io_handle,
        .panel_handle = lcd_panel_handle,
        .buffer_size = DISP_WIDTH*DISP_HEIGHT,
        .trans_size = 4096,
        .double_buffer = true,
        .hres = DISP_WIDTH,
        .vres = DISP_HEIGHT,
        .monochrome = false,
        // .mipi_dsi = false,
        .color_format = LV_COLOR_FORMAT_RGB565,
        .rotation = {
            .swap_xy = false,
            .mirror_x = false,
            .mirror_y = false,
        },
        .flags = {
            .buff_dma = false,
            .buff_spiram = true,
            .swap_bytes = false,
        }
    };
    printf("Loading display handle\n");
    disp_handle = lvgl_port_add_disp(&disp_cfg);
    printf("HANDLE LOADED\n");
    lvgl_port_lock(0);
    printf("HANDLE LOCKED\n");
    lv_display_set_default(disp_handle);
    lv_obj_t* screen = lv_screen_active();
    // lv_screen_load(screen);
    if(screen == NULL) {
        printf("SCREEN IS NULL\n");
        return;
    }
    lv_obj_t* label = lv_label_create(screen);
    lv_label_set_text(label, "Hello World");
    lv_obj_set_align(label, LV_ALIGN_CENTER);
    lvgl_port_unlock();
    
    while(1) {
        vTaskDelay(5 / portTICK_PERIOD_MS);
        lv_tick_set_cb(xTaskGetTickCount);
        lv_timer_handler();
    }
}

Other Steps to Reproduce

No response

I have checked existing issues, README.md and ESP32 Forum

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@github-actions github-actions bot changed the title esp_lvgl_port random restart; esp_lvgl_port random restart; (BSP-573) Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant