@@ -19,41 +19,89 @@ download pre-compiled version of the standard library (a reduced version of it a
19
19
target. That's done using ` rustup ` :
20
20
21
21
``` console
22
- $ rustup target add thumbv7em-none-eabihf
22
+ rustup target add thumbv7em-none-eabihf
23
23
```
24
24
25
25
You only need to do the above step once; ` rustup ` will re-install a new standard library
26
26
(` rust-std ` component) whenever you update your toolchain.
27
27
28
- With the ` rust-std ` component in place you can now cross compile the program using Cargo:
28
+ With the ` rust-std ` component in place you can now cross compile the program using Cargo.
29
29
30
+ > Note: make sure you are in the ` src/05-led-roulette ` directory
31
+ > and run ` cargo build ` command below to create the executable:
32
+ ``` console
33
+ cargo build --target thumbv7em-none-eabihf
34
+ ```
35
+ On your console you should see something like:
30
36
``` console
31
- $ # make sure you are in the `src/05-led-roulette` directory
32
-
33
37
$ cargo build --target thumbv7em-none-eabihf
34
38
Compiling typenum v1.12.0
35
39
Compiling semver-parser v0.7.0
36
40
Compiling version_check v0.9.2
37
- Compiling cortex-m v0.6.4
41
+ Compiling nb v1.0.0
42
+ Compiling void v1.0.2
43
+ Compiling autocfg v1.0.1
44
+ Compiling cortex-m v0.7.1
45
+ Compiling proc-macro2 v1.0.24
46
+ Compiling vcell v0.1.3
47
+ Compiling unicode-xid v0.2.1
48
+ Compiling stable_deref_trait v1.2.0
49
+ Compiling syn v1.0.60
50
+ Compiling bitfield v0.13.2
51
+ Compiling cortex-m v0.6.7
38
52
Compiling cortex-m-rt v0.6.13
39
- Compiling stm32f3-discovery v0.5.0
40
- ...
53
+ Compiling r0 v0.2.2
54
+ Compiling stm32-usbd v0.5.1
55
+ Compiling stm32f3 v0.12.1
56
+ Compiling usb-device v0.2.7
57
+ Compiling cfg-if v1.0.0
58
+ Compiling paste v1.0.4
59
+ Compiling stm32f3-discovery v0.6.0
60
+ Compiling panic-halt v0.2.0
61
+ Compiling embedded-dma v0.1.2
62
+ Compiling volatile-register v0.2.0
63
+ Compiling nb v0.1.3
64
+ Compiling embedded-hal v0.2.4
65
+ Compiling semver v0.9.0
66
+ Compiling generic-array v0.14.4
67
+ Compiling switch-hal v0.3.2
68
+ Compiling num-traits v0.2.14
69
+ Compiling num-integer v0.1.44
70
+ Compiling rustc_version v0.2.3
71
+ Compiling bare-metal v0.2.5
72
+ Compiling cast v0.2.3
73
+ Compiling quote v1.0.9
74
+ Compiling generic-array v0.13.2
75
+ Compiling generic-array v0.12.3
76
+ Compiling generic-array v0.11.1
41
77
Compiling panic-itm v0.4.2
78
+ Compiling lsm303dlhc v0.2.0
79
+ Compiling as-slice v0.1.4
80
+ Compiling micromath v1.1.0
81
+ Compiling accelerometer v0.12.0
82
+ Compiling chrono v0.4.19
83
+ Compiling aligned v0.3.4
84
+ Compiling rtcc v0.2.0
42
85
Compiling cortex-m-rt-macros v0.1.8
43
- Compiling stm32f3xx-hal v0.5.0
44
- Compiling aux5 v0.2.0 (file://$PWD /auxiliary)
45
- Compiling led-roulette v0.2.0 (file://$PWD/ )
46
- Finished dev [unoptimized + debuginfo] target(s) in 19.45s
86
+ Compiling stm32f3xx-hal v0.6.1
87
+ Compiling aux5 v0.2.0 (~/embedded-discovery/src/05-led-roulette /auxiliary)
88
+ Compiling led-roulette v0.2.0 (~/embedded-discovery/src/05-led-roulette )
89
+ Finished dev [unoptimized + debuginfo] target(s) in 17.91s
47
90
```
48
91
49
92
> ** NOTE** Be sure to compile this crate * without* optimizations. The provided Cargo.toml file and build command above will ensure optimizations are off.
50
93
51
94
OK, now we have produced an executable. This executable won't blink any leds, it's just a simplified version that we will build upon later in the chapter. As a sanity check, let's verify that the produced executable is actually an ARM binary:
52
95
53
96
``` console
54
- $ # equivalent to `readelf -h target/thumbv7em-none-eabihf/debug/led-roulette`
55
- $ cargo readobj --target thumbv7em-none-eabihf --bin led-roulette -- -file-headers
56
- Finished dev [unoptimized + debuginfo] target(s) in 0.03s
97
+ cargo readobj --target thumbv7em-none-eabihf --bin led-roulette -- --file-header
98
+ ```
99
+ The ` cargo readobj .. ` above is equivalent to
100
+ ` readelf -h target/thumbv7em-none-eabihf/debug/led-roulette `
101
+ and should produce something similar to:
102
+ ``` console
103
+ $ cargo readobj --target thumbv7em-none-eabihf --bin led-roulette -- --file-header
104
+ Finished dev [unoptimized + debuginfo] target(s) in 0.02s
57
105
ELF Header:
58
106
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
59
107
Class: ELF32
@@ -66,7 +114,7 @@ ELF Header:
66
114
Version: 0x1
67
115
Entry point address: 0x8000195
68
116
Start of program headers: 52 (bytes into file)
69
- Start of section headers: 797192 (bytes into file)
117
+ Start of section headers: 818328 (bytes into file)
70
118
Flags: 0x5000400
71
119
Size of this header: 52 (bytes)
72
120
Size of program headers: 32 (bytes)
0 commit comments