Skip to content

MiSTer FPGA

sairuk edited this page Oct 3, 2022 · 45 revisions

MiSTer FPGA

Contents:

About

MiSTer FPGA is an open source, FPGA based device that simulates numerous classic video game consoles and computers.

See the main project wiki here:

MiSTer FPGA can mount a CIFS share (provided by Samba) to load ROM, ISO, BIN/CUE, VHD and numerous other images from a network share.

Specific to the MiSTer's DE10Nano hardware, SMB/CIFS file loading over Gigabit Ethernet is the fastest method of accessing storage. The onboard MicroSD card access is quite slow, and the USB ports are limited to USB2 which are not only quite slow, but half duplex.

PorkChop Express, owner of MiSTer Addons and the maintainer of excellent MiSTer related resources like the comprehensive controller input latency database did a deep dive on MiSTer FPGA storage options and benchmarks to match. Read the report here:

Video

Note that some of the config in this video is now out of date, however it shows what's possible on MiSTer. Please refer to the wiki entries below on the specific config you require. Click to watch the instructional video on YouTube (please also watch the Samba video for how to set your CIFS password):

Watch the video

Generic ROMs folder

Please see the notes about the Generic ROMs folder in RetroNAS.

Install RetroNAS Services

Run RetroNAS, navigate to "Install things" -> "MiSTer FPGA CIFS config". This will install Samba automatically as a prerequisite.

See the Samba wiki page for more information on Samba, including how to set your Samba username and password.

Take note of your RetroNAS/RPi IP address, as you'll need to use that later.

File paths on RetroNAS

RetroNAS creates a directory called mister (all lower case) under the top level directory. Below it, numerous directories defined by the individual core developers (if you run the MiSTer updater scripts, you'll find similar cores on your MiSTer's SD card under "/media/fat/Games"). Note that some of these will have specific localisations, for example Genesis for both "Sega Megadrive" (Japan and PAL territories) and "Sega Genesis" (North American territories). Likewise SNES for both the "Super Nintendo" and "Super Famicom", NES (NES/Famicom), MegaCD (MegaCD/SegaCD), etc.

These specific directories should not be renamed or have the case changed, as they are defined elsewhere. Extra directories can be added as new cores are released for MiSTer.

These paths can be browsed to either directly via the mister share over SMB/CIFS, or via the the top level directory shared by any other protocol (Samba, Netatalk, FTP, etc).

You can copy your ROM, ISO, CHD, VHD, IMG images or other content needed for specific cores into the relevant directories. If your MiSTer is correctly configure to read the share, these will appear immediately to the MiSTer framework itself (no need to reboot).

Documentation per-core is available at the MiSTer wiki:

MiSTer FPGA configuration

Note that the MiSTer downloader/updater scripts do not update the cifs scripts. If you've installed your MiSTer system some time in the past, it's worth grabbing the new files fresh.

You can see these files online by clicking these URLs:

Or download them to your MiSTer directly. SSH to your MiSTer as "root" (password by default is "1"). And then:

cd /media/fat/Scripts
mv cifs_mount.sh cifs_mount.sh.bak
mv cifs_umount.sh cifs_umount.sh.bak
wget https://raw.githubusercontent.com/MiSTer-devel/Scripts_MiSTer/master/cifs_mount.sh
wget https://raw.githubusercontent.com/MiSTer-devel/Scripts_MiSTer/master/cifs_umount.sh
chmod a+x cifs*sh

Edit the following configuration lines in the cifs_mount.ini scripts. You'll need to substitute in the correct IP address, username and password for your RetroNAS setup. You can do this either by editing the ini elsewhere and copying it over, or SSH in and run

cd /media/fat/Scripts
nano cifs_mount.ini

Navigate with the arrow keys on your keyboard and edit as you wish. When complete, press:

  • Control + x to exit
  • It will ask at the bottom of the screen : Save modified buffer?. Press y for yes.
  • It will ask at the bottom of the screen: File Name to Write: cifs_mount.ini. Press enter to confirm.
  • You will drop back to the command prompt with the file saved.

Use the following values inside your cifs_mount.ini file. For the "ipaddress" part below, substitute in your RetroNAS device's IP address or you may use the NetBIOS name retrosmb. This is convenient if your RetroNAS device changes IP address due to DHCP.

SERVER="ipaddress"
SHARE="mister"
USERNAME="pi"
PASSWORD="yourpipassword"
WAIT_FOR_SERVER="true"
MOUNT_AT_BOOT="true"
SINGLE_CIFS_CONNECTION="true"
LOCAL_DIR="*"

