Search "Arduino Uno"
DIY Projects

How to Build a DIY Crypto Hardware Wallet for Bitcoin, Ethereum and BSC (STM32 + OLED)

Build your own hardware wallet from an STM32 board, a 0.96" SPI OLED and two buttons, running the open-source Trezor One firmware. Wiring, firmware build, flashing, and setup for BTC in Trezor Suite and ETH/BSC in MetaMask.

By circuitdukaan11 min read
How to Build a DIY Crypto Hardware Wallet for Bitcoin, Ethereum and BSC (STM32 + OLED)

A hardware wallet keeps your crypto's private keys on a small device that never connects to the internet by itself – the keys stay inside, and only signed transactions come out. In this project you'll build your own DIY crypto hardware wallet for Bitcoin (BTC), Ethereum (ETH) and BNB Smart Chain (BSC) from an STM32 development board, a 0.96" OLED display and two push buttons, running the open-source Trezor One firmware.

The finished wallet works with Trezor Suite for Bitcoin and with MetaMask (or Rabby) for Ethereum, BSC and their tokens. Total cost is roughly ₹2,500–3,500.

Read this first: a DIY wallet is a brilliant way to learn how hardware wallets work, but it is not as safe as a factory-made one. Its debug port stays open and it runs unofficial firmware. Use it for learning and small amounts, always set a passphrase, and keep serious savings on a certified hardware wallet. Nothing here is financial advice.

What you're building

Every modern wallet starts from a list of recovery words (a BIP39 seed). From those words the device calculates separate accounts for each coin. Bitcoin uses its own path, while Ethereum and BSC are both "EVM" chains that use the same keys – so your ETH address and your BSC address are the same 0x… address.

How one recovery seed gives a Bitcoin account and an EVM account used on both Ethereum and BNB Smart Chain
One seed, three coins: Bitcoin on its own path, ETH and BSC sharing one 0x address. Tap to enlarge.

When you send coins, the app on your computer prepares the transaction and passes it to the wallet over USB. The wallet shows the amount and address on its own screen, you press the confirm button, and it returns only the signature – never the keys.

How safe is a DIY hardware wallet?

This DIY buildFactory Trezor OneSecure-element wallets
Keys stay off the computerYesYesYes
Confirm on device screenYesYesYes
Secure chipNoNoYes
Debug port lockedNo – open by designYesYes
Signed official firmwareNo (you build it)YesYes
Good forLearning, small amountsEveryday holdingsLarge holdings

The biggest difference is the open debug port. Anyone who gets the device and an ST-Link could read its memory and try to brute-force your PIN offline. The defence is a BIP39 passphrase (sometimes called the "25th word"): without it, the stored seed alone doesn't open your real wallet. Treat the passphrase as mandatory on this build.

Parts list

PartWhat to buyApprox. price
STM32 boardSTM32F405RGT6 or STM32F407VGT6 board with 1 MB flash, 8 MHz crystal and micro-USB₹1,500–2,500
Display0.96" 128×64 SSD1306 OLED, 7-pin SPI version₹250–400
Buttons2 × 6×6 mm tactile push buttons₹10
ProgrammerST-Link V2 (USB SWD programmer)₹350–500
WiringJumper wires, a breadboard or perfboard, male header pins₹150–300
CableMicro-USB data cable (not charge-only)₹100
ToolsSoldering iron, solder, multimeter for checking connections–

Important: the common 4-pin (GND, VCC, SCL, SDA) OLED is the I2C version and will not work – the firmware drives the display over SPI. Buy the 7-pin module labelled GND, VCC, D0, D1, RES, DC, CS.

Choosing the STM32 board

The original Trezor One uses an STM32F205. Bare F205 boards are rare, so DIY builders use the pin-compatible STM32F405 or STM32F407, which run the same firmware. Check four things before you buy:

  • 8 MHz crystal (HSE) on the board – the firmware sets its clock for exactly 8 MHz.
  • 1 MB flash (part numbers ending in GT6). Current firmware is large; 512 KB (ET6) parts may not fit it.
  • USB socket wired to PA11/PA12 (USB OTG FS) – true for almost every F4 board with a micro-USB port.
  • Pins PA4, PA5, PA7, PB0, PB1, PC2 and PC5 reachable on the headers. An on-board LED on one of them is harmless.

Step 1: Wire it up

All the pin numbers below come straight from the Trezor One firmware source, so the display and buttons work without changing any code.

