idp.py: Changing the target programmatically

cruvus
Posts: 59
Joined: Fri Jul 08, 2022 5:08 pm
Location: Planet Earth

idp.py: Changing the target programmatically

Postby cruvus » Thu Apr 11, 2024 8:36 pm

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.
ESP32 / ESP-IDF 5.1.4

DrMickeyLauer
Posts: 167
Joined: Sun May 22, 2022 2:42 pm

Re: idp.py: Changing the target programmatically

Postby DrMickeyLauer » Fri Apr 12, 2024 10:46 am

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.

MicroController
Posts: 1688
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: idp.py: Changing the target programmatically

Postby MicroController » Fri Apr 12, 2024 11:30 am

See if un-setting the environment variable IDF_TARGET, or setting it to the desired target, before invoking idf.py set-target helps.

Who is online

Users browsing this forum: AG_OHP and 72 guests