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

Some functions are missing in the binding file generated by esp-idf-sys #329

Closed
silent-rain opened this issue Dec 15, 2023 · 7 comments
Closed

Comments

@silent-rain
Copy link

Esp32s3 does not have many methods in the binding file 'bindings. rs' generated by' esp-idf-sys', but it does exist in the API doc. Why is this?

For example, esp_flash_get_size function, How can I configure to generate bindings for these functions?

@Vollbrecht
Copy link
Collaborator

First of this is a esp-idf-sys issue not esp-idf-svc specific.

To understand why you can't see the method you need to look how the complete chain is generated.
Step by step

  1. understand where the functions come from - e.g in what C header files they are living. In your example they come from esp_flash.h

  2. Check if they are exported in the include site of esp-idf-sys here

  3. In your case we currently dont expose the esp_flash.h directly only with the conditional

#ifdef ESP_IDF_COMP_SPI_FLASH_ENABLED
#include "esp_spi_flash.h"
#include "esp_partition.h"
#endif
  1. As of recomendation of the esp-idf guide its best to use esp_partition.h for most of the access.

@ivmarkov
Copy link
Collaborator

Esp32s3 does not have many methods in the binding file 'bindings. rs' generated by' esp-idf-sys', but it does exist in the API doc. Why is this?

For example, esp_flash_get_size function, How can I configure to generate bindings for these functions?

(I've checked for esp32, not for esp32s3, but I don't think there is any difference between esp32 and esp32s3 w.r.t. flash functions.)

The TL;DR is:

  • I see esp_flash_get_size in the generated bindings
  • The component @Vollbrecht talks about from above is actually enabled by default, as long as you use the regular cargo build. Now, if you use the CMake-based build, you need to enable that component explicitly, but otherwise you should be good to go?

So... are you actually sure that you don't see that function?

Feel free to reopen if there's an additional detail I'm missing.

@github-project-automation github-project-automation bot moved this from Todo to Done in esp-rs Dec 15, 2023
@silent-rain
Copy link
Author

Esp32s3 does not have many methods in the binding file 'bindings. rs' generated by' esp-idf-sys', but it does exist in the API doc. Why is this?
For example, esp_flash_get_size function, How can I configure to generate bindings for these functions?

(I've checked for esp32, not for esp32s3, but I don't think there is any difference between esp32 and esp32s3 w.r.t. flash functions.)

The TL;DR is:

  • I see esp_flash_get_size in the generated bindings
  • The component @Vollbrecht talks about from above is actually enabled by default, as long as you use the regular cargo build. Now, if you use the CMake-based build, you need to enable that component explicitly, but otherwise you should be good to go?

So... are you actually sure that you don't see that function?

Feel free to reopen if there's an additional detail I'm missing.

This function was not generated in esp32s3

@Vollbrecht
Copy link
Collaborator

Vollbrecht commented Dec 15, 2023

you guys first need to tell what specific function you are talking about( what esp-idf version and where it comes from in the original C code), because there is a chance that there are multiple function with the same name here around. Also take note about this info regarding esp-idf 5+:

ROM SPI Flash

In versions before v5.0, ROM SPI flash functions were included via esp32**/rom/spi_flash.h. Thus, code written to support different ESP chips might be filled with ROM headers of different targets. Furthermore, not all of the APIs could be used on all ESP chips.

Now, the common APIs are extracted to esp_rom_spiflash.h. Although it is not a breaking change, you are strongly recommended to only use the functions from this header (i.e., prefixed with esp_rom_spiflash and included by esp_rom_spiflash.h) for better cross-compatibility between ESP chips.

To make ROM SPI flash APIs clearer, the following functions are also renamed:

    esp_rom_spiflash_lock() to esp_rom_spiflash_set_bp()
    esp_rom_spiflash_unlock() to esp_rom_spiflash_clear_bp()

@ivmarkov
Copy link
Collaborator

Esp32s3 does not have many methods in the binding file 'bindings. rs' generated by' esp-idf-sys', but it does exist in the API doc. Why is this?
For example, esp_flash_get_size function, How can I configure to generate bindings for these functions?

(I've checked for esp32, not for esp32s3, but I don't think there is any difference between esp32 and esp32s3 w.r.t. flash functions.)
The TL;DR is:

  • I see esp_flash_get_size in the generated bindings
  • The component @Vollbrecht talks about from above is actually enabled by default, as long as you use the regular cargo build. Now, if you use the CMake-based build, you need to enable that component explicitly, but otherwise you should be good to go?

So... are you actually sure that you don't see that function?
Feel free to reopen if there's an additional detail I'm missing.

This function was not generated in esp32s3

OK, I'll try to check for esp32s3 on my machine shortly (with both ESP IDF 4.X and 5.X).

What ESP IDF specifically are you using?
Can you also confirm, that you are using the cargo build, and not the cmake build?

@ivmarkov
Copy link
Collaborator

OK, so these functions are missing in the bindings from ESP IDF 5 onward.
However I don't think this is esp32s3 specific at all.

It is more about the fact that since ESP IDF 5 there is a new component, esp_partition, and the new esp_partition.h header no longer includes the esp_flash header (which is now in a separate component).

Anyway, I've pushed esp-rs/esp-idf-sys@2785e38 which should fix this. If the CI passes, please use esp-idf-sys from GitHub, until I branch a new release on crates.io.

@silent-rain
Copy link
Author

Thanks

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

3 participants