Try Trezor-T Firmware on your laptop via the Trezor Emulator

This is VERY technical, and completely UNSUPPORTED. Please don't write support tickets. Just reply to this thread.

Most might not know that Trezor maintains a Trezor-T emulator that runs on Windows, Linux or macOS. This is VERY useful if you perform firmware builds and want to test them before loading onto hardware. To use it, you have to build it from source, but if you are patient, and comfortable with compiling code, it isn't that hard.

Warning

This is a technical toy to try out features. DO NOT hold assets in the emulator. DO NOT put seed mnemonics in the emulator. DO NOT put passphrases in the emlator. It is also, AFAIK, totally unsupported. Don't log issues or complain if it's broke. Just nag on this thread if you need to vent. Learn about Testnet coins if you want to practice transactions. DO NOT put real coins on here

  • Bitcoin Testnet
  • Ethereum Testnet

If you do have questions or run into problems post on this thread, or, if you find reddit too adversarial, you can post on the GitHub discussion board tied to my posts. Please don't DM me.

Windows

I'll start from Windows, since that is what I'm working in currently. This process is only marginally “Windows”. It's actually something called WSL which is effectively Linux-on-Windows. Similar, perhaps to Andorid-on-ChromeOS, or similar type projects. WSL may “technically” be a container, but it integrates into Windows pretty seemlessly. Most might not even know.

Install WSL on Windows

Luckilly Microsoft has documented the hell out of this, so the HowTo is insanely detailed. You have to be running a fully patched version of Windows 10 or Windows 11. I'm running this on Windows 10 22H2, which most should be able to get. You will also need the “correct” processor. Since this does use some of the virutualization instruction set you need an Intel or AMD processor that supports it. Most do, but some VERY lean netbooks might not. Settle in, the HowTo could burn an entire afternoon of cross-linked articles and proceedures.

  • Install WSL on Windows

The default is to land Ubuntu 22.04, which is what I'm running. If you just want to run the emulator, that is about all you have to do. But if you want to run physical Trezor hardware under WSL you will need to toy around with usbipd. Since I wanted to play with physical hardware as a FIDO2 SSH keystore, I also needed HIDRAW support which entailed a kernel compilation. NOT required, but I'll leave it here if anyone is interested.

  • (Optional) Physical USB access (usbipd) under WSL
  • (Optional) Enabling HIDRAW for FIDO2 under WSL

Linux / macOS

The offical documentation in the next section go into pretty good detail for how to spin up the Linux or macOS build environments. For WSL users, just follow the Ubuntu procedures from here on out. So what follows should match what both Ubuntu and WSL users experience. For macOS, it's likely pretty close, just with installations via brew instead of apt

Prepare the Build Environment

Honestly, if you landed WSL, then from here on out, you just pretend you are running Ubuntu 22.04. You drop into the WSL shell using the wsl command, but from there on out it's just normal Ubuntu. Here are the docs I referenced:

  • Github : Trezor-Firmware : Build : Index.md
  • Github : Trezor-Firmware : Build : Emulator.md

First we will need to install all the apt packages. My “all” may be overkill, but fresh installs are always missing a bunch of this.

sudo apt update
sudo apt-get install scons libsdl2-dev libsdl2-image-dev llvm-dev libclang-dev 
     clang build-essential trezor python3-pip python3-trezor python3-munch 
     python3-venv librust-bindgen-dev protobuf-compiler python3-munch

Next we need to install poetry

python3 -m pip install --upgrade pip setuptools wheel
python3 -m pip install poetry

Now we need to install rust

curl https://sh.rustup.rs -sSf | sh
source ~/.cargo/env
rustup default nightly
rustup update

Build the Trezor-T Emulator

Checkout a fresh copy of source. You can reuse the source, but it's MUCH easier with fresh source

mkdir -p ~/src/trezor-model-t/trezor-firmware
cd ~/src/trezor-model-t/trezor-firmware
git clone -b core/v2.6.0 --recurse-submodules https://github.com/trezor/trezor-firmware.git .
git checkout -b local/core/v2.6.0

Launch a poetry shell to build the project from

poetry install
poetry shell

Run the build

cd core
make clean build_unix

Launch the emulator

./emu.py

You will get a freshly wiped Trezor-T window. Just click on the window where the touchscreen is displayed and it will by just like touch. You can play with the trezor.flash and trezor.sdcard files if you want, but I won't get into that here.

BONUS: Build Trezor-R Emulator

mkdir -p ~/src/trezor-model-r/trezor-firmware
cd ~/src/trezor-model-r/trezor-firmware
git clone -b python/v0.13.7 --recurse-submodules https://github.com/trezor/trezor-firmware.git .
git checkout -b local/python/v0.13.7

Launch a poetry shell to build the project from

poetry install
poetry shell

Run the build

cd core
TREZOR_MODEL=R make clean build_unix

Launch the emulator

./emu.py

To operate the buttons on the Trezor-R emulator, you have to use the keyboard arrow keys. Left for the left button and Right for the right button.

Interacting with the Emulator

Most interfaces that connect to Trezor hardware can be convinced to connect to the emulator, but it might take some convincing. I found that TrezorCTL worked out of the box, and I saw that there were settings to allow trezor-bridge and trezor-suite to connect to it as well.

At your own risk

Please take heed and don't put your stash into a toy emulator. There are NO protections and the seed will be clearly visible in the filesystem when running the emulator. And NO, running it on Tails is no better. Hopefully this is plainly obvious to the most casual observer.

1 thought on “Try Trezor-T Firmware on your laptop via the Trezor Emulator”

  1. For some, this might be easier to run. https://github.com/trezor/trezor-user-env/

Comments are closed.