rust-embedded / discovery Goto Github PK
View Code? Open in Web Editor NEWDiscover the world of microcontrollers through Rust!
Home Page: https://docs.rust-embedded.org/discovery/
License: Apache License 2.0
Discover the world of microcontrollers through Rust!
Home Page: https://docs.rust-embedded.org/discovery/
License: Apache License 2.0
When executing the following from the discovery/src/05-led-roulette
directory:
xargo build --target thumbv7em-none-eabihf
It's not clear the the resulting target is discovery/target
since the previous page says "Now, jump into the src/05-led-roulette directory
."
Thanks for putting together this great tutorial series. I have succesfully tested my install with openocd -f interface/stlink-v2-1.cfg -f target/stm32f3x.cfg
but I am unable to build 05-led-roulette
on OSX.
The output is as follows:
$ rustc --version
rustc 1.27.0-nightly (ac5c0848d 2018-05-14)
$ cargo build --target thumbv7em-none-eabihf
Compiling panic-abort v0.2.0
Compiling stm32f30x-hal v0.2.0
error[E0658]: The attribute `panic_implementation` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> /Users/josh/.cargo/registry/src/github.com-1ecc6299db9ec823/panic-abort-0.2.0/src/lib.rs:28:1
|
28 | #[panic_implementation]
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.
error: Could not compile `panic-abort`.
warning: build failed, waiting for other jobs to finish...
error: build failed
Any thoughts on this?
When trying to build the sixth project, hello world, it fails because the macro_reexport feature has been removed. My clone is as of today (17/5-18) up to date with the official repo.
[rzmd@rzmd 06-hello-world]$ cargo build
Compiling aux6 v0.1.0 (file:///home/rzmd/Documents/git-repos/discovery/src/06-hello-world/auxiliary)
error[E0557]: feature has been removed
--> src/06-hello-world/auxiliary/src/lib.rs:4:12
|
4 | #![feature(macro_reexport)]
| ^^^^^^^^^^^^^^
|
note: subsumed by `#![feature(use_extern_macros)]` and `pub use`
--> src/06-hello-world/auxiliary/src/lib.rs:4:12
|
4 | #![feature(macro_reexport)]
| ^^^^^^^^^^^^^^
error[E0658]: The attribute `macro_reexport` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> src/06-hello-world/auxiliary/src/lib.rs:8:1
|
8 | #[macro_reexport(iprintln, iprint)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
error: aborting due to 2 previous errors
Some errors occurred: E0557, E0658.
For more information about an error, try `rustc --explain E0557`.
error: Could not compile `aux6`.
To learn more, run the command again with --verbose.
I have been unable to get any of examples from Chapter 06, Hello World, on to compile in debug without modifying Cargo.toml
.
$ xargo build --target thumbv7em-none-eabihf
Compiling usart v0.1.0 (file:///home/cldershem/Dev/LearningStuffs/LearnRust/DiscoveryBook/discovery/src/06-hello-world)
error: linking with `arm-none-eabi-gcc` failed: exit code: 1
|
= note: "arm-none-eabi-gcc" "-L" "/home/cldershem/.xargo/lib/rustlib/thumbv7em-none-eabihf/lib"
//
// lots of stuff omitted
//
= note: /home/cldershem/.xargo/lib/rustlib/thumbv7em-none-eabihf/lib/libcore-1e711822e5d5d922.rlib(core-1e711822e5d5d922.0.o): In function `co
re::panicking::panic_fmt::hb7c1829b06bc1b3c':
core.cgu-0.rs:(.text.cold._ZN4core9panicking9panic_fmt17hb7c1829b06bc1b3cE+0x24): undefined reference to `rust_begin_unwind'
collect2: error: ld returned 1 exit status
error: aborting due to previous error
error: Could not compile `hello-world`.
To learn more, run the command again with --verbose.
$ uname -a && xargo --version && rustc --version
Linux cldershem-xps 4.10.0-35-generic #39-Ubuntu SMP Wed Sep 13 07:46:59 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
xargo 0.3.9
cargo 0.23.0-nightly (e447ac7e9 2017-09-27)
rustc 1.22.0-nightly (417c73891 2017-10-05)
Compiling with --release
works fine. I can get it to compile in debug
if I change the default opt-level
in the Cargo.toml
.
[profile.dev]
opt-level = 1
I cannot be sure if this is something specific to my setup or if it's an issue with a newer nightly. Any guidance on how to troubleshoot this issue will be appreciated.
Hello,
I can't seem to build with Xargo by following the instruction because the .cargo/config was missing instructions for my board.
Here is the fixed .cargo/config that should work for all boards :
[target.thumbv7em-none-eabihf]
rustflags = [
"-C",
"link-arg=-Tstm32f3discovery.ld",
"-C",
"link-arg=-nostartfiles",
]
[target.thumbv7em-none-eabi]
rustflags = [
"-C",
"link-arg=-Tstm32f3discovery.ld",
"-C",
"link-arg=-nostartfiles",
]
[target.thumbv7m-none-eabi]
rustflags = [
"-C",
"link-arg=-Tstm32f3discovery.ld",
"-C",
"link-arg=-nostartfiles",
]
[target.thumbv6m-none-eabi]
rustflags = [
"-C",
"link-arg=-Tstm32f3discovery.ld",
"-C",
"link-arg=-nostartfiles",
]
If I have the time, I will make a pull request.
On my mac I have the reproducible issue that the "official" ARM GNU ARM Embedded Toolchain (6-2016-q4-major) as installed by brew cask info gcc-arm-embedded
mis-compiles/-links all Rust examples independent of the type of build (debug vs release).
For example for the led-roulette example from Japaric's f3 crate I get the following (non-working) binary code with the "official" toolchain:
Disassembly of section .text:
08000000 <_VECTOR_TABLE>:
8000000: 10002000 .word 0x10002000
8000004: 08000195 .word 0x08000195
08000008 <_EXCEPTIONS>:
8000008: 08000323 08000323 08000323 08000323 #...#...#...#...
8000018: 08000323 00000000 00000000 00000000 #...............
8000028: 00000000 08000323 00000000 00000000 ....#...........
8000038: 08000323 08000323 #...#...
08000040 <_INTERRUPTS>:
8000040: 08000323 08000323 08000323 08000323 #...#...#...#...
8000050: 08000323 08000323 08000323 08000323 #...#...#...#...
8000060: 08000323 08000323 08000323 08000323 #...#...#...#...
8000070: 08000323 08000323 08000323 08000323 #...#...#...#...
8000080: 08000323 08000323 08000323 08000323 #...#...#...#...
8000090: 08000323 08000323 08000323 08000323 #...#...#...#...
80000a0: 08000323 08000323 08000323 08000323 #...#...#...#...
80000b0: 08000323 08000323 08000323 08000323 #...#...#...#...
80000c0: 08000323 08000323 08000323 08000323 #...#...#...#...
80000d0: 08000323 08000323 08000323 08000323 #...#...#...#...
80000e0: 08000323 08000323 08000323 08000323 #...#...#...#...
80000f0: 08000323 08000323 08000323 08000323 #...#...#...#...
8000100: 08000323 00000000 00000000 08000323 #...........#...
8000110: 08000323 08000323 08000323 08000323 #...#...#...#...
8000120: 08000323 08000323 08000323 08000323 #...#...#...#...
8000130: 08000323 08000323 00000000 00000000 #...#...........
8000140: 08000323 08000323 08000323 00000000 #...#...#.......
...
8000160: 08000323 08000323 08000323 08000323 #...#...#...#...
8000170: 08000323 08000323 08000323 08000323 #...#...#...#...
8000180: 08000323 08000323 00000000 00000000 #...#...........
8000190: 08000323 #...
08000194 <_reset>:
8000194: b580 push {r7, lr}
8000196: b098 sub sp, #96 ; 0x60
8000198: f10d 0c04 add.w ip, sp, #4
800019c: e88c 000f stmia.w ip, {r0, r1, r2, r3}
...
800020a: f001 f8e4 bl 80013d6 <core::fmt::write>
800020e: be00 bkpt 0x0000
8000210: e7fe b.n 8000210 <_reset+0x7c>
08000212 <<&'a T as core::fmt::Display>::fmt>:
8000212: e9d0 3200 ldrd r3, r2, [r0]
8000216: 4608 mov r0, r1
8000218: 4619 mov r1, r3
800021a: f000 bcfc b.w 8000c16 <core::fmt::Formatter::pad>
...
while I do get the following with another toolchain:
Disassembly of section .text:
08000000 <_VECTOR_TABLE>:
8000000: 10002000 .word 0x10002000
8000004: 08000195 .word 0x08000195
08000008 <_EXCEPTIONS>:
8000008: 080007d9 080007d9 080007d9 080007d9 ................
8000018: 080007d9 00000000 00000000 00000000 ................
8000028: 00000000 080007d9 00000000 00000000 ................
8000038: 080007d9 080007d9 ........
08000040 <_INTERRUPTS>:
8000040: 080007d9 080007d9 080007d9 080007d9 ................
8000050: 080007d9 080007d9 080007d9 080007d9 ................
8000060: 080007d9 080007d9 080007d9 080007d9 ................
8000070: 080007d9 080007d9 080007d9 080007d9 ................
8000080: 080007d9 080007d9 080007d9 080007d9 ................
8000090: 080007d9 080007d9 080007d9 080007d9 ................
80000a0: 080007d9 080007d9 080007d9 080007d9 ................
80000b0: 080007d9 080007d9 080007d9 080007d9 ................
80000c0: 080007d9 080007d9 080007d9 080007d9 ................
80000d0: 080007d9 080007d9 080007d9 080007d9 ................
80000e0: 080007d9 080007d9 080007d9 080007d9 ................
80000f0: 080007d9 080007d9 080007d9 080007d9 ................
8000100: 080007d9 00000000 00000000 080007d9 ................
8000110: 080007d9 080007d9 080007d9 080007d9 ................
8000120: 080007d9 080007d9 080007d9 080007d9 ................
8000130: 080007d9 080007d9 00000000 00000000 ................
8000140: 080007d9 080007d9 080007d9 00000000 ................
...
8000160: 080007d9 080007d9 080007d9 080007d9 ................
8000170: 080007d9 080007d9 080007d9 080007d9 ................
8000180: 080007d9 080007d9 00000000 00000000 ................
8000190: 080007d9 ....
08000194 <_reset>:
8000194: b570 push {r4, r5, r6, lr}
8000196: f240 0000 movw r0, #0
800019a: f240 0110 movw r1, #16
800019e: f2c2 0000 movt r0, #8192 ; 0x2000
80001a2: f2c2 0100 movt r1, #8192 ; 0x2000
80001a6: 1a09 subs r1, r1, r0
80001a8: f021 0103 bic.w r1, r1, #3
80001ac: f001 fed3 bl 8001f56 <__aeabi_memclr4>
80001b0: f240 0010 movw r0, #16
80001b4: f240 0110 movw r1, #16
80001b8: f2c2 0000 movt r0, #8192 ; 0x2000
80001bc: f2c2 0100 movt r1, #8192 ; 0x2000
80001c0: 1a09 subs r1, r1, r0
...
8000476: f04f 4390 mov.w r3, #1207959552 ; 0x48000000
800047a: 250a movs r5, #10
800047c: 681e ldr r6, [r3, #0]
800047e: f365 4695 bfi r6, r5, #18, #4
8000482: 601e str r6, [r3, #0]
8000484: f643 0304 movw r3, #14340 ; 0x3804
8000488: f2c4 0301 movt r3, #16385 ; 0x4001
800048c: 6019 str r1, [r3, #0]
800048e: 6059 str r1, [r3, #4]
8000490: 2145 movs r1, #69 ; 0x45
8000492: 6099 str r1, [r3, #8]
8000494: 210d movs r1, #13
8000496: f8c2 17f8 str.w r1, [r2, #2040] ; 0x7f8
800049a: 6881 ldr r1, [r0, #8]
800049c: f041 0101 orr.w r1, r1, #1
80004a0: 6081 str r1, [r0, #8]
80004a2: f04f 4080 mov.w r0, #1073741824 ; 0x40000000
80004a6: 2101 movs r1, #1
80004a8: 6001 str r1, [r0, #0]
80004aa: f000 f801 bl 80004b0 <main>
...
080004b0 <main>:
80004b0: e92d 4ff0 stmdb sp!, {r4, r5, r6, r7, r8, r9, sl, fp, lr}
80004b4: f641 7086 movw r0, #8070 ; 0x1f86
80004b8: f241 0118 movw r1, #4120 ; 0x1018
80004bc: f241 4310 movw r3, #5136 ; 0x1410
80004c0: 2400 movs r4, #0
80004c2: f6c0 0000 movt r0, #2048 ; 0x800
80004c6: f6c4 0100 movt r1, #18432 ; 0x4800
80004ca: f2c4 0300 movt r3, #16384 ; 0x4000
80004ce: f100 0e08 add.w lr, r0, #8
80004d2: 2001 movs r0, #1
80004d4: f641 7686 movw r6, #8070 ; 0x1f86
80004d8: f04f 0801 mov.w r8, #1
80004dc: 2700 movs r7, #0
80004de: f6c0 0600 movt r6, #2048 ; 0x800
...
Most obviously (although I shortened it quite a bit above) is the much shorter _reset () and the total omission of the main function with the broken compiler. Also the included arm-none-eabi-gdb
in the cask version crashes all the time with the simplest activities, like:
# arm-none-eabi-gdb f3/target/thumbv7em-none-eabihf/release/examples/led-roulette
GNU gdb (GNU Tools for ARM Embedded Processors) 7.12.0.20161204-git
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-apple-darwin10 --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from f3/target/thumbv7em-none-eabihf/release/examples/led-roulette...(no debugging symbols found)...done.
(gdb) list
Abort trap: 6
For the working compiler I'm using the brew package gcc-arm-none-eabi from the px4/px4 tap.
Trying to compile the LED example from chapter 5 results in this:
$> cargo build --target thumbv7em-none-eabihf
Compiling cortex-m-rt v0.3.15
error[E0522]: definition of an unknown language item: `panic_fmt`
--> C:\Users\maxst\.cargo\registry\src\github.com-1ecc6299db9ec823\cortex-m-rt-0.3.15\src\lang_items.rs:3:1
|
3 | #[lang = "panic_fmt"]
| ^^^^^^^^^^^^^^^^^^^^^ definition of unknown language item `panic_fmt`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0522`.
error: Could not compile `cortex-m-rt`.
To learn more, run the command again with --verbose.
The reason for this is due to this:
https://users.rust-lang.org/t/psa-breaking-change-panic-fmt-language-item-removed-in-favor-of-panic-implementation/17875
Hi,
I've been working my way through the tutorial lately but today I've hit a bump. First stm32f30x stopped building, because it wouldn't take latest (0.4.0) cortex-m-rt but insisted on previous version. I cloned it and changed Cargo.toml in both discovery and stm32f30x, added a dupe panic_fmt, and then when I tried to build using local dependency everything broke at last linking step, mainly getting errors as such:
= note: /home/damck/mgr/discovery/target/thumbv7em-none-eabihf/debug/deps/libcortex_m-3ff1d9f0667fc7b0.rlib(cortex_m-3ff1d9f0667fc7b0.cortex_m0.rcgu.o): In function 'core::ptr::swap_nonoverlapping_bytes': /home/damck/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/ptr.rs:223: undefined reference to '__aeabi_memcpy'
And I can't seem to find what else I could do. Is this the 'outdated' part I've noticed on the repository? Any clue what else I might be doing wrong/missing?
Sorry for a newb issue, but I'd rather use this than mail.
EDIT:
Nvm, fixed it.
I went and re-read the updated setup pages and noticed xargo was no longer used. Works with cargo. Sorry for bothering you.
I migrated my dev system from Debian 8 to Debian 9. I followed https://japaric.github.io/discovery/03-setup/linux.html to set up my toolchain which worked well in Debian 8. Now with Debian 9 I get the following error: led_roulette...0.o uses VFP register arguments, but ... does not
(see log below).
I found this post explaining:
Your target triplet indicates that your compiler is configured for the hard-float ABI. This means that the libgcc library will also be hardfp. The error message indicates that at least part of your system is using soft-float ABI.
Any idea how can I fix this?
Thank you in advance
Compiling led-roulette v0.1.0 (file:///tmp/05-led-roulette)
error: linking with `arm-none-eabi-gcc` failed: exit code: 1
|
= note: "arm-none-eabi-gcc" "-L" "/home/getreu/.xargo/lib/rustlib/thumbv7em-none-eabihf/lib" "/tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/led_roulette-132d63accba18f60.0.o" "-o" "/tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/led_roulette-132d63accba18f60" "-Wl,--gc-sections" "-nodefaultlibs" "-L" "/tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps" "-L" "/tmp/05-led-roulette/target/debug/deps" "-L" "/tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/build/f3-cdfa7b9c1efa4255/out" "-L" "/home/getreu/.xargo/lib/rustlib/thumbv7em-none-eabihf/lib" "-Wl,-Bstatic" "-Wl,-Bdynamic" "/tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/libpg-ac6e51f0e61b6a31.rlib" "/tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/libf3-123e742e98e90c5b.rlib" "/tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/libstm32f30x_memory_map-cc3041989572365a.rlib" "/tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/libcompiler_builtins_snapshot-1a4209288c3e868c.rlib" "/tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/librlibc-3706ac36a4368afe.rlib" "/tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/libcortex_m-f673cf33e5b39258.rlib" "/tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/libvolatile_register-92f00f85b2478495.rlib" "/tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/libref_slice-62a5a8ad65c5543f.rlib" "/home/getreu/.xargo/lib/rustlib/thumbv7em-none-eabihf/lib/libcore-78cdc976288fbcf3.rlib"
= note: /usr/lib/gcc/arm-none-eabi/5.4.1/../../../arm-none-eabi/bin/ld: error: /tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/led_roulette-132d63accba18f60.0.o uses VFP register arguments, /tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/led_roulette-132d63accba18f60 does not
/usr/lib/gcc/arm-none-eabi/5.4.1/../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/led_roulette-132d63accba18f60.0.o
/usr/lib/gcc/arm-none-eabi/5.4.1/../../../arm-none-eabi/bin/ld: error: /tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/libf3-123e742e98e90c5b.rlib(f3-123e742e98e90c5b.0.o) uses VFP register arguments, /tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/led_roulette-132d63accba18f60 does not
/usr/lib/gcc/arm-none-eabi/5.4.1/../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/libf3-123e742e98e90c5b.rlib(f3-123e742e98e90c5b.0.o)
/usr/lib/gcc/arm-none-eabi/5.4.1/../../../arm-none-eabi/bin/ld: error: /tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/libstm32f30x_memory_map-cc3041989572365a.rlib(stm32f30x_memory_map-cc3041989572365a.0.o) uses VFP register arguments, /tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/led_roulette-132d63accba18f60 does not
/usr/lib/gcc/arm-none-eabi/5.4.1/../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/libstm32f30x_memory_map-cc3041989572365a.rlib(stm32f30x_memory_map-cc3041989572365a.0.o)
/usr/lib/gcc/arm-none-eabi/5.4.1/../../../arm-none-eabi/bin/ld: error: /tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/librlibc-3706ac36a4368afe.rlib(rlibc-3706ac36a4368afe.0.o) uses VFP register arguments, /tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/led_roulette-132d63accba18f60 does not
/usr/lib/gcc/arm-none-eabi/5.4.1/../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/librlibc-3706ac36a4368afe.rlib(rlibc-3706ac36a4368afe.0.o)
/usr/lib/gcc/arm-none-eabi/5.4.1/../../../arm-none-eabi/bin/ld: error: /tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/libcortex_m-f673cf33e5b39258.rlib(cortex_m-f673cf33e5b39258.0.o) uses VFP register arguments, /tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/led_roulette-132d63accba18f60 does not
/usr/lib/gcc/arm-none-eabi/5.4.1/../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/libcortex_m-f673cf33e5b39258.rlib(cortex_m-f673cf33e5b39258.0.o)
/usr/lib/gcc/arm-none-eabi/5.4.1/../../../arm-none-eabi/bin/ld: error: /home/getreu/.xargo/lib/rustlib/thumbv7em-none-eabihf/lib/libcore-78cdc976288fbcf3.rlib(core-78cdc976288fbcf3.0.o) uses VFP register arguments, /tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/led_roulette-132d63accba18f60 does not
/usr/lib/gcc/arm-none-eabi/5.4.1/../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/getreu/.xargo/lib/rustlib/thumbv7em-none-eabihf/lib/libcore-78cdc976288fbcf3.rlib(core-78cdc976288fbcf3.0.o)
/usr/lib/gcc/arm-none-eabi/5.4.1/../../../arm-none-eabi/lib/crt0.o: In function `_start':
/build/newlib-XAuz1P/newlib-2.4.0.20160527/build/arm-none-eabi/libgloss/arm/../../../../libgloss/arm/crt0.S:421: undefined reference to `atexit'
/build/newlib-XAuz1P/newlib-2.4.0.20160527/build/arm-none-eabi/libgloss/arm/../../../../libgloss/arm/crt0.S:423: undefined reference to `__libc_init_array'
/build/newlib-XAuz1P/newlib-2.4.0.20160527/build/arm-none-eabi/libgloss/arm/../../../../libgloss/arm/crt0.S:429: undefined reference to `exit'
/build/newlib-XAuz1P/newlib-2.4.0.20160527/build/arm-none-eabi/libgloss/arm/../../../../libgloss/arm/crt0.S:429: undefined reference to `__libc_fini_array'
/tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/led_roulette-132d63accba18f60.0.o:(.ARM.exidx.text._ZN4core3mem7size_of17h74cc3cbcf81503d9E+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
/tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/led_roulette-132d63accba18f60.0.o:(.ARM.exidx.text._ZN4core3ptr31_$LT$impl$u20$$BP$mut$u20$T$GT$15wrapping_offset17h644baddd8c4db2ceE+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
/tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/led_roulette-132d63accba18f60.0.o:(.ARM.exidx.text._ZN4core3ptr33_$LT$impl$u20$$BP$const$u20$T$GT$6offset17hdd27b6245f827a4eE+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
/tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/led_roulette-132d63accba18f60.0.o:(.ARM.exidx.text._ZN4core3ptr33_$LT$impl$u20$$BP$const$u20$T$GT$7is_null17hc997f70270022e5bE+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
/tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/led_roulette-132d63accba18f60.0.o:(.ARM.exidx.text._ZN4core3ptr4null17h43d11c6995bde0abE+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
/tmp/05-led-roulette/target/thumbv7em-none-eabihf/debug/deps/led_roulette-132d63accba18f60.0.o:(.ARM.exidx.text._ZN4core5slice67_$LT$impl$u20$core..ops..Index$LT$I$GT$$u20$for$u20$$u5b$T$u5d$$GT$5index17hd85f1523675f69baE+0x0): more undefined references to `__aeabi_unwind_cpp_pr0' follow
/home/getreu/.xargo/lib/rustlib/thumbv7em-none-eabihf/lib/libcore-78cdc976288fbcf3.rlib(core-78cdc976288fbcf3.0.o): In function `core::panicking::panic_fmt::h0735e1d1e2768939':
core.cgu-0.rs:(.text._ZN4core9panicking9panic_fmt17h0735e1d1e2768939E+0x24): undefined reference to `rust_begin_unwind'
/home/getreu/.xargo/lib/rustlib/thumbv7em-none-eabihf/lib/libcore-78cdc976288fbcf3.rlib(core-78cdc976288fbcf3.0.o):(.ARM.exidx.text._ZN4core9panicking9panic_fmt17h0735e1d1e2768939E+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
/home/getreu/.xargo/lib/rustlib/thumbv7em-none-eabihf/lib/libcore-78cdc976288fbcf3.rlib(core-78cdc976288fbcf3.0.o):(.ARM.exidx.text._ZN4core3fmt9Formatter12pad_integral17h53007ef69e7b4667E+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
/home/getreu/.xargo/lib/rustlib/thumbv7em-none-eabihf/lib/libcore-78cdc976288fbcf3.rlib(core-78cdc976288fbcf3.0.o):(.ARM.exidx.text._ZN4core3fmt3num54_$LT$impl$u20$core..fmt..Display$u20$for$u20$usize$GT$3fmt17hc953ff2732709e0aE+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
collect2: error: ld returned 1 exit status
Following the guide here, running cargo size -- --version
results in the following error:
dyld: Library not loaded: @rpath/libLLVM.dylib
Referenced from: /Users/twilcock/.rustup/toolchains/nightly-x86_64-apple-darwin/bin/llvm-size
Reason: image not found
I think there's been changes recently in how LLVM is referenced by the Rust compiler, so maybe that has something to do with it? The other commands on that page worked without issue.
I'm using a 2014 MacBook Pro. Here is my Rust version:
$ rustc --version
rustc 1.30.0-nightly (6e0f1cc15 2018-09-05)
I found extern crate pg
to be a little bit confusing, especially since it is included locally in the repository. I think that a better name than pg (which kept making me think propertygroup
or postgresql
and not playground
) might be suitable. Possibly something like my_hal
or playground_hal
, sandbox_hal
etc.
https://japaric.github.io/discovery/03-setup/linux.html
Typically those things belong to dialout on my systems, but as far as I can tell there is no uucp group by default on my machine
[grazfather ~/code/discovery/src/05-led-roulette]$ rustup default nightly
info: using existing install for 'nightly-x86_64-apple-darwin'
info: default toolchain set to 'nightly-x86_64-apple-darwin'
nightly-x86_64-apple-darwin unchanged - rustc 1.22.0-nightly (277476c4f 2017-09-16)
[grazfather ~/code/discovery/src/05-led-roulette]$ xargo build --target thumbv7em-none-eabihf
Compiling f3 v0.3.1
Compiling cortex-m v0.1.6
error: `<core::cell::UnsafeCell<T>>::new` is not yet stable as a const fn
--> /Users/grazfather/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-m-0.1.6/src/interrupt.rs:13:24
|
13 | Mutex { inner: UnsafeCell::new(value) }
| ^^^^^^^^^^^^^^^^^^^^^^
|
= help: in Nightly builds, add `#![feature(const_unsafe_cell_new)]` to the crate attributes to enable
error: aborting due to previous error
error: Could not compile `cortex-m`.
To learn more, run the command again with --verbose.
It was hard to find out that itmdump
is hosted on crates.io
and I have to install it with cargo install itm
. You should definitely point that out more explicitly :)
Wasn't sure where to ask this question! At the end of registers chapters, you are showing us how to print content of gpioe
register block. I noticed that your version of output for print *gpioe
nicely shows the struct
's fields in terms of Rust module's path:
(gdb) print *gpioe
$2 = f3::peripheral::gpio::Gpio {
moder: f3::peripheral::gpio::Moder {
register: volatile_register::RW<u32> {
register: 0x55550000
}
However mine, just shows the field names and their value:
(gdb) print *gpioe
$3 = {
moder = {
register = {
register = 1431633920
}
},
otyper = {
register = {
register = 0
}
},
I tried this both on OSX's gdb (7.10.1.20160923) and Debian's (7.11.1-2+9+b1) and did not get output similar to yours. Is there any setting or argument that needs to be passed to gdb to enable that?
Openocd is a AUR-Package so it can't be installed directly with pacman, but one needs to use ones favorite aur-manger or install it by "hand" with the aur package.
The sample we're meant to complete for uprintln!
has us implementing the Write
trait, but we don't have the std
crate available to bring std::fmt
into scope. Am I missing something here?
My first stab at this code was as follows:
for c in "The quick brown fox jumps over the lazy dog.".chars() {
usart1.tdr.write(|w| w.tdr(u16::from(c as u8)));
}
Using a String rather than a byte string apparently introduces enough overhead in the debug build that the sentence comes across the serial connection just fine:
`for` loop took 30798 ticks (3849.75 us)
At the top of the page you say "If you wrote your program like this", it just might be worth pointing out that other common ways might not produce this result.
(Thanks for this project overall, this has been fun to work through!)
130 /home/xyh/magismoke/discovery/src/05-led-roulette (master)
px cargo build --target thumbv7em-none-eabihf
[proxychains] config file found: /home/xyh/.proxychains/proxychains.conf
[proxychains] preloading /usr/lib/libproxychains4.so
Updating registry `https://github.com/rust-lang/crates.io-index`
Downloading cortex-m-rt v0.5.4
Downloading r0 v0.2.2
Downloading panic-abort v0.2.0
Downloading cortex-m v0.5.7
Downloading f3 v0.6.1
Downloading aligned v0.2.0
Downloading bare-metal v0.2.3
Downloading volatile-register v0.2.0
Downloading vcell v0.1.0
Downloading stm32f30x-hal v0.2.0
Downloading lsm303dlhc v0.2.0
Downloading l3gd20 v0.2.0
Downloading stm32f30x v0.7.1
Downloading embedded-hal v0.2.1
Downloading nb v0.1.1
Downloading cortex-m-rt v0.6.1
Downloading cortex-m-rt-macros v0.1.0
Downloading generic-array v0.11.1
Compiling proc-macro2 v0.4.18
Compiling unicode-xid v0.1.0
Compiling libc v0.2.43
Compiling rand_core v0.2.1
Compiling cortex-m-rt v0.6.1
Compiling cortex-m v0.5.7
Compiling typenum v1.10.0
Compiling vcell v0.1.0
Compiling stm32f30x v0.7.1
Compiling bare-metal v0.2.3
Compiling aligned v0.2.0
Compiling r0 v0.2.2
Compiling nb v0.1.1
Compiling void v1.0.2
Compiling f3 v0.6.1
Compiling cortex-m-rt v0.5.4
Compiling cast v0.2.2
Compiling panic-abort v0.2.0
Compiling rand v0.5.5
Compiling volatile-register v0.2.0
Compiling embedded-hal v0.2.1
Compiling quote v0.6.8
Compiling generic-array v0.11.1
Compiling syn v0.14.9
Compiling l3gd20 v0.2.0
Compiling lsm303dlhc v0.2.0
Compiling cortex-m-rt-macros v0.1.0
Compiling stm32f30x-hal v0.2.0
Compiling aux5 v0.1.0 (file:///home/xyh/magismoke/discovery/src/05-led-roulette/auxiliary)
Compiling led-roulette v0.1.0 (file:///home/xyh/magismoke/discovery/src/05-led-roulette)
error: linking with `rust-lld` failed: exit code: 1
|
= note: "rust-lld" "-flavor" "gnu" "-L" "/home/xyh/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/thumbv7em-none-eabihf/lib" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/led_roulette-7003b953f9707fdd.2gvdue3lexsze7ea.rcgu.o" "-o" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/led_roulette-7003b953f9707fdd" "--gc-sections" "-L" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps" "-L" "/home/xyh/magismoke/discovery/target/debug/deps" "-L" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/build/cortex-m-306f5924e0119627/out" "-L" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/build/cortex-m-rt-107e2318a0bdb4e4/out" "-L" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/build/f3-aee5918ef6c0db4e/out" "-L" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/build/stm32f30x-fc5c0604003c8138/out" "-L" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/build/cortex-m-rt-7a556696fd7220d1/out" "-L" "/home/xyh/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/thumbv7em-none-eabihf/lib" "-Bstatic" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libaux5-e6fd8fc7a8c5788e.rlib" "--start-group" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libpanic_abort-02324c692a31f947.rlib" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libf3-8b54b1d3345a8a66.rlib" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libstm32f30x_hal-c95c76d59f85822c.rlib" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libstm32f30x-92f986590f4ce34a.rlib" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libcortex_m_rt-657d932de92cf175.rlib" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/liblsm303dlhc-197262740cce284e.rlib" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libcast-76f018da73c28584.rlib" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libl3gd20-5e8b472c3e812d01.rlib" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libgeneric_array-2f978d6ba8eae7de.rlib" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libtypenum-70f6e206bc16c525.rlib" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libembedded_hal-fa4b1f418deed0cf.rlib" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libvoid-89a68ad6553fb210.rlib" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libnb-fd72e2ca23440bb9.rlib" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libcortex_m_rt-fe9359f76589f893.rlib" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libr0-91e7596db01c5ee4.rlib" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libcortex_m-a7bffe7c29cd199e.rlib" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libvolatile_register-86534ccb05932bfd.rlib" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libvcell-f00ec07c8e9caa2f.rlib" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libbare_metal-4c7ecdb5fa6ab06f.rlib" "/home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libaligned-60940c5763543bdb.rlib" "/home/xyh/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/thumbv7em-none-eabihf/lib/libcore-b276b64f149a1ab9.rlib" "--end-group" "/home/xyh/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/thumbv7em-none-eabihf/lib/libcompiler_builtins-43525f2d3bc6e46d.rlib" "-Tlink.x" "-Bdynamic"
= note: rust-lld: error: undefined symbol: WWDG
>>> referenced by stm32f30x.8wanakcq-cgu.10
>>> stm32f30x-92f986590f4ce34a.stm32f30x.8wanakcq-cgu.10.rcgu.o:(__INTERRUPTS) in archive /home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libstm32f30x-92f986590f4ce34a.rlib
rust-lld: error: undefined symbol: PVD
>>> referenced by stm32f30x.8wanakcq-cgu.10
>>> stm32f30x-92f986590f4ce34a.stm32f30x.8wanakcq-cgu.10.rcgu.o:(__INTERRUPTS) in archive /home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libstm32f30x-92f986590f4ce34a.rlib
rust-lld: error: undefined symbol: TAMP_STAMP
>>> referenced by stm32f30x.8wanakcq-cgu.10
>>> stm32f30x-92f986590f4ce34a.stm32f30x.8wanakcq-cgu.10.rcgu.o:(__INTERRUPTS) in archive /home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libstm32f30x-92f986590f4ce34a.rlib
rust-lld: error: undefined symbol: RTC_WKUP
>>> referenced by stm32f30x.8wanakcq-cgu.10
>>> stm32f30x-92f986590f4ce34a.stm32f30x.8wanakcq-cgu.10.rcgu.o:(__INTERRUPTS) in archive /home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libstm32f30x-92f986590f4ce34a.rlib
rust-lld: error: undefined symbol: FLASH
>>> referenced by stm32f30x.8wanakcq-cgu.10
>>> stm32f30x-92f986590f4ce34a.stm32f30x.8wanakcq-cgu.10.rcgu.o:(__INTERRUPTS) in archive /home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libstm32f30x-92f986590f4ce34a.rlib
rust-lld: error: undefined symbol: RCC
>>> referenced by stm32f30x.8wanakcq-cgu.10
>>> stm32f30x-92f986590f4ce34a.stm32f30x.8wanakcq-cgu.10.rcgu.o:(__INTERRUPTS) in archive /home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libstm32f30x-92f986590f4ce34a.rlib
rust-lld: error: undefined symbol: EXTI0
>>> referenced by stm32f30x.8wanakcq-cgu.10
>>> stm32f30x-92f986590f4ce34a.stm32f30x.8wanakcq-cgu.10.rcgu.o:(__INTERRUPTS) in archive /home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libstm32f30x-92f986590f4ce34a.rlib
rust-lld: error: undefined symbol: EXTI1
>>> referenced by stm32f30x.8wanakcq-cgu.10
>>> stm32f30x-92f986590f4ce34a.stm32f30x.8wanakcq-cgu.10.rcgu.o:(__INTERRUPTS) in archive /home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libstm32f30x-92f986590f4ce34a.rlib
rust-lld: error: undefined symbol: EXTI2_TSC
>>> referenced by stm32f30x.8wanakcq-cgu.10
>>> stm32f30x-92f986590f4ce34a.stm32f30x.8wanakcq-cgu.10.rcgu.o:(__INTERRUPTS) in archive /home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libstm32f30x-92f986590f4ce34a.rlib
rust-lld: error: undefined symbol: EXTI3
>>> referenced by stm32f30x.8wanakcq-cgu.10
>>> stm32f30x-92f986590f4ce34a.stm32f30x.8wanakcq-cgu.10.rcgu.o:(__INTERRUPTS) in archive /home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libstm32f30x-92f986590f4ce34a.rlib
rust-lld: error: undefined symbol: EXTI4
>>> referenced by stm32f30x.8wanakcq-cgu.10
>>> stm32f30x-92f986590f4ce34a.stm32f30x.8wanakcq-cgu.10.rcgu.o:(__INTERRUPTS) in archive /home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libstm32f30x-92f986590f4ce34a.rlib
rust-lld: error: undefined symbol: DMA1_CH1
>>> referenced by stm32f30x.8wanakcq-cgu.10
>>> stm32f30x-92f986590f4ce34a.stm32f30x.8wanakcq-cgu.10.rcgu.o:(__INTERRUPTS) in archive /home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libstm32f30x-92f986590f4ce34a.rlib
rust-lld: error: undefined symbol: DMA1_CH2
>>> referenced by stm32f30x.8wanakcq-cgu.10
>>> stm32f30x-92f986590f4ce34a.stm32f30x.8wanakcq-cgu.10.rcgu.o:(__INTERRUPTS) in archive /home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libstm32f30x-92f986590f4ce34a.rlib
rust-lld: error: undefined symbol: DMA1_CH3
>>> referenced by stm32f30x.8wanakcq-cgu.10
>>> stm32f30x-92f986590f4ce34a.stm32f30x.8wanakcq-cgu.10.rcgu.o:(__INTERRUPTS) in archive /home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libstm32f30x-92f986590f4ce34a.rlib
rust-lld: error: undefined symbol: DMA1_CH4
>>> referenced by stm32f30x.8wanakcq-cgu.10
>>> stm32f30x-92f986590f4ce34a.stm32f30x.8wanakcq-cgu.10.rcgu.o:(__INTERRUPTS) in archive /home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libstm32f30x-92f986590f4ce34a.rlib
rust-lld: error: undefined symbol: DMA1_CH5
>>> referenced by stm32f30x.8wanakcq-cgu.10
>>> stm32f30x-92f986590f4ce34a.stm32f30x.8wanakcq-cgu.10.rcgu.o:(__INTERRUPTS) in archive /home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libstm32f30x-92f986590f4ce34a.rlib
rust-lld: error: undefined symbol: DMA1_CH6
>>> referenced by stm32f30x.8wanakcq-cgu.10
>>> stm32f30x-92f986590f4ce34a.stm32f30x.8wanakcq-cgu.10.rcgu.o:(__INTERRUPTS) in archive /home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libstm32f30x-92f986590f4ce34a.rlib
rust-lld: error: undefined symbol: DMA1_CH7
>>> referenced by stm32f30x.8wanakcq-cgu.10
>>> stm32f30x-92f986590f4ce34a.stm32f30x.8wanakcq-cgu.10.rcgu.o:(__INTERRUPTS) in archive /home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libstm32f30x-92f986590f4ce34a.rlib
rust-lld: error: undefined symbol: ADC1_2
>>> referenced by stm32f30x.8wanakcq-cgu.10
>>> stm32f30x-92f986590f4ce34a.stm32f30x.8wanakcq-cgu.10.rcgu.o:(__INTERRUPTS) in archive /home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libstm32f30x-92f986590f4ce34a.rlib
rust-lld: error: undefined symbol: USB_HP_CAN_TX
>>> referenced by stm32f30x.8wanakcq-cgu.10
>>> stm32f30x-92f986590f4ce34a.stm32f30x.8wanakcq-cgu.10.rcgu.o:(__INTERRUPTS) in archive /home/xyh/magismoke/discovery/target/thumbv7em-none-eabihf/debug/deps/libstm32f30x-92f986590f4ce34a.rlib
rust-lld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
error: aborting due to previous error
error: Could not compile `led-roulette`.
To learn more, run the command again with --verbose.
101 /home/xyh/magismoke/discovery/src/05-led-roulette (master)
The borrow checker does not seem happy as is.
error[E0596]: cannot borrow immutable local variable `rx` as mutable
--> src/main.rs:30:21
|
27 | let Serial { tx, rx } = Serial::new().unwrap();
| -- consider changing this to `mut rx`
...
30 | let mut bytes = rx.bytes();
| ^^ cannot borrow mutably
error[E0596]: cannot borrow immutable local variable `tx` as mutable
--> src/main.rs:45:13
|
27 | let Serial { tx, rx } = Serial::new().unwrap();
| -- consider changing this to `mut tx`
...
45 | tx.write(byte).wait();
| ^^ cannot borrow mutably
error: aborting due to 2 previous errors
error: Could not compile `async`.
To learn more, run the command again with --verbose.
This example does not compile:
#![deny(unsafe_code)]
#![no_std]
extern crate aux5;
use aux5::prelude::*;
use aux5::{Delay, Leds};
fn main() {
let (mut delay, mut leds): (Delay, Leds) = aux5::init();
let half_period = 500_u16;
loop {
leds[0].on();
delay.delay_ms(half_period);
leds[0].off();
delay.delay_ms(half_period);
}
}
$ rustc -V
rustc 1.29.0-nightly (12ed235ad 2018-07-18)
$ cargo build --target thumbv7em-none-eabihf
Compiling cc v1.0.17
Compiling vcell v0.1.0
Compiling typenum v1.10.0
Compiling stm32f30x v0.7.0
Compiling bare-metal v0.2.0
Compiling r0 v0.2.2
Compiling aligned v0.2.0
Compiling void v1.0.2
Compiling nb v0.1.1
Compiling cast v0.2.2
Compiling f3 v0.6.1
Compiling panic-abort v0.2.0
Compiling volatile-register v0.2.0
Compiling embedded-hal v0.2.1
Compiling cortex-m-rt v0.5.1
Compiling cortex-m v0.5.2
Compiling generic-array v0.11.1
Compiling l3gd20 v0.2.0
Compiling lsm303dlhc v0.2.0
Compiling stm32f30x-hal v0.2.0
Compiling aux5 v0.1.0 (file:///Users/user/GitHub/discovery/src/05-led-roulette/auxiliary)
Compiling led-roulette v0.1.0 (file:///Users/user/GitHub/discovery/src/05-led-roulette)
error: requires `start` lang_item===================================> ] 31/32: led-roulette
error: aborting due to previous error
error: Could not compile `led-roulette`.
To learn more, run the command again with --verbose.
Host OS: macOS 10.13.6
A disclaimer on 06-hello-world says that "you'll have to solder the solder bridge SB10" to get to print anything with the printing macro for the itmdump.
It needs to be noted in the disclaimer that you don't have to solder anything at all. That you can just literally plug the last pin of the SWD (CN3? idk..) into PB3 with some extra wires.
The solder bridge SB10 is just a more permanent option, it's not "required".
Hi! Neither led roulette nor cortex-m-quickstart build for me with the following, with both nightly-2018-08-17
and nightly-2018-06-28
:
$ cargo build --target thumbv7em-none-eabihf
...
/usr/lib/gcc/arm-none-eabi/6.3.1/../../../arm-none-eabi/bin/ld:
BUG(cortex-m-rt): the reset vector is missing
/usr/lib/gcc/arm-none-eabi/6.3.1/../../../arm-none-eabi/bin/ld:
BUG(cortex-m-rt): the exception vectors are missing
$ rustc -V
rustc 1.30.0-nightly (1fa944914 2018-08-17)
$ cargo -V
cargo 1.29.0-nightly (6a7672ef5 2018-08-14)
$ git rev-parse HEAD
d1a1d8a30e177036a399ef12faf3691a72e37676
$ lsb_release -d
Description: Ubuntu 18.04.1 LTS
Hi Jorge, first of all thanks a lot for your great job on rust-embedded
๐ .
I am using the STM32F3348-DISCO board which is the replacement for the STM32F3DISCOVERY (no longer available in my country).
When I follow the instructions, everything builds, flashes and starts debugging correctly. The problem is that if I hit continue
(in gdb) after setting the breakpoint, it blocks indefinitely; and if I step
a few times, I arrive to this statement and it blocks:
โโโasm.sโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ1 .global HardFault โ
โ2 .thumb_func โ
โ3 HardFault: โ
โ4 mrs r0, MSP โ
>โ5 bl UserHardFault โ
โ6 โ
โ7 โ
โ8 โ
โ9 โ
โ10 โ
โ11 โ
โ12 โ
โ13 โ
โ14 โ
โ15 โ
โ16 โ
โ17 โ
โ18 โ
โ19 โ
โ20 โ
โ21 โ
โ22 โ
โ23 โ
โ24 โ
โ25 โ
โ26 โ
โ27 โ
โ28 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
remote Remote target In: HardFault L5 PC: 0x80003ee
Loading section .rodata, size 0x6c lma 0x80004a0
Start address 0x800023a, load size 1286
Transfer rate: 4 KB/sec, 428 bytes/write.
(gdb) l
(gdb) l
(gdb) step
Reset ()
at /Users/nico/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-m-rt-0.5.2/src/lib.rs:494
(gdb) step
(gdb) step
HardFault () at asm.s:4
(gdb) step
(gdb) step
Note: automatically using hardware breakpoints for read-only addresses.
Now, I am aware that this problem may come from the fact that the board is not exactly the same as you used; and more specifically, when compiling I see Compiling stm32f30x v0.7.0
and my board uses the STM32F334C8 MCU instead of an STM32F30x.
Is there something I can change or would you have any idea how to solve this?
Thanks a lot
I know this is explicitly not in the scope of the discovery book, but I would like some more details on the linker script generation that you use between f3, pg and the examples and how one can augment those with new interrupts/etc. Is there a place you documented that? copper seems out of date with this method
On PCB version C and newer of the STM32F3DISCOVERY board, the embedded ST-LINK has virtual COM port support. This means that a separate USB-UART module (such as the CH340G module mentioned in the book) is not necessary with recent boards. This is really nice because you don't need to buy the extra hardware, and you can use one less USB port.
While it may be a good idea to continue using a separate USB-UART module in the book to ensure maximum compatibility across different STM32F3DISCOVERY PCB versions, it's probably worth mentioning that this isn't necessary on recent boards that have the newer ST-LINK.
Some observations about the virtual COM port:
The "VCP configuration" section of the STM32F3DISCOVERY user manual says that the USART pins connected to the ST-LINK are PA9 and PA10, but that's incorrect. The correct pins are PC4 and PC5 (as shown in the electrical schematic, by inspecting the board itself, and with testing).
On my Linux machine, the serial port is connected as /dev/ttyACM0
.
I see a lot less noise in ADC measurements when I use the USART support in the ST-LINK than when I use a separate USB-UART module. This could be a result of my cheap USB-UART module, but it may also be true for higher-quality modules.
The solder bridges for connecting the USART pins to the ST-LINK are SB13 and SB15. They were already connected on my board, and the user manual says that they should be connected for PCB version C and newer, but it's probably worth suggesting that the user check that the bridges are connected. (In fact, this might be a good way to determine the PCB version you have, because these solder bridges were not connected on PCBs before version C.)
By the way, many thanks for writing the Discovery book! It's what got me started with embedded Rust development.
After moving this repo into the rust-embedded org we should host it under the rust-embedded.org domain as well.
cc @jamesmunns
From https://japaric.github.io/discovery/06-hello-world/README.html The following instructions appear to be wrong
# *nix
$ cd /tmp
# Windows
$ cd %TEMP%
$ itmdump itm.txt
Instead you must run itmdump itm.txt
in the directory you ran gdb in with your current instructions. I believe you can make them correct by changing the following:
(gdb) monitor tpiu config internal itm.txt uart off 8000000
To
(gdb) monitor tpiu config internal /tmp/itm.txt uart off 8000000
Once OpenOCD issue 200 is fixed, we can update the guide to simplify the launching of openocd
from two arguments to one argument.
Here:
openocd -f interface/stlink-v2-1.cfg -f target/stm32f3x.cfg
Can become:
openocd -f board/stm32f3discovery.cfg
But this can't be merged until OpenOCD fixes the issue linked above because the current stm32f3discovery.cfg
points to the older interface/stlink-v2-1.cfg
.
The discovery was a real find.
-- "Zen and the Art of Motorcycle Maintenance"
Following the book instruction from Debug it, I can setup the gdb to talk to openocd and load the program correctly, but I am unable to set a breakpoint:
Reading symbols from target/thumbv7em-none-eabihf/debug/led-roulette...done
(gdb) target remote :3333
Remote debugging using :3333
pg::init () at ~/discovery/05-led-roulette/pg/src/lib.rs:19
19 pub unsafe fn init() {
(gdb) load
Loading section .text, size 0xa00 lma 0x8000000
Start address 0x8000040, load size 2560
Transfer rate: 1 KB/sec, 2560 bytes/write.
(gdb) break main
Function "main" not defined.
Make breakpoint pending on future shared library load? (y or [n])
Of course continuing program causes an exception?!
Breakpoint 1 (main) pending.
(gdb) cont
Continuing.
Program received signal SIGTRAP, Trace/breakpoint trap.
pg::exception_handler () at ~/discovery/05-led-roulette/pg/src/lib.rs:27
27 bkpt!();
(gdb)
I am on OS X and use ARM's gcc toolchain:
GNU gdb (GNU Tools for ARM Embedded Processors 6-2017-q1-update) 7.12.1.20170215-git
First I'm a absolute beginner so I hope you understand these suggestions are to help other absolute beginners and probably seem obvious to a more advanced user and do not imply something is "broken".
First it It could be made clear the the first build of the src/05-led-roulette/main.rs does not actually make the actual roulette led spin as in the photo when compiled and uploaded. Its something you work up to by the end of the chapter. I flashed the src/05-led-roulette/main.rs and spent a lot of time trying to figure out what I did wrong because I didn't see the roulette leds spinning output. I looked at the source and had no idea how it could make it do that.
Second the warning "NOTE Be sure to compile this crate without optimizations" is 100% accurate but explaining that the provided Config.toml file does not enable optimizations so don't change it would have been helpful.
Next, I think this one may already be fixed in the next release by looking at the source to rust-embedded/discovery is I had to change (gdb) break led_roulette::main to (gdb) break main.
A confidence building option for something to add before the roulette chapter would be a super simple just build a supplied blink one led main.rs file and flash and run it using a script if possible. Next have them change one variable for a delay (i.e blink much faster) so you can tell you modified the program and everything still works. This would handle making sure openOCD and gdb worked with out any of the details to be filled in later.
Along with the long list of names that can't be used for files on windows, Aux breaks git clone
on Windows 10, and I assume all other versions of Windows.
It would be great if there was a topic/section walking through how to use CAN from the F3DISCOVERY board.
STM32CubeF3 has a CAN networking example written in C using their HAL layer for the STM32303E-EVAL board, which uses the same microcontroller as the F3DISCOVERY. Might be useful as a guide.
Projects/STM32303C_EVAL/Examples/CAN/CAN_Networking
All the code snippets must be using 2018 edition features and must compile on 1.30-beta by RC1.
gdb-multiarch -q target/thumbv7em-none-eabihf/debug/led-roulette works though.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.