How do you program the boardloader for a DIY Trezor?

As stated here Boardloader - Trezor Wiki the Trezor model T Boardloader is stored in non firmware/software modifyable memory. How do you go about burning this boardloader for a DIY Trezor?

I am assuming it can be programmed via an ftdi programmer via these pads. Are their instructions for doing this anywhere?
image

In short: boardloader occupies first sector of flash, it’s not on any special memory range. Any SWD adapter can be used to program it, STLink, JLink, FTDI as long as the FTDI chip supports SWD and not just JTAG (older did support only JTAG). You need to connect SWDIO, SWCLK, GND.

One set of instructions - TREZOR Model T Dev Kit

In core/Makefile there is make flash_boardloader option you can derive from, but you need to change the OPENOCD_INTERFACE to something else than STLink if you don’t use STLink.

You can also use GDB with openocd, open boardloader.elf and flash it. E.g.

In one terminal: (this is for STLink, so adapt parameters for FTDI)

openocd -f interface/stlink.cfg -f target/stm32f4x.cfg

That will open SWD connection to chip.

In another terminal run GDB (must be compiled with ARM or multiarch support) with the boardloader executable to flash:

gdb-multiarch core/build/boardloader/boardloader.elf

In GDB (assuming openocd runs at default port localhost:3333) :

target extended remote :3333
load
monitor reset init
continue

You should be able to run boardloader now.

2 Likes

I have assembled my Trezor T, but I don’t understand how to properly flash it. There is no boardloader.bin on github. Only bootloader and firmware. What is the correct way to flash.
After flashing bootloader 2.0.1-2.1.0 the device does not turn on via USB.
Please tell me how to do it correctly. From under Windows

you’ll need to build your own boardloader image. make build_boardloader in the core/ subdirectory will do it.

note that you’ll need to be careful to set PRODUCTION=0, otherwise the boardloader will lock your device the same way an actual production Trezor is locked

Tell me a little more about it, please. The sequence of actions should be as follows:

  1. Build boardloader.bin (set PRODUCTION=0)
  2. Flash boardloader.bin
  3. Flash bootloader.bin without erasing the chip?
    Unfortunately I got a brick by flashing boardloader.bin with PRODUCTION=1
    Is there any possibility to flash boardloader+bootloader with PRODUCTION=1 to make the device working?

You should flash the bootloader to the sectors after the boardloader. Unfortunately I won’t be able to help you there because I never did that.

If you flashed but didn’t run the device yet, you should be able to just erase it and flash a PRODUCTION=0 version.

If you already ran it, you could go the “actual Trezor” route, dump contents of https://github.com/trezor/data/raw/master/bootloader/t2t1/bootloader-t2t1-2.1.0.bin raw on a SD card and insert it into the SD slot. The boardloader will look at the card and if it finds a valid bootloader, it should install it. That’s assuming that the boardloader actually runs. On the positive side, if it’s so broken that it didn’t run, it also didn’t lock your chip so you can still start over…

I replaced the chip on my Trezor T. I built boardloader.bin (PRODUCTION=0), flashed it to address 0x08000000. Then checked “Skip flash erase before prigramming” and flashed …/t2t1/bootloader-t2t1-2.1.0.bin to address 0x08020000. But the device does not turn on, is not detected via usb, the screen is not lit. What am I doing wrong? Can someone ask me to make a normal firmware file boardloader+bootloader+firmware.bin?