Having idf_component.yml issues when trying to create my own components.

uC_Jon
Posts: 18
Joined: Fri Jan 05, 2024 7:03 pm

Having idf_component.yml issues when trying to create my own components.

Postby uC_Jon » Mon Apr 22, 2024 11:39 am

I have been hitting my head against the proverbial brick wall trying to create my own components... Having found they exist they seem an excellent way to sub-divide a project into multiple independent units.

It seems that the idf_component.yml files are being ignored in some specific cases causing the cmake build to fail. All my components work when they are pulled directly from my github, as dependencies, and they also work when the directory name that contains the component matches the component name. But when using directory names that don't match the component name it fails to create the build system. I am not looking to put any components on the official components website at present, just within my own github.

My folders and files have the following structure (some files omitted for brevity):

Code: Select all


~/vscode/esp-idf/
     i2c-mcp9808/
          example/
               CmakeLists.txt
               sdkconfig
               main/
                    CmakeLists.txt
                    idf_component.yml
                    i2c_mcp9808.main.c
          CmakeLists.txt
          idf_component.yml
          i2c_mcp9808.c
          
     lcd-2090/
          example/
               CmakeLists.txt
               sdkconfig
               main/
                    idf_component.yml
                    lcd_2090_main.c
          CmakeLists.txt
          idf_component.yml
          lcd-2090.c

     lcd-2090_bk0/
          example/
               CmakeLists.txt
               sdkconfig
               main/
                    idf_component.yml
                    lcd_2090_main.c
          CmakeLists.txt
          idf_component.yml
          lcd-2090.c 
As you can see each 'component' I'm developing is stored in a common '~/vscode/esp-idf' (this is actually a longer path, but used for brevity) directory and has its own effective "root/" and then the example code (that uses the component) is within an 'example' directory.

Occasionally when I'm making a large changes I will create a backup '_bk0' directory which normally I just ignore. However, lvgl has major breaking changes between 8.3 and 9.1 so while I was working on the new version I needed to go look at the original and that is where I realised that things fell down in a big messy heap!

During testing I also noticed that if I were to clone a "component" from my github into a directory that didn't have the same name it would also fail.

Using 'lcd-2090' as the example it works if it contains the following:

Code: Select all


/example/main/CmakeLists.txt
     idf_component_register(SRCS "lcd_2090_main.c"
                            INCLUDE_DIRS ".")

/example/main/idf_component.yml
     dependencies:
       idf: ">=5.3"
       lvgl/lvgl: "^8.3"
       i400s/i2c-mcp9808:
         override_path: "../../../i2c-mcp9808"
       i400s/lcd-2090:
         version: "0.0.1"
         path: "../../"
         override_path: "../../"

/example/CmakeLists.txt
     # The following lines of boilerplate have to be in your project's CMakeLists
     # in this exact order for cmake to work correctly
     cmake_minimum_required(VERSION 3.5)

     include($ENV{IDF_PATH}/tools/cmake/project.cmake)
     project(lcd-2090)

/CmakeLists.txt
     idf_component_register(SRCS "lcd_2090.c"
                            INCLUDE_DIRS "include"
                            REQUIRES "driver"
                                     "esp_driver_gpio")

/idf_component.yml
     version: 0.0.1
     description: "lcd-2090 driver for Adafruit 2090 (ili9341 lcd & i2c-ft6x06 capacitive touch)"
     repository: https://github.com/i400s/lcd-2090.git
     url: https://github.com/i400s/lcd-2090.git
     dependencies:
       idf:
         version: '>=5.3'
       esp_lcd_touch:
         version: '>=1.1.1'
       esp_lcd_ili9341: "^2.0"
       i400s/i2c-ft6x06:
         git: git@github.com:i400s/i2c-ft6x06.git

The various dependencies are downloaded and the code compiles and works with no issues.

If however I am within the 'lcd-2090_bk0' directory the dependencies are downloaded but the cmake creation state fails with the following errors:

Code: Select all


