embedded-trainings-2020/embedded-workshop-book/src/building-program.md

23 lines
822 B
Markdown
Raw Normal View History

2020-07-08 13:06:49 +00:00
# Building an Embedded Program
The following command cross compiles the program to the ARM Cortex-M4 architecture.
2020-07-08 13:06:49 +00:00
``` console
$ cargo build --bin hello
```
2020-07-10 16:38:53 +00:00
The default in a Cargo project is to compile for the host (native compilation) but the `beginner/apps` project has been configured for cross compilation. This configuration can be seen in the Cargo configuration file (`.cargo/config`):
2020-07-08 13:06:49 +00:00
``` text
# .cargo/config
[build]
target = "thumbv7em-none-eabi" # = ARM Cortex-M4
2020-07-08 13:06:49 +00:00
```
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-eabi` directory.
2020-07-08 13:06:49 +00:00
``` console
$ file target/thumbv7em-none-eabi/debug/hello
hello: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped
2020-07-08 13:06:49 +00:00
```