DIY hardware wallet wiring: SSD1306 SPI OLED to PA5, PA7, PB1, PB0, PA4; buttons on PC5 and PC2; ST-Link on PA13 and PA14
OLED, buttons and ST-Link connections. Tap to enlarge.
FromTo STM32 pinNotes
OLED GND / VCCGND / 3V33.3 V only
OLED D0 (SCK)PA5SPI1 clock
OLED D1 (MOSI)PA7SPI1 data
OLED RESPB1Display reset
OLED DCPB0Data / command
OLED CSPA4Chip select
Left button (Cancel)PC5 → button → GNDInternal pull-up, active low
Right button (Confirm)PC2 → button → GNDInternal pull-up, active low
ST-Link SWDIO / SWCLK / GNDPA13 / PA14 / GNDFor flashing only
BOOT0GNDBoot from flash

Build it on a breadboard first. Once everything works, move it to a perfboard and solder it so nothing comes loose – check each joint with the multimeter's continuity test (our multimeter guide shows how).

Step 2: Prepare the build computer

The firmware builds on Linux. On Windows, install WSL2 with Ubuntu from the Microsoft Store and run these commands inside it:

sudo apt update
sudo apt install -y git make gcc-arm-none-eabi protobuf-compiler python3 stlink-tools
curl -LsSf https://astral.sh/uv/install.sh | sh

The official build expects a specific version of the ARM GCC toolchain. If the build fails with compiler errors, check the version listed in the repository's ci/Dockerfile and install that one.

Step 3: Build the bootloader and firmware

git clone --recurse-submodules https://github.com/trezor/trezor-firmware.git
cd trezor-firmware
git tag -l 'legacy/v1*'          # pick the newest release tag
git checkout legacy/v1.X.Y       # replace with that tag
git submodule update --init --recursive
cd legacy
uv sync
export PRODUCTION=0
uv run ./script/setup
uv run ./script/cibuild
Never skip export PRODUCTION=0. If it is missing, the build defaults to production mode, which turns on memory protection. Flashed onto your board, that can permanently lock the bootloader area and disable the debug port – you would not be able to reflash the chip.

Leave BITCOIN_ONLY unset – the Bitcoin-only build has no Ethereum support. When the build finishes you have two files: legacy/bootloader/bootloader.bin and legacy/firmware/trezor.bin.

Step 4: Flash it with the ST-Link

The repository includes a small script that joins the bootloader and the firmware into one image with the right gap between them:

cd bootloader/combine
cp ../bootloader.bin bl.bin
cp ../../firmware/trezor.bin fw.bin
python3 prepare.py
st-flash write combined.bin 0x8000000
Build and flash flow: PRODUCTION=0, cibuild, bootloader.bin and trezor.bin, prepare.py combined.bin, st-flash at 0x8000000, flash memory map
From source code to a flashed board, with the flash memory layout. Tap to enlarge.

WSL2 can't see USB devices without extra setup. The easy way is to copy combined.bin to Windows and write it with STM32CubeProgrammer (free from ST): connect via ST-LINK/SWD, open the file and download it at address 0x08000000.

If the screen stays blank or the board keeps resetting, check the wiring and BOOT0 first. If it still won't start, read the "PRODUCTION combinations" table in the official legacy firmware docs – some older firmware versions need a different bootloader/firmware combination.

Step 5: First start and wallet setup

  1. Disconnect the ST-Link and plug the board's micro-USB into your computer. The OLED should light up.
  2. Open Trezor Suite (desktop app or web). It will show "Unofficial firmware detected". That is expected – you built the firmware yourself. Read the warning, then choose to continue.
  3. Choose Create new wallet. The device generates the recovery words itself – write them on paper in order. Never photograph them or type them into a computer or phone.
  4. Set a PIN. The device shows a scrambled number grid, and you click the matching positions on the computer, so a keylogger can't learn the PIN.
  5. In Suite's settings, turn on Passphrase. Choose a long passphrase and store it separately from the recovery words.

Before you send any coins, test the recovery. Note your first receive address, wipe the device in Suite, choose Recover wallet, type the words on the device, and check that the same address comes back. DIY hardware can fail – the recovery words are your real backup.

Step 6: Bitcoin with Trezor Suite

Add a Bitcoin account in Suite (native SegWit, addresses starting with bc1q). Click Receive, and check that the address on the OLED matches the one on the screen before you share it. To send, enter the address and amount in Suite and confirm each detail on the device with the right button.

