Page 1 of 1

Correct Way to Select the Target Chip in Unit Testing?

Posted: Wed Jan 29, 2025 9:30 am
by kozmotronik
Hi there!
I am trying to get familiar with ESP-IDF unit testing, using the official unit test example. I've gone through the official unit testing docs and also unit testing docs for the ESP-IDF VSCode Plugin.
As a development board, I use the ESP32-C3-DevKitM-1.

However, I get an error about target configuration when I try to run tests from the vscode activity bar, though the correct target chip selected in the target configuration.
Image

Below is the full error output link:
https://gist.github.com/kozmotronik/5d5 ... c79882a952

Looking at the error output, there is one line that describes the main cause of the error which is:
2025-01-29 10:34:36 /dev/ttyUSB0 failed to connect: This chip is ESP32-C3 not ESP32. Wrong --chip argument?
Am I missing any configuration? Can someone please help? Thank you.

Re: Correct Way to Select the Target Chip in Unit Testing?

Posted: Thu Jan 30, 2025 6:41 am
by kozmotronik
I figured out the issue. Here is what happens:
When the ESP-IDF Unit Test: Install ESP-IDF PyTest requirements command is issued as per the docs, the vscode extension automatically installs the requirements, as well as copies the unity-app from the extension template. However the extension does not automatically set the target configuration from the main project into the unity-app project. That's where the conflict begins.

The esp32c3 is selected for the main project on the other hand the esp32 is selected for the automatically copied unity-app. So when I run tests from the activty bar of vscode, it is the unity-app that complains about wrong chip argument since building and flashing the chip is made according to its perspective.

I had to do the followings to fix this target chip conflict:
  • Opened the unity-app directory as project in vscode
  • Changed the chip from esp32 to esp32c3
  • Set the port to the port to which the dev board is connected (ttyUSB0)
  • Set the flash method to UART
  • Closed unity-app and reopened the main project
None of the above is mentioned in the documentation of the esp-idf vscode extension.

Now that the main cause of issue is revealed, my question is: Is this the way the vscode extension works or is there a more clean way to select the target chip automatically for the automatically copied unity-app project?

Re: Correct Way to Select the Target Chip in Unit Testing?

Posted: Wed Feb 05, 2025 2:24 am
by ESP_bignacio
Thank you for sharing! This is indeed a bug to fix !

The unity-app project is created from extension templates. I will update the unit test functionality to set the IDF_TARGET in the unity-app project to match the parent ESP-IDF project.

Re: Correct Way to Select the Target Chip in Unit Testing?

Posted: Mon Feb 17, 2025 8:51 am
by ESP_bignacio
This issue was actually related to IDF_TARGET not being persisted issues that was fixed in this GitHub Pull Request

Please try the latest master vsix install to see the issue is fixed. I've tested myself and seems to work with unity-test ESP-IDF example using different target.