Skip to content

Commit fc15fa9

Browse files
authored
Merge pull request #1951 from mintlayer/trezor_firmware_versioning_followup
Update TREZOR_SUPPORT.md
2 parents 145f79e + 01be78a commit fc15fa9

1 file changed

Lines changed: 101 additions & 37 deletions

File tree

wallet/TREZOR_SUPPORT.md

Lines changed: 101 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ From the Trezor perspective, there are two types of firmware: a) the official on
1313
Since Mintlayer is not officially supported by Trezor, the firmware we provide falls into the latter category. This has certain implications:
1414
- When installing the firmware, the device will show the warning "UNSAFE, DO NOT USE!".
1515
- When installing custom firmware over the official one, **the device will be wiped clean**. Make sure you have a backup of your seed phrase.
16-
- When installing custom firmware over different custom firmware, the device will **not** be wiped clean. This makes it succeptible to the so-called "evil maid attack",
16+
- When installing custom firmware over different custom firmware, the device will **not** be wiped clean. This makes it susceptible to the so-called "evil maid attack",
1717
where the attacker has physical access to your device. It goes like this:
1818
* The "maid" temporarily steals your device and installs on it firmware that she has built herself; it looks identical to the previously installed firmware, but also logs the PIN and the passphrase entered by the user. Then she puts the device back.
1919
* You use the device.
@@ -24,19 +24,17 @@ where the attacker has physical access to your device. It goes like this:
2424
* keep your device in a safe place;
2525
* preferably, use a dedicated device with a dedicated seed phrase and PIN specifically for Mintlayer;
2626
- In order to install custom firmware on a Trezor Safe family device (e.g. Safe 3 or Safe 5), you have to [unlock the bootloader first](https://trezor.io/learn/security-privacy/how-trezor-keeps-you-safe/unlocking-the-bootloader-on-trezor-safe-devices);
27-
this is an irreversible operation after which the device authenticity check will no longer work. This means that every time you use Trezor Suite, you will be presented with a warning "Your device may have been compromised" (unless you disable
28-
the authenticity check in the Trezor Suite's device settings).
27+
this is an irreversible operation after which the device authenticity check will no longer work.
28+
This means that every time you use Trezor Suite, you will be presented with a warning "Your device may have been compromised"
29+
(unless you disable the authenticity check in the Trezor Suite's device settings).
2930

30-
### Building and flashing the firmware
31-
32-
#### A note about versioning
31+
### A note about versioning
3332

3433
Firmware built from the Mintlayer fork has two version numbers:
3534
- A version number assigned by Trezor; this is the original release that we've based our release upon
3635
and this is what is shown to you on the device screen when you flash the firmware.
37-
- An additional version number assigned by us, to which we refer as "Mintlayer firmware version".
38-
It is obtainable via `trezorctl mintlayer get-firmware-info` and it's what
39-
our wallets display in their UI.
36+
- An additional version number assigned by us, to which we refer as "Mintlayer firmware version";
37+
this is what our wallets display in their UI.
4038

4139
The table of correspondence between the two versions can be found in the [firmware repository](https://github.com/mintlayer/mintlayer-trezor-firmware/blob/mintlayer-master/README.md).
4240

@@ -50,28 +48,47 @@ Note: if you've built Core wallets directly from `master` instead of using a spe
5048
you'll probably won't be able to use a specific release for the firmware either.
5149
Instead, you'll have to build it from `mintlayer-master`.
5250

53-
#### How to build
51+
### Flashing pre-built firmware
52+
53+
If you are interested in a particular release, you may just go to [the firmware releases page](https://github.com/mintlayer/mintlayer-trezor-firmware/releases),
54+
download the `.bin` file corresponding to your device model and install it via Trezor Suite:
55+
- Inside Trezor Suite go to "Settings" -> "Device" -> "Danger area" -> "Install custom firmware" and click "Install".
56+
- Follow the instructions that will appear on your screen.
57+
58+
Note:
59+
- Trezor Safe 3 comes in two revisions, A and B, that look identical but require different firmware.\
60+
Determining the revision of your particular device is non-trivial, unfortunately:
61+
* If you have `trezorctl` installed, which is the Trezor command line tool, you may run `trezorctl get-features`[^1]
62+
(after having connected the device to the PC and having entered the PIN) and then look for the `internal_model` value
63+
in the output - 'T2B1' will mean you have revision A and 'T3B1' revision B.
64+
* In any case, the device won't allow you to install wrong firmware, so you may try the one for revision A
65+
and if that fails, try the one for revision B instead.
66+
- Trezor Model One is not supported.
67+
68+
### Building the firmware from source
69+
70+
There are two options here:
71+
- A more verbose approach using `Nix`, useful during development.
72+
- A simpler approach using `Docker`; this results in reproducible builds and is used on our CI when creating releases.
73+
74+
In either case, you'll first need to clone the repository and checkout the required revision:
75+
- If you want the latest version that is in development, checkout the `mintlayer-master` branch.
76+
- If you want a particular release, checkout the tag corresponding to that release. The list of tags
77+
can be found [here](https://github.com/mintlayer/mintlayer-trezor-firmware/tags).
78+
79+
In the examples below we'll be assuming that you want the release 1.0.0, whose tag is `mintlayer-v1.0.0`.
80+
81+
#### Building the firmware using `Nix`
5482

5583
##### Get the source code
5684

57-
Clone the repository and `cd` into it:
85+
Clone the repository, `cd` into the directory and checkout the required revision:
5886
```sh
5987
git clone --recurse-submodules https://github.com/mintlayer/mintlayer-trezor-firmware
6088
cd mintlayer-trezor-firmware
89+
git checkout --recurse-submodules mintlayer-v1.0.0
6190
```
6291

63-
Then checkout the required revision:
64-
- If you want the latest version that is in development, checkout the `mintlayer-master` branch:
65-
```sh
66-
git checkout --recurse-submodules mintlayer-master
67-
```
68-
- If you want a particular release, checkout the tag corresponding to that release. The list of tags
69-
can be found [here](https://github.com/mintlayer/mintlayer-trezor-firmware/tags).
70-
Assuming that you've chosen `mintlayer-v1.0.0`, run:
71-
```sh
72-
git checkout --recurse-submodules mintlayer-v1.0.0
73-
```
74-
7592
##### Install `Nix`
7693

7794
On a Debian-based system you can do this via `sudo apt install nix-bin`.
@@ -81,7 +98,7 @@ Check that `Nix` works by running `nix-shell -p hello --run hello`
8198
If you're getting the error `getting status of /nix/var/nix/daemon-socket/socket: Permission denied`
8299
on your Linux machine, you may need to add the current user to the `nix-users` group:
83100
```sh
84-
sudo usermod -aG nix-users your_username
101+
sudo usermod -aG nix-users $USER
85102
```
86103
You'll also need to re-login after that.
87104

@@ -117,29 +134,76 @@ The possible values are:
117134
| T3B1 | Safe 3 revision B |
118135
| T3T1 | Safe 5 |
119136

120-
Note:
121-
- Trezor Safe 3 revision A and B look identical. To determine the revision of your particular device,
122-
first connect the device (which means, both connect it physically and enter the PIN) and then run:
123-
```sh
124-
nix-shell --run "poetry run trezorctl get-features"
125-
```
126-
Look for the `internal_model` value in the output.
127-
- Trezor Model One is not supported.
137+
So in the example above we're building it for Safe 5.
128138

129139
##### Flash the firmware
130140

141+
The file `core/build/firmware/firmware.bin` in the source directory will be the firmware that you've just built,
142+
so you can go ahead and install it via Trezor Suite.
143+
144+
However you can also do it via the command line:
145+
131146
First you need to put your device into bootloader mode. To do so
132147
- On Safe 3, hold the left button when connecting the USB cable.
133148
- On Model T and Safe 5, swipe across the screen when connecting the USB cable.
134149

135150
After that the device will present you with an option to install firmware, select that option.
136151

137-
Now you can flash the firmware by running:
152+
Now you can flash the firmware by running[^2]:
138153
```sh
139154
nix-shell --run "poetry run make -C core upload"
140155
```
141156

142-
Note: instead of executing `nix-shell --run "poetry run the_command"` every time, you can enter
143-
the nix-shell by running `nix-shell`
144-
and then inside the nix-shell enter poetry shell by running `poetry shell`.
145-
After this, you can run the commands directly, e.g. `trezorctl get-features`.
157+
Note: after having installed the firmware you may use Mintlayer-specific commands of `trezorctl`. Run
158+
```sh
159+
nix-shell --run "poetry run trezorctl mintlayer --help"
160+
```
161+
to see what commands are available.
162+
163+
#### Building the firmware using `Docker`
164+
165+
##### Make sure `Docker` is installed and set up correctly
166+
167+
##### Get the source code
168+
169+
Clone the repository, `cd` into the directory and checkout the required revision:
170+
```sh
171+
git clone https://github.com/mintlayer/mintlayer-trezor-firmware
172+
cd mintlayer-trezor-firmware
173+
git checkout mintlayer-v1.0.0
174+
```
175+
176+
Note that the `--recurse-submodules` parameter is not needed in this case. This is because the build script will
177+
do the cloning again, so this initial clone is mainly to get the correct build script.
178+
179+
##### Build the firmware
180+
181+
Run:
182+
```sh
183+
PRODUCTION=0 ./build-docker.sh --models T3T1 --skip-bitcoinonly --targets firmware mintlayer-v1.0.0
184+
```
185+
186+
Note:
187+
- The value of the `--models` parameter is a comma-separated list of target device models.
188+
The possible values are the same as for the `TREZOR_MODEL` variable used in the previous section.
189+
E.g. here we will be building the firmware for Safe 5.
190+
- The last argument is the repository revision from which the firmware will be built. Make sure you
191+
specify the same revision that you've used during the initial checkout. Also note that it has to
192+
be either a branch name or a tag, but not an arbitrary commit hash.
193+
- `PRODUCTION=0` is needed to produce the "UNSAFE, DO NOT USE!" firmware with the "DEVEL" signature
194+
(as opposed to the "Trezor" firmware without a signature, which would be unusable).
195+
196+
The resulting binary will be `build/core-MODEL/firmware/firmware.bin`, where MODEL is the model identifier
197+
that you've specified via the `--models` parameter
198+
(i.e. in this particular example the path will be `build/core-T3T1/firmware/firmware.bin`).\
199+
Install it via Trezor Suite.
200+
201+
[^1]: If you instead decide to build the firmware from source using the `Nix` approach,
202+
you'll be able to run `trezorctl` directly from the source directory like this:
203+
`nix-shell --run "poetry run trezorctl get-features"`.\
204+
I.e. you won't have to install it separately in this case.
205+
206+
[^2]: instead of executing `nix-shell --run "poetry run YOUR_COMMAND"` every time,
207+
you can enter the nix-shell by running `nix-shell`
208+
and then inside the nix-shell enter poetry shell by running `poetry shell`.\
209+
After this, you can run `YOUR_COMMAND` directly, e.g. `make -C core upload` or `trezorctl get-features`.

0 commit comments

Comments
 (0)