pdf-icon

ESP-IDF Quick Start

2. Devices & Examples

Core2

CoreS3

Core2 ESP-IDF BSP Usage Tutorial

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.

1. Preparation

  1. Environment setup: This tutorial is based on building the ESP-IDF development environment on the Ubuntu operating system. For setup on other platforms, please refer to ESP-IDF - ESP32 Getting Started Guide.
ESP-IDF Version
This tutorial recommends using ESP-IDF version v5.4.1
  1. Use the git version control tool to clone the esp-idf project, switch to the specified branch, and run scripts to install the related toolchain.
Note
The . 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
  1. The 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.

2. Project Creation

  1. Open a terminal and navigate to your working directory. Create a project folder named 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
  1. Change into the project directory, and use the Espressif Component Registry tool to add the M5Stack Core2 BSP.
cd my_project
idf.py add-dependency "espressif/m5stack_core_2^2.0.0"
  1. Set the target chip platform:
idf.py set-target esp32

3. Example Program

  1. Open the entry file of the blank template and copy the following example program content into it.
vim main/my_project.c 
cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
#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();
}
  1. This example program demonstrates how to drive the display to show LVGL component demos. You can switch between different demos by uncommenting the corresponding lines to compile different display examples. Before using a particular demo component, run idf.py menuconfig, navigate to Component config -> LVGL Configuration -> Demos, and enable the corresponding LVGL demo.

4. Program Compilation and Flashing

  1. Execute the following command to compile and flash the program.
idf.py flash
On This Page