Skip to content

MiSTer FPGA user port connection

Dale Whinham edited this page Feb 8, 2021 · 43 revisions

The MiSTer FPGA platform is an open-source project that can emulate vintage computing and gaming systems. The FPGA approach has the potential for greater accuracy and lower latency than what would be possible with traditional software-based emulation, and MiSTer provides an affordable route to benefitting from it, with community-supported hardware and emulation cores.

Many cores are available, and some are able to use external MIDI hardware, such as the AO486, Atari ST, and Minimig (Amiga) cores. This makes it possible to use mt32-pi with these cores.

Whilst MiSTer does allow you to run Munt and FluidSynth on its built-in Hard Processor System (HPS), there are severe limitations. See the FAQ for more information on why you might consider using mt32-pi with your MiSTer.

User port connection

For convenience, mt32-pi and the MiSTer project have collaborated to develop a solution to directly connect the Raspberry Pi to the MiSTer, without the need for separate power, audio, or MIDI cabling.

MiSTer's I/O board provides a "user port" that provides direct access to some of the FPGA's GPIO pins, as well as power. The physical connector is a USB 3.0 Standard-A receptacle.

⚠ Note: MiSTer's user port is not a USB port - the USB receptacle was chosen because they are inexpensive and widely available.

The user port connection offers the following benefits:

  • Can power the Raspberry Pi.
  • Transmits MIDI data directly to the Raspberry Pi's UART.
  • Receives digital audio back from the Raspberry Pi via IΒ²S and mixes it with the FPGA core's audio output.
  • Provides a control channel via IΒ²C so that mt32-pi settings can be changed from the MiSTer's OSD menu system.
  • MiSTer can simulate an SSD1306 OLED display so that you can see mt32-pi's output right on your MiSTer's display!

Custom hardware

An official MiSTer-endorsed HAT PCB design for the Raspberry Pi is available for a plug and play solution. You should soon be able to purchase one from your favorite MiSTer supplier.

If you have the means to assemble your own, you can find the PCB designs and further information over at the MiSTer hardware repository.

⚠ Note: A MiSTer I/O board verion 5.6 or later is required to use the HAT. It may be possible to use earlier versions with minor modifications.


⚠ IMPORTANT: Cabling considerations

Whether you are connecting the Raspberry Pi to the MiSTer using an off-the-shelf USB 3.0 A-A cable and the MiSTer HAT PCB, or with home-made cabling (e.g. cutting up a USB 3.0 cable or using jumper wires), you must use a short cable to ensure reliable operation.

