Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra component #363

Closed
ghost opened this issue Jan 16, 2024 · 6 comments
Closed

Extra component #363

ghost opened this issue Jan 16, 2024 · 6 comments

Comments

@ghost
Copy link

ghost commented Jan 16, 2024

Is there an example or something to help us how to add a new component to esp-idf-hal.
I have read "https://github.com/esp-rs/esp-idf-sys/blob/master/BUILD-OPTIONS.md#extra-esp-idf-components", but even that is not a complete guide. e.g. I searched for this
[package.metadata.esp-idf-sys] extra_components = [ { component_dirs = [ "dir1", "dir2" ], bindings_header = "bindings.h", bindings_module = "name" } ]
i added this to my cargo.toml in the root directory, but nothing happens ("I expected to at least get an error message that there is no dir1 dir2 or something similar, but nothing happened after the cargo build).
My real question is that I use the following
[dependencies] esp-idf-svc = { version = "0.47.3", default-features = false }
And I would like to add the following :
https://github.com/joltwallet/esp_littlefs
as an external component to my project.
What are the ways I can achieve this (I prefer to use it as a patch besides using "esp-idf-svc" in my load and not to clone "esp-idf-svc" codes to my project directly and customize this . )

@N3xed
Copy link
Collaborator

N3xed commented Jan 16, 2024

See esp-rs/esp-idf-sys#114 (comment) for reference.
Also to note is that you don't have to vendor esp-idf components anymore with remote components.

@ghost
Copy link
Author

ghost commented Jan 16, 2024

For remote components,
I've tried this

Also to note is that you don't have to vendor esp-idf components anymore with remote components.

And add this :

[package.metadata.esp-idf-sys.extra_components.0.remote_component]
# The name of the remote component. Corresponds to a key in the dependencies of
# `idf_component.yml`.
name = "littlefs"
# The version of the remote component. Corresponds to the `version` field of the
# `idf_component.yml`.
version = "1.13.0"
# A git url that contains this remote component. Corresponds to the `git`
# field of the `idf_component.yml`.
#
# This field is optional.
git = "https://github.com/joltwallet/esp_littlefs"
# A path to the component.
# Corresponds to the `path` field of the `idf_component.yml`.
#
# Note: This should not be used for local components, use
# `component_dirs` of extra components instead.
#
# This field is optional.
# path = "path/to/component"
path = "excomponent/little"

# A url to a custom component registry. Corresponds to the `service_url`
# field of the `idf_component.yml`.
#
# This field is optional.
# service_url = "https://componentregistry.company.com"

in my Cargo.toml in the root directory, but nothing happened after I ran the Cargo build (nothing with the name littlefs came up in the bindings.rs or anywhere else).
Am I missing something?

@N3xed
Copy link
Collaborator

N3xed commented Jan 16, 2024

I don't know if you already did this, but you still need a bindings_header, so a C header file that includes the relevant littlefs bindings. Otherwise, no bindings to littlefs APIs will be generated (e.g. the bindings.h in esp-rs/esp-idf-sys#114 (comment)).

E.g.

[[package.metadata.esp-idf-sys.extra_components]]
# Name and version from registry https://components.espressif.com/components/joltwallet/littlefs
remote_component = {name = "joltwallet/littlefs", version = "1.13.0"}
# The C header file in the src directory, that includes the relevant littlefs headers for bindings generation.
bindings_header = "src/bindings.h"

esp-idf-sys is probably not rebuilt from the cargo.toml changes, so you have to cargo clean -p esp-idf-sys to force a rebuild of esp-idf-sys and the generated bindings (this should work to force a rebuild of esp-idf-sys, if not do a whole clean rebuild cargo clean).

@N3xed
Copy link
Collaborator

N3xed commented Jan 16, 2024

Its also good to compile with cargo build -vv (the -vv flag) so that the build script output of esp-idf-sys is shown, which displays the build components etc.

@ghost
Copy link
Author

ghost commented Jan 16, 2024

Now it is interesting and easy to use .
Thank you .(I tried both ways and got answer from both ) .
And in the second way ("Remote" one) It adds "Components_esp32s3.lock" during building and everything has been built.

dependencies:
  idf:
    component_hash: null
    source:
      type: idf
    version: 5.1.1
  joltwallet/littlefs:
    component_hash: f7813d2c2ddde8bc74cd9d044f063d758672f8504ca56132f518ff1438c9a051
    source:
      service_url: https://api.components.espressif.com/
      type: service
    version: 1.13.0
manifest_hash: 901bba517a4f6d0ff5dfd02a5aaff14e4eb6faa3517d481644bf6b99992f04fe
target: esp32s3
version: 1.0.0

@ghost
Copy link
Author

ghost commented Jan 16, 2024

Thanks to "N3xed" , Got the result that I wanted.

@ghost ghost closed this as completed Jan 16, 2024
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

1 participant