diff --git a/Apps.cmake b/Apps.cmake new file mode 100644 index 0000000..890aa19 --- /dev/null +++ b/Apps.cmake @@ -0,0 +1,58 @@ +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 +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}) +endforeach() diff --git a/README.md b/README.md index edae281..a80f3e3 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,47 @@ 3rd stage graphical bootloader which let's you pick an applications whic are stored in OTA partitions. -The default configuration for ESP32-S3-BOX. +## Selected board -For ESP32-S3-BOX-3 or M5Stack-CoreS3 - uncomment BSP in `idf_component.yml` +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 and all applications in apps directory): + +```shell +cmake -P SelectBoard.cmake +``` ## Quick start +Build and flash all applications at once: + +```shell +idf.py flash +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 new file mode 100644 index 0000000..303250d --- /dev/null +++ b/SelectBoard.cmake @@ -0,0 +1,52 @@ +# 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}") + +# 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}") +configure_file(${IDF_COMPONENT_YML_TEMPLATE} ${IDF_COMPONENT_YML_DEST} COPYONLY) + +# 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/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" diff --git a/main/bootloader_ui.c b/main/bootloader_ui.c index 01cf439..a5290f3 100644 --- a/main/bootloader_ui.c +++ b/main/bootloader_ui.c @@ -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/resources/images/icon_game_of_life.png b/resources/images/icon_game_of_life.png new file mode 100644 index 0000000..d5a786f Binary files /dev/null and b/resources/images/icon_game_of_life.png differ 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 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