Closed adminSxs closed 1 year ago
I am not able to reproduce the error. I added cortex-m-rtic
to a the app-template
, but the bin
s still compiles just fine for me.
The error says error: undefined symbol: _defmt_release
and the same for _defmt_release
and _defmt_write
. Do you have defmt-rtt
in your list of dependencies? (It should be there by default).
What happens if you remove "-C", "linker=flip-link",
from the rustflags
in .cargo/config.toml
? This will skip flip-link
and just invoke the native linker.
rustflags = [
- "-C", "linker=flip-link",
"-C", "link-arg=-Tlink.x",
"-C", "link-arg=-Tdefmt.x",
# This is needed if your flash or ram addresses are not aligned to 0x10000 in memory.x
# See https://github.com/rust-embedded/cortex-m-quickstart/pull/95
"-C", "link-arg=--nmagic",
]
I'm running into the same issue, however when I remove the line in config.toml I get this:
error: linking with `rust-lld` failed: exit code: 1
|
= note: "rust-lld" "-flavor" "gnu" "C:\\Users\\Ragarnoy\\AppData\\Local\\Temp\\rustc5b0jk9\\symbols.o" "C:\\Users\\Ragarnoy\\embedded-trainings-2020\\beginner\\apps\\target\\thumbv7em-none-eabihf\\debug\\deps\\hello-8229623d76740f1f.hello.f932f36f-cgu.0.rcgu.o" "--as-needed" "-L" "C:\\Users\\Ragarnoy\\embedded-trainings-2020\\beginner\\apps\\target\\thumbv7em-none-eabihf\\debug\\deps" "-L" "C:\\Users\\Ragarnoy\\embedded-trainings-2020\\beginner\\apps\\target\\debug\\deps" "-L" "C:\\Users\\Ragarnoy\\embedded-trainings-2020\\beginner\\apps\\target\\thumbv7em-none-eabihf\\debug\\build\\cortex-m-c452bec137310b55\\out" "-L" "C:\\Users\\Ragarnoy\\embedded-trainings-2020\\beginner\\apps\\target\\thumbv7em-none-eabihf\\debug\\build\\cortex-m-rt-be4f982373b21b56\\out" "-L" "C:\\Users\\Ragarnoy\\embedded-trainings-2020\\beginner\\apps\\target\\thumbv7em-none-eabihf\\debug\\build\\defmt-7fb01f6acebd88d4\\out" "-L" "C:\\Users\\Ragarnoy\\embedded-trainings-2020\\beginner\\apps\\target\\thumbv7em-none-eabihf\\debug\\build\\dk-54fd7126418f8b29\\out" "-L" "C:\\Users\\Ragarnoy\\embedded-trainings-2020\\beginner\\apps\\target\\thumbv7em-none-eabihf\\debug\\build\\nrf52840-hal-19cebceb665df9d9\\out" "-L" "C:\\Users\\Ragarnoy\\embedded-trainings-2020\\beginner\\apps\\target\\thumbv7em-none-eabihf\\debug\\build\\nrf52840-pac-e7d0e23c12afa921\\out" "-L" "C:\\Users\\Ragarnoy\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\thumbv7em-none-eabihf\\lib" "-Bstatic" "C:\\Users\\Ragarnoy\\AppData\\Local\\Temp\\rustc5b0jk9\\libcortex_m-3b1a265280aea223.rlib" "C:\\Users\\Ragarnoy\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\thumbv7em-none-eabihf\\lib\\libcompiler_builtins-1f7e7d1541f43b6f.rlib" "-Bdynamic" "--eh-frame-hdr" "-znoexecstack" "-L" "C:\\Users\\Ragarnoy\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\thumbv7em-none-eabihf\\lib" "-o" "C:\\Users\\Ragarnoy\\embedded-trainings-2020\\beginner\\apps\\target\\thumbv7em-none-eabihf\\debug\\deps\\hello-8229623d76740f1f" "--gc-sections" "-Tlink.x" "-Tdefmt.x"
= note: rust-lld: warning: section type mismatch for .uninit.defmt-rtt.BUFFER
>>> C:\Users\Ragarnoy\embedded-trainings-2020\beginner\apps\target\thumbv7em-none-eabihf\debug\deps\hello-8229623d76740f1f.hello.f932f36f-cgu.0.rcgu.o:(.uninit.defmt-rtt.BUFFER): SHT_PROGBITS
>>> output section .uninit: SHT_NOBITS
rust-lld: warning: section type mismatch for .got
>>> <internal>:(.got): SHT_PROGBITS
>>> output section .got: SHT_NOBITS
rust-lld: warning: section type mismatch for .got.plt
>>> <internal>:(.got.plt): SHT_PROGBITS
>>> output section .got: SHT_NOBITS
rust-lld: warning: section type mismatch for .got
>>> <internal>:(.got): SHT_PROGBITS
>>> output section .got: SHT_NOBITS
rust-lld: error: undefined symbol: _critical_section_1_0_acquire
>>> C:\Users\Ragarnoy\embedded-trainings-2020\beginner\apps\target\thumbv7em-none-eabihf\debug\deps\hello-8229623d76740f1f.hello.f932f36f-cgu.0.rcgu.o:(_defmt_acquire)
rust-lld: error: undefined symbol: _critical_section_1_0_release
>>> referenced by lib.rs:45 (C:\Users\Ragarnoy\.cargo\registry\src\github.com-1ecc6299db9ec823\critical-section-0.2.8\src\lib.rs:45)
>>> C:\Users\Ragarnoy\embedded-trainings-2020\beginner\apps\target\thumbv7em-none-eabihf\debug\deps\hello-8229623d76740f1f.hello.f932f36f-cgu.0.rcgu.o:(_defmt_release)
error: could not compile `apps` due to previous error
That's caused by an update to critical-section
and isn't a flip-link bug (although perhaps we need to bump some dependencies in our example project). The update resolves an unsoundness bug, but requires you to opt-in to a trait implementation from somewhere (or write your own) - if you don't, you are missing those two symbols.
See https://docs.rs/critical-section/latest/critical_section/#usage-in-no-std-binaries.
That's caused by an update to
critical-section
and isn't a flip-link bug (although perhaps we need to bump some dependencies in our example project). The update resolves an unsoundness bug, but requires you to opt-in to a trait implementation from somewhere (or write your own) - if you don't, you are missing those two symbols.See https://docs.rs/critical-section/latest/critical_section/#usage-in-no-std-binaries.
tyvm!
Please see our blog post on the issue for how to fix it and how it happened: https://ferrous-systems.com/blog/defmt-rtt-linker-error/
windows os: 11 I use
https://github.com/knurling-rs/app-template
generate project add