-
Notifications
You must be signed in to change notification settings - Fork 15
Support full thread device #49
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
base: main
Are you sure you want to change the base?
Conversation
|
Nice! Afk right now, please be patient... |
|
As I've continued to add more FTD feature support (SRP server, DNS-SD server) I realise that the possible combinations of OpenThread configurations isn't really compatible with the approach of precompiling the libraries. The approach I've got working locally right now is to use the pre-compiled libraries only when the combination of feature flags matches the default configuration, otherwise compile fresh ones. This seems more flexible as more OpenThread features are conditionally added, but I'm not sure if this approach aligns with the project's goals and would welcome guidance. For ESP32 it's trivial to get a working toolchain using Espressif's |
|
Hey @MattsGitCode keep up the good work! :)
Yes. It is trivial to check the enabled cargo features in
It does. As per above, ideally you could add the check to
For NRF it is also relatively trivial to get the ARM GCC toolchain installed.
The project was always under the If you have a better idea for an org to host the project, I'm all ears, but (Ditto for (esp-)mbedtls BTW which I'm "cross-platforming" as we speak.) |
|
Thanks @ivmarkov,
That sounds sensible, I'll tidy up my local spike and get it pushed.
Ah, thank you for the clarifying, I saw #27 and somehow inferred a reverse direction of travel. |
|
I've pushed up the change for this now, @ivmarkov. Since the ability to use pre-generated libraries and bindings depends on OpenThread's configuration, rather than the crate's feature flags, I've used them to drive the conditional. In doing so, I've pulled out the definition of OpenThread config flags from I've encoded a hash of the OpenThread configuration into the path of the pre-generated bindings and libraries in order to provide a bit of safety moving forwards. This also leaves the door open to providing another set of "sane defaults" in the future. I've got some failing CI checks that don't fail locally, I'll take a look at those when I can. |
|
There seems to be something introduced in Rust nightly-2025-12-27 that causes it to incorrectly flag some existing code as having identical if/then branches. I can't see that anything requires nightly rust, and so I propose that the CI workflows use stable Rust instead. |
|
I've updated the README to expand on when the build script will kick in. @ivmarkov, this is ready for review when you have time |
|
@MattsGitCode Sorry for providing feedback so late but I was literally swamped with other PRs upon my return, and I also had to work on esp-mbedtls. In general, I do like the code in the PR, so no objections there. Just a few small nits we can address later. My (major) concern is the following - and I must apologize as I framed it wrongly when typing on my phone - when I was explaining here that we have a combinatoric explosion issue I guess I named it wrongly. What I meant was not really "how to manage the various precompiled builds of My concern was rather a size constraint concern. I.e.:
... we end up with a X * Y precompiled versions of the library, where this number might be 14 in the best case, and more like 24 or more in reality. Now, once we publish the What is giving me "uncomfort" is therefore this. Would we be able to fit in the 10MB limit - compressed - if we have too many precompiled variations? And again, keep in mind we have to count towards the compressed crate bundle not just the
So the question is a bit, can we estimate the size of the problem before we continue further? |
|
Small correction: the supported platforms might be < 7 or ~ 7. Namely:
|
|
More info on the targets: I just figured out the above might not be the only targets... :( This would increase the number of platforms for which we would need precompiled binaries by at least 2 or 3 (esp32s2, esp32s3, esp32) or even more. But this also brings the question of... do we really want to do our own Rust-based serde between the actual radio and the OpenThread running on the other MCU (I'm inclined towards this) ... or do we want to buy into the (what was the terminology in OpenThread again?) their NCP/RCP framework. Which would mean another permutation => even more |
|
Yeah of the two we want RCP it seems. I.e. a |
|
All very valid concerns.
I understood your meaning, I think. My primary goal with encoding the hash into the file path wasn't to allow multiple variants, but rather to provide safety for future changes in this crate. If the precompiled libs got out of step with the "sane defaults" defined in the build script, then it would lead to potential frustration for consumers of this crate. The hash just offers a safety net so that even if things get out of step, they will recompiled on-the-fly. A gzip of the openthread-sys directory today is about 8.7MB, so it's not going to take much to knock it over the 10MB limit. Personally I think it might be better to remove the precompiled libs and just provide a better story for getting a toolchain up and running. It took me the better part of two evenings to figure out how to get the GNU RISCV toolchain built correctly. For ESP targets, it could favour the ESP-provided toolchain if present, which is much more idiot (me) proof. I imagine other vendors offer similar idiot proof toolchains too. In all cases it could fall back to the GNU toolchain if needed. If multiple precompiled lib configurations are desired, there could always be multiple crates:
You're absolutely right, if there's never going to be more than one or two, it might seem a bit overkill. That said, even without the hashing, I'd argue that the OpenThreadConfig is a nice way to get from Cargo feature flags to OpenThread config flags, and it encapsulates the concept of the sane defaults neatly. |
I've been considering a similar question about using Rust crates for features that OpenThread provides, specifically a DNS client supporting service discovery queries). I'm leaning towards OpenThread being battle-tested, and already pulled in as a dependency, so why not just use that. |
|
Thinking further on my multiple crates comment above. This would align better with Cargo's features-are-additive requirement. As it stands today these crates cannot be used safely in a workspace that needs multiple variants. |
did you remove the
My feeling is that would be a disaster. Judging from my experience with the esp-idf-* crates, which do compile on the fly. And which even do download the correct GCC cross toolchain for the user. Rust novices just can't be bothered with with C toolchains that's the harsh reality. If we can get rid of the sysroot, then maybe we can switch the C compilation step to clang, that might help as clang is often pre-installed, and it is a single cross-compiler. That would work for everything but xrtensa which needs a patched clang.
That might be an idea if indeed we are at 8.7MB.
That's true. |
Not sure I follow your comment here? |
I thought I had but I'll try again later.
That's fair. I'm coming back to embedded Rust after 6 or 7 years away from it, so far the experience has been considerably smoother than back then. Perhaps I was too optimistic :)
Apologies, this was an ill-thought-out comment based on half-baked assumptions. Everything in That said, it's an existing problem in the embedded space. If you change the default feature of one of those workspace packages to be the H2 instead, you get build errors because ESP-HAL also has feature flags intended to be mutually exclusive. So based on this, there should probably be no expectation of |
This PR adds a feature to the crates for building the OpenThread library in FTD mode. To support this, it also:
otPlatRadioEnableSrcMatch, however the required function is not exposed in the HAL at this time, so it's just a no-opI've tested this works on a couple of ESP32-C6 boards, one running with the FTD feature. The FTD board successfully promotes itself to leader, and the MTD board is able to become a child.