• Stars
    star
    214
  • Rank 184,678 (Top 4 %)
  • Language
    C
  • License
    Other
  • Created over 1 year ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Handheld RISC-V Mini Game Console with OLED Display

CH32V003 RISC-V Mini Game Console

Mini Game Console utilizing the CH32V003J4M6 ultra-cheap (10 cents by the time of writing) 32-bit RISC-V microcontroller, an SSD1306 128x64 pixels OLED display and CR/LIR2032 coin cell battery holder.

GameConsole_pic1.jpg

Hardware

Schematic

GameConsole_wiring.png

The CH32V003 Family of 32-bit RISC-V Microcontrollers

The CH32V003 series is a collection of industrial-grade 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, wide 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.

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.

GameConsole_invaders_1.png GameConsole_invaders_2.png

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.

GameConsole_lander_1.png GameConsole_lander_2.png

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.

GameConsole_tris_1.png GameConsole_tris_2.png

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.

GameConsole_arkanoid_1.png GameConsole_arkanoid_2.png

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.

GameConsole_pacman_1.png GameConsole_pacman_3.png

Compiling and Uploading Firmware

Programming and Debugging Device

To program the CH32V003 microcontroller, you will need a special programming device 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 commercially for around $4. This debugging tool is not only compatible with the CH32V003 but also with other WCH RISC-V and ARM-based microcontrollers.

CH32V003_wch-linke.jpg

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:

WCH-LinkE     GameConsole
+-------+      +-------+
|  SWDIO| <--> |DIO    |
|    GND| ---> |GND    |
|    3V3| ---> |3V3    |
+-------+      +-------+

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 initially. There are a few ways to accomplish this:

  • You can utilize the Python tool rvprog.py (with -v option), which is provided with the games in the software folder.
  • Alternatively, you can select "WCH-LinkRV" in the software provided by WCH, such as MounRiver Studio or WCH-LinkUtility.
  • Another option is to hold 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.

Compiling and Uploading (Linux)

To use the WCH-LinkE on Linux, you need to grant access permissions beforehand by executing the following commands:

echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="1a86", ATTR{idProduct}=="8010", MODE="666"' | sudo tee /etc/udev/rules.d/99-WCH-LinkE.rules
echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="1a86", ATTR{idProduct}=="8012", MODE="666"' | sudo tee -a /etc/udev/rules.d/99-WCH-LinkE.rules
sudo udevadm control --reload-rules

Install the toolchain (GCC compiler, Python3, and PyUSB):

sudo apt install build-essential libnewlib-dev gcc-riscv64-unknown-elf
sudo apt install python3 python3-pip
python3 -m pip install pyusb

Switch off the Game Console or remove the battery. Connect the Console via the 3-pin PROG header to the programming device. Open a terminal and navigate to the folder with the makefile. Run the following command to compile and upload:

make flash

If you want to just upload the pre-compiled binary, run the following command instead:

python3 .tools/rvprog.py -f <firmware>.bin

Uploading Firmware Binary (Windows/Mac)

WCH offers the free but closed-source software WCH-LinkUtility to upload the precompiled hex-file with Windows. Select the "WCH-LinkRV" mode in the software, open the .hex file and upload it to the microcontroller.

Alternatively, there is a platform-independent open-source tool called minichlink developed by Charles Lohr (CNLohr), which can be found here. It can be used with Windows, Linux and Mac.

If you have installed Python3 and pyusb on your system, you can also use the included Python tool rvprog.py:

python ./tools/rvprog.py -f <firmware>.bin

References, Links and Notes

GameConsole_pic2.jpg

License

license.png

