newAM / stm32wl-lightswitch-demo

Demo project for the stm32wlxx-hal
MIT License
7 stars 2 forks source link

Critical section problems #122

Closed rickpayne closed 4 months ago

rickpayne commented 4 months ago

Compiling it gives:

rror: linking with `rust-lld` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/Users/rickp/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/bin:/opt/homebrew/opt/libarchive/bin:/Users/rickp/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/opt/X11/bin:/Library/Apple/usr/bin:/usr/local/MacGPG2/bin:/usr/local/go/bin:/Users/rickp/.cargo/bin:/Applications/kitty.app/Contents/MacOS:/Users/rickp/src/go/bin" VSLANG="1033" "rust-lld" "-flavor" "gnu" "/var/folders/4x/05vbnptx3w13v1bd6q4rbz_m0000gn/T/rustcGAcziA/symbols.o" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/server-a2ee1eee59d28362.2v4ud7ylk2kznn2z.rcgu.o" "--as-needed" "-L" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps" "-L" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/debug/deps" "-L" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/build/cortex-m-52174aed6de00894/out" "-L" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/build/defmt-b6d44b9f26295d7c/out" "-L" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/build/cortex-m-rt-62c206e347f6ee4f/out" "-L" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/build/stm32wl-6259260bc62128de/out" "-L" "/Users/rickp/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/thumbv7em-none-eabi/lib" "-Bstatic" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libpostcard-d50e35d02c01a5f6.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libcobs-aa1806bf62918743.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libbytemuck-571371019ba24440.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libshared-b68941f2254a9440.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libstatic_assertions-f881445a9993faf2.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/librtic-5ea28902912d334f.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libheapless-a84db421ed0c9714.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libstable_deref_trait-dcd0f7159f62a900.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libserde-e2363f8ab7264fe0.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libhash32-0397e6f81633928d.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libbyteorder-cc0f28a4a8031c33.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libbare_metal-fb089834975a2080.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/librtic_monotonic-79e92c14f2ead652.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/librtic_core-f5da406875c232a1.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libnucleo_wl55jc_bsp-308751c3533b09d3.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libstm32wlxx_hal-440e7b3a0da5b89a.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libstm32wl-c9b2b7a93a36eb90.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libcfg_if-8c3c170a664af187.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libcortex_m_rt-4b928a5cbe346375.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libchrono-3ad8d532018bcc7e.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/librand_core-9590d9c4360b3159.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libnum_integer-a19d209b98f28703.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libnum_traits-38494231adce542f.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libpanic_probe-e81b8d73ad597cba.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libcortex_m-0f1d29b64e4fb61c.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libembedded_hal-52ad6048dba7115e.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libvoid-0a618972d70da748.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libnb-6919fe9d7b88ff2d.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libnb-9d66ceeceaab3443.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libvolatile_register-086ba6fd4d206977.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libvcell-db0faaa2e13737f5.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libbare_metal-7885cd8d68d4c15c.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libdefmt_rtt-704495590a3082ec.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libcritical_section-5689bb02d51df90c.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libdefmt-dcd42097e0ff935a.rlib" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libbitflags-715ff1e2a5e1c21b.rlib" "/Users/rickp/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/thumbv7em-none-eabi/lib/librustc_std_workspace_core-421035a2c97d9003.rlib" "/Users/rickp/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/thumbv7em-none-eabi/lib/libcore-8cfdefe7e5577bcd.rlib" "/Users/rickp/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/thumbv7em-none-eabi/lib/libcompiler_builtins-66b662759d92889d.rlib" "-Bdynamic" "--eh-frame-hdr" "-z" "noexecstack" "-L" "/Users/rickp/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/thumbv7em-none-eabi/lib" "-o" "/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/server-a2ee1eee59d28362" "--gc-sections" "-O1" "-Tlink.x" "-Tdefmt.x"
  = note: rust-lld: error: undefined symbol: _critical_section_1_0_release
          >>> referenced by lib.rs:197 (/Users/rickp/.cargo/registry/src/index.crates.io-6f17d22bba15001f/critical-section-1.1.1/src/lib.rs:197)
          >>>               defmt_rtt-704495590a3082ec.defmt_rtt.52bded20d281072c-cgu.0.rcgu.o:(_$LT$defmt_rtt..Logger$u20$as$u20$defmt..traits..Logger$GT$::release::hf07140440817ec3e) in archive /Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libdefmt_rtt-704495590a3082ec.rlib

          rust-lld: error: undefined symbol: _critical_section_1_0_acquire
          >>> referenced by lib.rs:180 (/Users/rickp/.cargo/registry/src/index.crates.io-6f17d22bba15001f/critical-section-1.1.1/src/lib.rs:180)
          >>>               defmt_rtt-704495590a3082ec.defmt_rtt.52bded20d281072c-cgu.0.rcgu.o:(_defmt_acquire) in archive /Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps/libdefmt_rtt-704495590a3082ec.rlib

