Page 1 of 1

idp.py: Changing the target programmatically

Posted: Thu Apr 11, 2024 8:36 pm
by cruvus
I am using Windows, VSCode and the ESP-IDF extention. I need to compile a project for several targets, for example ESP32, ESP32-C3 and ESP32-S3. I can do this manually by clicking the "ESP-IDF: Set Espressif Device Target" command, then "ESP-IDF: Build Project", then copying the binaries, and so on.
I need to do this programmatically, using a batch file.

I can compile by executing
idf.py app
in the terminal. But how can I change the target?

If I enter this:
idf.py set-target esp32c3
the terminal displays this:
Adding "set-target"'s dependency "fullclean" to list of commands with default set of options.
Executing action: fullclean
Executing action: set-target
Set Target to: esp32c3, new sdkconfig will be created.
Target 'esp32c3' specified on command line is not consistent with target 'esp32' in the environment.

Re: idp.py: Changing the target programmatically

Posted: Fri Apr 12, 2024 10:46 am
by DrMickeyLauer
This is not really supported well by IDF (same as sdkconfig for different scenarios, like, debug and release). You will find a lot of workarounds though. I‘m using a custom board directory for every single target where the sdkconfig resides in. The rest of the files is symlinked to the general directory.

Re: idp.py: Changing the target programmatically

Posted: Fri Apr 12, 2024 11:30 am
by MicroController
See if un-setting the environment variable IDF_TARGET, or setting it to the desired target, before invoking idf.py set-target helps.