Skip to content

Commit

Permalink
examples: Build examples for all supported BSPs
Browse files Browse the repository at this point in the history
Many examples can be run on multiple boards.
This commit adds idf.py extension that allows user to change BSP in the example.

Closes espressif#30
  • Loading branch information
tore-espressif committed Mar 30, 2023
1 parent 4b2314d commit 5b6bdb9
Show file tree
Hide file tree
Showing 45 changed files with 433 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE/pr_template_bsp.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- [ ] Component contains idf_component.yml file with `url` field defined
- [ ] Component was added to CI [upload job](https://github.com/espressif/esp-bsp/blob/master/.github/workflows/upload_component.yml#L17)
- [ ] New files were added to CI build job
- [ ] New BSP definitions added to [build_example_for_all_bsps.sh](./build_example_for_all_bsps.sh) and to [bsp_ext.py](../examples/bsp_ext.py)
- [ ] New BSP definitions added to [bsp_ext.py](../examples/bsp_ext.py)
- [ ] _Optional:_ Component contains unit tests
- [ ] CI passing

Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/build_example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ jobs:
- name: Build ESP-BSP examples
shell: bash
run: |
export IDF_EXTRA_ACTIONS_PATH=${GITHUB_WORKSPACE}/examples
. ${IDF_PATH}/export.sh
pip install idf-component-manager --upgrade
cd examples
for d in */; do
pushd $d
idf.py build
popd
done
pip install idf-component-manager ruamel.yaml idf-build-apps==0.5.0 --upgrade
idf-build-apps find -p examples --recursive --config sdkconfig.bsp.* --target all
idf-build-apps build -p examples --recursive --config sdkconfig.bsp.* --target all --build-dir build_@w --check-warnings
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
build
build*
sdkconfig
sdkconfig.old
managed_components
Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,33 @@ ESP-IDF v5.0 brings a lot of new features, but, as the bump in major version sug

ESP-BSP is kept up-to-date with the latest ESP-IDF version, but some breaking changes in ESP-BSP API are inevitable.
Usually, BSPs compatible with IDF v5.0 are version 2. If you want to use BSP with IDF v4.4 you can still use version 1 of the particular BSP.
If you are interested in BSP examples for IDF v4.4, you can git checkout tag `examples_v4.4`.

More information about ESP-IDF breaking changes can be found in the [official migration guide](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/migration-guides/release-5.x/index.html).

### Compiling project for multiple BSPs

> :warning: **Experimental feature**: This feature is under development!
A single project can be run on multiple different development boards, if the boards contain the features required by the project (such as audio, display, camera...).
For this purpose, `idf.py` is extended by [examples/bsp_ext.py](examples/bsp_ext.py) which allows you to build an example for your specific BSP. Example command for [display](examples/display) e.g.:
```
idf.py -D SDKCONFIG_DEFAULTS=sdkconfig.bsp.esp_wrover_kit build
```

In case you want to build locally for multiple boards at the same time, it is useful to have separate build directories for each BSP configuration.
In order to achieve this, you can extend the above command like this:
```
idf.py -B build/wrover_kit -D SDKCONFIG_DEFAULTS=sdkconfig.bsp.esp_wrover_kit build
```
> Note: This feature is not yet integrated to idf.py by default. If you want to use it, you must set your environmental variable `IDF_EXTRA_ACTIONS_PATH` to path to `esp-bsp/examples/bsp_ext.py`.
## Additional information
More information about idf-component-manager can be found in [Espressif API guide](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-component-manager.html)
or [PyPi registry](https://pypi.org/project/idf-component-manager/).

You can find more information about idf.py extensions [here](https://github.com/espressif/esp-idf/blob/master/tools/idf_py_actions/README.md).

## Contributing to ESP-BSP

Please check [CONTRIBUTING.md](CONTRIBUTING.md) if you'd like to contribute to ESP-BSP.
Expand Down
3 changes: 0 additions & 3 deletions examples/audio/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
| Supported Boards | ESP32-S3-Korvo-2 |
| ---------------- | ---------------- |

# BSP: Audio example

This example demonstrates capabilities of Audio board of ESP32-S3-Korvo-2.
Expand Down
83 changes: 83 additions & 0 deletions examples/bsp_ext.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import os
from re import match, compile
from pathlib import Path
from click.core import Context
from typing import List
from idf_py_actions.tools import PropertyDict, red_print


def action_extensions(base_actions, project_path=os.getcwd()):
""" Describes extension for Board Support Packages. """

try:
import ruamel.yaml
except ImportError:
red_print('ruamel.yaml package is not installed. No BSP extension is added!')
return {}

bsp_sdkconfig_regex = compile('^SDKCONFIG_DEFAULTS=.*sdkconfig\.bsp\.')

def global_callback(ctx: Context, global_args: PropertyDict, tasks: List) -> None:
# In case the user has defined his own BSP configuration, run set-bsp action before anything else
for entry in global_args['define_cache_entry']:
if match(bsp_sdkconfig_regex, entry):
tasks.insert(0, ctx.invoke(ctx.command.get_command(ctx, 'set-bsp')))
return

def bsp_short_name(bsp):
return bsp.split('/')[-1]

def set_bsp_callback(action: str, ctx: Context, args: PropertyDict, **kwargs: str) -> None:
# Find configuration name
bsp = ''
for entry in args['define_cache_entry']:
if match(bsp_sdkconfig_regex, entry):
bsp = entry.split('.')[-1]
break

# List of supported BSPs
bsps = {
'esp_wrover_kit',
'esp32_azure_iot_kit',
'esp32_s2_kaluga_kit',
'esp32_s3_eye',
'esp32_s3_lcd_ev_board',
'esp32_s3_usb_otg',
'esp-box',
'esp32_s3_korvo_2',
}

if bsp == '': return
if bsp not in bsps:
print("Invalid BSP configuration " + bsp)
return

print('Setting project for BSP: ' + bsp)
manifest_path = Path(args['project_dir']) / 'main' / 'idf_component.yml'
yaml = ruamel.yaml.YAML()
manifest = yaml.load(manifest_path)

# Remove all BSPs
for dep in list(manifest['dependencies']):
if bsp_short_name(dep) in bsps:
del manifest['dependencies'][dep]

# Add the one we need
manifest['dependencies'].insert(0, bsp, {'version': '*', 'override_path': ('../../../' + bsp_short_name(bsp))})
yaml.dump(manifest, manifest_path)

extensions = {
'global_action_callbacks': [global_callback],
'actions': {
'set-bsp': {
'callback': set_bsp_callback,
'help': 'Utility to set Board Support Package for a project.',
'hidden': True,
'options': [],
'order_dependencies': [],
'arguments': [],
},
},
}

return extensions
3 changes: 0 additions & 3 deletions examples/display/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
| Supported Boards | Wrover kit |
| ---------------- | ---------- |

# BSP: Display example

This is a minimalistic display + LVGL graphics library example.
Expand Down
12 changes: 12 additions & 0 deletions examples/display/sdkconfig.bsp.esp-box
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32s3"
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESP_DEFAULT_CPU_FREQ_240=y
CONFIG_LV_COLOR_16_SWAP=y
CONFIG_LV_MEM_CUSTOM=y
CONFIG_LV_MEMCPY_MEMSET_STD=y
CONFIG_LV_USE_PERF_MONITOR=y
CONFIG_LV_SPRINTF_CUSTOM=y
# CONFIG_LV_BUILD_EXAMPLES is not set
12 changes: 12 additions & 0 deletions examples/display/sdkconfig.bsp.esp32_s2_kaluga_kit
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32s2"
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESP_DEFAULT_CPU_FREQ_240=y
CONFIG_LV_COLOR_16_SWAP=y
CONFIG_LV_MEM_CUSTOM=y
CONFIG_LV_MEMCPY_MEMSET_STD=y
CONFIG_LV_USE_PERF_MONITOR=y
CONFIG_LV_SPRINTF_CUSTOM=y
# CONFIG_LV_BUILD_EXAMPLES is not set
12 changes: 12 additions & 0 deletions examples/display/sdkconfig.bsp.esp32_s3_eye
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32s3"
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESP_DEFAULT_CPU_FREQ_240=y
CONFIG_LV_COLOR_16_SWAP=y
CONFIG_LV_MEM_CUSTOM=y
CONFIG_LV_MEMCPY_MEMSET_STD=y
CONFIG_LV_USE_PERF_MONITOR=y
CONFIG_LV_SPRINTF_CUSTOM=y
# CONFIG_LV_BUILD_EXAMPLES is not set
12 changes: 12 additions & 0 deletions examples/display/sdkconfig.bsp.esp32_s3_korvo_2
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32s3"
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESP_DEFAULT_CPU_FREQ_240=y
CONFIG_LV_COLOR_16_SWAP=y
CONFIG_LV_MEM_CUSTOM=y
CONFIG_LV_MEMCPY_MEMSET_STD=y
CONFIG_LV_USE_PERF_MONITOR=y
CONFIG_LV_SPRINTF_CUSTOM=y
# CONFIG_LV_BUILD_EXAMPLES is not set
12 changes: 12 additions & 0 deletions examples/display/sdkconfig.bsp.esp32_s3_lcd_ev_board
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32s3"
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESP_DEFAULT_CPU_FREQ_240=y
CONFIG_LV_COLOR_16_SWAP=y
CONFIG_LV_MEM_CUSTOM=y
CONFIG_LV_MEMCPY_MEMSET_STD=y
CONFIG_LV_USE_PERF_MONITOR=y
CONFIG_LV_SPRINTF_CUSTOM=y
# CONFIG_LV_BUILD_EXAMPLES is not set
12 changes: 12 additions & 0 deletions examples/display/sdkconfig.bsp.esp32_s3_usb_otg
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32s3"
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESP_DEFAULT_CPU_FREQ_240=y
CONFIG_LV_COLOR_16_SWAP=y
CONFIG_LV_MEM_CUSTOM=y
CONFIG_LV_MEMCPY_MEMSET_STD=y
CONFIG_LV_USE_PERF_MONITOR=y
CONFIG_LV_SPRINTF_CUSTOM=y
# CONFIG_LV_BUILD_EXAMPLES is not set
12 changes: 12 additions & 0 deletions examples/display/sdkconfig.bsp.esp_wrover_kit
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32"
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESP_DEFAULT_CPU_FREQ_240=y
CONFIG_LV_COLOR_16_SWAP=y
CONFIG_LV_MEM_CUSTOM=y
CONFIG_LV_MEMCPY_MEMSET_STD=y
CONFIG_LV_USE_PERF_MONITOR=y
CONFIG_LV_SPRINTF_CUSTOM=y
# CONFIG_LV_BUILD_EXAMPLES is not set
1 change: 1 addition & 0 deletions examples/display/sdkconfig.defaults
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32"
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESP_DEFAULT_CPU_FREQ_240=y
CONFIG_LV_COLOR_16_SWAP=y
Expand Down
3 changes: 0 additions & 3 deletions examples/display_audio/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
| Supported Boards | Kaluga kit |
| ---------------- | ---------- |

# BSP: Display and audio example

This example demonstrates capabilities of Audio and Display board of ESP32-S2-Kaluga-Kit.
Expand Down
3 changes: 0 additions & 3 deletions examples/display_audio_photo/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
| Supported Targets | ESP-BOX (ESP32-S3) |
| ----------------- | ------------------ |

# ESP-BOX Display Audio Photo Example

This example demonstrates usage of ESP-BOX Board Support Package. This is a single purpose example, which is focused on display + touch applications: you can see list of files saved on SPIFFS. You can open certain file types like JPG images, WAV music files and TXT text files.
Expand Down
2 changes: 1 addition & 1 deletion examples/display_audio_photo/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
idf_component_register(SRCS "bsp_espbox_disp_example.c" "app_disp_fs.c"
INCLUDE_DIRS "."
REQUIRES "spiffs" "vfs" "es8311" "esp_jpeg")
REQUIRES "spiffs" "vfs")
18 changes: 18 additions & 0 deletions examples/display_audio_photo/sdkconfig.bsp.esp-box
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32s3"
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_SPIRAM=y
CONFIG_SPIRAM_MODE_OCT=y
CONFIG_SPIRAM_SPEED_80M=y
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
CONFIG_SPIFFS_PAGE_SIZE=1024
CONFIG_LV_COLOR_16_SWAP=y
CONFIG_LV_MEM_CUSTOM=y
CONFIG_LV_MEMCPY_MEMSET_STD=y
CONFIG_LV_USE_PERF_MONITOR=y
CONFIG_LV_SPRINTF_CUSTOM=y
# CONFIG_LV_BUILD_EXAMPLES is not set
15 changes: 15 additions & 0 deletions examples/display_audio_photo/sdkconfig.bsp.esp32_s3_korvo_2
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32s3"
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESP_DEFAULT_CPU_FREQ_240=y
CONFIG_LV_COLOR_16_SWAP=y
CONFIG_LV_MEM_CUSTOM=y
CONFIG_LV_MEMCPY_MEMSET_STD=y
CONFIG_LV_USE_PERF_MONITOR=y
CONFIG_LV_SPRINTF_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_SPIRAM=y
CONFIG_SPIFFS_PAGE_SIZE=1024
# CONFIG_LV_BUILD_EXAMPLES is not set
15 changes: 15 additions & 0 deletions examples/display_audio_photo/sdkconfig.bsp.esp32_s3_lcd_ev_board
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32s3"
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESP_DEFAULT_CPU_FREQ_240=y
CONFIG_LV_COLOR_16_SWAP=y
CONFIG_LV_MEM_CUSTOM=y
CONFIG_LV_MEMCPY_MEMSET_STD=y
CONFIG_LV_USE_PERF_MONITOR=y
CONFIG_LV_SPRINTF_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_SPIRAM=y
CONFIG_SPIFFS_PAGE_SIZE=1024
# CONFIG_LV_BUILD_EXAMPLES is not set
3 changes: 0 additions & 3 deletions examples/display_camera/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
| Supported Targets | Kaluga-kit (ESP32-S2) |
| ----------------- | --------------------- |

# Display + camera example

This example shows how you can obtain frames from camera a display them on LCD.
Expand Down
13 changes: 13 additions & 0 deletions examples/display_camera/sdkconfig.bsp.esp32_s2_kaluga_kit
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32s2"
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_SPIRAM=y
CONFIG_SPIRAM_SPEED_80M=y
CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=8192
CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
CONFIG_LV_MEM_CUSTOM=y
CONFIG_LV_MEMCPY_MEMSET_STD=y
12 changes: 12 additions & 0 deletions examples/display_camera/sdkconfig.bsp.esp32_s3_eye
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32s3"
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESP_DEFAULT_CPU_FREQ_240=y
CONFIG_LV_COLOR_16_SWAP=y
CONFIG_LV_MEM_CUSTOM=y
CONFIG_LV_MEMCPY_MEMSET_STD=y
CONFIG_LV_USE_PERF_MONITOR=y
CONFIG_LV_SPRINTF_CUSTOM=y
# CONFIG_LV_BUILD_EXAMPLES is not set
12 changes: 12 additions & 0 deletions examples/display_camera/sdkconfig.bsp.esp32_s3_korvo_2
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32s3"
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESP_DEFAULT_CPU_FREQ_240=y
CONFIG_LV_COLOR_16_SWAP=y
CONFIG_LV_MEM_CUSTOM=y
CONFIG_LV_MEMCPY_MEMSET_STD=y
CONFIG_LV_USE_PERF_MONITOR=y
CONFIG_LV_SPRINTF_CUSTOM=y
# CONFIG_LV_BUILD_EXAMPLES is not set
1 change: 1 addition & 0 deletions examples/display_lvgl_demos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
cmake_minimum_required(VERSION 3.5)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
add_compile_options("-Wno-format")
add_compile_options("-Wno-attributes") # For LVGL demo code
project(display_lvgl_demos)
3 changes: 0 additions & 3 deletions examples/display_lvgl_demos/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
| Supported Targets | ESP32-S3-LCD-EV-BOARD |
| ----------------- | --------------------- |

# Display LVGL Demos

This example shows LVGL internal demos with RGB LCD.
Expand Down
Loading

0 comments on commit 5b6bdb9

Please sign in to comment.