This work is licensed under Creative Commons Attribution-ShareAlike 3.0 Unported License. (http://creativecommons.org/licenses/by-sa/3.0/)

More Repositories

1

ATmega-Soldering-Station

T12 Quick Heating Soldering Station
C++
915
star
2

Power-Boards

Collection of DC/DC Converters, Battery Chargers and Power Supplies
381
star
3

C64-Collection

Collection of cartridges, adapters and replacements for the Commodore C64
C
162
star
4

ATtiny13-TinyUPS

Uninterruptible Power Supply
C++
142
star
5

CH552-USB-Knob

Rotary Encoder with NeoPixels and USB Interface
C
142
star
6

AVR-Programmer

Collection of AVR Programmers and Accessories
C
136
star
7

Development-Boards

Collection of various development boards for microcontrollers (e.g., CH55x, CH32, PY32, STC8, STM32) and accompanying example software.
C
133
star
8

ATtiny412-PocketRadio

Small FM Radio with RDS and OLED
Python
127
star
9

ATmega-Transistor-Tester

Small version of the famous component tester from mikrocontroller.net
C
116
star
10

ATtiny13-TinyOLEDdemo

I²C OLED on an ATtiny10/13/202
C++
98
star
11

CH32X035-USB-PD-Tester

USB Power Delivery Testing Device and Variable Power Supply
C
97
star
12

ATtiny13-TinySolder

T12 Quick Heating Soldering Station
C++
75
star
13

ATtiny13-TinyRemote

IR Remote Control
C++
68
star
14

ATtiny85-TinyFMRadio

FM Radio with RDS
C++
64
star
15

ATtiny85-TinyTerminal

USB controlled OLED Display
C++
61
star
16

ATtiny814-USB-PD-Adapter

USB Type-C Power Delivery Trigger and Monitoring Board
C
57
star
17

ATtiny85-TinyCharger

Single-Cell Li-Ion Battery Charger with Monitoring
C++
57
star
18

CH32V003-FM-Transmitter

Portable Digital Stereo FM Radio Transmitter
C
54
star
19

CH552-USB-OLED

USB controlled I²C OLED
C
54
star
20

ATtiny13-TinyTacho

Simple RPM-Meter
C++
52
star
21

ATtiny84-TinyCalibrator

OSC Calibrator and High-Voltage Fuse Resetter for 8-Pin ATtinys
C++
52
star
22

ATtiny412-USB-Power-Isolator

2.5kV Isolator for the USB Power Rail
C
50
star
23

MCU-Templates

Templates for bare-metal firmware development for some entry-level microcontrollers
C
50
star
24

ATtiny85-USB-Tester

Simple USB Power Tester
C++
49
star
25

ADuM3160-USB-Isolator

2.5kV USB 2.0 Isolator with 200mA Power Supply and Full Speed (12Mbps) Support
48
star
26

ATtiny814-Power-Analyzer

Power Supply Analyzer with USB Interface
Python
48
star
27

MCU-Flash-Tools

Simple ISP Flash Tools for various Microcontrollers
Python
46
star
28

CH552-MacroPad-plus

Programmable MacroPad with Rotary Encoder and NeoPixels
C
45
star
29

ATtiny85-TinyLoad

Electronic Dummy Load
C++
44
star
30

CH32V003-FM-Receiver

Portable Digital FM Radio Receiver with RDS
C
43
star
31

ATtiny13-TinyRemoteXL

12-Button IR Remote Control
C++
42
star
32

ATtiny13-TinyPocketRadio

FM Stereo Radio with Headphone Plug
C++
41
star
33

ATtiny13-TinyProbe

Simple Logic Probe
C++
39
star
34

ATtiny85-TinyKnob

Rotary Encoder with USB Interface
Assembly
38
star
35

ATtiny13-TinyDecoder

IR Remote Receiver and Decoder
C++
37
star
36

ATmega-EEPROM-Programmer

Parallel EEPROM Programmer for 28C64B and 28C256
C++
37
star
37

ATtiny85-USB-C-Tester

Simple USB-C Power Delivery Tester
C++
34
star
38

AVR-Development-Boards

Collection of AVR Development Boards
C
32
star
39

ATtiny412-I2C-Rotary-Encoder

Rotary Encoder with I²C Interface
C
32
star
40

ATtiny85-TinyDFPlayer

MP3-Player
C++
31
star
41

VUSB-AVR

V-USB Board Definition Package for Arduino IDE
C
30
star
42

ATtiny85-IR2USB

IR Remote to USB HID Converter
C++
28
star
43

ATtiny13-TinyRemoteRF

RF Remote Control
C++
28
star
44

ATtiny84-TinyHVSP

High-Voltage Serial Programmer and Fuse Resetter
C++
27
star
45

SAMD-Development-Boards

Collection of SAMD Development Boards, Programmers, Tools and Firmware
C
26
star
46

CH552-MouseWiggler

Simple Board that can be used as a Mouse Jiggler, a Rubber Ducky or a Caps Blocker
C
25
star
47

CH552-USB-NRF

USB controlled nRF24L01+ 2.4GHz Transceiver
C
25
star
48

ATtiny13-VolumeAdjuster

Automatic Volume Adjuster for TVs and Sound Systems
C++
23
star
49

CH32X035-USB-PD-Adapter

Portable Programmable Power Supply
C
23
star
50

ATtiny13-ContinuityTester

Simple Continuity Tester
C++
21
star
51

ATtiny13-TinyTouchLight

Dimmable USB Night Light with Capacitive Touch Control
C++
20
star
52

ATtiny412-BatteryCapacityTester

Single-Cell Li-Ion, LiPo and LiFePO4 Battery Capacity Tester
Python
20
star
53

CH552-DAPLink

CMSIS-DAP compliant debugging probe with SWD, JTAG, and VCP support
C
20
star
54

ATtiny85-PhoneChargeGuard

USB Phone Charge Guard
C++
19
star
55

ATtiny412-VoiceChanger

Change the Pitch of your Voice
Python
19
star
56

ATtiny13-NeoController

Control almost any number of NeoPixels with an IR Remote
C++
18
star
57

ATtiny814-USB-RTC

Real-Time Clock USB-Stick
C
18
star
58

ATtiny412-USB-PD-Inverter

Turn your USB PD Power Adapter into an AC Power Source
C
17
star
59

CH552-Macropad-mini

Programmable Macropad with NeoPixels
C
16
star
60

ATtiny13-TinyMoisture

Soil Moisture Monitor
C++
15
star
61

CH32V003-USB-Joystick

Simple Joystick with USB Interface
C
14
star
62

CH552-picoDAP

CMSIS-DAP compliant SWD Programmer
C
14
star
63

ATtiny13-TinyBling

It just does bling bling ...
C++
14
star
64

ATtiny814-NRF2USB

USB Serial Controlled 2.4GHz Transceiver
C
13
star
65

ATtiny85-TinyCandle

Tea Light Candle Simulation
C++
13
star
66

ATtiny13-TinyNightLight

Night Light with NeoPixels and Rotary Encoder
C++
12
star
67

ATtiny84-TinyICOC

In-Circuit Oscillator Calibrator for AVR Microcontrollers
C++
11
star
68

CH32X033-USB-Knob

Rotary Encoder with NeoPixels and USB Interface
C
11
star
69

ATtiny13-TinyCandle

Simple Candle Simulation
C++
10
star
70

ATtiny13-TinyPlayer

IR Remote Controlled MP3 Player
C++
10
star
71

ATtiny13-TinyDice

Tiny Electronic Dice
C++
9
star
72

ATtiny814-AquaTimer

Programmable Timer for Aquariums
Python
8
star
73

CH32V003-IR-Remote

Simple 5-Button IR Remote Control
C
8
star
74

CH32V003-USB-Knob

Rotary Encoder with USB Interface
C
6
star
75

ATtiny13-TinySat

Solar Powered Blinken Lights
C++
6
star
76

ATtiny412-HamsterTracker

Simple Fitness Monitoring Device for your Pet Hamster
Python
6
star
77

ATtiny13-TinySonar

Ultrasonic Range Finder
C++
6
star
78

ATtiny85-RocketLamp

Dual Core ATtiny85 Board
C++
6
star
79

CH32X033-USB-NRF

USB controlled nRF24L01+ 2.4GHz Transceiver
C
6
star
80

CH32V003-NeoPixel-Pendant

It just does bling bling ...
C
5
star
81

CH32V003-Mouse-Wiggler

Simple USB Plug that can be used as a Mouse Jiggler, a Rubber Ducky, or a Caps Blocker
C
5
star
82

CH32V003-I2C-Knob

Rotary Encoder with I2C Interface
C
4
star
83

CH32V003-USB-IR-Receiver

IR Remote Control to USB HID Converter
C
4
star
84

CH32V003-MacroPad-plus

Programmable MacroPad with Rotary Encoder and NeoPixels
C
4
star
85

TinyRDA

RDA5807 FM radio library using TinyI2C
C++
3
star