How to add gpio component

ktowers
Posts: 2
Joined: Thu Nov 21, 2024 12:21 am

How to add gpio component

Postby ktowers » Thu Nov 21, 2024 12:38 am

This should be very simple... I have over 30 years of embedded devlopment experience with makefiles of various flavors.

I've started with the hello_world example project from the IDF tree. Compiled and flashed it fine and it works.

Now I want to add a simple GPIO toggle LED to the same project. I copy a few lines of code from the example generic_gpio project. I get the compilation error can't find some GPIO definitions. Some googling has me adding 'REQUIRES driver' to the hello_world project CMakeList.txt file. What I find interesting is that the generic_gpio project DOESN'T have the REQUIRES line in its file. I compiled that project without errors.

My CMakeList.txt now looks like this:

Code: Select all

idf_component_register(SRCS "hello_world_main.c"
                    INCLUDE_DIRS "."
                    REQUIRES driver)
When I compile, I now get the error "No such file or directory: "esp_flash.h"!?!?

Somehow adding the REQUIRES command seems to mess up the include paths that did work? And why does one project need the REQUIRES line and another doesn't? Any idea what's going on?

Thanks

Kevin

ESP_Sprite
Posts: 9764
Joined: Thu Nov 26, 2015 4:08 am

Re: How to add gpio component

Postby ESP_Sprite » Thu Nov 21, 2024 3:44 am

Unless you specify otherwise, the 'main' component implicitly 'require's all available components (including e.g. the flash driver). What you did is specify a component explicitly, which makes it depend on *only* that component (and not the flash driver). In other words: the REQUIRES line was never your issue. If you can post the particular code you added and the error you got, we may be able to help you further.

ktowers
Posts: 2
Joined: Thu Nov 21, 2024 12:21 am

Re: How to add gpio component

Postby ktowers » Thu Nov 21, 2024 5:42 pm

Thanks for that. Helps me understand a little about how components are referenced.

I did find my problem. The code I snipped came from the generic_gpio example which creates a define in the Kconfig.projbuild file which I didn't have.

Who is online

Users browsing this forum: albkharisov and 83 guests