-
Notifications
You must be signed in to change notification settings - Fork 131
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
Undefined reference to tinyusb callback funcs #359
Comments
I tried to understand why the build fail. It seems like that the esp-idf-sys build system is building tinyusb as a static lib? But the callback functions are defined in esp_tinyusb. May need to dig deeper to understand what's going on here. |
The callbacks are not really referenced from your program so the linker is pruning them. What happens if you call this function in your program? |
@ivmarkov I think you're right. Indeed it seems like it's linker is pruning them. I just call a random one from them unsafe { tud_msc_test_unit_ready_cb(0) }; And now it builds. Any idea how to make esp/rust build system to keep those functions without making a call? I can make a always false if condition to fix this problem as a workaround, but there must be a better solution than this. |
My point is that if you are trying to implement a mass-storage device, you have to place a call to this function anyway in your code (right? or else how would your mass-storage device connect to the SD card?), and then if you do that, this function is anyway calling the callbacks, so they would be preserved? |
@ivmarkov yep, I see, you're right. Looks like I will need to call that function anyway. So the header for
After that, if I call Thank you so much for the help. Silly problem as it turns out 😅 |
BTW, I've now directly included all TinyUSB headers in the about-to-be-released next What this means is that while you still have to refer to the TinyUSB custom component from your binary crate, you no longer need to define your own "bindings_header" header. The moment you include the tinyusb component, the bindings will be generated for you. Would you like to try this out? I really don't have time to try if it works correctly myself. You need to patch the [patch.crates-io]
embuild = { git = "https://github.com/esp-rs/embuild" }
esp-idf-svc = { git = "https://github.com/esp-rs/esp-idf-svc" }
esp-idf-hal = { git = "https://github.com/esp-rs/esp-idf-hal" }
esp-idf-sys = { git = "https://github.com/esp-rs/esp-idf-sys" } Also note that you have to remove the |
I just tried it out in my reproducing repo here: And here's the error I got
Probably because in my reproducing repo, I only have I guess you need to put probably the same for all the conditional stuff and their corresponding headers such as:
|
Thank you for your feedback! Can you try again (do
|
Hmmm That's odd. I tried your new commit LaunchPlatform/esp-idf-sys-esp-tinyusb-build-erro-reproduce@edc25d7 Still encountering the same error
|
OK, let me try myself, though weird - as if you did not pick up the latest commit. |
|
@fangpenlin Now fixed for real & tested. :-) |
Yep, I got it wrong. Didn't notice that the patch actually was not applied. Sorry still pretty new to rust 😅 And yes, I tested it locally now it builds. 👍 Thanks for the help! 🙌 |
Thank you for the help and no you did not get it wrong (that's why I did strikethrough my original message). It wasn't working because the tiny usb config settings (for whatever reason) are always present, but are either equal to 0 or to 1, so I had to fix the |
Bug description
Build extra
esp_tinyusb
component withCONFIG_TINYUSB_MSC_ENABLED
set toy
, somehow encounter the cakkback functions symbols missing issue:To Reproduce
Have esp_tinyusb in Cargo.toml extra components like this:
Have a binding header file like this
Add
in
sdkconfig.defaults
fileThe repository for reproduction is here:
https://github.com/LaunchPlatform/esp-idf-sys-esp-tinyusb-build-erro-reproduce
Please note that to make the reproduction repo works, you need to downgrade espup to 11 with older clang runtime and also put the folder in a shorter path to avoid path too long problem under windows
Expected behavior
It should build
Environment
esp-idf-sys
) version: 0.35.0The text was updated successfully, but these errors were encountered: