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

Move malloc(), free(), etc. from esp-wifi to esp-alloc #2865

Open
AnthonyGrondin opened this issue Dec 24, 2024 · 2 comments
Open

Move malloc(), free(), etc. from esp-wifi to esp-alloc #2865

AnthonyGrondin opened this issue Dec 24, 2024 · 2 comments
Labels
status:needs-attention This should be prioritized

Comments

@AnthonyGrondin
Copy link
Contributor

Motivations

esp-wifi, esp-alloc and esp-mbedtls are tightly coupled by their memory allocator implementation. esp-wifi needs an implementation of malloc() and free(), and since #2099, it uses Rust's Global allocator. esp-alloc is a provider of a global allocator for ESP SoCs but users are free to provide their own allocator if they want.

esp-mbedtls and esp-mbedtls-sys depend on esp-wifi, strictly for providing malloc() and free().

Solution

These should be moved to esp-alloc, to only depend on an allocation crate, if one only needs malloc(), free(), etc. They should be defined with conditional compilation and / or weak linkage to avoid conflict issues if another crate provides these symbols.

Alternatives

Provide a c-lib / c-compat / esp-c-compat crate to define and implement C symbols, with conditional compilation. It would not only provide memory allocation symbols, but any symbols such as vsnprintf().

Additional context

@AnthonyGrondin AnthonyGrondin added the status:needs-attention This should be prioritized label Dec 24, 2024
@Dominaezzz
Copy link
Collaborator

Some extra motive. esp-wifi won't be available on the P4 (No WiFi or Bluetooth) but there's no reason esp-mbedtls shouldn't work there. The hard dependency on esp-wifi gets in the way.

@AnthonyGrondin
Copy link
Contributor Author

Ideally esp-mbedtls shouldn't depend on any ESP crates, because in the end, it's just a transport layer, over embedded-io(-async) Read and Write. We will provide hardware acceleration and such using crypto providers, the same way rustls and embedded-tls does. With a few refactors, it will be completely platform agnostic, and can work on any transport medium.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:needs-attention This should be prioritized
Projects
Status: Todo
Development

No branches or pull requests

2 participants