Once saved, on reboot your MiSTer FPGA will take a few seconds to get an IP address from your DHCP server. Once done, it should automatically mount your CIFS share. (If not, you can press F12 at the main MiSTer menu, navigate to the Scripts folder and run the cifs_mount.sh script).

From there, navigate MiSTer cores as normal, and when loading ROM, ISO, BIN/CUE, VHD, etc files through the F12 menus, the contents of your NAS should appear in MiSTer.

Note that this method will change the local (on MicroSD) /media/fat/games folder and mount your RetroNAS folder over the top. If you had games on your MicroSD card, these will be hidden by the mount, which now sits over the top from MiSTer's point of view. Your old games are not deleted, you can access them by running cifs_umount.sh to remove the NAS mount.

MiSTer changes and new cores

MiSTer is a constantly changing project, and new cores are released frequently. If you find that you can't load a new game's ROMs via CIFS, re-run the "Samba for MiSTer" installer from the RetroNAS menu. This will never delete old information. It will merely apply and configuration changes or symlink updates required to support new cores.

A note about MiSTer updates

Sometimes MiSTer updates can prevent the cifs_mount.sh script from triggering automatically at boot. To solve this, log in to your MiSTer via SSH (username "root", password "1"), and manually run the mount script one time:

cd /media/fat/Scripts
./cifs_mount.sh

Once done, it will modify the MiSTer internal Linux system to re-run the script automatically on boot, as long as the MOUNT_AT_BOOT="true" option is set inside cifs_mount.ini (see above for instructions).

Advanced mode - everything on a NAS, multi-MiSTer resource sharing

The default supplied MiSTer FPGA folders in RetroNAS, i.e.: BIOS, games, saves, savestates and wallpaper all mount in over the top of your MiSTer's internal system under /media/fat on the local MicroSD card install. You can take this one step further by creating any of the MiSTer internal folders that hold various cores, game content or addons to have these network mounted as well.

Depending on the folders, if you have things like _Arcade, _Console, etc all network mounted, updating your MiSTer with scripts like update_all.sh will update all MiSTers on your network connected to the same NAS. (You will still need to run update_all.sh to update local files like the MiSTer menu and Linux system, however the script will detect up to date cores, games, cheats, shadow masks, etc and not re-download them on each MiSTer device).

You will need to make sure your MiSTer has mounted the NAS correctly before you can select cores and features. For extra safety, you can add the following example line to your /media/fat/MiSTer.ini file to force the system to wait for a mount point:

waitmount=/media/fat/_Console

Here's a suggested list of folders you can add to the mister share on RetroNAS:

Cores:

_Arcade
_Computer
_Console
_Other
_Utility

Extra addons:

Cheats
docs
Filters
Filters_Audio
font
gamma
Presets
Shadow_Masks

Note that having these on your NAS will mount them over the top of the same directories on your MiSTer's MicroSD card. The originals on your MicroSD will never be deleted, but they will be hidden as long as the mount is active. To see them again, run the cifs_umount.sh script.