Dependencies lock doesn't exist, solving dependencies.
Using component placed at /home/wilsonj/Documents/foldered/vscode/esp-idf/i2c-mcp9808 for dependency i400s/i2c-mcp9808(*), specified in /home/wilsonj/Documents/foldered/vscode/esp-idf/lcd-2090_bk0/example/main/idf_component.yml
Using component placed at /home/wilsonj/Documents/foldered/vscode/esp-idf/lcd-2090_bk0 for dependency i400s/lcd-2090(0.0.1), specified in /home/wilsonj/Documents/foldered/vscode/esp-idf/lcd-2090_bk0/example/main/idf_component.yml
.............Updating lock file at /home/wilsonj/Documents/foldered/vscode/esp-idf/lcd-2090_bk0/example/dependencies.lock
Processing 8 dependencies:
[1/8] espressif/cmake_utilities (0.5.3)
[2/8] espressif/esp_lcd_ili9341 (2.0.0)
[3/8] espressif/esp_lcd_touch (1.1.1)
[4/8] i400s/i2c-ft6x06 (f330f25d871d3e8297df861f59f4bcb0b2b5c0f4)
[5/8] i400s/i2c-mcp9808 (0.0.1)
[6/8] i400s/lcd-2090 (0.0.1)
[7/8] idf (5.3.0)
[8/8] lvgl/lvgl (8.3.11)
CMake Error at /mnt/md8/_development/esp/esp-idf/tools/cmake/build.cmake:268 (message):
  Failed to resolve component 'i400s__lcd-2090'.
Call Stack (most recent call first):
  /mnt/md8/_development/esp/esp-idf/tools/cmake/build.cmake:310 (__build_resolve_and_add_req)
  /mnt/md8/_development/esp/esp-idf/tools/cmake/build.cmake:607 (__build_expand_requirements)
  /mnt/md8/_development/esp/esp-idf/tools/cmake/project.cmake:710 (idf_build_process)
  CMakeLists.txt:6 (project)


-- Configuring incomplete, errors occurred!

 *  The terminal process "/usr/bin/bash '-c', 'cmake -G Ninja -DPYTHON_DEPS_CHECKED=1 -DESP_PLATFORM=1 -B /home/wilsonj/Documents/foldered/vscode/esp-idf/lcd-2090_bk0/example/build -S /home/wilsonj/Documents/foldered/vscode/esp-idf/lcd-2090_bk0/example'" terminated with exit code: 1. 


The same '/example/main/idf_component.yml' file with 'lcd-2090' instead of 'i400s/lcd-2090' produces a similar error:

Code: Select all


Dependencies lock doesn't exist, solving dependencies.
Using component placed at /home/wilsonj/Documents/foldered/vscode/esp-idf/i2c-mcp9808 for dependency i400s/i2c-mcp9808(*), specified in /home/wilsonj/Documents/foldered/vscode/esp-idf/lcd-2090_bk0/example/main/idf_component.yml
Using component placed at /home/wilsonj/Documents/foldered/vscode/esp-idf/lcd-2090_bk0 for dependency lcd-2090(0.0.1), specified in /home/wilsonj/Documents/foldered/vscode/esp-idf/lcd-2090_bk0/example/main/idf_component.yml
.............Updating lock file at /home/wilsonj/Documents/foldered/vscode/esp-idf/lcd-2090_bk0/example/dependencies.lock
Processing 8 dependencies:
[1/8] espressif/cmake_utilities (0.5.3)
[2/8] espressif/esp_lcd_ili9341 (2.0.0)
[3/8] espressif/esp_lcd_touch (1.1.1)
[4/8] i400s/i2c-ft6x06 (f330f25d871d3e8297df861f59f4bcb0b2b5c0f4)
[5/8] i400s/i2c-mcp9808 (0.0.1)
[6/8] idf (5.3.0)
[7/8] lcd-2090 (0.0.1)
[8/8] lvgl/lvgl (8.3.11)
CMake Error at /mnt/md8/_development/esp/esp-idf/tools/cmake/build.cmake:268 (message):
  Failed to resolve component 'lcd-2090'.
Call Stack (most recent call first):
  /mnt/md8/_development/esp/esp-idf/tools/cmake/build.cmake:310 (__build_resolve_and_add_req)
  /mnt/md8/_development/esp/esp-idf/tools/cmake/build.cmake:607 (__build_expand_requirements)
  /mnt/md8/_development/esp/esp-idf/tools/cmake/project.cmake:710 (idf_build_process)
  CMakeLists.txt:6 (project)


