1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-26 17:38:39 +00:00
trezor-firmware/docs/core/build/emulator.md
obrusvit a47ae5da1a docs: minor fix of build emu
[no changelog]
2024-04-16 10:31:09 +02:00

2.5 KiB

Build instructions for Emulator (Unix port)

💡 Hint: Using emulator as described here is useful during firmware development. If you intend to use the emulator without modifying the firmware, you might be looking for Trezor User Env.

First clone, initialize submodules, install Poetry and enter the Poetry shell as defined here. Do not forget you need to be in a poetry shell environment!

Dependencies

Install the required packages, depending on your operating system.

  • Debian/Ubuntu:
sudo apt-get install scons libsdl2-dev libsdl2-image-dev llvm-dev libclang-dev clang
  • Fedora:
sudo yum install scons SDL2-devel SDL2_image-devel clang-devel
  • OpenSUSE:
sudo zypper install scons libSDL2-devel libSDL2_image-devel
  • Arch:
sudo pacman -S scons sdl2 sdl2_image clang-devel
  • NixOS:

There is a shell.nix file in the root of the project. Just run the following before entering the core directory:

nix-shell
  • Mac OS X:

Consider using Nix. With Nix all you need to do is nix-shell.

For other users:

brew install scons sdl2 sdl2_image pkg-config llvm
  • Windows: not supported yet, sorry.

Protobuf Compiler

The protocol buffer compiler protoc is needed to (unsurprisingly) compile protocol buffer files. Follow the installation instructions for your system.

Rust

You will require Rust and Cargo. The currently supported version is 1.64 nightly. The recommended way to install both is with rustup. Make sure you are up to date:

rustup default nightly
rustup update

The bindgen crate requires libclang for generating MicroPython FFI.

Build

Run the build with:

make build_unix                     # default
make build_unix TREZOR_MODEL=R      # different model

Run

Now you can start the emulator:

./emu.py

The emulator has a number of interesting features all documented in the Emulator section.

Building for debugging and hacking in Emulator (Unix port)

Build the debuggable unix binary so you can attach the gdb or lldb. This removes optimizations and reduces address space randomization. Beware that this will significantly bloat the final binary and the firmware runtime memory limit HEAPSIZE may have to be increased.

make build_unix_debug