This tutorial will introduce how to integrate the Core2 Board Support Package (BSP) in the ESP-IDF development environment, allowing for quick initialization and management of onboard peripheral drivers to improve development efficiency.
v5.4.1
.
in the . ./export.sh
command must be followed by a space before the script; this command is equivalent to source ./export.sh
git clone --recursive https://github.com/espressif/esp-idf.git
cd esp-idf
git checkout v5.4.1 # recommend
./install.sh
. ./export.sh
idf.py
commands used in the following tutorial all depend on ESP-IDF. Before running the commands, you need to invoke . ./export.sh
in the project directory to activate the relevant environment variables. For more details, please refer to ESP-IDF - ESP32 Getting Started Guide.cores2_projects
. After changing into this folder, invoke export.sh
from the esp-idf project to activate the environment variables. The following commands assume that the cores2_projects
folder and esp-idf
are in the same directory; adjust paths as needed. Execute the idf.py create-project
command below to create a blank project template, with the example project named my_project
.mkdir cores2_projects
cd cores2_projects
. ../esp-idf/export.sh
idf.py create-project my_project
cd my_project
idf.py add-dependency "espressif/m5stack_core_2^2.0.0"
idf.py set-target esp32
vim main/my_project.c
#include "freertos/FreeRTOS.h"#include "freertos/task.h"#include "esp_log.h" #include "lv_demos.h"#include "bsp/esp-bsp.h" static char *TAG = "app_main"; #define LOG_MEM_INFO (0) void app_main(void) { /* Initialize display and LVGL */ bsp_display_start(); /* Set display brightness to 100% */ bsp_display_backlight_on(); ESP_LOGI(TAG, "Display LVGL demo"); bsp_display_lock(0); lv_demo_widgets(); /* A widgets example */ // lv_demo_music(); /* A modern, smartphone-like music player demo. */ // lv_demo_stress(); /* A stress test for LVGL. */ // lv_demo_benchmark(); /* A demo to measure the performance of LVGL or // to compare different settings. */ bsp_display_unlock();}
idf.py menuconfig
, navigate to Component config
-> LVGL Configuration
-> Demos
, and enable the corresponding LVGL demo.idf.py flash