Mining Bitcoin with a Game Boy Console

Use a Game Boy and Raspberry Pi Pico to mine Bitcoin at a blistering rate of 0.8 hashes per second.

What Is Cryptocurrency?

The finance and technology industries are filled with buzzwords like "cryptocurrency" and "blockchain", but what do they actually mean? A cryptocurrency is a form of money that is decentralized and secured using encryption to verify the list of transactions is accurate. Imagine this list as a ledger, where countless users store their own copy of it. When a transaction is made, it gets recorded simultaneously onto each copy and verified. If a majority of the ledger holders agree to a block (ledger) then the block is stored in a large string of past transactions known as the blockchain.

Bitcoin was the first cryptocurrency to implement this, with a decentralized blockchain and proof of work to help verify each block. In Bitcoin's case, this involves running the SHA-256 hashing algorithm to generate hashes with an increasingly large number of leading zeroes.

Once this requirement is met, the user that solved the task gets rewarded with a few bitcoins. This reward will continue to decrease over time as more and more of the finite coins get mined.

Mining Mania

The last few years have been incredible for the crypto market, especially within the past year. Prices for many coins have gone up several fold, which makes mining coins profitable for so many more people. All of this mining has also brought about shortages of key computer components, including GPUs and CPUs.

From this desperation, YouTuber and modder StackSmashing wanted a way to mine bitcoin on an old device that was just lying around- a Game Boy.

A Custom ROM

You can't just go out and buy a Game Boy cartridge to start mining Bitcoin, so how is the code created/loaded in the first place? The custom firmware is written in C with the GPDK, an open source Game Boy software development kit. It runs the SHA-256 algorithm that's found within the trezor hardware wallet. The code simply runs in an endless loop where it receives the block and then begins to mine. If the hash comes out to match the target value, a 0 is returned and a message sent to the host computer.

Communicating with the Bitcoin Network

The Game Boy is unable to communicate with modern wireless networks and USB, but it does have a way to "link" several Game Boy consoles together using a proprietary cable and the SPI protocol. This can be hijacked using a Raspberry Pi Pico to emulate a second Game Boy. The Pico connects to one end of the link cable, where serial CLOCK, IN, and OUT are attached to three GPIO pins via a level shifter for a speed of 8KHz or 1KB per second.

Using Programmable IO

The Pico's firmware is quite simple. It begins by setting up a SPI peripheral on PIO instance 0, along with the USB serial connection. Next, it initializes the SPI subsystem to communicate at 8KHz, along with which pins to use. Finally, it enters an infinite loop where new data is read from USB and transmitted via SPI to the Game Boy.

Running the Mining Software

With everything in place, it was time to start mining some Bitcoins. The host computer runs a local node and mining software. It sends new block data and the target value to the Pico each time one is available on the network, as well as check in regularly to see if any coins have been mined.

In terms of performance, the console hashes at 0.8 hashes per second. In comparison, a modern ASIC miner (a calculator that is solely for running the SHA-256 algorithm) can achieve around 100 terahashes per second. That means the Game Boy is only 125,000,000,000,000 times slower, letting it mine a single Bitcoin in around 2 quadrillion years.

Although StackSmashing's project isn't meant to be used in any serious capacity, it's still a great way to learn about how cryptocurrencies work and to explore embedded systems development.

Arduino “having11” Guy
19 year-old IoT and embedded systems enthusiast. Also produce content for Hackster.io and love working on projects and sharing knowledge.
Related articles
Sponsored articles
Related articles