Introduction: Making My Own Trezor Crypto Hardware Wallet
In this project I am making my own Trezor cryptocurrency hardware wallet, complete with enclosure. This is possible because Trezor is open source so I used the files they provide on their github to build my own device for under $40. There were a few obstacles in the process so I hope this tutorial will help you if you decide to build one yourself.
Step 1: Watch the Build Video!
The video describes the entire build so I recommend watching the video first to get an overview of the project, the problems I encountered and how I solved them. Then you can come back and read the following steps for more detailed explanation.
Step 2: Order the Required Parts
Go to the Trezor github and download their hardware repository. Inside the electronics folder you will find the gerber files needed for ordering the PCBs. Send those files to your choice of prototyping pcb service and order a set with a thickness of 1.0mm and pretty much the standard setup for the rest of the parameters. You can also order a stencil to help you with the assembly, I didn't get one I just did the assembly by hand applying solder paste.
Inside the electronics folder you will also find a file called trezor.bom.txt. Order the parts listed there from your favorite electronics distributor. The 0.96 OLED screen can be ordered from aliexpress, banggood or ebay.
Inside the case folder you will find STL files to 3d print the enclosure yourself. You will need to play with the parameters on your slicing software to get the best results. In my case, I used Cura and my Creality CR10 3D Printer for printing but the enclosure top face turned out pretty thin so I need to optimize that and re-print the design.
Step 3: Assembling Trezor Boards
I didn't capture any images or video of the actual assembly of the boards because the components are very small and it would have been difficult to record it and do the assembly at the same time. If you've never assembled SMD boards before you are going to find it impossible to do those 0402 passives by hand but if you have previous experience it should be ok to do with some magnification.
If you've ordered a stencil and you've used one before it should be pretty simple to apply some solder paste to the board and place the components on top. After that all you need to do is apply some heat to solder them in place.
One important thing to note here: The schematic shows R6 and R8 and there is no mention of this but do not populate them. Your trezor will not work if you populate those resistors. I had to spend quite some time to figure out what was wrong with mine before discovering those resistors are not actually populated on production boards.
Step 4: Setting Up the Development Environment and Compiling Firmware
You will need to setup the dev environment to be able to compile the firmware images. I used Ubuntu 16.04 and it was easy to setup everything. I mostly followed the instructions found on this github page. I've had a few dependencies missing so additionally I recommend installing these dependencies:
sudo apt-get install build-essential cmake curl libcurl4-gnutls-dev libprotobuf-dev pkg-config libusb-1.0-0 libusb-1.0-0-dev libmicrohttpd-dev libboost-all-dev protobuf-compiler
Do not forget about this line export MEMORY_PROTECT=0 before compiling any firmware. It is really important to declare that before compiling because that is a protection feature that if we do not disable it will lock our microcontroller, it will basically disable the JTAG interface and it will prevent further writes to the bootloader flash memory.
At this point when trying to compile the firmware I encountered this error:
Traceback (most recent call last):<br> File "nem_mosaics.py", line 6, in <module> from google.protobuf import json_format ImportError: cannot import name json_format Makefile:121: recipe for target 'nem_mosaics.h' failed make: *** [nem_mosaics.h] Error 1</module>
This is caused by another package missing and it can be fixed by installing it:
sudo pip install googleapis-common-protos
At this point everything should compile without any errors and you are ready to flash the resulting image to your trezor. Connect these 3 signals to your st-link v2 dongle: SWCLK SWDIO GND and you are now ready to run the commands for flashing the firmware image according to the instructions on the github page linked above.
Step 5: Testing and Configuring Your Trezor Wallet
After flashing the firmware if you connect the trezor to your computer it should be detected and the drivers will install automatically (at least on windows). After driver installation finished you need to go to trezor.io/start as prompted on the display of the trezor. You will be instructed to install a small piece of software that acts as a bridge between windows and their web service. After that is installed your new device should be detected by their online app and it should prompt you to upgrade the firmware if a newer version is available.
After upgrading the firmware the trezor app will offer you the possibility to setup and configure your new hardware wallet and this means you have successfully completed the project.
Thank you for following me on this tutorial and I hope it was useful. You should checkout my Youtube channel for more awesome projects: Voltlog Youtube Channel.