Skip to content

Latest commit

 

History

History
219 lines (163 loc) · 9.58 KB

1-Setup-Raspberry_Pi.md

File metadata and controls

219 lines (163 loc) · 9.58 KB

Table of Contents
Hardware
Setting up the Raspberry Pi
The INI files
Alternative serial setup
Media
Commands
NetworkManager
Bugs and things to do
License


Hardware

You obviously need a Rasoberry Pi. This is descibed in it's own chapter.
I'm using this display (not an affiliate link) as it's BIG in size, using HMDI and sound and fits my idea of a Marquee display. Any HDMI display will do in principle, but you'll need to have and use appropriate media files then.
A new feature was added at the end of 2023: You can now use almost any SPI, DSI and DPI display. See /boot/config.txt.example for some examples.


Setting up the Raspberry Pi

I assume that you are already familiar with setting up a Raspberry Pi. We are going to using Debian Bookworm, the current version of Debian

Obviously you need a Raspberry Pi. Any model except the Pico will do, but remember that - even a RPi1 will do a fine job - the faster the RPi is, the more responsive your experience will be. From my personal experience a good minimum is the RPi2, better would be a RPi3. A good choice regarding price/power a RPi 3A+

Download and start the Raspberry Pi Imager, insert a SD card, choose your Raspberry Pi Model, the OS version (standard 32- or 64-bit w/o desktop ("Lite") recommended) and the SD card you want to write to. Click on the button Next.
Click on the first button to edit settings as shown below, but be sure to set your own WiFi credentials & country and time zone 😉

General Settings Services Settings

Insert the SD into your RPi, connect all needed cables and devices and boot up your RPi.
If not already done with the Raspberry Pi Imager: Follow the instruction shown on the screen and setup your user and password. For simplicity you can create a user tty2rpi (see also at end of this paragraph). Enable and setup WiFi if you want to use it.

Update your Raspberry Pi OS and install the following packages:

sudo apt install mc dos2unix rsync git bc inotify-tools netcat-openbsd flex bison p7zip-full readline-common ncurses-base xorg xserver-xorg-video-fbdev openbox imagemagick vlc ffmpeg feh fim mplayer mpv

Disable avahi (optional):

sudo systemctl disable avahi-daemon.service avahi-daemon.socket

Enable SSH (it not already done in the RPi imager):

sudo systemctl enable ssh.service

Get and run the install/update script:

wget https://raw.githubusercontent.com/ojaksch/MiSTer_tty2rpi/main/update_tty2rpi.sh -O - | bash -

Files that will be created;

  • /boot/firmware/cmdline.txt.example -- compare with your existing cmdline.txt. The only relevant changes here are the parameters quiet and cfg80211.ieee80211_regdom=COUNTRYCODE. See here for a list of WiFi regulatory domains.
  • /boot/firmware/config.txt.example -- compare with and edit your existing config.txt. Changes are:
...
#dtoverlay=vc4-kms-v3d
...
[all]
disable_splash=1

Use dtoverlay=vc4-kms-v3d for a standard HDMI setup or #dtoverlay=vc4-kms-v3d for other display types and have a look above the # ----------- line for examples.

  • /etc/X11/xorg.conf.d/10-monitor.conf -- Monitor config file that disables DPMS
  • /tmp/home/tty2rpi/ -- User files that will be copied to the user you have created - this is "the engine"
  • /usr/local/bin/ -- Needed and needful programs

Read on the next chapters for the media content and a readup of the INI fles. When done, just reboot your RPi and continue with setting up the MiSTer


Alternative serial setup

If your going not to use WiFi (or whatever your intention is), you can use a serial connection. Buy and use a simple USB2Serial adapter, connect the USB part to your MiSTer and the loose cables to the RPi as shown below, but do not use the red wire which is carrying a voltatge of 3V or 5V and might destroy your RPi!

Connection scheme

  • Edit RPi's /boot/firmware/cmdline.txt and change the part console=serial0,115200 to console=tty1
  • Edit /boot/firmware/config.txt and enable the last two line so they're reading
[all]
enable_uart=1
dtoverlay=disable-bt
  • In ~/tty2rpi-user.ini set SERIALSOCKET="yes"
  • Disable Bluetooth modems which are connected via UART
    sudo systemctl disable hciuart
  • Don't forget to set two parameters in MiSTer's /media/fat/tty2rpi/tty2rpi-user.ini:
TTYDEV="/dev/ttyUSB0"
TTYPARAM="115200 cs8 raw -parenb -cstopb -hupcl -echo"

The INI files

There are two INI files: tty2rpi.ini and tty2rpi-user.ini which are read and evaluated by the daemon in that order. tty2rpi-user.ini is overwriting values done by tty2rpi.ini
tty2rpi.ini contains the system wide variables and definitions. Do not edit this file as it will be overwritten when doing an update!
For your own favorite variables please use tty2rpi-user.ini and take over and edit the needed line from tty2rpi.ini. All useful variables are commented - see "# Userdata" in tty2rpi.ini


Media

You can create and use your own media files or get all the Marquee pictures from progetto-SNAPS (or search for MAME's marquees.zip - there are many similar projects providing HQ Marquee sized images) and the Marquee videos from Arcade Punks and store them on you RPi's SD card, on your NAS or wherever you want, as long as they are accessable by the OS' file system. Don't forget to mount the file system if needed and set their destination variables in $HOME/tty2rpi-user.ini
The default set in tty2rpi.ini is

PATHPIC="${HOME}/marquee-pictures"
PATHVID="${HOME}/marquee-videos"

for RPi's SD in your created user's home.

You'll find some additional media files in the folder media_files_rpi of this repository. Copy the pictures to your created PATHPIC and MISTER-MENU.mp4 to PATHVID, but renamed to MENU.png and MENU.mp4 when you are setting up tty2rpi for MiSTer, otherwise, when setting up tty2rpi for MAME, copy MAME-MENU.png and MAME-MENU.mp4 without renaming it.

Paths are now predefined and already filled with some files for easier setup. Don't forget to copy these files to another folder or mount point, if changed by you.


Commands

The commands available on RPi's side are handled by the Daemon (tty2rpi.sh) itself and are flexible...just create a file with the name of the command plus the extension of ".sh" (e.g. ~/tty2rpi-scripts/CMDHELLO.sh), set file's attribute to "executable" and copy/write your script into that file. That's easy, isn't it?

Send the command from your client through the defined TCP socket (e.g.

echo "CMDHELLO,1st_parameter,2nd_parameter" > /dev/tcp/IP-ADDRESS-OF-RPI/6666)

As you can see, (many) parameters are possible and a comma sign is used as separator. No spaces are allowed as they're also interpreted as separator.
Have a look at the already existing scripts in ~/tty2rpi-scripts/ to get an idea.

Available commands:

Command Description
CMDCOR§PARAM§PARAM Shows a video and/or picture named PARAM
CMDSHOWCPU Shows CPU informations
CMDSHOWIPS Shows RPi's IP address(es)
CMDSHUTDOWN Shutdown the RPi

NetworkManager

Debian Bookworm is now the actual version for our Raspberry's. If you are going to upgrade to Bookworm, you may stumble about a change how networking is done now as they are using NetworkManager for managing networks.

For WiFi setups: After upgrading but before rebooting, create a file named /etc/NetworkManager/system-connections/wlan.nmconnection and copy and edit this code snipped

[connection]
id=YourOwnSSID-Or-Name
uuid=26cbd98d-c857-4b9e-a313-0a07bea76d55
type=wifi
interface-name=wlan0

[wifi]
mode=infrastructure
ssid=YourOwnSSID

[wifi-security]
auth-alg=open
# for WPA2 or mixed WPA2/WPA3
key-mgmt=wpa-psk
# for WPA3
# key-mgmt=sae
psk=YourVeryStrongAndSecretPassword

[ipv4]
method=auto

[ipv6]
addr-gen-mode=default
method=auto

[proxy]

Edit id, ssid and psk for your needs, quit editor, set the correct file mode bits and disable wpa_supplicant

chmod 600 /etc/NetworkManager/system-connections/wlan.nmconnection

Reboot and all should work.

  • Revise and publish the documentation for MAME

Bugs and things still to do

  • If your are getting a blank screen only after booting, you could try to set one or all HDMI related settings in config.txt: hdmi_safe, hdmi_force_hotplug and hdmi_drive Another hint, especially when using a RPi5, could be to set vc4.force_hotplug=3 in cmdline.txt - see that issue we had in the past.

License

CC BY-NC-SA 4.0
Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)