Table of Contents
The Retron 77 is a retrogaming VCS clone released by Hyperkin that runs Stella. It has a HDMI connector and is controlled via original 9-pin controllers. The R77 has a cartridge port used for dumping original cartridges for playback (thus trying to recreate a vintage plug-and-play experience), but can also run ROM images from an included Micro SD cart.
Hardware
Overview
The R77 contains the following hardware
- Allwinner H3 quad core ARM SOC (clocked at 1GHz in the stock firmware)
- 128MB RAM
- A Weltrend WT51F104S MCUs that drives the cartridge dumper (connected via UART)
- Another WT51F104S that drives the front panel with the joystick ports (connected via I2C)
- SD card slot
- Micro USB connector
There is no onboard flash memory.
Board shots
Main board
Front panel daughterboard
UART
There is a single UART header (labelled as UART0) on the mainboard that can be used to obtain a serial console to both the U-Boot bootloader and the linux system running on the device. The UART is configured by both U-Boot and linux at 115200 bps.
USB
The external micro USB connector has its data lines connected and can be used to connect USB peripherals (in conjunction with an USB OTG adaptor to power the device). In addition, there is an additional USB port exposed on the board as JP1:
Credit for discovering this (both header and micro USB) goes to Fluxit on AtariAge.
Software
Overview
Both an image of the included SD card and a tarball of the source and development environment can be downloaded from Hyperkin. The system is an embedded linux system build around the Armbian Linux 3.4.113 kernel. Apart from the kernel, the system shipped by Hyperkin contains the following components:
- Busybox
- SDL 1.2
- ALSA
- Glibc
- Stella 3.7.5
and several more support libraries. Apart from the dumper and the UI, all components are open source software.
Components
Stella
The stock firmware uses an almost unmodified version of Stella 3.7.5 for emulation.
SDL 1.2
Both Stella and Hyperkin's UI use SDL 1.2 for video and audio. SDL runs directly on top of the linux frame buffer without any hardware acceleration.
UI
The source for Hyperkin's UI is included in the source drop and links against SDL 1.2 and Freetype. The UI was written by Hyperkin, and the license is unclear.
Dumper
The cartridge port is driven by the WT51F104S MCU on the main board. The dumper code runs directly on the MCU; the dumper process in linux communicates with the MCU via one of the H3's UARTs. The dumper polls the MCU for cartridge changes (insert and remove). If a cartridge has been inserted, the dumper process tries to read the image from the MCU. As the MCU has only 256 bytes of RAM, the image is read and transferred on the fly. The dumper was written by Hyperkin, and the license is unclear.
Buttons and joystick ports
The buttons on the backside of the device are directly connected to the H3 via GPIO, the buttons on the front side and the joystick ports sit on the daughter board and connect to the second WT51F104S. A kernel driver (sunxi-atari) is responsible for reading buttons and ports and generates matching keyboard events. The driver communicates with the WT51F104S via I2C and generates keyboard events that are chosen to match Stella's default keybindings. The kernel driver is licensed under the GPL.
Building
The firmware can be built from scratch on Linux using Hyperkin's source drop and the Makefiles contained therein. The source drop contains the Linaro ARM toolchain, only standard Linux tools are required for building.
Setup and boot process
Firmware image and bootloader
The SD image generated by the build process contains the bootloader in the first few sectors after the MBR / partition table. U-Boot is used to boot the system. On powerup, the CPU starts from a ROM embedded into the H3 (BROM). The BROM then tries to load the bootloader from SD. The boot process is standard for Allwinner SOCs and documented here. The U-Boot console can be accessed from a serial terminal connected to the UART header on the board (see above).
Linux boot
Following after the bootloader, the SD card contains a single FAT32 partition. From there, U-Boot reads a script file (boot.scr
). This script loads the kernel image from the uImage
file and boots into linux.
Root file system and system lifecycle
The build setup packages the root filesystem as an initramfs that is built into the kernel. The initramfs is never unmounted and contains the full userland, including all binaries and libraries. The FAT32 partition is mounted under /mnt
. On boot, a serial terminal is started on ttyS0 and can be accessed via the UART header on the board (see above). On startup, init starts the dumper process which keeps running until the console is switched off. The dumper communicates with the WT51F104S MCU connected to the cartridge port via ttyS2 and executes shell commands. The program flow looks like this:
- Check whether a cartridge is inserted or removed
- If a cartridge is inserted, try to dump the image
- If no cartridge is inserted on startup or a cartridge is removed, kill the running Stella / UI process and start the UI
- If the dump was successful, kill the running UI / Stella process and launch Stella for the dumped image
- If the dump was unsuccessful, kill the running Stella / UI process and start the UI
The UI is a simple menu that launches Stella as soon as a ROM image is selected. The dumper stays running in the background and will kill the UI and Stella if a cartridge is inserted.
MCU firmware
The firmware running on the two WT51F104S MCUs is proprietary and has been published. It is unclear whether the firmware could be read or reflashed from linux.
Quirks and known issues
FAT32 partition type (aka MacOS cannot mount the drive)
The FAT32 partition is wrongly labelled as type 0x83 (linux ext2). As a consequence, MacOS will not mount it and instead offer to format ("initialize") the card. This can be fixed by manually changing the partition type to 0x0c (FAT32) with fdisk.
WARNING: Only use fdisk if you know what you are doing. Don't accidentally mess up your other drives.
SDL2 and Stella 6
An updated and cleaned up firmware tree is available here. This firmware runs Stella 6 contains kernel patches and firmware to enable the Mali GPU and a modified version of SDL2 that runs on Mali without X11 and supports gamepads without udev. In addition, this firmware supports a developer mode that enables SSH access via an ethernet USB dongle.