This is because IΒ²C is not really designed to be used over lengths of cable, and so signal degradation can occur due to capacitance in the cable and/or signal reflection. If you experience a corrupted OLED screen display or erratic synth switching behavior (e.g. as in issue #59), try a shorter cable.

The maximum USB cable length that has been tested successfully is ~50cm, and so this should be considered an "extreme" configuration. It is recommended that you try to find a cable <30cm long for a reliable connection. Anything longer is very likely to fail, so please consider this carefully when choosing a cable. Some users have used short jumper wires and still experienced failures because of poor quality of the wires and lack of shielding.

The following USB cables have been tested by users of the MiSTer HAT PCB.

Name Length Success? Comments
ADT-LINK USB 3.0 flat cable 5-20cm ❌ I²C corruption. 5cm, 10cm, 15cm, and 20cm all fail. Tested by @anakin.
AFUNTA A-A USB 3.0 adaptor N/A βœ” Sold by Amazon in several countries. Note: tested with adapter only, no cable! Tested by @bzeiss.
Good Connections black A-A 50cm ❌ I²C corruption. Tested by @bzeiss.
InLine USB 3.0 cable, A-A (35203) 30cm βœ” Tested by @bzeiss.
Innov8 black right-angle A-A 15cm βœ” Tested by @dwhinham.
Innov8 blue A-A 50cm βœ” Tested by @dwhinham.
Innov8 white A-A 30cm βœ” Tested by @dwhinham.
TUPower TP-U3-K55 50cm ❌ Sold by Amazon DE. I²C corruption/OLED screen black. Power & I²S ok. Tested by @bzeiss.
USB 3.0 extension with AFUNTA A-A USB 3.0 adaptor 15cm βœ” Tested by @anakin.
Ugreen 10369 50cm ❌ Sold on Amazon US as "1.5ft". I²C corruption. Tested by @dwhinham.
Ugreen 80789 50cm ❌ I²C corruption. Tested by @anakin.
deleyCON black/blue A-A 50cm ❌ I²C corruption. Tested by @anakin.

Setup

Follow the quick-start guide in the main README, but ignore the last two steps regarding MIDI and audio connections.

You must ensure the following options in your mt32-pi.cfg are set to make the MiSTer user port interface fully functional. The rest of the settings are assumed to be set to the defaults.

[audio]
output_device = i2s

[control]
# Required for physical buttons
scheme = simple_buttons

# Required for OSD controls
mister = on

[lcd]
# Required for OSD "LCD-On" and "LCD-Auto" modes even if you don't have a real OLED display connected 
type = ssd1306_i2c

# You can use either 32 or 64 pixel height
height = 64

Usage

  1. Connect the Raspberry Pi to the user port on the MiSTer and switch it on. mt32-pi should start up.
  2. If you see Low voltage! Chk PSU on the Raspberry Pi's LCD, see the next section.
  3. On the MiSTer, start a core that includes mt32-pi support (currently AO486, Atari ST, or Minimig).
  4. You should see the MiSTer logo appear on the Raspberry Pi's LCD briefly - this means that IΒ²C communications between Pi and MiSTer are working.
  5. mt32-pi is now ready for use - try some games!

MiSTer OSD options

If mt32-pi is detected by the MiSTer, a new "MT32-pi" submenu will appear in the MiSTer's OSD.

When changing these options, remember to save your configuration to ensure they persist.

  • Use MT32-pi: Enables/disables MIDI output to mt32-pi.
  • Show Info: Selects OSD information display mode.
    • No: Disables information display.
    • Yes: Brief "pop-up" notifications (similar to video mode/joystick notifications) are shown when mt32-pi's synthesizer/MT-32 ROM/SoundFont are changed, e.g. via button press, or sending a custom SysEx message from within the core.
    • LCD-On(non-FB): Shows a copy of mt32-pi's LCD display on your MiSTer's video output (may not work for certain higher-resolution video modes).
    • LCD-Auto(non-FB): As above, but automatically hides when the display is idle.
  • Default Config section: Allows you to set the synth, MT-32 ROM and SoundFont you'd like the core to start up with. mt32-pi will switch immediately when you change these from the OSD, and will also switch when the core is re-loaded.
  • Current Config: Shows the currently selected configuration as reported by mt32-pi. This may not necessarily match the Default Config above if you have changed the configuration from a button press or custom SysEx message.
  • Reset Hanging Notes: Tells mt32-pi to switch off all notes on all synthesizers. Useful for if a game crashes and you want to silence any stuck notes.

πŸ’‘ Tip: If you reset the AO486 core using CTRL-ALT-ALT instead of CTRL-ALT-DEL, a core hardware reset will be performed, and mt32-pi will silence all notes. This may be a more convenient way to recover from a crashed system with hanging notes.

Low voltage warnings

It is possible that some voltage drop may occur if the Raspberry Pi is being powered by the MiSTer, which could cause mt32-pi to display Low voltage! Chk PSU on the LCD. Although it's not ideal, in practice there shouldn't be any issues so long as the voltage reaching the Pi isn't too far below +4.8V.

This message is triggered by the Raspberry Pi's GPU-based firmware, which will also throttle the CPU when it notices a low voltage condition. This will cause the audio to stutter. This mechanism exists to prevent data loss when using the Raspberry Pi as a computer, but for mt32-pi we should be able to safely disable it.

To do this, edit your config.txt and add the following line above the [pi3] section. This disables the warnings and the throttling:

avoid_warnings=2

⚠ Note: This is not recommended; a better solution would be to find a stronger PSU that doesn't suffer as much voltage drop under load, and/or a less resistive cable between the user port and the Raspberry Pi. Please ensure your Raspberry Pi's CPU is heatsinked, as it's not known if this option disables thermal throttling!

Alternatively, you can cut the +5V connection between MiSTer and Raspberry Pi, and use a dedicated power supply for the Raspberry Pi. If you use the MiSTer HAT, simply turn off the switch to achieve this.

⚠ Note: Make sure you turn off the switch when powering the Raspberry Pi externally. Otherwise, the Pi's PSU will begin powering the MiSTer, resulting in further loss of power to the Pi.

Pinout

Use this pinout if you'd like to build your own custom MiSTer interface.

  • The leftmost five columns are for when constructing a USB cable to connect between the user port and a Raspberry Pi.
  • If you want to connect a DE-10 Nano directly to a Raspberry Pi without an I/O board or USB cable, use the rightmost two columns and refer to your DE-10 Nano's manual for the pin positions.
  • You can omit some of the connections if you don't want certain features. For example, if you don't want to use the MiSTer OSD integration, don't connect the IΒ²C SDA and SCL signals. If you don't want to send audio back to the MiSTer for mixing, don't connect any of the IΒ²S signals.
  • You can connect a real SSD1306 OLED display too, if you'd like to have both a real display and make use of the OSD integration. Just connect your display as usual to the IΒ²C SCL and SDA signals of both the Pi and the MiSTer.
USB pin (user port) USB signal name* MiSTer signal name* Wire color‑ Raspberry Pi pin DE-10 Nano Arduino pinΒ§
1 VBUS +5V Red 2† VCC5
2 D- TX (MIDI out) White 10 SDA
3 D+ IΒ²C SDA Green 3 SCL
4 GND GND Black 6 GND
5 RX- IΒ²S DAT Blue or Purple 40 D10/SS
6 RX+ IΒ²S BCLK Yellow or Orange 12 D11/MOSI
7 GND_DRAIN IΒ²C SCL Bare wire 5 D12/MISO
8 TX- IΒ²S WS Purple or Blue 35 D13/SCK
9 TX+ RX (MIDI in) Orange or Yellow 8ΒΆ D8

Notes

  • * Signal names are as seen from the MiSTer side (i.e. USB pin 2 is MIDI out FROM the MiSTer). The "USB signal name" is simply for cross-referencing the original purpose of the USB pin; the "MiSTer signal name" is what is actually being delivered on that pin.
  • † Do not connect +5V if you want to use an external power supply for the Raspberry Pi.
  • ‑ Wire colors for the RX and TX differential pairs could be swapped depending on which half of a cut USB cable you may be using.
  • ΒΆ Optional, not currently used by mt32-pi.
  • Β§ This column is for connecting a DE-10 Nano directly to a Raspberry Pi. Refer to page 30 of the DE-10 Nano User Manual to locate the pin positions.
Clone this wiki locally