Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated cargo config #18

Closed
wants to merge 1 commit into from
Closed

Conversation

Tomer-Eliahu
Copy link
Contributor

Follow up to #17: updating the rest of the cargo configs in the book.

I think @BartMassey is probably right that this fix is needed due to platform differences (I am on Windows and without this I get an error). If this change causes an error for anyone else maybe it is best to just mention this as a potential fix in the General troubleshooting section of the book.

@Tomer-Eliahu Tomer-Eliahu requested a review from a team as a code owner March 22, 2025 13:18
@neduard
Copy link

neduard commented Mar 29, 2025

Hey - just letting you know this doesn't work on my system - I've had issues with flashing 03-setup getting the following error (introduced in the related PR #17):

> cargo embed
   Compiling rtt-check v0.1.0 (/home/ed/discovery-mb2/mdbook/src/03-setup)
error: could not compile `rtt-check` (bin "rtt-check") due to 1 previous error
error: linking with `rust-lld` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/home/ed/.rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/bin:/home/ed/.cargo/bin:/home/ed/.local/bin:/home/ed/.cargo/bin:/home/ed/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin" VSLANG="1033" "rust-lld" "-flavor" "gnu" "/tmp/rustc4X4LcF/symbols.o" "<3 object files omitted>" "--as-needed" "-Bstatic" "/home/ed/discovery-mb2/target/thumbv7em-none-eabihf/debug/deps/{libcortex_m_rt-10d5562cd3ae9879.rlib,libnrf52833_pac-2de8fc1100e222c7.rlib,libpanic_rtt_target-3ea4e2eabdd9713f.rlib,librtt_target-4d15bfbf65248f0c.rlib,libufmt_write-aafa603ef3be7e22.rlib,libcortex_m-e66cc1941f71678e.rlib,libembedded_hal-26f46a1f292fb026.rlib,libvoid-38e58dbcdcbca52a.rlib,libnb-7cd497236ce83849.rlib,libnb-4badc18e08ab03a2.rlib,libcritical_section-9b1e1eff12d07eb4.rlib,libvolatile_register-6439588298711bd7.rlib,libvcell-5fe821c2679c6c8e.rlib,libbare_metal-99ad248edd9d3415.rlib}" "/home/ed/.rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/thumbv7em-none-eabihf/lib/{librustc_std_workspace_core-89717189c5caa977.rlib,libcore-e6122f30404945e0.rlib,libcompiler_builtins-5581ff22e90261f7.rlib}" "-Bdynamic" "--eh-frame-hdr" "-z" "noexecstack" "-L" "/home/ed/discovery-mb2/target/thumbv7em-none-eabihf/debug/build/rtt-check-7d4ade2b6103c7d0/out" "-L" "/home/ed/discovery-mb2/target/thumbv7em-none-eabihf/debug/build/cortex-m-4af511cf6e414211/out" "-L" "/home/ed/discovery-mb2/target/thumbv7em-none-eabihf/debug/build/cortex-m-rt-b3105827ac0d8c50/out" "-o" "/home/ed/discovery-mb2/target/thumbv7em-none-eabihf/debug/deps/rtt_check-50c3fc1d83ac45bd" "--gc-sections" "-Tlink.x" "-Tlink.x"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: rust-lld: error: /home/ed/discovery-mb2/target/thumbv7em-none-eabihf/debug/build/rtt-check-7d4ade2b6103c7d0/out/memory.x:5: region 'FLASH' already defined
          >>>   FLASH : ORIGIN = 0x00000000, LENGTH = 512K
          >>>                                         ^
          

       Error Failed to run cargo build: exit code = Some(101).
             
             Stack backtrace:
                0: anyhow::error::<impl core::convert::From<E> for anyhow::Error>::from
                1: probe_rs::cmd::cargo_embed::main_try
                2: probe_rs::main
                3: std::sys::backtrace::__rust_begin_short_backtrace
                4: std::rt::lang_start::{{closure}}
                5: std::rt::lang_start_internal
                6: main

note the duplicated argument "-Tlink.x". This has been reported by others (link1, link2). Indeed with this patch, I get the error on 05-meet-your-software as well.

It's strange since we already have a top level .cargo/config.toml. Not very familiar with cargo & cargo embed, but it seems to pick it up even if I remove the example-specific .cargo folders. Not sure what's the correct approach.

Versions:

cargo embed 0.27.0 (git commit: crates.io)
cargo 1.85.1 (d73d2caf9 2024-12-31)

@BartMassey
Copy link
Member

@neduard Thanks much for the report. What host platform are you on? Which chapter were you trying to build? I didn't update anything after Chapter 3 because subsequent chapters have Cargo dependencies that should make it unnecessary to explicitly include link.x — but maybe so.

@Tomer-Eliahu
Copy link
Contributor Author

As this causes an error for others, I closed this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants