pi.ms

plan 9 on pi

mkf

ABSTRACT

Tips for running plan 9 on raspberry pi


Raspberry pi is a single board computer made by raspberry pi foundation somewhere in UK. In 2012(?) Richard miller have made the plan 9, this is known as miller's pi. at some point 9front have imported miller's code. 9front have since got a 64-bit version of bcm kernel. this guide covers 9front, more info on miller's is appercited.

1 installtion



As time of writing by default 9front ships with hjfs on installation image and that image is sized 2Gb. You can dd (or cp, or whatever your prefered method may be) that into your sdcard. That's all.

Resizing the paritions



Hjfs however does not support growing a parition (gefs seems to be the only file system capable of doing so), Thus to do so. you may need to do a classic installation, there are many ways for it; but the easiest way is to install using a usb thumb drive.

2 ISSUES

audio



Raspberry Pi is odd, audio hardware in pi is perhaps the most odd part of it. Use usb audio cards if you can, but if you can't:
1.
3.5MM jack uses a PWM connected to arm core, and offers poor quality. However it is much simpler to write a driver for. Load on cpu sometimes casues noticable effects on PWM, and thus results in audiable and annoying noises.
2.
HDMI audio is much more sophisticated (or horribly complex, depending on your point of view), and uses a RPC protocol to communicate with broadcom core. which makes writing drivers much harder offers better audio.


There are two drivers for PWM, one is located under /n/extra/src/audiobcm.tgz and said to be working for first pi (bcm2385). I haven't tested it, but PWM audio interface have been realtively same since bcm2385 (with some minor improvments) from arm core's view point.

3 Wireless



9front has recently added support for raspberry pi's wifi. this supports 3+ and zero 2. zero too should work but requires changes to kernel. On pi 3 and zero, wireless card is ether0. source code for wireless driver is available in /sys/src/9/bcm/ether4330.c

4 USB



It's widely believe before raspberry pi 4 (that includes zero 2), they had nasty USB controllers, while they may (is there a case otherwise?) work well for keyboard, mouses and thumb drives, they may not work as well as expected for devices that need more power.

Also note that, USB controller can crash (is it a hardware limit?) if it gets too hot, using a heat sink and fan is recommended if you are you are going to use that raspberry pi's USB (which sadly, also includes ethernet, since it uses USB).

5 UART

6 Compiling a kernel



Kernels for pi port are located under /sys/src/9/bcm for 32-bit port (all raspberry pis) and /sys/src/9/bcm64 for 64-bit kernel (late revisions of pi 2, pi zero 2 and pi 3 and newer)
# 32 bit kernels (work on 64 bit pis as well)
cd /sys/src/9/bcm
mk 'CONF=pi'
mk 'CONF=pi2'

# 64 bit kernels:
cd /sys/src/9/bcm64
mk 'CONF=pi3' # for pi 3
mk 'CONF=pi4' # for pi 4

7 HDMI



Raspberry pi uses HDMI for video output. thankfully (or not), Firmware capable of handling framebuffer, and we use that. the only drawback there is we can't change resolution during run-time. to change it, first mount pidos partition (on 64-bit kernels you may need to mount dos instead):
; 9fs pidos
And then add the following into your config.txt file:
[all]
hdmi_blanking=1
hdmi_group=2
hdmi_mode=51
framebuffer_depth=32


First line means this configuration will be applied to all raspberry pi models. This is handy for when you share same sd card between several boards. hdmi_blanking will blank your monitor when not in use, see mouse(3) man page to see how to use it. The lines hdmi_group and hdmi_mode are used to set type of display (TV or monitor) and resolution of such. see raspberry pi documention for more info on those. Lastly framebuffer_depth is for amount of colors you have, 32 means 32-bit color, default value is 16.