new esp-idf-project with the use of components; #include driver/gpio.h: No such file or directory

mmueller
Posts: 3
Joined: Fri Jun 30, 2023 6:21 pm

new esp-idf-project with the use of components; #include driver/gpio.h: No such file or directory

Postby mmueller » Fri Jun 30, 2023 8:38 pm

Hi together,

first of all, I don't have much experience in programming the ESP32 a the moment.
So the answer for my problem could be simple.

Currently, I have ESP-IDF v5.2 installed on my ubuntu host under the directory ~esp/esp-idf/.
Next to this directory I have created a simple esp-blinki-project with the command `idf.py create-project bliki`.
The main `blinki.c` includes among others `#include driver/gpio.h`.
When I use the comman `idf.py build` and `idf.py flash`, everithing works fine.
A LED, which is connected to the ESP32-Board, goes on and off... .

Now the Problem:
Next to my simple esp-blinki-project I created a new project to get experience with the use of own written components.
I used the the commands:
- idf.py create-project blinki-03
- Created the sub directory components for my component cledlight.
- mkdir components
- cd components
- idf.py create-component cledlight

The file cledlight.c includes among other includes `#include driver/gpio.h`.
When I try to build the project with the comman `idf.py build` I get the error message `fatal error: driver/gpio.h: No such file or directory`.

My attempts to include the esp-idf components (gpio.h ...) in the CMake-Files have so far been unsuccessful.
(I hope this post will be readable :? )
I would be very greatful if someone could help me.



Here you can see the code of the component cledlight:
[1] cledlight.c
  1. #include <stdio.h>
  2. #include "cledlight.h"
  3.  
  4. #include "freertos/FreeRTOS.h"
  5. #include "freertos/task.h"
  6.  
  7. #include "driver/gpio.h"
  8.  
  9. void config_blink(void){
  10.     gpio_set_direction(GPIO_NUM_5, GPIO_MODE_DEF_OUTPUT);
  11. }
  12.  
  13. void blink_on(void){
  14.     gpio_set_level(GPIO_NUM_5, 1);
  15.     vTaskDelay(2000 / portTICK_PERIOD_MS);
  16.     gpio_set_level(GPIO_NUM_5, 0);
  17.     vTaskDelay(2000 / portTICK_PERIOD_MS);
  18. }
[2] include/cledlight.h
  1. void config_blink(void);
  2. void blink_on(void);
[3]CMakeLists.txt
  1. idf_component_register(SRCS "cledlight.c"
  2.                     INCLUDE_DIRS "include")
Here you can see the main:
[4] blinki-03.c
  1. #include <stdio.h>
  2.  
  3. #include "cledlight.h"
  4.  
  5. void app_main(void)
  6. {
  7.     config_blink();
  8.  
  9.     while(1){
  10.         blink_on();
  11.     }
  12.  
  13. }
[5] CmakeList.txt
  1. idf_component_register(SRCS "blinki-03.c"
  2.                     INCLUDE_DIRS ".")
Here you can see the "main"-CMakeLists.txt of the project.
[6] CMakeLists.txt
  1. # For more information about build system see
  2. # https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
  3. # The following five lines of boilerplate have to be in your project's
  4. # CMakeLists in this exact order for cmake to work correctly
  5. cmake_minimum_required(VERSION 3.16)
  6.  
  7. include($ENV{IDF_PATH}/tools/cmake/project.cmake)
  8. project(blinki-03)

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

Re: new esp-idf-project with the use of components; #include driver/gpio.h: No such file or directory

Postby ESP_Sprite » Sat Jul 01, 2023 3:34 am

You need to add a 'REQUIRES driver' to the idf_component_register of your component.

mmueller
Posts: 3
Joined: Fri Jun 30, 2023 6:21 pm

Re: new esp-idf-project with the use of components; #include driver/gpio.h: No such file or directory

Postby mmueller » Sat Jul 01, 2023 8:25 am

It works, i'm so happy :D
I tried so many things to solve this problem.
Many thanks for this hint.

joy586210
Posts: 5
Joined: Tue Sep 26, 2023 5:25 am

Re: new esp-idf-project with the use of components; #include driver/gpio.h: No such file or directory

Postby joy586210 » Wed Nov 22, 2023 1:03 pm

thanks!
ESP_Sprite wrote:
Sat Jul 01, 2023 3:34 am
You need to add a 'REQUIRES driver' to the idf_component_register of your component.

ikkesia
Posts: 2
Joined: Tue Mar 19, 2024 12:37 pm

Re: new esp-idf-project with the use of components; #include driver/gpio.h: No such file or directory

Postby ikkesia » Fri Oct 18, 2024 8:02 am

I have the same problem and can't solve it. Can you share your CMakeLists.txt ?

Who is online

Users browsing this forum: No registered users and 402 guests