#!/bin/rc ISO=/usr/web/9legacy.iso SDIMG=/tmp/9legacy.rpi SDBLOCKS=7743330 # for a 4GB SD card #SDBLOCKS=3855600 # for a 2GB SD card SDCYLS=`{hoc -e $SDBLOCKS/255/63} test -f /srv/9660 || 9660srv mount /srv/9660 /n/cd $ISO # partition the SD card image dd -if /dev/zero -of $SDIMG -bs 512 -count 1 aux/disksim -f $SDIMG echo geometry $SDBLOCKS 512 $SDCYLS 255 63 >/dev/sdXX/ctl disk/mbr /dev/sdXX/data {echo a p1 0 8; echo t p1 FAT32; echo a p2 8 '$'; echo w} | disk/fdisk -b /dev/sdXX/data {echo a nvram 2551 2552; echo a fossil 2552 '$'; echo w} | disk/prep -b /dev/sdXX/plan9 # format and populate the dos partition for booting all raspberry pi models disk/format -b /386/pbs -df /dev/sdXX/dos rm -f /srv/dos.rpi dossrv -f/dev/sdXX/dos dos.rpi mount -c /srv/dos.rpi /n/dos cd /n/dos RPI=(LICENCE.broadcom bcm2711-rpi-4-b.dtb bcm2711-rpi-400.dtb bootcode.bin fixup.dat fixup4.dat fixup4cd.dat fixup_cd.dat start.elf start4.elf start4cd.elf start_cd.elf) for (i in $RPI) { echo $i hget https://github.com/raspberrypi/firmware/raw/stable/boot/$i >x && mv x $i } echo >cmdline-demo.txt 'readparts=1 nobootprompt=local user=glenda' echo >cmdline-term.txt 'readparts=1 nvram=#S/sdM0/nvram ipconfig=' echo >cmdline-cpu.txt 'readparts=1 nvram=#S/sdM0/nvram bootargs=local!#S/sdM0/fossil' echo >cmdline-wifiroot.txt 'ether1=type=4330 essid=WHATEVER wificrypt=wpa2 fs=N.N.N.N auth=N.N.N.N' cp cmdline-demo.txt cmdline.txt cat >config.txt <LICENCE <>/srv/fscons.rpi mount -c /srv/fossil.rpi /n/fossil.rpi cd /n/fossil.rpi # copy the Plan 9 tree from cd to fossil, without 386 or amd64 binaries for (d in 386 amd64) { bind /n/cd/mips/bin /n/cd/$d/bin bind /n/cd/mips/lib /n/cd/$d/lib bind /n/cd/acme/bin/mips /n/cd/acme/bin/$d for (f in /n/cd/$d/9*) bind /dev/null $f } disk/mkfs -a -s /n/cd /n/cd/dist/replica/plan9.proto | disk/mkext -ud . echo users -w >>/srv/fscons.rpi echo fsys main create /active/usr/glenda/bin/arm glenda glenda d775 >>/srv/fscons.rpi for (d in 386 amd64) rm $d/9* rm -f 9load bootdisk.img pbsraw # adjust some config files for convenience of rpi users ape/patch -p1 <<'XXX' --- /n/sources/usr/glenda/bin/rc/riostart Tue Apr 16 17:23:12 2002 +++ /usr/glenda/bin/rc/riostart Thu Jun 24 20:01:42 2021 @@ -6,6 +6,10 @@ window 0,0,161,117 stats -lmisce window 161,0,560,117 faces -i +window -scroll -r 560 0 $wid 117 ' + label console + echo ''Console output (/dev/kprint):'' + cat /dev/kprint' if(~ `{screensize} small) dump=acme.dump.small --- /n/sources/usr/glenda/lib/profile Fri Jan 7 20:11:03 2005 +++ /usr/glenda/lib/profile Mon Apr 9 20:28:42 2018 @@ -6,6 +6,11 @@ font = /lib/font/bit/pelm/euro.9.font upas/fs fn cd { builtin cd $* && awd } # for acme + +# make vfp the default for ARM +fn 5l { /$cputype/bin/5l -f $* } +fn pcc { /$cputype/bin/pcc -f $* } + switch($service){ case terminal plumber --- /n/sources/sys/lib/newuser Sat Apr 13 00:28:29 2013 +++ /sys/lib/newuser Mon Apr 9 20:28:38 2018 @@ -21,6 +21,11 @@ bind -a $x^home/bin/$x^cputype /bin bind -c $x^home/tmp /tmp font = /lib/font/bit/pelm/euro.9.font + +# make vfp the default for ARM +fn 5l { /$x^cputype/bin/5l -f $x^* } +fn pcc { /$x^cputype/bin/pcc -f $x^* } + switch($x^service){ case terminal plumber XXX # to avoid 5-minute dhcp delay if not connected to a network, undo patch termrc-ipconfig, # and instead use the ipconfig env variable to control network initialisation: for example # ipconfig= (starts ipconfig with no arguments, to use dhcp) # ipconfig=-N (get network parameters by searching ethernet address in /lib/ndb) # ipconfig='-g N.N.N.N ether /net/ether0 N.N.N.N' (set local and gateway addresses) # if ipconfig env variable is undefined, don't run ipconfig automatically from termrc hget http://9legacy.org/9legacy/patch/termrc-ipconfig.diff | ape/patch -R -p1 ape/patch -p1 <<'XXX' --- /n/sources/rc/bin/termrc.local Fri Nov 8 22:56:06 2013 +++ /rc/bin/termrc.local Mon Jun 23 20:02:37 2014 @@ -11,3 +11,12 @@ facedom=FACEDOM # replace CPU with the name of your cpu server cpu=CPU +# start network if ipconfig variable is set +if(test ! -e /net/ipifc/0/ctl -a -e /env/ipconfig) { + echo -n ipconfig... + eval ip/ipconfig $ipconfig + echo +} +TIMESYNCARGS='' +if(test -e /net/ipifc/0/ctl) + TIMESYNCARGS=(-n pool.ntp.org) XXX echo fsys main sync >>/srv/fscons.rpi