Open xphoniex opened 1 year ago
I had the same issue. The problem is that avr-hal
uses custom targets, and therefore this and other tools won't work.
As a temporary solution, you can use the built-in avr-unknown-gnu-atmega328
target together with the default-linker-libraries
flag set in your .cargo/config.toml
file:
[target.'cfg(target_arch = "avr")']
runner = "ravedude nano -cb 57600"
rustflags = [
"-C", "default-linker-libraries",
]
[build]
target = "avr-unknown-gnu-atmega328"
[unstable]
build-std = ["core"]
I opened a discussion on avr-hal
to discuss switching to built-in targets to fix these issues, but I haven't received any reply so far.
Still not working for me, here's a sample: avr-bug.zip
after changing:
# .cargo/config.toml
rustflags = ["-Z emit-stack-sizes", "-C", "default-linker-libraries"]
# ...
[build]
target = "avr-unknown-gnu-atmega328"
now getting a lot of:
/.cargo/git/checkouts/noble-secp256k1-rs-de6fa1b71b2c997d/cc4b0d9/src/point.rs:88: undefined reference to `memcpy'
/.cargo/git/checkouts/noble-secp256k1-rs-de6fa1b71b2c997d/cc4b0d9/src/point.rs:91: undefined reference to `memcpy'
/avr-bug/target/avr-unknown-gnu-atmega328/release/deps/avr_bug-c860dd4dcd188a17.avr_bug.61b298e20baa14c7-cgu.0.rcgu.o: In function `awint_core::data::inlawi::InlAwi$LT$_$C$_$GT$::unstable_from_u8_slice::h6374a892fad81781':
/.cargo/registry/src/index.crates.io-6f17d22bba15001f/awint_core-0.7.0/src/data/inlawi.rs:169: undefined reference to `memset'
/.cargo/registry/src/index.crates.io-6f17d22bba15001f/awint_core-0.7.0/src/data/inlawi.rs:169: undefined reference to `memset'
/.cargo/registry/src/index.crates.io-6f17d22bba15001f/awint_core-0.7.0/src/data/inlawi.rs:169: undefined reference to `memset'
/avr-bug/target/avr-unknown-gnu-atmega328/release/deps/avr_bug-c860dd4dcd188a17.avr_bug.61b298e20baa14c7-cgu.0.rcgu.o: In function `core::intrinsics::copy_nonoverlapping::h0c9c42d02499e18c':
/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/intrinsics.rs:2663: undefined reference to `memcpy'
/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/intrinsics.rs:2663: undefined reference to `memcpy'
/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/intrinsics.rs:2663: undefined reference to `memcpy'
/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/intrinsics.rs:2663: undefined reference to `memcpy'
/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/intrinsics.rs:2663: undefined reference to `memcpy'
/avr-bug/target/avr-unknown-gnu-atmega328/release/deps/avr_bug-c860dd4dcd188a17.avr_bug.61b298e20baa14c7-cgu.0.rcgu.o:/.cargo/git/checkouts/noble-secp256k1-rs-de6fa1b71b2c997d/cc4b0d9/src/point.rs:519: more undefined references to `memcpy' follow
/avr-bug/target/avr-unknown-gnu-atmega328/release/deps/avr_bug-c860dd4dcd188a17.avr_bug.61b298e20baa14c7-cgu.0.rcgu.o: In function `noble_secp256k1::point::Point::double_assign_mod::h5cae01c52035a5db':
avr_bug.61b298e20baa14c7-cgu.0:(.text._ZN15noble_secp256k15point5Point17double_assign_mod17h5cae01c52035a5dbE+0x818): undefined reference to `abort'
collect2: error: ld returned 1 exit status
= note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
= note: use the `-l` flag to specify native libraries to link
= note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)
warning: `avr-bug` (bin "avr-bug") generated 3 warnings
error: could not compile `avr-bug` (bin "avr-bug") due to previous error; 3 warnings emitted
Some notes about the code you attached:
rustflags
option must be placed under the [target]
attribute."-Z emit-stack-sizes"
is not a valid flag, you need to split it in two strings: "-Z", "emit-stack-sizes"
.[target]
attribute accordingly.Therefore, this is the correct .cargo/config.toml
:
[target.avr-unknown-gnu-atmega328]
runner = "qemu-system-avr -M uno -nographic -serial tcp::5678,server=on -bios"
rustflags = ["-Z", "emit-stack-sizes", "-C", "default-linker-libraries"]
[build]
target = "avr-unknown-gnu-atmega328"
[unstable]
build-std = ["core"]
Still no luck, now I'm getting:
error: couldn't open ELF file `/avr-bug/target/avr-unknown-gnu-atmega328/release/avr-bug`: No such file or directory (os error 2)
This error seems to be unrelated to the compilation target, so I cannot really help.
I'm compiling rust code for AVR using avr-hal which uses
avr-gcc
for final compilation and bypasses LLVM. If I try:file rename and attached: arduino_lib-3273400ccbbcd796.txt