Issue in including driver files in project directory in ESP32C3 using ESP-IDE

Dakshk
Posts: 9
Joined: Tue May 21, 2024 11:02 am

Issue in including driver files in project directory in ESP32C3 using ESP-IDE

Postby Dakshk » Thu Jan 23, 2025 9:04 am

I am trying to include UART driver files in my project folder and for that I have make appropriate changes in CMAKE file. I have added a custom function in "uart.c" file and it needs to be in that particular file only.

Now this works perfectly in ESP-IDF v5.2.2 but when I import the code any try to build it with versions 5.3+ I am having issues of multiple definitions. These are all the functions of "uart.c" files one from the file I have included locally and one from the original component directory of framework.

I am using ESP IDE

[img]FAILED: 4G_Module.elf [/img]

This is my file structure
Project
->driver
-->uart.c
-->uart.h
-->cmake.txt
->main
-->main.c
-->other files
-->cmake.txt
->cmake.txt

From the online reference I read about migration guide the have changed the structure of driver files and have added linking method but I am unclear about it.

Can somebody guide me through this, am I missing something or it is not possible?


Dakshk
Posts: 9
Joined: Tue May 21, 2024 11:02 am

Re: Issue in including driver files in project directory in ESP32C3 using ESP-IDE

Postby Dakshk » Thu Jan 23, 2025 11:04 am

I tried this method as mentioned here I have shared few snap shots if it helps, still I am not able to resolve error, it seems it cannot find driver files, any suggestions?
Screenshot 2025-01-23 163049.png
Screenshot 2025-01-23 163049.png (183.28 KiB) Viewed 528 times
And cmake for components:

Code: Select all

idf_component_register(SRCS "m_uart.c"
                    INCLUDE_DIRS "include")
cmake for main:

Code: Select all

idf_component_register(SRCS "Application/src/main.c" "Application/src/lte_module.c" "Application/src/esp_uart.c" 
                    INCLUDE_DIRS "./Application/include/" 
                  )
target_link_libraries(${COMPONENT_LIB} PRIVATE custom_uart)

Dakshk
Posts: 9
Joined: Tue May 21, 2024 11:02 am

Re: Issue in including driver files in project directory in ESP32C3 using ESP-IDE

Postby Dakshk » Thu Jan 23, 2025 11:46 am

I found the issue in cmake although I ended up at the same place still I am getting multiple definition error,
I made the following changes in cmake of components directory:

Code: Select all

idf_component_register(SRCS "m_uart.c"
                    INCLUDE_DIRS "include"
                    PRIV_REQUIRES "esp_driver_gpio")
Can anybody help?

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

Re: Issue in including driver files in project directory in ESP32C3 using ESP-IDE

Postby MicroController » Thu Jan 23, 2025 12:19 pm

Dakshk wrote:
Thu Jan 23, 2025 11:46 am
still I am getting multiple definition error,
Because now you have symbols from a component named "custom_uart" colliding with symbols from the component "esp_driver_uart".
"copy the component into your project's "components"" means copying the directory from the IDF, in this case "esp_driver_uart". The name of the component is the name of the directory; if it's different it is seen as a different component and won't 'override' the IDF's "esp_driver_uart".

See also https://esp32.com/viewtopic.php?f=13&t=43585#p142107

Dakshk
Posts: 9
Joined: Tue May 21, 2024 11:02 am

Re:[Solved] Issue in including driver files in project directory in ESP32C3 using ESP-IDE

Postby Dakshk » Thu Jan 23, 2025 12:53 pm

That works Issue solved, Thank you!

Who is online

Users browsing this forum: No registered users and 98 guests