Linux_Example


Setting up a Pi0w for headless (no monitor connected to the Pi0) access via SSH over WiFi, configuring to run the PiTrex software correctly using the pitrex-config.sh script, and installing the PiTrex development environment. See the software guide for details and alternative set-up options.

From a PC running Linux. The SD card/adapter is connected and identified as /dev/sdc (can check with "fdisk -l"). Installation and access is also possible from Windows/Mac, but may require extra software to be installed on the PC first.

Download Raspberry Pi OS from the official download page outlink.

$ unzip -p 2020-08-20-raspios-buster-armhf-lite.zip | dd of=/dev/sdc bs=1024 conv=fsync


If your system mounts to "/mnt" or somewhere other than "/media", change commands to suit.

$ mount /media/sdc1
$ cd /media/sdc1


Create wpa_supplicant.conf file according to the official guide outlink.

$ touch ssh
$ cd
$ umount /media/sdc1


Remove SD card, insert in Pi0w, apply power to Pi0w (can be from the Vectrex if already connected).

$ ssh pi@raspberrypi


Or find IP address that has been assigned to the Pi by your wireless router and:

$ ssh pi@<Pi IP address>


Default password: raspberry

$ passwd


Set new password.

$ wget https://www.ombertech.com/cnk/pitrex/ftp/cnk/pitrex%2dconfig.sh
$ chmod u+x pitrex-config.sh


Note that this will disable HDMI and Composite video output. If you still want these to work, then run pitrex-config.sh with the "-configonly" parameter and always start games using the PLAY script (eg. "sudo ./DRAWSHIPS" instead of "sudo ./drawships").

$ sudo ./pitrex-config.sh -y
$ sudo reboot


$ ssh pi@raspberrypi

or

$ ssh pi@<Pi IP address>


$ sudo apt-get update


This installs dependencies for building everything. You can get away with just "sudo apt-get install git" if you don't want to build VMMenu (libsdl2) or the SVGAlib-Vectrex games (alsa-oss).

$ sudo apt-get install git libsdl2-2.0-0 libsdl2-dev libsdl2-mixer-2.0-0 libsdl2-mixer-dev alsa-oss
$ git clone https://github.com/gtoal/pitrex
$ cd pitrex


You can install ROMs for the emulators following instructions in README-ROMS.txt, after which you can build everything with:

$ make -f Makefile.raspbian


Or build only one program (even if you haven't got ROMs, so long as that program doesn't need any) with (for the hello_world example programs):

$ cd hello_world
$ make -f Makefile.raspbian


See the binaries that have been created (lowercase filenames without file extension, coloured green):

$ ls


Run binaries with, eg.

$ sudo ./drawships


Most programs can be exited by pressing Ctrl-C, or all four Vectrex controller buttons at once, or pressing the Vectrex's reset button.

Enable sound

Bluetooth Speaker

Note that bluetooth sound output doesn't seem to be working right with the SVGAlib-Vectrex games Zblast and Hyperoid. In fact Zblast seems to stuff it up until the next reboot.


Install the BlueALSA outlink package:

$ sudo apt-get install bluealsa
$ sudo service bluealsa start


Turn on the Bluetooth speaker, then configure using bluetoothctl as follows:

$ sudo bluetoothctl
power on
# agent on
# scan on


Your bluetooth speaker should now be identified after a time with a MAC address and its device ID eg:

Device 93:39:04:05:91:A0 CP-OW-18-127


The MAC address (93:39:04:05:91:A0 in the above example) is used to identify the device in the following commands to pair and enable it:

# pair 93:39:04:05:91:A0
# trust 93:39:04:05:91:A0
# connect 93:39:04:05:91:A0


You should now see confirmation that the device has connected, and can exit the bluetoothctl prompt with the command:

# quit


Now create the file /etc/asound.conf containing the text (again replacing the MAC address with your own):

defaults.bluealsa.service "org.bluealsa"
defaults.bluealsa.device "93:39:04:05:91:A0"
defaults.bluealsa.profile "a2dp"
defaults.bluealsa.delay 10000

pcm.!default {
type plug
slave {
pcm "bluealsa"
}
}


For quick confirmation that it's working, you can download a small WAV audio file and play it using aplay:

$ wget http://www.ombertech.com/cnk/octabeat/500Hz-1500HzSweep.wav
$ aplay 500Hz-1500HzSweep.wav


From now on your Pi0w should connect to that bluetooth speaker automatically. If not, try issueing the connect command in bluetoothctl again.

USB Audio Adapter

If you want to use a USB audio adapter for sampled sound output, connect it and then:

$ cat /proc/asound/cards

0 [Headphones     ]: bcm2835_headphonbcm2835 Headphones - bcm2835 Headphones
bcm2835 Headphones
1 [Device ]: USB-Audio - USB Audio Device
GeneralPlus USB Audio Device at usb-20980000.usb-1, full speed


Create file /etc/asound.conf containing text:

defaults.pcm.card 1
defaults.ctl.card 1


Use the number that matches your USB device listed in /proc/asound/cards (probably 1).

For quick confirmation that it's working, you can download a small WAV audio file and play it using aplay:

$ wget http://www.ombertech.com/cnk/octabeat/500Hz-1500HzSweep.wav
$ aplay 500Hz-1500HzSweep.wav

Build for Bare-Metal


$ sudo apt-get install gcc-arm-none-eabi binutils-arm-none-eabi


$ cd ~/pitrex


This builds everything, again you can build specific things by running within their own directories.

$ make -f Makefile.baremetal


Bare-Metal binaries are files in the program directories ending in ".img". Copy them manually to /boot:

$ sudo cp hello_world/drawships.img /boot/


You need to edit /boot/config.txt to add a line saying "kernel <image file>". Pointing it to the menu program (pitrex.img) and using that to launch other programs is usually easiest.

In most programs, pressing all four Vectrex buttons at once, or the Vectrex reset button, will return to the PiTrex Bare-Metal menu (if present).