Step 7: Ethereum and BSC with MetaMask

  1. In MetaMask, open the account menu and choose Add hardware wallet → Trezor. Follow the Trezor Connect window (it will show the same unofficial-firmware warning).
  2. Pick the first account. Its 0x… address is your Ethereum address.
  3. Add BNB Smart Chain as a network (if MetaMask doesn't already list it):
FieldValue
Network nameBNB Smart Chain
RPC URLhttps://bsc-dataseed.bnbchain.org
Chain ID56
Currency symbolBNB
Block explorerhttps://bscscan.com

Switch MetaMask to BNB Smart Chain and you'll see the same 0x address – the wallet signs for both chains. Tokens such as USDT (ERC-20 or BEP-20) show up once you import them in MetaMask on the right network. Rabby works the same way.

How the DIY wallet signs a BSC transaction: MetaMask sends the unsigned transaction over USB, the OLED shows amount and address, Confirm returns only the signature
Every transaction is checked on the wallet's own screen before it is signed. Tap to enlarge.

Step 8: Test with a tiny amount

Send a very small amount to each address first – a little BTC, a little ETH and a little BNB. Then send part of it back out, confirming on the device each time, and check every transaction on a block explorer. Only once all three work should you trust the wallet with more – and even then, keep it to amounts you're comfortable learning with.

Finishing touches

  • Solder everything onto a perfboard and put it in a small 3D-printed or plastic case with the two buttons on top.
  • Cover or remove the ST-Link header pins so the debug port isn't sitting there exposed.
  • Label the left button ✕ and the right button ✓.
  • Keep the recovery words and the passphrase in two different safe places.

Troubleshooting

ProblemLikely causeFix
OLED stays darkI2C display, or a wrong pinUse the 7-pin SPI OLED; recheck PA4, PA5, PA7, PB0, PB1 and 3V3
st-flash can't find the chipSWD wiring or BOOT0Check SWDIO→PA13, SWCLK→PA14, GND; hold RESET while connecting
Computer doesn't see the walletCharge-only cable, or USB not on PA11/PA12Try a data cable; check the board's USB wiring
Board resets in a loopWrong crystal, firmware too big, or a PRODUCTION mismatchUse an 8 MHz, 1 MB board; rebuild with PRODUCTION=0
Buttons do nothingButton wired to 3.3 V instead of GNDWire PC2 and PC5 through the buttons to GND
Suite warns about firmwareYou built it yourselfExpected on a DIY build

Frequently asked questions

Can I really build my own hardware wallet?

Yes. The Trezor One firmware is open source, and its display and buttons are simple parts, so it runs on a pin-compatible STM32 board. You get the same "keys stay on the device, confirm on the screen" workflow – just without the factory security locks.

Does it support USDT, BNB and other tokens?

On Ethereum and BNB Smart Chain, yes – tokens live at your 0x address, and MetaMask signs token transfers through the wallet. Bitcoin is handled in Trezor Suite.

What if the DIY board breaks?

Your coins are on the blockchain, not in the device. Restore your recovery words (and passphrase) into a new DIY wallet or any compatible BIP39 wallet. Bitcoin uses the path m/84'/0'/0' and Ethereum/BSC use m/44'/60'/0'/0/0.

Can I use an ESP32 instead?

Not with this firmware – it is written for STM32 chips. ESP32 DIY wallets exist, but most open-source ones support Bitcoin only.

Does the wallet need internet?

No. The device itself never goes online; the computer with Trezor Suite or MetaMask talks to the blockchain and only asks the wallet for signatures.

Wrapping up

With an STM32 board, a 7-pin SPI OLED, two buttons and an ST-Link, you can build a working hardware wallet for Bitcoin, Ethereum and BSC in an afternoon – and understand exactly how one works inside. Build it on a breadboard, flash it with PRODUCTION=0, test the recovery before funding it, and keep the amounts small.

CircuitDukaan is not affiliated with SatoshiLabs. "Trezor" is a trademark of its owner, used here only to identify the open-source firmware (GPLv3) this project runs. You build and use this device at your own risk; this article is not financial advice.

Related products

Products linked to this article.

  • #Hardware wallet
  • #Crypto
  • #STM32
  • #Bitcoin
  • #Ethereum
  • #BSC
  • #DIY project
Back to blogs