How georgik/esp32-graphical-bootloader works
Project type and purpose
• This is an embedded firmware project for ESP32 devices, centered on a third-stage graphical OTA bootloader that lets users pick one of several applications stored in different OTA partitions.
File structure
• Top-level:
– CMakeLists.txt, Bootloader.cmake – orchestrate building the bootloader and all apps.
– .github/workflows/build.yml – CI pipeline for building & testing.
– boards/ – board-specific .cfg files.
– partitions.csv – base partition layout.
– resources/images – UI assets for the bootloader.
• main/ – source (graphical_bootloader_main.c, bootloader_ui.c) and idf_component.yml for the bootloader.
• apps/ – five separate ESP-IDF apps (calculator, game_of_life, synth_piano, tic_tac_toe, wifi_list), each with its own CMakeLists.txt, sdkconfig.defaults, idf_component.yml, source file, and partition placement.
Extract architecture insights from the README
• The bootloader lives in the “factory” partition and renders a graphical menu on boots.
• Each app is flashed into a distinct OTA partition (ota_0…ota_4) at fixed offsets.
• Upon user selection, the bootloader sets the chosen partition as the next boot partition and reboots.
• Each app, on startup, runs fallback code (esp_ota_set_boot_partition(factory)) so that a subsequent restart returns to the bootloader.
• Build flow: can build all apps at once via Bootloader.cmake or individually with idf.py and esptool/espflash.
• A final merge step combines bootloader, partition table, OTA data, and app binaries into one flashable image.
Components
a. Hardware layer
b. Bootloader layer
– Factory partition containing graphical_bootloader_main.c, bootloader_ui.c, image resources.
– Bootloader.cmake orchestrates the build and merging process.
c. Partition management
– partitions.csv defines factory, partition_table, ota_data_initial, ota_0…ota_4.
– OTA manager (esp_ota_ops) sets next-boot partition.
d. Application layer
– Five individual ESP-IDF apps, each in its own ota_X partition:
· tic_tac_toe, wifi_list, calculator, synth_piano, game_of_life
– Each app’s main.c + idf_component.yml + sdkconfig.defaults
– Fallback code to factory partition on startup.
e. Build & deployment pipeline
– CMake (CMakeLists.txt + Bootloader.cmake) and idf.py for configuration & build.
– esptool.py or espflash for flashing binaries to specific addresses.
– .github workflows for CI.
f. Simulation & documentation
Relationships & data flows
1. Power-on → bootloader in factory partition reads partitions.csv → renders menu from resources/images.
2. User selects app → bootloader calls esp_ota_set_boot_partition(partition_of_selected_app) → system reset.
3. Device boots into selected app partition → app’s fallback code sets boot partition back to factory → system reset.
4. Device returns to bootloader.
5. Build pipeline ingests board .cfg → generates build artifacts → flash to each partition → optional merge into one combined.bin.
Architectural patterns & design principles
• OTA multi-image pattern separating bootloader and applications.
• Partition table for flexible application placement.
• Single-responsibility: bootloader solely manages UI + partition selection; apps focus on their own logic.
• Modular build: common CMake script to build all apps or single apps.
• CI/CD via GitHub Actions.