Skip to content

Commit

Permalink
Single binary for flashing and testing (#6)
Browse files Browse the repository at this point in the history
* doc: instructions for merging applications
* switch default idf_components to ESP32-S3-BOX-3
* add ESP32-P4 build
* doc: add screenshot from the application
* doc: remove partition table and bootloader from uf2 instructions
  • Loading branch information
georgik authored Jul 16, 2024
1 parent e927427 commit 9c905da
Show file tree
Hide file tree
Showing 17 changed files with 276 additions and 40 deletions.
2 changes: 1 addition & 1 deletion Apps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function(build_and_flash_app APP ADDR)

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
COMMAND esptool.py --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)
Expand Down
38 changes: 33 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

3rd stage graphical bootloader which let's you pick an applications whic are stored in OTA partitions.

![ESP32-S3-Box-3 Graphical Bootloader](doc/esp32-s3-box-3-graphical-bootloader.webp)


## 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:
Expand Down Expand Up @@ -32,6 +35,17 @@ Finish the configuration (copy of proper idf_component.yml to main and all appli
cmake -P SelectBoard.cmake
```

### Switching to other board

If you already built a project for existing board and you'd like to build for a different one, then it's necessary remove sdkconfig created for the specific HW.

```shell
rm -rf managed_components sdkconfig build
idf.py fullclean
```

You should repeat this process also for applications.

## Quick start

Build and flash all applications at once:
Expand All @@ -47,22 +61,36 @@ cmake -S . -B build -P Apps.cmake
idf.py build flash
pushd apps/tic_tac_toe
idf.py build
esptool.py --chip esp32s3 --baud 921600 --before default_reset --after hard_reset write_flash 0x220000 build/tic_tac_toe.bin
esptool.py --before default_reset --after hard_reset write_flash 0x220000 build/tic_tac_toe.bin
popd
pushd apps/wifi_list
esptool.py --chip esp32s3 --baud 921600 --before default_reset --after hard_reset write_flash 0x4E0000 build/wifi_list.bin
esptool.py --before default_reset --after hard_reset write_flash 0x4E0000 build/wifi_list.bin
popd
pushd apps/calculator
esptool.py --chip esp32s3 --baud 921600 --before default_reset --after hard_reset write_flash 0x7A0000 build/calculator.bin
esptool.py --before default_reset --after hard_reset write_flash 0x7A0000 build/calculator.bin
popd
pushd apps/synth_piano
esptool.py --chip esp32s3 --baud 921600 --before default_reset --after hard_reset write_flash 0xA60000 build/synth_piano.bin
esptool.py --before default_reset --after hard_reset write_flash 0xA60000 build/synth_piano.bin
popd
pushd apps/game_of_life
esptool.py --chip esp32s3 --baud 921600 --before default_reset --after hard_reset write_flash 0xD20000 build/game_of_life.bin
esptool.py --before default_reset --after hard_reset write_flash 0xD20000 build/game_of_life.bin
popd
```

### Merging all applications

Following command merges all applications into UF2 format:

```
esptool.py --chip esp32s3 merge_bin --format uf2 -o build/uf2.bin --flash_mode dio --flash_size 16MB \
0x10000 build/esp32-graphical-bootloader.bin \
0x220000 apps/tic_tac_toe/build/tic_tac_toe.bin \
0x4E0000 apps/wifi_list/build/wifi_list.bin \
0x7A0000 apps/calculator/build/calculator.bin \
0xA60000 apps/synth_piano/build/synth_piano.bin \
0xD20000 apps/game_of_life/build/game_of_life.bin
```

## Build

Initial build and flash of the application and partition table.
Expand Down
40 changes: 40 additions & 0 deletions SingleImage.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Paths to binaries
set(BOOTLOADER_BIN "${CMAKE_SOURCE_DIR}/build/bootloader/bootloader.bin")
set(PARTITION_TABLE_BIN "${CMAKE_SOURCE_DIR}/build/partition_table/partition-table.bin")

set(TIC_TAC_TOE_BIN "${CMAKE_SOURCE_DIR}/apps/tic_tac_toe/build/tic_tac_toe.bin")
set(WIFI_LIST_BIN "${CMAKE_SOURCE_DIR}/apps/wifi_list/build/wifi_list.bin")
set(CALCULATOR_BIN "${CMAKE_SOURCE_DIR}/apps/calculator/build/calculator.bin")
set(SYNTH_PIANO_BIN "${CMAKE_SOURCE_DIR}/apps/synth_piano/build/synth_piano.bin")
set(GAME_OF_LIFE_BIN "${CMAKE_SOURCE_DIR}/apps/game_of_life/build/game_of_life.bin")

# Output files
set(COMBINED_BIN "${CMAKE_SOURCE_DIR}/combined.bin")
set(COMBINED_UF2 "${CMAKE_SOURCE_DIR}/combined.uf2")

# Add custom target to merge binaries
add_custom_target(merge_binaries ALL
COMMAND ${CMAKE_COMMAND} -E echo "Merging binaries into ${COMBINED_BIN}..."
COMMAND esptool.py --chip esp32s3 merge_bin -o ${COMBINED_BIN}
--flash_mode dio --flash_freq 80m --flash_size 16MB
0x1000 ${BOOTLOADER_BIN}
0x8000 ${PARTITION_TABLE_BIN}
0x220000 ${TIC_TAC_TOE_BIN}
0x4E0000 ${WIFI_LIST_BIN}
0x7A0000 ${CALCULATOR_BIN}
0xA60000 ${SYNTH_PIANO_BIN}
0xD20000 ${GAME_OF_LIFE_BIN}
COMMAND ${CMAKE_COMMAND} -E echo "Converting ${COMBINED_BIN} to ${COMBINED_UF2}..."
COMMAND python ${CMAKE_SOURCE_DIR}/uf2conv.py ${COMBINED_BIN} --chip esp32s3 --base 0x0 --output ${COMBINED_UF2}
COMMENT "Merging and converting binaries to UF2"
VERBATIM
)

# Ensure merge_binaries runs after all binaries are built
add_dependencies(merge_binaries
tic_tac_toe_app
wifi_list_app
calculator_app
synth_piano_app
game_of_life_app
)
9 changes: 3 additions & 6 deletions apps/calculator/main/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
## IDF Component Manager Manifest File
description: ESP32 Graphical Bootloader

dependencies:
espressif/esp-box: "^3.1.0"
#espressif/esp-box-3: "^1.2.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"
## Required IDF version
idf:
version: ">=5.0.0"
33 changes: 33 additions & 0 deletions apps/calculator/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

9 changes: 3 additions & 6 deletions apps/game_of_life/main/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
## IDF Component Manager Manifest File
description: ESP32 Graphical Bootloader

dependencies:
espressif/esp-box: "^3.1.0"
#espressif/esp-box-3: "^1.2.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"
## Required IDF version
idf:
version: ">=5.0.0"
33 changes: 33 additions & 0 deletions apps/game_of_life/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

9 changes: 3 additions & 6 deletions apps/synth_piano/main/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
## IDF Component Manager Manifest File
description: ESP32 Graphical Bootloader

dependencies:
espressif/esp-box: "^3.1.0"
#espressif/esp-box-3: "^1.2.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"
## Required IDF version
idf:
version: ">=5.0.0"
33 changes: 33 additions & 0 deletions apps/synth_piano/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

9 changes: 3 additions & 6 deletions apps/tic_tac_toe/main/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
## IDF Component Manager Manifest File
description: ESP32 Graphical Bootloader

dependencies:
espressif/esp-box: "^3.1.0"
#espressif/esp-box-3: "^1.2.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"
## Required IDF version
idf:
version: ">=5.0.0"
33 changes: 33 additions & 0 deletions apps/tic_tac_toe/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

9 changes: 3 additions & 6 deletions apps/wifi_list/main/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
## IDF Component Manager Manifest File
description: ESP32 Graphical Bootloader

dependencies:
espressif/esp-box: "^3.1.0"
#espressif/esp-box-3: "^1.2.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"
## Required IDF version
idf:
version: ">=5.0.0"
33 changes: 33 additions & 0 deletions apps/wifi_list/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

16 changes: 16 additions & 0 deletions diagram.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": 1,
"author": "Uri Shaked",
"editor": "wokwi",
"parts": [
{
"type": "board-esp32-s3-box-3",
"id": "esp32",
"top": -24.91,
"left": -388.54,
"attrs": { "psramSize": "16", "flashSize": "16" }
}
],
"connections": [ [ "$serialMonitor:RX", "esp32:G14", "", [] ], [ "$serialMonitor:TX", "esp32:G11", "", [] ] ],
"dependencies": {}
}
Binary file added doc/esp32-s3-box-3-graphical-bootloader.webp
Binary file not shown.
5 changes: 1 addition & 4 deletions main/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
description: ESP32 Graphical Bootloader

dependencies:
espressif/esp-box: "^3.1.0"
#espressif/esp-box-3: "^1.2.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"
#m5stack_core_s3:
# version: "^1.0.0"
Loading

0 comments on commit 9c905da

Please sign in to comment.