-- Configuring incomplete, errors occurred!

 *  The terminal process "/usr/bin/bash '-c', 'cmake -G Ninja -DPYTHON_DEPS_CHECKED=1 -DESP_PLATFORM=1 -B /home/wilsonj/Documents/foldered/vscode/esp-idf/lcd-2090_bk0/example/build -S /home/wilsonj/Documents/foldered/vscode/esp-idf/lcd-2090_bk0/example'" terminated with exit code: 1. 

I did originally think that maybe this was something to do with the dependency chain because if I changed the '/example/main/idf_component.yml' path/override_path to point to "../../../lcd-2090" or I changed the line 'i400s/lcd-2090' to be either 'i400s/lcd-2090_bk0' or 'lcd-2090_bk0' then the dependencies are met and the build works correctly. Obviously in the first instance it makes the build look at the incorrect component code directory and in the latter two changes I've had to manually change the name of the component when I rename the folder which defeats the whole purpose of using the relative 'path: "../../"'.

Also I thought about, and tested, making the '/example/main/idf_component.yml' 'i400s/lcd-2090' pull from 'git: git@github.com:i400s/lcd-2090.git' and that worked fine, but obviously then means that the 'example/managed_components' now has a 'i400s__lcd-2090' and in the case of the '~/vscode/lcd-2090_bk0' has downloaded the incorrect version (the '~/vscode/lcd-2090' repository) and I really don't want to start having multiple versions all requiring uploads to download when the relative path should be working.

I also tested just using 'path:', using 'path:' and 'override_path:' and just using 'override_path:' and none seemed to may any difference to it failing.

My reading of the component manual was that using just the relative paths it should have found the component directory '~/vscode/esp-idf/lcd-2090_bk0' (which I think it did!) and then the creating of the make system by esp-idf should look at (use) the relative path component but for some reason it is trying to find a "directory" with the names 'i400s__lcd-2090' or 'lcd-2090' which it can't find even though it found the component.

Anyways, that's the issue I'm having so any help or guidance on why its not working as the manual seems to suggest it should would be much appreciated.

uC_Jon
Posts: 18
Joined: Fri Jan 05, 2024 7:03 pm

Re: Having idf_component.yml issues when trying to create my own components.

Postby uC_Jon » Tue Apr 23, 2024 10:35 am

I have created an absolute minimum project that shows the issue. https://github.com/i400s/show-component-bug/tree/main

The project does a dependency to espressif/esp_lcd_touch so that the managed_components directory is created as it is within my components.

The project then works if the directory name matches the component name, but fails if the directory name does not match the component name.

uC_Jon
Posts: 18
Joined: Fri Jan 05, 2024 7:03 pm

Re: Having idf_component.yml issues when trying to create my own components.

Postby uC_Jon » Wed Apr 24, 2024 9:35 am

Oh fiddle sticks! I did some more digging into the IDF programming guide documentation and it seems that the name of the directory is very important to the name of the component: https://docs.espressif.com/projects/esp ... properties

I guess that because I'm very new to both C and IDF and microprocessor programming in general (and that I work very haphazardly trying new things and then returning to things temporally put to one side) and coming from an AS/400 (IBM I on Power) that the way I layout my directory structures is probably quite unique in that its very much a single directory containing lots of "components" and "projects" all directly below that single directory which allows for each project/component to reference others relative to that single directory and so to my mind copying a component to a temp name (so it could still be worked on while also working on the new version) was a logical step that isn't possible with the way the IDF uses directory names to name the component.

Obviously what I need to do is have more than one top level directory for differing versions, and to copy the components in to the relevant top level directory as and when required.

I do however think that the component manager (or the component manager/registry documentation) should make it clear that its an error if the component name doesn't match the component directory (especially with the use of a path or override_path; relative or direct).

There is no issue when a project auto-clones/downloads to the "managed_components". There is also no issue when a directory of the component with the same name as the component is within the "components" directory.

There is however an issue when a component is manually cloned to a different directory name (or a directory is copied or renamed) and that directory is referenced by an idf_component.yml file with a name that doesn't match the resolved path.

This is now resolved, it was my missunderstanding.

Who is online

Users browsing this forum: No registered users and 68 guests