Development environment for ESP-IDF Components

I’m trying to setup a development environment to develop ESP-IDF components that will be shared within my team in platformIO. My IDE of choice is VScode.

I’m using this as the reference to setup the environment. https://www.youtube.com/watch?v=D86gQ4knUnc
Currently, my file structure is like this
image
ESPIDF-Component_testcomp\test-apps\testcomp-test1\src\idf_component.yml

## IDF Component Manager Manifest File
dependencies:
  ## Required IDF version
  idf:
    version: ">=4.1.0"

  ESPIDF-Component_testcomp:
    override_path: "../../.."

The components files are generated manually, and the test project is generated through the platformIO VScode Home page.

If I include the testcomp.h in the main.c file, everything seems to compile properly and I can even call the functions from the testcomp.h.

However, the moment I actually start developing the testcomp.c file and including esp-idf files such as “esp_log.h”. It does not get recognized and I keep getting errors “undefined file”

So how do I make platformIO include ESPIDF in the root folder and successfully compile it. Alternatively, are there any better methods to developing ESP-IDF components in platformIO.
Thank you

Your project folders don’t appear to match PlatformIO’s common structure:

project-name
->components
–>test_component
->include
->lib
->src

See component examples here: ESP32-S3 ESP-IDF Components

I think I’m a little confused. So I’m trying to develop the components myself. Hence, to test the components, I require a test-app which I place in the directory in the root component folder as requested by the video that I shared.

If you write “my-component” then your component goes into the folder ./components/my-component where your test-app resides in the ./src folder

.
├── components
│   └── my-component
├── include
├── lib
├── src
└── test

I intend to upload this components into a github repo. And then from multiple different projects, I would like to pull the component through the idf_component.yml file. In the mentioned file structure, would that still work?

No, that’s just the test project for “local development”

I think what you’re looking for is Packaging ESP-IDF Components — IDF Component Management documentation

I think GitHub - espressif/esp32-camera is a good example component. It contains an idf_component.yml and a library.json.

So if I understand correctly, I would have to develop it in a local setup as you provided, then repackage it to upload to github?

That’s how I develop my (arduino) libraries. Starting with a local project where the library files are located in the lib folder.

As soon as the library has the necessary basic functions I will host it on github and continue development there.

But I think that’s a matter of taste :slight_smile: