aboutsummaryrefslogtreecommitdiff
path: root/docs/modules/ROOT/pages/faq.adoc
diff options
context:
space:
mode:
Diffstat (limited to 'docs/modules/ROOT/pages/faq.adoc')
-rw-r--r--docs/modules/ROOT/pages/faq.adoc44
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
38For Xtensa ESP32, consider using the executors and `#[main]` macro provided by your appropriate link:https://crates.io/crates/esp-hal-common[HAL crate]. 38For 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
42The 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]
47debug = false
48lto = true
49opt-level = "s"
50incremental = true
51----
52
53All 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
57This 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
59You can remedy this by adding the following to your `.cargo/config.toml`:
60
61[source,toml]
62----
63[unstable]
64build-std = ["core"]
65build-std-features = ["panic_immediate_abort"]
66----
67
68This replaces all panics with a `UDF` (undefined) instruction.
69
70Depending on your chipset, this will exhibit different behavior.
71
72Refer 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]
77unsafe fn HardFault(_frame: &ExceptionFrame) -> ! {
78 SCB::sys_reset() // <- you could do something other than reset
79}
80----
81
82Refer to cortex-m's link:https://docs.rs/cortex-m-rt/latest/cortex_m_rt/attr.exception.html[exception handling] for more info.