Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions Apps.cmake
Original file line number Diff line number Diff line change
@@ -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()
38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
52 changes: 52 additions & 0 deletions SelectBoard.cmake
Original file line number Diff line number Diff line change
@@ -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()
8 changes: 8 additions & 0 deletions idf_component_templates/esp-box-3.yml
Original file line number Diff line number Diff line change
@@ -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"
8 changes: 8 additions & 0 deletions idf_component_templates/esp-box.yml
Original file line number Diff line number Diff line change
@@ -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"
9 changes: 9 additions & 0 deletions idf_component_templates/esp32_p4_function_ev_board.yml
Original file line number Diff line number Diff line change
@@ -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"
10 changes: 10 additions & 0 deletions idf_component_templates/m5stack_core_s3.yml
Original file line number Diff line number Diff line change
@@ -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"
4 changes: 0 additions & 4 deletions main/bootloader_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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();
}
Binary file added resources/images/icon_game_of_life.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions sdkconfig.defaults.esp-box
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions sdkconfig.defaults.esp-box-3
Original file line number Diff line number Diff line change
Expand Up @@ -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
33 changes: 33 additions & 0 deletions sdkconfig.defaults.esp32_p4_function_ev_board
Original file line number Diff line number Diff line change
@@ -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

1 change: 1 addition & 0 deletions sdkconfig.defaults.m5stack_core_s3
Original file line number Diff line number Diff line change
Expand Up @@ -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