Introduction
Surfing on the Internet I recently bumped into a really cool (and tiny!) project building a RISC-V based mini game console. I built a few units to my kids and siblings and decided do document all the steps here so others can do the same.
The Mini Game Console uses the CH32V003 32-bit RISC-V microcontroller, an SSD1306 128×64 pixels OLED display and 3.6V LIR2032 coin cell battery holder.
The CH32V003 series is a collection of general-purpose microcontrollers that utilize the QingKe RISC-V2A core design supporting the RV32EC instruction set. These microcontrollers are equipped with various features such as a 48MHz system main frequency, 16KB flash, 2KB SRAM, 2.7V – 5.5V supply voltage support, a single-wire serial debug interface, low power consumption, and an ultra-small package.
Additionally, the CH32V003 series includes a built-in set of components including a DMA controller, a 10-bit ADC, op-amp comparators, multiple timers, and standard communication interfaces such as USART, I2C, and SPI. A very complete thing in a such small form factor.
The project is open source and all the files to order the PCBs and build the project, including a few games already ported to it, can be found at GitHub – wagiminator/CH32V003-GameConsole: Handheld RISC-V Mini Game Console with OLED Display
For those of you interested in building one of those, I prepared a set of instructions, tips and tricks that I documented during the build process. I also included a table below with links to the components if you want to order.
Bill of Materials
Reference | Value | Description | Qty | Link |
PCB | N/A | RISC-V Mini Game Console Printed Circuit Board | 1 | CH32V003-GameConsole/hardware/GameConsole_v1.1_gerber.zip at main · wagiminator/CH32V003-GameConsole |
U1 | CH32V003J4M6 | 32-bit general-purpose RISC-V MCU-CH32V003 | 1 | AliExpress |
R5,R6 | 2KR | 0603 2K Ohms Resistor | 2 | AliExpress |
R4 | 20KR | 0603 20K Ohms Resistor | 1 | AliExpress |
R3 | 3.9KR | 0603 3.9K Ohms Resistor | 1 | AliExpress |
R2 | 8.2KR | 0603 8.2K Ohms Resistor | 1 | AliExpress |
R1 | 22R | 0603 22 Ohms Resistor | 1 | AliExpress |
Q1 | 2A SOT23 | MMBT3906 SILICON EPITAXIAL PLANAR PNP TRANSISTOR | 1 | AliExpress |
C2 | 10uF | 0603 10uF Ceramic Capacitor | 1 | AliExpress |
C1 | 100nF | 0603 100nF Ceramic Capacitor | 1 | AliExpress |
ACT,DOWN,LEFT,RIGHT,UP | BUTSMD180G6x6x4 | SMD Tactile Switch6*6*4mm | 5 | AliExpress |
BUZZER1 | MLT-5030 | MLT-5030 Passive electromagnetic buzzer | 1 | AliExpress |
SW1 | MSK-12C02 | Mini 7-Pin On/Off 1P2T SPDT MSK-12C02 SMD Toggle Slide Switch For MP3 MP4 | 1 | AliExpress |
B1 | BS-6 ZX3C451-GD | White Housing Gold-Plated Tin-Plated Button Battery Holder For CR2032 Cr2025 Bs-6 SMD Button Battery Holder Socket Case | 1 | AliExpress |
H1 | I2C OLED 0.96 | 0.96 inch IIC Serial 4pin White 128X64 12864 LCD Screen Board for arduino oled | 1 | AliExpress |
Building and Programming Instructions
Locate the Gerber files (by following the link provided on the previous section) and upload them to a PCB manufacturer of your choice, such as JLCPCB. These files contain all the necessary information for fabricating your circuit board, which the manufacturer will produce and ship to you.
Once the PCB arrives, you can begin assembling it by soldering the components in place. Use the BOM as reference to ensure each component is correctly positioned and connected.
After assembling the PCB, proceed to upload the firmware following the instructions below:
- To program the CH32V003 microcontroller, you will need a special programmer which utilizes the proprietary single-wire serial debug interface (SDI). The WCH-LinkE (pay attention to the “E” in the name) is a suitable device for this purpose and can be purchased for around $4 here. The programmer is not only compatible with the CH32V003 but also with other WCH RISC-V and ARM-based microcontrollers.
- If using Windows, you may need to install the WinUSB driver over the WCH interface 1 using the Zadig tool.
- To upload the firmware, you need to ensure that the Game Console is switched off or the battery is removed. Then, you should make the following connections to the WCH-LinkE:
- If the blue LED on the WCH-LinkE remains illuminated once it is connected to the USB port, it means that the device is currently in ARM mode and must be switched to RISC-V mode. You can do that by holding down the ModeS button on the device while plugging it into the USB port. More information can be found in the WCH-Link User Manual.
- Use the WCH-LinkUtility to upload a precompiled hex-file with Windows. Select the “WCH-LinkRV” mode in the software, open the .hex file in the bin folder and upload it to the microcontroller. The games are available in the links shared on the next section.
Games
Tiny Invaders
Tiny Invaders was originally developed by Daniel Champagne for the ATtiny85. It is an adaptation of the classic game Space Invaders. The player controls a laser cannon that moves horizontally along the bottom of the screen. The objective is to defend the Earth from waves of descending alien invaders. The aliens move side to side, gradually descending towards the player, and the player’s goal is to destroy them before they reach the bottom of the screen.
The player can shoot projectiles at the aliens and must strategically time their shots to hit the moving targets. As the game progresses, the aliens’ movement becomes faster, making it more challenging to eliminate them. Additionally, the aliens periodically fire back at the player, creating a sense of urgency and adding to the gameplay difficulty.
Tiny Lander
Tiny Lander was originally developed by tscha70 for the ATtiny85. It is an adaptation of the classic game Lunar Lander that simulates the experience of piloting a spacecraft and landing it safely on the moon’s surface. The objective of the game is to control the descent of the lunar lander module, adjusting the thrust and direction to ensure a smooth landing without crashing or running out of fuel. It requires careful maneuvering and precision to navigate the gravitational forces and terrain obstacles present on the moon.
If you hold down the UP button on the start screen while pressing the fire button, the game will automatically start in a later level. On the other hand, if you hold down the DOWN button, you get 255 lives.
Tiny Tris
Tiny Tris was originally developed by Daniel Champagne for the ATtiny85. It is an adaptation of the well-known game Tetris. The objective of Tetris is to manipulate and arrange the falling Tetriminos to create complete horizontal lines without any gaps. When a line is completed, it clears from the playfield, and the player earns points. As the game progresses, the Tetriminos fall faster, increasing the challenge. If the Tetriminos stack up and reach the top of the playfield, the game ends.
Tiny Arkanoid
Tiny Arkanoid was originally developed by Daniel Champagne for the ATtiny85. It is an adaptation of the classic game Arkanoid. The player controls a paddle at the bottom of the screen and uses it to bounce a ball against a wall of bricks at the top.
The objective of the game is to destroy all the bricks by hitting them with the ball. Each brick that is hit will disappear, and the player earns points for each brick destroyed. The ball bounces off the walls and the paddle, and the player must maneuver the paddle to keep the ball in play and prevent it from falling off the bottom of the screen.
Tiny Pacman
Tiny Pacman was originally developed by Daniel Champagne for the ATtiny85. The player controls a round character called Pacman, who must navigate through a maze filled with pellets and various types of enemies, known as ghosts. The objective of the game is for Pacman to eat all the pellets in the maze while avoiding the ghosts.