本チュートリアルでは、ESP-IDF 開発環境に Core2 ボードサポートパッケージ(BSP)を統合する方法を紹介します。これにより、オンボード周辺機器ドライバーの迅速な初期化と管理が可能となり、開発効率を向上させます。
v5.4.1
の使用を推奨します. ./export.sh
コマンドの .
とスクリプトファイル名の間に半角スペースが必要です。このコマンドは 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
コマンドはすべて ESP-IDF に依存しています。コマンドを実行する前に、プロジェクトディレクトリで . ./export.sh
を呼び出して環境変数を有効化してください。詳細は ESP-IDF - ESP32 Getting Started Guide を参照してください。cores2_projects
という名前のプロジェクトフォルダを作成します。フォルダに移動した後、esp-idf プロジェクトの export.sh
を呼び出して環境変数を有効化します。以下のコマンドは cores2_projects
フォルダと esp-idf
が同階層にある場合を想定しています。パスが異なる場合は適宜修正してください。次に、以下の idf.py create-project
コマンドを実行して空のプロジェクトテンプレートを作成します。例としてプロジェクト名は 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
を実行し、Component config
-> LVGL Configuration
-> Demos
で対応する LVGL デモを有効にしてください。idf.py flash