Comments (3)
UPDATE: Turns out even binstart
is not a default now. Text updated accordingly.
Having an app_main
symbol defined by default is a tricky topic. For one, esp-idf-sys
(and its friends like esp-idf-hal
, esp-idf-svc
) might be pulled in as a dependency in CMake-first/PIO-first projects with a mixed C/Rust codebase, where the app_main
symbol might already be defined in C, and the developer might want to leave it like that.
With that said, we do have the means here to automatically define an app_main
symbol, which does call a Rust main
symbol that the user should provide. This start.rs
code currently lives in the esp-idf-svc
crate however, and that's one of the main questions we should address.
It works as follows:
- If you are building a STD binary crate (typical case for cargo-first builds), the above code gets triggered, but you have to opt-in by enabling the
binstart
feature. - If you are building a library crate (the usual scenario for CMake-first and PIO-first projects),
binstart
cannot be utilized, as it works for binary crates only. Instead, there is alibstart
feature. It has less features compared tobinstart
but it still might be useful. The user should opt-in into that, just like withbinstart
.
With all of the above said... the questions are:
- Shall we move the
start.rs
code fromesp-idf-svc
toesp-idf-sys
? Perhaps yes, because even thoughesp-idf-sys
is supposed to model the ESP-IDF unsafe API only, it already does have a few small utilities, and furthermore, it models the building and linking of ESP-IDF builds too, so perhapsstart.rs
belongs here. Jut like thepanic_handler
definition is already here. Btw it should also be protected by a feature flag, as the user might want to override it. - Shall we have the
binstart
feature enabled by default (it is not, currently)? Perhaps yes, as this gives more ergonomics to cargo-first projects that do build a binary crate, at the expense of less ergonomics for CMake-first and PIO-first projects that currently cannot use thedefault
feature ofesp-idf-sys
(currentlyesp-idf-svc
) because of that default, which makes sense only when building binary crates in Rust.
from esp-idf-sys.
I had to patch esp-idf-sys
anyway (due to your atomics fixes pushed to ESP-IDF master now, yay!) so I decided to bite the bullet and moved binstart
to esp-idf-sys
. You still need to enable it with esp-idf-sys = { version = .., features = ["binstart"] }
though.
The alloc handler and the panic handler are now guarded with explicit features and not enabled by default for no_std
.
from esp-idf-sys.
Closing. I feel the user having to opt-in for binstart
(or libstart
) is somehow the best possible compromise ATM, and it's very easy to do so. Feel free to reopen if you think otherwise.
from esp-idf-sys.
Related Issues (20)
- Failing to add mdns remote component HOT 4
- How to allocate a vector or array in PSRAM HOT 4
- backtrace (of rust code) is incomplete on esp32c6 HOT 17
- Integration with `bevy_ecs` - linker failure `pthread_setcancelstate is not implemented` HOT 5
- Do Rust Native Queues and Mutexes Properly Suspend Tasks HOT 3
- Misaligned struct pointer from esp camera HOT 22
- could not identify the root crate and `ESP_IDF_SYS_ROOT_CRATE` not specified HOT 2
- Time for `espidf_time32`? HOT 4
- Trying to set CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=1 not working HOT 2
- esp-idf-sys HOT 1
- esp-idf-sys build started fail on arm mac os HOT 20
- Unable to build on Mac M1 HOT 1
- ...no 'IDF_PYTHON_ENV_PATH' item,Debian 12, std mode, esp-idf-template, idf master HOT 4
- Windows path length message is wrong. HOT 1
- tskNO_AFFINITY missing with esp-idf v5.2.1 HOT 1
- Using custom components introduces a requirement of specifying all components HOT 7
- failed to run custom build command for `esp-idf-sys v0.34.1` HOT 1
- Wrapper for RTC Slow memory HOT 2
- Implementing tinyusb callbacks in rust HOT 1
- Use of mixed i2c legacy and new apis HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esp-idf-sys.