error: could not compile `server` (bin "server") due to 1 previous error

Does it need a critical section implementation now?

rickpayne commented 4 months ago

I got this to compile by adding this to the Cargo.toml of both the server and client:

cortex-m = { version = "0.7.6", features = ["critical-section-single-core"]}

newAM commented 4 months ago

Thanks for letting me know and providing the fix! Looks like it bitrotted since the last CI run passed :(

rickpayne commented 3 months ago

Thanks for the updates. I'm struggling to run this on the NUCLEO-WL55JC1 boards I have. I don't see anything when I run it as describe in the README:

    Running `CARGO=/Users/rickp/.rustup/toolchains/stable-aarch64-apple-darwin/bin/cargo CARGO_MANIFEST_DIR=/Users/rickp/src/lora/stm32wl-lightswitch-demo/client CARGO_PKG_AUTHORS='Alex Martens <alex@thinglab.org>' CARGO_PKG_DESCRIPTION='' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE=MIT CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=client CARGO_PKG_README='' CARGO_PKG_REPOSITORY='' CARGO_PKG_RUST_VERSION='' CARGO_PKG_VERSION=0.1.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=1 CARGO_PKG_VERSION_PATCH=0 CARGO_PKG_VERSION_PRE='' DYLD_FALLBACK_LIBRARY_PATH='/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/build/cortex-m-f5f641789d97e48a/out:/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/build/cortex-m-rt-648539013d4ac8fe/out:/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/build/defmt-b6d44b9f26295d7c/out:/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/build/stm32wl-b333b19af76c615b/out:/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug/deps:/Users/rickp/src/lora/stm32wl-lightswitch-demo/target/thumbv7em-none-eabi/debug:/Users/rickp/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/thumbv7em-none-eabi/lib:/Users/rickp/.rustup/toolchains/stable-aarch64-apple-darwin/lib:/Users/rickp/lib:/usr/local/lib:/usr/lib' probe-run --chip STM32WLE5JCIx target/thumbv7em-none-eabi/debug/client --probe 002400323331511934333834`
(HOST) INFO  flashing program (32 pages / 32.00 KiB)
(HOST) INFO  success!
(HOST) WARN  `defmt::timestamp!` implementation was found, but timestamp is not part of the log format; consider adding the timestamp `{t}` argument to the log format
────────────────────────────────────────────────────────────────────────────────
^C────────────────────────────────────────────────────────────────────────────────
(HOST) INFO  program has used at least 0.16/62.39 KiB (0.3%) of stack space
stack backtrace:
   0: stm32wlxx_hal::subghz::wakeup
        at /Users/rickp/.cargo/registry/src/index.crates.io-6f17d22bba15001f/stm32wlxx-hal-0.6.1/src/subghz/mod.rs:151:11
   1: stm32wlxx_hal::subghz::SubGhz<MISO,MOSI>::new_with_dma_no_reset
        at /Users/rickp/.cargo/registry/src/index.crates.io-6f17d22bba15001f/stm32wlxx-hal-0.6.1/src/subghz/mod.rs:590:18
   2: stm32wlxx_hal::subghz::SubGhz<MISO,MOSI>::new_with_dma
        at /Users/rickp/.cargo/registry/src/index.crates.io-6f17d22bba15001f/stm32wlxx-hal-0.6.1/src/subghz/mod.rs:555:18
   3: client::app::init
        at client/src/main.rs:214:13
   4: client::app::rtic_ext::main::{{closure}}
        at client/src/main.rs:143:1
   5: client::app::rtic_ext::main::__rtic_init_resources
        at client/src/main.rs:143:1
   6: cortex_m::asm::nop
        at /Users/rickp/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cortex-m-0.7.7/src/asm.rs:35:5
   7: main
        at client/src/main.rs:143:1
   8: Reset
(HOST) INFO  device halted by user

Poking with the debugger (manually, as cargo embed also seems to fail), it seems to block in stm32wlxx_hal::subghz::wakeup.

Any ideas?