wm: doc

ref: dcfe2d38c6d53dfd6a1bbcf1ec6c5fcdbce8847b
dir: /cpu-rpi-p9.ms/

View raw version
Configure the cpu server for plan 9 on Raspberry Pi

First add your user to the adm group. See fossil-p9.

Afterwards, set your timezone, see timezone-p9.ms.

Next, make sure to configure your network information. See ndb-p9.ms.

Now, we prepare rc scripts that must run on system bootup:

term% mkdir /cfg/$sysname/
term% dircp /cfg/example /cfg/$sysname/

Now, we need to configure networking. On Raspberry Pi, we are using wifi
and dynamic networking, so we need to add these lines:

bind -a '#l1' /net
echo 'key proto=wpapsk essid=ESSID !password='^`{cat /lib/wpa/ESSID} > /mnt/factotum/ctl
aux/wpa -2 -s 'ESSID' /net/ether1
ip/ipconfig ether /net/ether1

Replace ESSID and make sure to store the wifi password in /lib/wpa/ESSID.
For wifi on Raspberry Pi boards, see rpi-wifi-p9.

Note: You also want to copy these lines to /cfg/$sysname/termrc and also to run the
command manually, because by default, plan 9 runs as a terminal service. It will not
run as a cpu service until the cpu kernel has been compiled as described below.

Note: You *must* run ip/ipconfig before running ndb/dns (and possibly other
network services). Otherwise, you might see errors like:

ndb/dns: can't read my ip address

term% auth/wrkey
bad authentication password
bad authentication id
bad authentication domain
authid: glenda
authdom: example.com
auth password:
secstore password:

Make sure to configure the auth server, see auth-p9.ms.

Build the cpu kernel:

% cd /sys/src/9/bcm
% mk 'CONF=picpu'
% dossrv; mount /srv/dos /n/9fat /dev/sdM0/dos
% cp /sys/src/9/bcm/9picpu /n/9fat/

This guide was written for the Raspberry Pi Zero WH. You may need to
replace picpu with pi2cpu, or pi4cpu, depending upon your specific model.

Edit config.txt to use the new kernel. For RPI Zero WH, the [pi1] block
should reads as follows:

[pi0]
kernel=9picpu

Edit cmdline.txt to specify the location of nvram. On RPI Zero WH,
cmdline.txt might read as follows:

readparts=1 nobootprompt=local console='0 b115200' ether1=type=4330 nvram='#S/sdM0/nvram' sysname=rpi

You will want to replace rpi with your desired sysname.

Make sure cmdline.txt is only one single line!

You may need to reboot so nvram is detected correctly.

Now clear nvram and then set a new password:

% echo garbage >/dev/sdM0/nvram

Set the password:

term% auth/keyfs

Add the hostowner pi to sys and adm groups:

term% con -Cl /srv/fscons
prompt: uname pi pi
prompt: uname sys +pi
prompt: uname adm +pi
prompt: fsys main
main: create /active/cron/bootes bootes bootes d775
main: create /active/sys/log/cron bootes bootes a664

Append these lines to the bottom of /lib/ndb/auth:

hostid=pi
       uid=!sys uid=!adm uid=*

You may need to reboot and login as hostowner (bootes) in order for
the next step to work.

When prompted, fill in the following values:

authid: glenda
authdom: example.com
auth password:
secstore password:

Check that you are using the cpu kernel:

% echo $service
cpu

Change the hostowner's password:

term% auth/keyfs
auth/changeuser glenda

If you are using 9front drawterm and want to connect in text-only mode
(no graphics) with the -G flag, you will need to edit $home/lib/profile
to remove calls to rio. Comment out line 31:

#		exec rio

You can run the below command:

term% mv (/usr/$user/lib/)^(profile profile.bak)
term% sed '31s/^/#/' /usr/$user/lib/profile.bak > /usr/$user/lib/profile

Then afterwards, you will be able to connect with drawterm -G as
follow:

$ drawterm -u $USER -h $SYSNAME -G

See also:

https://plan9.io/wiki/plan9/Configuring_a_Standalone_CPU_Server/index.html
https://9p.io/wiki/plan9/Drawterm_to_your_terminal/index.html
http://mirror.9grid.fr/mirror.9grid.fr/plan9-cpu-auth-server-howto.html