diff options
Diffstat (limited to 'docs/modules/ROOT/pages/faq.adoc')
| -rw-r--r-- | docs/modules/ROOT/pages/faq.adoc | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/docs/modules/ROOT/pages/faq.adoc b/docs/modules/ROOT/pages/faq.adoc index 6032985fc..2994c6278 100644 --- a/docs/modules/ROOT/pages/faq.adoc +++ b/docs/modules/ROOT/pages/faq.adoc | |||
| @@ -36,3 +36,47 @@ For Cortex-M targets, consider making sure that ALL of the following features ar | |||
| 36 | * `nightly` | 36 | * `nightly` |
| 37 | 37 | ||
| 38 | For Xtensa ESP32, consider using the executors and `#[main]` macro provided by your appropriate link:https://crates.io/crates/esp-hal-common[HAL crate]. | 38 | For Xtensa ESP32, consider using the executors and `#[main]` macro provided by your appropriate link:https://crates.io/crates/esp-hal-common[HAL crate]. |
| 39 | |||
| 40 | == Why is my binary so big? | ||
| 41 | |||
| 42 | The first step to managing your binary size is to set up your link:https://doc.rust-lang.org/cargo/reference/profiles.html[profiles]. | ||
| 43 | |||
| 44 | [source,toml] | ||
| 45 | ---- | ||
| 46 | [profile.release] | ||
| 47 | debug = false | ||
| 48 | lto = true | ||
| 49 | opt-level = "s" | ||
| 50 | incremental = true | ||
| 51 | ---- | ||
| 52 | |||
| 53 | All of these flags are elaborated on in the Rust Book page linked above. | ||
| 54 | |||
| 55 | === My binary is still big... filled with `std::fmt` stuff! | ||
| 56 | |||
| 57 | This means your code is sufficiently complex that `panic!` invocation's formatting requirements could not be optimized out, despite your usage of `panic-halt` or `panic-reset`. | ||
| 58 | |||
| 59 | You can remedy this by adding the following to your `.cargo/config.toml`: | ||
| 60 | |||
| 61 | [source,toml] | ||
| 62 | ---- | ||
| 63 | [unstable] | ||
| 64 | build-std = ["core"] | ||
| 65 | build-std-features = ["panic_immediate_abort"] | ||
| 66 | ---- | ||
| 67 | |||
| 68 | This replaces all panics with a `UDF` (undefined) instruction. | ||
| 69 | |||
| 70 | Depending on your chipset, this will exhibit different behavior. | ||
| 71 | |||
| 72 | Refer to the spec for your chipset, but for `thumbv6m`, it results in a hardfault. Which can be configured like so: | ||
| 73 | |||
| 74 | [source,rust] | ||
| 75 | ---- | ||
| 76 | #[exception] | ||
| 77 | unsafe fn HardFault(_frame: &ExceptionFrame) -> ! { | ||
| 78 | SCB::sys_reset() // <- you could do something other than reset | ||
| 79 | } | ||
| 80 | ---- | ||
| 81 | |||
| 82 | Refer to cortex-m's link:https://docs.rs/cortex-m-rt/latest/cortex_m_rt/attr.exception.html[exception handling] for more info. | ||
