How to compile firmware for two ESP32 and ESP32-S2 devices in one project?

Actually the question: How to compile the firmware for two devices ESP32 and ESP32-S2 in one project?
My platformio.ini

; PlatformIO Project Configuration File
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
; Please visit documentation for the other options and examples

src_dir = main
include_dir = main/include
description = Radiola2
default_envs = 

platform =
framework = espidf
board = esp-wrover-kit
monitor_speed = 115200
board_build.partitions = partitions.csv
extra_scripts =

build_flags = 

build_type = release
build_flags = 
	-D FILENAME=Radiola2-release

build_type = debug
monitor_filters = esp32_exception_decoder
build_flags = 
	-D FILENAME=Radiola2-debug

ESP32 and ESP32-S2 need different sdkconfig. And in the root of the project, only 1 sdkconfig file is always created.
In my project Radiola-2 there is a lot of common code for both ESP32 and ESP32-S2.
Please help with advice or an idea on how to implement compilation of firmware for ESP32 and ESP32-S2 in one project.
Thank you.

That’s a good question. Even if you use the same board = .., if you want to compile the firmware with 2 different sdkconfig.h configurations, I don’t think there’s a way to do that except of course building the first one, then pio run -t menuconfig to enter the second configuration, and then rebuild again.

One could maybe hack something together with Advanced scripting that can e.g. use two configs sdkconfig_1 and sdkconfig_2, and before the build for each board, copy the correct file as sdkconfig, and then continue building.

But it really should be a possibility in the build system to specify the sdkconfig file – when I look in the code however, and other places, the sdkconfig path there is hardcoded and unchangable.

Pleas file an issue in Issues · platformio/platform-espressif32 · GitHub for this. Opened per Make used sdkconfig file user-selectible · Issue #539 · platformio/platform-espressif32 · GitHub.

1 Like