From 158a9b79909e4e1adad55116ac8a8955818ba3a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Mich=C3=A1lek?= Date: Tue, 16 Jul 2024 07:25:09 +0200 Subject: [PATCH 1/5] add option to configure board --- README.md | 29 ++++++++++++++ SelectBoard.cmake | 38 +++++++++++++++++++ idf_component_templates/esp-box-3.yml | 8 ++++ idf_component_templates/esp-box.yml | 8 ++++ .../esp32_p4_function_ev_board.yml | 9 +++++ idf_component_templates/m5stack_core_s3.yml | 10 +++++ 6 files changed, 102 insertions(+) create mode 100644 SelectBoard.cmake create mode 100644 idf_component_templates/esp-box-3.yml create mode 100644 idf_component_templates/esp-box.yml create mode 100644 idf_component_templates/esp32_p4_function_ev_board.yml create mode 100644 idf_component_templates/m5stack_core_s3.yml diff --git a/README.md b/README.md index edae281..d61da4e 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,35 @@ The default configuration for ESP32-S3-BOX. For ESP32-S3-BOX-3 or M5Stack-CoreS3 - uncomment BSP in `idf_component.yml` +## Selected board + +The project is by default configured for ESP32-S3-BOX-3. In case of different board please run one of following exports and then CMake command: + +- ESP32-S3-BOX-3 +```shell +export SDKCONFIG_DEFAULTS=sdkconfig.defaults.esp-box-3 +``` + +- ESP32-S3-BOX (prior Dec. 2023) +```shell +export SDKCONFIG_DEFAULTS=sdkconfig.defaults.esp-box +``` + +- ESP32-P4 +```shell +export SDKCONFIG_DEFAULTS=sdkconfig.defaults.esp32_p4_function_ev_board +``` + +- M5Stack-CoreS3 +```shell +export SDKCONFIG_DEFAULTS=sdkconfig.defaults.m5stack_core_s3 +``` + +Finish the configuration (copy of proper idf_component.yml to main): + +```shell +cmake -P SelectBoard.cmake +``` ## Quick start diff --git a/SelectBoard.cmake b/SelectBoard.cmake new file mode 100644 index 0000000..13c6192 --- /dev/null +++ b/SelectBoard.cmake @@ -0,0 +1,38 @@ +# Check if SDKCONFIG_DEFAULTS is set +if(NOT DEFINED ENV{SDKCONFIG_DEFAULTS}) + message(FATAL_ERROR "Environment variable SDKCONFIG_DEFAULTS is not set.") +else() + set(SDKCONFIG_DEFAULTS $ENV{SDKCONFIG_DEFAULTS}) +endif() + +message(STATUS "Using SDKCONFIG_DEFAULTS: ${SDKCONFIG_DEFAULTS}") + +# Map SDKCONFIG_DEFAULTS to the corresponding idf_component.yml template +if(SDKCONFIG_DEFAULTS STREQUAL "sdkconfig.defaults.esp-box") + set(IDF_COMPONENT_YML_TEMPLATE "${CMAKE_SOURCE_DIR}/idf_component_templates/esp-box.yml") +elseif(SDKCONFIG_DEFAULTS STREQUAL "sdkconfig.defaults.esp-box-3") + set(IDF_COMPONENT_YML_TEMPLATE "${CMAKE_SOURCE_DIR}/idf_component_templates/esp-box-3.yml") +elseif(SDKCONFIG_DEFAULTS STREQUAL "sdkconfig.defaults.m5stack_core_s3") + set(IDF_COMPONENT_YML_TEMPLATE "${CMAKE_SOURCE_DIR}/idf_component_templates/m5stack_core_s3.yml") +elseif(SDKCONFIG_DEFAULTS STREQUAL "sdkconfig.defaults.esp32_p4_function_ev_board") + set(IDF_COMPONENT_YML_TEMPLATE "${CMAKE_SOURCE_DIR}/idf_component_templates/esp32_p4_function_ev_board.yml") +else() + message(FATAL_ERROR "Unsupported SDKCONFIG_DEFAULTS: ${SDKCONFIG_DEFAULTS}") +endif() + +message(STATUS "IDF_COMPONENT_YML_TEMPLATE: ${IDF_COMPONENT_YML_TEMPLATE}") + +# Destination path +set(IDF_COMPONENT_YML_DEST "${CMAKE_SOURCE_DIR}/main/idf_component.yml") + +message(STATUS "Copying ${IDF_COMPONENT_YML_TEMPLATE} to ${IDF_COMPONENT_YML_DEST}") + +# Copy the appropriate idf_component.yml template +configure_file(${IDF_COMPONENT_YML_TEMPLATE} ${IDF_COMPONENT_YML_DEST} COPYONLY) + +# Verify that the file was copied +if(EXISTS ${IDF_COMPONENT_YML_DEST}) + message(STATUS "File copied successfully to ${IDF_COMPONENT_YML_DEST}") +else() + message(FATAL_ERROR "Failed to copy ${IDF_COMPONENT_YML_TEMPLATE} to ${IDF_COMPONENT_YML_DEST}") +endif() diff --git a/idf_component_templates/esp-box-3.yml b/idf_component_templates/esp-box-3.yml new file mode 100644 index 0000000..b2f6efb --- /dev/null +++ b/idf_component_templates/esp-box-3.yml @@ -0,0 +1,8 @@ +description: ESP32 Graphical Bootloader + +dependencies: + espressif/esp-box-3: "^1.2.0" + # Workaround for i2c: CONFLICT! driver_ng is not allowed to be used with this old driver + esp_codec_dev: + public: true + version: "==1.1.0" diff --git a/idf_component_templates/esp-box.yml b/idf_component_templates/esp-box.yml new file mode 100644 index 0000000..3005136 --- /dev/null +++ b/idf_component_templates/esp-box.yml @@ -0,0 +1,8 @@ +description: ESP32 Graphical Bootloader + +dependencies: + espressif/esp-box: "^3.1.0" + # Workaround for i2c: CONFLICT! driver_ng is not allowed to be used with this old driver + esp_codec_dev: + public: true + version: "==1.1.0" diff --git a/idf_component_templates/esp32_p4_function_ev_board.yml b/idf_component_templates/esp32_p4_function_ev_board.yml new file mode 100644 index 0000000..f5d1e35 --- /dev/null +++ b/idf_component_templates/esp32_p4_function_ev_board.yml @@ -0,0 +1,9 @@ +description: ESP32 Graphical Bootloader + +dependencies: + espressif/esp32_p4_function_ev_board: "^2.0.0" + #espressif/esp-box-3: "^1.2.0" + # Workaround for i2c: CONFLICT! driver_ng is not allowed to be used with this old driver + # esp_codec_dev: + # public: true + # version: "==1.1.0" diff --git a/idf_component_templates/m5stack_core_s3.yml b/idf_component_templates/m5stack_core_s3.yml new file mode 100644 index 0000000..ea46ca7 --- /dev/null +++ b/idf_component_templates/m5stack_core_s3.yml @@ -0,0 +1,10 @@ +description: ESP32 Graphical Bootloader + +dependencies: + # espressif/esp-box-3: "^1.2.0" + # Workaround for i2c: CONFLICT! driver_ng is not allowed to be used with this old driver + esp_codec_dev: + public: true + version: "==1.1.0" + m5stack_core_s3: + version: "^1.0.0" From d78100b558e4afc52759375b65415da0bebf6a5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Mich=C3=A1lek?= Date: Tue, 16 Jul 2024 09:02:56 +0200 Subject: [PATCH 2/5] add p4 --- sdkconfig.defaults.esp-box | 1 + sdkconfig.defaults.esp-box-3 | 1 + sdkconfig.defaults.esp32_p4_function_ev_board | 33 +++++++++++++++++++ sdkconfig.defaults.m5stack_core_s3 | 1 + 4 files changed, 36 insertions(+) create mode 100644 sdkconfig.defaults.esp32_p4_function_ev_board diff --git a/sdkconfig.defaults.esp-box b/sdkconfig.defaults.esp-box index 2c5ed8c..b3e1de9 100644 --- a/sdkconfig.defaults.esp-box +++ b/sdkconfig.defaults.esp-box @@ -4,3 +4,4 @@ CONFIG_IDF_TARGET="esp32s3" CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_LV_FONT_DEFAULT_MONTSERRAT_32=y diff --git a/sdkconfig.defaults.esp-box-3 b/sdkconfig.defaults.esp-box-3 index 2c5ed8c..b3e1de9 100644 --- a/sdkconfig.defaults.esp-box-3 +++ b/sdkconfig.defaults.esp-box-3 @@ -4,3 +4,4 @@ CONFIG_IDF_TARGET="esp32s3" CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_LV_FONT_DEFAULT_MONTSERRAT_32=y diff --git a/sdkconfig.defaults.esp32_p4_function_ev_board b/sdkconfig.defaults.esp32_p4_function_ev_board new file mode 100644 index 0000000..aca718d --- /dev/null +++ b/sdkconfig.defaults.esp32_p4_function_ev_board @@ -0,0 +1,33 @@ +# This file was generated using idf.py save-defconfig. It can be edited manually. +# Espressif IoT Development Framework (ESP-IDF) 5.4.0 Project Minimal Configuration +# +CONFIG_IDF_TARGET="esp32p4" +CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y +CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_LV_FONT_DEFAULT_MONTSERRAT_32=y + +CONFIG_ESPTOOLPY_FLASHMODE_QIO=y +CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y +CONFIG_COMPILER_OPTIMIZATION_PERF=y +CONFIG_SPIRAM=y +CONFIG_SPIRAM_MODE_OCT=y +CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y +CONFIG_SPIRAM_RODATA=y +CONFIG_SPIRAM_SPEED_80M=y +CONFIG_FREERTOS_HZ=1000 +CONFIG_BSP_LCD_RGB_BUFFER_NUMS=2 +CONFIG_BSP_LCD_RGB_BOUNCE_BUFFER_MODE=y +CONFIG_BSP_DISPLAY_LVGL_AVOID_TEAR=y +CONFIG_BSP_DISPLAY_LVGL_DIRECT_MODE=y +CONFIG_SPIRAM_MODE_HEX=y +CONFIG_SPIRAM_SPEED_200M=y +CONFIG_IDF_EXPERIMENTAL_FEATURES=y + +## LVGL9 ## +CONFIG_LV_CONF_SKIP=y + +#CLIB default +CONFIG_LV_USE_CLIB_MALLOC=y +CONFIG_LV_USE_CLIB_SPRINTF=y +CONFIG_LV_USE_CLIB_STRING=y + diff --git a/sdkconfig.defaults.m5stack_core_s3 b/sdkconfig.defaults.m5stack_core_s3 index 2c5ed8c..b3e1de9 100644 --- a/sdkconfig.defaults.m5stack_core_s3 +++ b/sdkconfig.defaults.m5stack_core_s3 @@ -4,3 +4,4 @@ CONFIG_IDF_TARGET="esp32s3" CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_LV_FONT_DEFAULT_MONTSERRAT_32=y From 32d136861ac545f0933103f82aaa9493031df648 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Mich=C3=A1lek?= Date: Tue, 16 Jul 2024 09:22:12 +0200 Subject: [PATCH 3/5] add missing font --- main/bootloader_ui.c | 6 +----- sdkconfig.defaults | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/main/bootloader_ui.c b/main/bootloader_ui.c index 01cf439..0881f56 100644 --- a/main/bootloader_ui.c +++ b/main/bootloader_ui.c @@ -61,7 +61,7 @@ static item_desc_t item[] = { static lv_obj_t *g_img_btn, *g_img_item = NULL; static lv_obj_t *g_lab_item = NULL; -static lv_obj_t *g_led_item[5]; +static lv_obj_t *g_led_item[6]; static size_t g_item_size = sizeof(item) / sizeof(item[0]); static lv_obj_t *g_status_bar = NULL; @@ -424,8 +424,6 @@ void ui_app5_start(void (*fn)(void)) } void bootloader_ui(lv_obj_t *scr) { - - bsp_display_lock(0); lv_obj_set_style_bg_color(lv_scr_act(), lv_color_make(237, 238, 239), LV_STATE_DEFAULT); ui_button_style_init(); @@ -453,6 +451,4 @@ void bootloader_ui(lv_obj_t *scr) { lv_obj_align(g_status_bar, LV_ALIGN_TOP_MID, 0, 0); ui_main_menu(g_item_index); - - bsp_display_unlock(); } diff --git a/sdkconfig.defaults b/sdkconfig.defaults index 2c5ed8c..b3e1de9 100644 --- a/sdkconfig.defaults +++ b/sdkconfig.defaults @@ -4,3 +4,4 @@ CONFIG_IDF_TARGET="esp32s3" CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_LV_FONT_DEFAULT_MONTSERRAT_32=y From 95155f88f2fdc981d91e63663f13ab6c28b84cc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Mich=C3=A1lek?= Date: Tue, 16 Jul 2024 11:24:41 +0200 Subject: [PATCH 4/5] add option to build and flash all applications --- Apps.cmake | 57 ++++++++++++++++++++++++++++++++++++++++++++ README.md | 15 ++++++++---- SelectBoard.cmake | 24 +++++++++++++++---- main/bootloader_ui.c | 2 +- 4 files changed, 87 insertions(+), 11 deletions(-) create mode 100644 Apps.cmake diff --git a/Apps.cmake b/Apps.cmake new file mode 100644 index 0000000..8a96f41 --- /dev/null +++ b/Apps.cmake @@ -0,0 +1,57 @@ +cmake_minimum_required(VERSION 3.5) + +# List of sub-applications +set(SUB_APP_NAMES + tic_tac_toe + wifi_list + calculator + synth_piano + game_of_life +) + +# List of corresponding flash addresses +set(SUB_APP_ADDRS + 0x220000 + 0x4E0000 + 0x7A0000 + 0xA60000 + 0xD20000 +) + +# Get the length of each list +list(LENGTH SUB_APP_NAMES LENGTH_SUB_APP_NAMES) +list(LENGTH SUB_APP_ADDRS LENGTH_SUB_APP_ADDRS) + +# Ensure both lists have the same length +if(NOT LENGTH_SUB_APP_NAMES EQUAL LENGTH_SUB_APP_ADDRS) + message(FATAL_ERROR "The number of applications does not match the number of addresses.") +endif() + +# Function to build and flash each sub-application +function(build_and_flash_app APP ADDR) + message(STATUS "Building ${APP}") + execute_process( + COMMAND idf.py build + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/apps/${APP} + RESULT_VARIABLE build_result + ) + if(NOT build_result EQUAL 0) + message(FATAL_ERROR "Failed to build ${APP}") + endif() + + message(STATUS "Flashing ${APP} to address ${ADDR}") + execute_process( + COMMAND esptool.py --chip esp32s3 --baud 921600 --before default_reset --after hard_reset write_flash ${ADDR} ${CMAKE_SOURCE_DIR}/apps/${APP}/build/${APP}.bin + RESULT_VARIABLE flash_result + ) + if(NOT flash_result EQUAL 0) + message(FATAL_ERROR "Failed to flash ${APP}") + endif() +endfunction() + +# Iterate through each sub-application and build/flash them +foreach(APP_IDX RANGE 0 ${LENGTH_SUB_APP_NAMES}-1) + list(GET SUB_APP_NAMES ${APP_IDX} APP) + list(GET SUB_APP_ADDRS ${APP_IDX} ADDR) + build_and_flash_app(${APP} ${ADDR}) +endforeach() diff --git a/README.md b/README.md index d61da4e..93512fe 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,6 @@ 3rd stage graphical bootloader which let's you pick an applications whic are stored in OTA partitions. -The default configuration for ESP32-S3-BOX. - -For ESP32-S3-BOX-3 or M5Stack-CoreS3 - uncomment BSP in `idf_component.yml` - ## Selected board The project is by default configured for ESP32-S3-BOX-3. In case of different board please run one of following exports and then CMake command: @@ -30,7 +26,7 @@ export SDKCONFIG_DEFAULTS=sdkconfig.defaults.esp32_p4_function_ev_board export SDKCONFIG_DEFAULTS=sdkconfig.defaults.m5stack_core_s3 ``` -Finish the configuration (copy of proper idf_component.yml to main): +Finish the configuration (copy of proper idf_component.yml to main and all applications in apps directory): ```shell cmake -P SelectBoard.cmake @@ -38,6 +34,15 @@ cmake -P SelectBoard.cmake ## Quick start +Build and flash all applications at once: + +```shell +idf.py flash monitor +cmake -S . -B build -P Apps.cmake +``` + +## Build applications one by one + ```shell idf.py build flash pushd apps/tic_tac_toe diff --git a/SelectBoard.cmake b/SelectBoard.cmake index 13c6192..303250d 100644 --- a/SelectBoard.cmake +++ b/SelectBoard.cmake @@ -22,17 +22,31 @@ endif() message(STATUS "IDF_COMPONENT_YML_TEMPLATE: ${IDF_COMPONENT_YML_TEMPLATE}") -# Destination path +# Copy the appropriate idf_component.yml template to main set(IDF_COMPONENT_YML_DEST "${CMAKE_SOURCE_DIR}/main/idf_component.yml") - message(STATUS "Copying ${IDF_COMPONENT_YML_TEMPLATE} to ${IDF_COMPONENT_YML_DEST}") - -# Copy the appropriate idf_component.yml template configure_file(${IDF_COMPONENT_YML_TEMPLATE} ${IDF_COMPONENT_YML_DEST} COPYONLY) -# Verify that the file was copied +# Verify that the file was copied to main if(EXISTS ${IDF_COMPONENT_YML_DEST}) message(STATUS "File copied successfully to ${IDF_COMPONENT_YML_DEST}") else() message(FATAL_ERROR "Failed to copy ${IDF_COMPONENT_YML_TEMPLATE} to ${IDF_COMPONENT_YML_DEST}") endif() + +# List of sub-applications +set(SUB_APPS calculator game_of_life synth_piano tic_tac_toe wifi_list) + +# Copy the appropriate idf_component.yml template to each sub-application +foreach(APP ${SUB_APPS}) + set(IDF_COMPONENT_YML_DEST "${CMAKE_SOURCE_DIR}/apps/${APP}/main/idf_component.yml") + message(STATUS "Copying ${IDF_COMPONENT_YML_TEMPLATE} to ${IDF_COMPONENT_YML_DEST}") + configure_file(${IDF_COMPONENT_YML_TEMPLATE} ${IDF_COMPONENT_YML_DEST} COPYONLY) + + # Verify that the file was copied to the sub-application + if(EXISTS ${IDF_COMPONENT_YML_DEST}) + message(STATUS "File copied successfully to ${IDF_COMPONENT_YML_DEST}") + else() + message(FATAL_ERROR "Failed to copy ${IDF_COMPONENT_YML_TEMPLATE} to ${IDF_COMPONENT_YML_DEST}") + endif() +endforeach() diff --git a/main/bootloader_ui.c b/main/bootloader_ui.c index 0881f56..a5290f3 100644 --- a/main/bootloader_ui.c +++ b/main/bootloader_ui.c @@ -61,7 +61,7 @@ static item_desc_t item[] = { static lv_obj_t *g_img_btn, *g_img_item = NULL; static lv_obj_t *g_lab_item = NULL; -static lv_obj_t *g_led_item[6]; +static lv_obj_t *g_led_item[5]; static size_t g_item_size = sizeof(item) / sizeof(item[0]); static lv_obj_t *g_status_bar = NULL; From 5cab308a0152ddaae8f23a797821b77f5a5b8d2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Mich=C3=A1lek?= Date: Tue, 16 Jul 2024 11:44:44 +0200 Subject: [PATCH 5/5] add option to build all applications at once --- Apps.cmake | 3 ++- README.md | 2 +- resources/images/icon_game_of_life.png | Bin 0 -> 359 bytes 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 resources/images/icon_game_of_life.png diff --git a/Apps.cmake b/Apps.cmake index 8a96f41..890aa19 100644 --- a/Apps.cmake +++ b/Apps.cmake @@ -50,7 +50,8 @@ function(build_and_flash_app APP ADDR) endfunction() # Iterate through each sub-application and build/flash them -foreach(APP_IDX RANGE 0 ${LENGTH_SUB_APP_NAMES}-1) +math(EXPR LAST_IDX "${LENGTH_SUB_APP_NAMES} - 1") +foreach(APP_IDX RANGE 0 ${LAST_IDX}) list(GET SUB_APP_NAMES ${APP_IDX} APP) list(GET SUB_APP_ADDRS ${APP_IDX} ADDR) build_and_flash_app(${APP} ${ADDR}) diff --git a/README.md b/README.md index 93512fe..a80f3e3 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ cmake -P SelectBoard.cmake Build and flash all applications at once: ```shell -idf.py flash monitor +idf.py flash cmake -S . -B build -P Apps.cmake ``` diff --git a/resources/images/icon_game_of_life.png b/resources/images/icon_game_of_life.png new file mode 100644 index 0000000000000000000000000000000000000000..d5a786f3b707bcbb33cc85aafb368d1a2d6cab24 GIT binary patch literal 359 zcmeAS@N?(olHy`uVBq!ia0vp^J|N7&1|*M957Y)yoCO|{#S9GG!XV7ZFl&wkP>``W z$lZxy-8q?;Kn_c~qpu?a!^VE@KZ&eB{vS^l$B+ufx3^AnH3f(`1m=JFzdy#eI7xcl zvQ5`?I9ks>e2~4zPOR=*ga=DEVL0zJOLEWp`{i}M35S#pDji&;X`QoobK09NUk$gN zs}vCy;{-zAn~B-gZ?