mirror of
https://github.com/ferrous-systems/embedded-trainings-2020.git
synced 2024-06-26 17:10:39 +00:00
3cd3211368
This change updates the information on "Building an Embedded Program". There is a mismatch between the described target `thumbv7em-none-eabi` compared to the set target in file `beginner/apps/.cargo/config` that contains target entry `thumbv7em-none-eabihf`.
25 lines
1,022 B
Markdown
25 lines
1,022 B
Markdown
# Building an Embedded Program
|
|
|
|
The default in a Cargo project is to compile for the host (native compilation). The `beginner/apps` project has been configured for cross compilation to the ARM Cortex-M4 architecture. This configuration can be seen in the Cargo configuration file (`.cargo/config`):
|
|
|
|
``` text
|
|
# .cargo/config
|
|
[build]
|
|
target = "thumbv7em-none-eabihf" # = ARM Cortex-M4
|
|
```
|
|
|
|
✅ Inside the folder `beginner/apps`, use the following command to cross compile the program to the ARM Cortex-M4 architecture.
|
|
|
|
``` console
|
|
$ cargo build --bin hello
|
|
```
|
|
|
|
The output of the compilation process will be an ELF (Executable and Linkable Format) file. The file will be placed in the `target/thumbv7em-none-eabihf` directory.
|
|
|
|
✅ Run `$ file target/thumbv7em-none-eabihf/debug/hello` and compare if your output is as expected.
|
|
|
|
Expected output:
|
|
``` console
|
|
$ file target/thumbv7em-none-eabihf/debug/hello
|
|
hello: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped
|
|
``` |