If you have these existing directories on your MicroSD already (say, you've previously run update_all.sh to generate them), simply copy them over to your mister share on RetroNAS (you can use an SFTP tool like CyberDuck to log into your MiSTer with its SSH credentials and copy files/folders across to the mounted RetroNAS mister share on your computer).

If you want to use the arcade origanizer script (or any other scripts that use symlinks to save space) you will need to update your cifs_mount.ini to include the following

ADDITIONAL_MOUNT_OPTIONS="mfsymlinks"

PSX core - Latency performance

Certain cores such as the PSX core require some strict timings for successful reads. In the PSX core's case, 6.6ms is the maximum latency (i.e.: the total time taken for a single data read to be accessed) for the complete round trip of data from FPGA core, through the ARM CPU, across the storage, and back. It is assumed that the FPGA core itself internally adds 1ms of latency, and the HPS (Hard Processor System, i.e.: the ARM CPU) adds 2ms of latency. So the upper bounds of the storage latency should be somewhere in the order of 3.6ms, with any number lower than that being acceptable.

This is a very different measurement to bandwidth, where we normally measure things in MB/s. Latency instead is measured in time, again with the PSX core requiring 6ms (six milliseconds) or faster (i.e.: smaller number) to make it back into the system memory.

We can test that latency with a handy tool called "ioping". Similar to a regular network ping, this will measure how long a total round trip for the system to request and receive a 4KB block of data and have it ready for the FPGA core to access.

We can download the Debian Bullseye armhf binary of ioping and use that directly on MiSTer. To do so

  • Ensure you've run cifs_mount.sh and that the CIFS share from RetroNAS is mounted. You can verify this with the command mount | grep cifs
  • Run the following commands to download ioping:
# Change to the MiSTer MicroSD mount
cd /media/fat
# Make a temporary directory to use the tool
mkdir ioping
cd ioping
# Download the ioping compressed archive
wget http://ftp.debian.org/debian/pool/main/i/ioping/ioping_1.2-1_armhf.deb
# Decompress the archive
ar -vx ioping_1.2-1_armhf.deb
# Decompress the data portion
tar xvJf data.tar.xz
  • Change to the binary directory, and use the tool to test various parts of the system
  • ioping runs constantly. Cancel it with Control+C on your keyboard.
# Change to ioping binary dir
cd /media/fat/ioping/usr/bin
# Test the MicroSD card
./ioping /
# Test the CIFS mount
./ioping /media/fat/games/PSX/

My test system is a Raspberry Pi 4 with a Hitachi 3TB 7200 RPM spindle drive in a USB3 caddy (model HUA723030ALA640) formatted as BtrFS. The system is connected by 1GbE wired Ethernet, with 2 network switches and roughly 50m of Cat5e cable between the MiSTer device and the RPi4. Results:

./ioping /media/fat/games/PSX/
4 KiB <<< /media/fat/games/PSX/ (cifs //192.168.3.200/mister 2.73 TiB): request=1 time=1.05 ms (warmup)
4 KiB <<< /media/fat/games/PSX/ (cifs //192.168.3.200/mister 2.73 TiB): request=2 time=1.60 ms
4 KiB <<< /media/fat/games/PSX/ (cifs //192.168.3.200/mister 2.73 TiB): request=3 time=1.38 ms
4 KiB <<< /media/fat/games/PSX/ (cifs //192.168.3.200/mister 2.73 TiB): request=4 time=1.47 ms
4 KiB <<< /media/fat/games/PSX/ (cifs //192.168.3.200/mister 2.73 TiB): request=5 time=1.17 ms
4 KiB <<< /media/fat/games/PSX/ (cifs //192.168.3.200/mister 2.73 TiB): request=6 time=1.10 ms
4 KiB <<< /media/fat/games/PSX/ (cifs //192.168.3.200/mister 2.73 TiB): request=7 time=1.03 ms (fast)
4 KiB <<< /media/fat/games/PSX/ (cifs //192.168.3.200/mister 2.73 TiB): request=8 time=1.34 ms
4 KiB <<< /media/fat/games/PSX/ (cifs //192.168.3.200/mister 2.73 TiB): request=9 time=1.12 ms

Here we can see random 4KB IO read times are taking a total round trip of consistently under 1.6ms, well under the 3.6ms requirement for the PSX core.

ao486 core - Write performance

MiSTer's write performance is affected by the way in which MISTer immediately flushes data to disk (rather than writing to memory cache and letting it get to disk seconds later). This is done to ensure that a MiSTer device can be powered off at any time with minimal data loss (which is a good thing).

However for write-heavy ao486 applications (and presumably other Computer cores, although these are not tested yet), this behaviour can make write-heavy games and applications quite slow. As a workaround, several tweaks can be made.

The mister share in RetroNAS already ignores client sync requests (other shares obey client sync requests). This is done by setting the strict sync = no option for the share alone (you can do this on any Samba server, RetroNAS does it for you by default).

On the MiSTer side, you can add three more options to the cifs_mount.ini file. Open the file in an editor either modify the existing setting or add it if missing:

ADDITIONAL_MOUNT_OPTIONS="noatime,cache=loose,nostrictsync"

Note that this can lead to issues if your MiSTer is using the same files for writing to as other MiSTer devices or computers. If your MiSTer is the only device writing to the files specifically in the mister share, this is safe. Any MiSTer devices only doing reads (i.e.: console ROM/CHD/BIN/CUE reading) don't need to apply this tweak.

Doing so however roughly doubles the write speed of the ao486 core running an MS-DOS guest and writing to files or doing other disk operations (partitioning/formatting VHDs inside ao486 DOS, etc).

Home

Getting started:

Contributing

Multi-system protocols:

Specific system configurations:

Services:

Tools:

Physical Media:

On-Device Management:

Advanced storage options:

  • BtrFS RAID, Snapshots, Compression, Deduplication
  • FAT Advanced guide to using FAT loopback mounts for EtherDFS
  • TBA
    • SMR Shingled Magnetic Recording hard drives (TBA)
    • NTFS Advanced guide for NTFS formatted disks
    • SMB Loopback Mounting an existing SMB NAS
    • NFS Loopback Mounting an existing NFS NAS
    • MDRAID (TBA)
    • LVM (TBA)
    • iSCSI Configuring iSCSI

Other:

Clone this wiki locally