2019-08-08 09:12:17 +00:00
# Build instructions for Embedded (ARM port)
2020-09-25 14:21:23 +00:00
First clone, initialize submodules and install Poetry as defined [here ](index.md ).
**Do not forget you need to be in a `poetry shell` environment!**
2019-08-08 09:12:17 +00:00
## Requirements
You will need the GCC ARM toolchain for building and OpenOCD for flashing to a device.
You will also need Python dependencies for signing.
### Debian/Ubuntu
```sh
2021-05-20 09:58:09 +00:00
sudo apt-get install scons gcc-arm-none-eabi libnewlib-arm-none-eabi llvm-dev libclang-dev clang
2019-08-08 09:12:17 +00:00
```
2020-02-10 12:05:41 +00:00
### NixOS
There is a `shell.nix` file in the root of the project. Just run the following
**before** entering the `core` directory:
```sh
nix-shell
```
2019-08-08 09:12:17 +00:00
### OS X
2020-07-20 08:48:22 +00:00
_Consider using [Nix ](https://nixos.org/download.html ). With Nix all you need to do is `nix-shell` ._
For other users:
2019-08-08 09:12:17 +00:00
1. Download [gcc-arm-none-eabi ](https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads )
2. Follow the [install instructions ](https://launchpadlibrarian.net/287100883/readme.txt )
3. To install OpenOCD, run `brew install open-ocd`
2020-02-10 12:05:41 +00:00
4. Run `make vendor build_boardloader build_bootloader build_firmware`
2019-08-08 09:12:17 +00:00
2023-08-15 19:51:16 +00:00
## Protobuf Compiler
The protocol buffer compiler `protoc` is needed to (unsurprisingly) compile protocol buffer files. [Follow the installation instructions for your system ](https://grpc.io/docs/protoc-installation/ ).
2021-05-20 09:58:09 +00:00
## Rust
Install the appropriate target with [`rustup` ](https://rustup.rs/ ):
```sh
rustup target add thumbv7em-none-eabihf # for TT
rustup target add thumbv7m-none-eabi # for T1
```
2019-08-08 09:12:17 +00:00
## Building
```sh
2020-02-10 12:05:41 +00:00
make vendor build_boardloader build_bootloader build_firmware
2019-08-08 09:12:17 +00:00
```
## Uploading
2024-02-05 10:17:00 +00:00
Use `make upload` to upload the firmware to a production device.
* For TT: Do not forget to [enter bootloader ](https://www.youtube.com/watch?v=3hes1H4qRbw ) on the device beforehand.
2024-04-08 11:30:47 +00:00
* For TS3: You will have to [unlock bootloader ](https://trezor.io/learn/a/unlocking-the-bootloader-on-trezor-safe-3 ) first. Make sure to read the link in completeness for potentially unwanted effects.
2019-08-08 09:12:17 +00:00
## Flashing
2018-07-04 19:21:01 +00:00
For flashing firmware to blank device (without bootloader) use `make flash` .
2019-08-08 09:12:17 +00:00
You need to have OpenOCD installed.
## Building in debug mode
2019-10-15 09:26:23 +00:00
You can also build firmware in debug mode to see log output or run tests.
2019-08-08 09:12:17 +00:00
```sh
2020-02-10 12:05:41 +00:00
PYOPT=0 make build_firmware
2019-08-08 09:12:17 +00:00
```
2021-03-06 23:37:54 +00:00
To get a full debug build, use:
```sh
make build_firmware BITCOIN_ONLY=0 PYOPT=0
```
2022-05-24 08:52:11 +00:00
Use `screen` to enter the device's console. Do not forget to add your user to the `dialout` group or use `sudo` . Note that both the group and the tty name can differ, use `ls -l /dev/tty*` or `ls /dev/tty* | grep usb` to find out proper names on your machine.
2019-08-08 09:12:17 +00:00
```sh
screen /dev/ttyACM0
```