Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ download-binutils-gdb: $(SRCS)
https://github.com/richlowe/binutils-gdb $(SRCS)/binutils-gdb

download-illumos-gate: FRC
git clone -b arm64-gate https://github.com/richlowe/illumos-gate
git clone -b arm64-gate https://github.com/mintyray/illumos-gate

download-u-boot: $(SRCS)
git clone --shallow-since=2019-01-01 -b v2022.10 \
Expand Down Expand Up @@ -346,6 +346,9 @@ rpi4-disk: $(PWD)/out/illumos.zfs

disk: qemu-disk rpi4-disk

nfs: illumos
ksh tools/build_nfs.sh

$(BUILDS):
mkdir -p $@
$(STAMPS):
Expand Down
168 changes: 168 additions & 0 deletions tools/README.nfs
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
# Illumos rpi4 NFS server setup
# based on n-hys network boot and richlowe build_disk utility
# [email protected] 2023
#
#
#

Preapre NFS boot space
----------------------

# NFS boot space is a network boot disk for rpi. The files/packaes are identical with a disk setup provided by "make disk".
# with some rpi4 and network related stuff.

make nfs

1, The NFS direcorty arm-gate/nfs is prepared and data are owned by root, sudo root password is required
2, All installation using night build is done as for standard disk setup "make disk"
3, Datetime correct setup is configured as legaxy service S10rdate - required to continue with https access for ZFS install stages
4, Console driver is binded to rpi serial console instead of qemu pl101
5, SD card driver binded
...

# within arm-gate directory run:
make nfs

Time server preparation
-----------------------
pkg install service/network/legacy
svcadm enable time:dgram
svcadm enable time:stream


NFS Server setup on solaris omnios
----------------------------------

# Prepare the share, basic example, the setup can vary on the server configuration.
# The directory is in RW mode and root priviledges required yet.

sharemgr share -F nfs -o anon=0,sec=none,rw /home/minty/solaris1/arm64-gate/nfs
sharemgr enable default

DHCP Server preparation example
-------------------------------

# Note the MAC address entry and valid IPs for server, client and network.

/etc/inet/dhcpd4.conf

option space SUNW;
option SUNW.root-mount-options code 1 = text;
option SUNW.root-server-ip-address code 2 = ip-address;
option SUNW.root-server-hostname code 3 = text;
option SUNW.root-path-name code 4 = text;
option SUNW.swap-server-ip-address code 5 = ip-address;
option SUNW.swap-file-path code 6 = text;
option SUNW.boot-file-path code 7 = text;
option SUNW.posix-timezone-string code 8 = text;
option SUNW.boot-read-size code 9 = unsigned integer 16;
option SUNW.install-server-ip-address code 10 = ip-address;
option SUNW.install-server-hostname code 11 = text;
option SUNW.install-path code 12 = text;
option SUNW.sysid-config-file-server code 13 = text;
option SUNW.JumpStart-server code 14 = text;
option SUNW.terminal-name code 15 = text;
option SUNW.standalone-boot-uri code 16 = text;
option SUNW.standalone-boot-http-proxy code 17 = text;

class "solaris" {
match if substring (hardware, 1, 3) = d8:3a:dd;
}

subnet 192.168.1.0 netmask 255.255.255.0 {
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.1.255;
option routers 192.168.1.254;
option domain-name-servers 192.168.1.254;
option domain-name "house.local";
default-lease-time 14400;
max-lease-time 172800;

vendor-option-space SUNW;
option SUNW.root-mount-options "rsize=32768";
option SUNW.root-server-hostname "omnios";
option SUNW.root-server-ip-address 192.168.1.6;
next-server 192.168.1.6;

group { # id="Solaris-ARMv8"
option SUNW.root-path-name "/home/minty/solaris1/arm64-gate/nfs";
host rpi4 {
option vendor-class-identifier "RaspberryPi,4";
option host-name "rpi4";
filename "/platform/RaspberryPi,4/inetboot";
fixed-address 192.168.1.92;
hardware ethernet d8:3a:dd:02:b2:e6;
}
}

}

# to run dhcp server in debug mode:
root# dhcpd -d -cf /etc/inet/dhcpd4.conf


TFTP server
----------
# Prepare the /tftp directory - link (example). The u-boot will try to download the file specified as "filename" in dhcpd.conf above.

/tftpboot -> /home/minty/solaris1/arm64-gate/nfs

# Enable the service:
pkg install tftp
svcadm enable tftp

online Jun_08 svc:/network/tftp/udp6:default

Rpi4 boot process:
------------------

# Load the inetboot

U-Boot> bootp
BOOTP broadcast 1
DHCP client bound to address 192.168.1.92 (1 ms)
Using ethernet@7d580000 device
TFTP from server 192.168.1.6; our IP address is 192.168.1.92
Filename '/platform/RaspberryPi,4/inetboot'.
Load address: 0x1000000
Loading: ################################################## 651.2 KiB
2.1 MiB/s
done
Bytes transferred = 666872 (a2cf8 hex)


# Set the boot device:
setenv bootargs "-D /scb/ethernet@7d580000"

# Boot the kernel from memory 0x1000000
U-Boot> bootm 0x1000000 - $fdt_addr

## Booting kernel from Legacy Image at 01000000 ...
Image Name: illumos
Image Type: AArch64 Linux Kernel Image (uncompressed)
Data Size: 666808 Bytes = 651.2 KiB
Load Address: 00080000
Entry Point: 00080000
Verifying Checksum ... OK
## Flattened Device Tree blob at 2eff2d00
Booting using the fdt blob at 0x2eff2d00
Working FDT set to 2eff2d00
Loading Kernel Image
Using Device Tree in place at 000000002eff2d00, end 000000002f0030ca
Working FDT set to 2eff2d00

Starting kernel ...

phys memory add 0000000000000000 - 000000003e5fffff
phys memory add 0000000040000000 - 00000000fbffffff
phys memory add 0000000100000000 - 000000017fffffff

<skip>

[ network/routing-setup:default starting (Initial routing-related configuration.) ]
[ milestone/sysconfig:default starting (Basic system configuration milestone) ]
[ system/filesystem/local:default starting (local file system mounts) ]
[ system/utmp:default starting (utmpx monitoring) ]
[ system/console-login:default starting (Console login) ]

rpi4 console login:
116 changes: 116 additions & 0 deletions tools/build_nfs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#!/bin/ksh93

set -e
set -x

MNT=$PWD/nfs
ROOT=$MNT
NFSIP=192.168.1.6

if [[ ! -f Makefile || ! -d illumos-gate ]]; then
print -u2 "$0 should be run from the root of arm64-gate"
exit 2
fi

mkdir -p $MNT
(cd $MNT && sudo rm -rf * )
# for reasons I can't fathom, synthetic packages don't get published right now
pkgsend publish -s illumos-gate/packages/aarch64/nightly/repo.redist \
illumos-gate/usr/src/pkg/packages.aarch64/osnet-incorporation.mog
pkgsend publish -s illumos-gate/packages/aarch64/nightly/repo.redist \
illumos-gate/usr/src/pkg/packages.aarch64/osnet-redist.mog

pkg image-create --full \
--variant variant.arch=aarch64 \
--set-property flush-content-cache-on-success=True \
--publisher $PWD/illumos-gate/packages/aarch64/nightly/repo.redist \
$ROOT

for publisher in omnios extra.omnios; do
pkg -R $ROOT set-publisher \
-g file:///$PWD/archives/omnios \
-g https://pkg.omnios.org/bloody/braich $publisher
done

# Install everything, to the degree that it is possible, for convenience since
# there's no pkg(8) in the image
sudo pkg -R $ROOT install --no-refresh \
--reject=osnet \
--reject=ssh-common \
'*@latest'

sudo sed -i '/^last_uuid/d' $ROOT/var/pkg/pkg5.image

sudo sed -i '/PermitRootLogin/s/no/yes/' $ROOT/etc/ssh/sshd_config

# Set up a skeleton /dev
sudo tar -xf tools/dev.tar -C $ROOT
sudo touch $ROOT/reconfigure

# Without mdb(8) or kmdb(8) kmem debugging is much less useful, and much too
# slow in the emulator. This is KMF_DEADBEEF|KMF_REDZONE
echo "set kmem_flags = 0x6" | sudo tee -a $ROOT/etc/system > /dev/null

# Don't require passwords
sudo sed -i 's/PASSREQ=YES/PASSREQ=NO/' $ROOT/etc/default/login

# Have a host name etc, in case dhcp
echo "rpi4" | sudo tee -a $ROOT/etc/nodename > /dev/null
sudo sed -i 's/localhost/localhost rpi4/' $ROOT/etc/inet/hosts

# Put the SMF profiles in place
sudo ln -s ns_files.xml $ROOT/etc/svc/profile/name_service.xml
sudo ln -s generic_limited_net.xml $ROOT/etc/svc/profile/generic.xml
sudo ln -s inetd_generic.xml $ROOT/etc/svc/profile/inetd_services.xml
sudo ln -s platform_none.xml $ROOT/etc/svc/profile/platform.xml

# Import all the services ahead of time. This is a shame, because allowing
# EMI to happen has found many bugs, but it also takes _forever_
SVCCFG=illumos-gate/usr/src/tools/proto/root_i386-nd/opt/onbld/bin/i386/svccfg
if [[ ! -x $SVCCFG ]]; then
SVCCFG=illumos-gate/usr/src/cmd/svc/svccfg/svccfg-native
fi
SVCCFG_REPOSITORY=/tmp/arm-gate.$$

cp $ROOT/lib/svc/seed/global.db $SVCCFG_REPOSITORY
chmod u+w $SVCCFG_REPOSITORY
env PKG_INSTALL_ROOT=$ROOT \
SVCCFG_DTD=$ROOT/usr/share/lib/xml/dtd/service_bundle.dtd.1 \
SVCCFG_REPOSITORY=$SVCCFG_REPOSITORY \
SVCCFG_CHECKHASH=1 $SVCCFG import \
-p - $ROOT/lib/svc/manifest
# -p /dev/stdout $ROOT/lib/svc/manifest
sudo cp -a $SVCCFG_REPOSITORY $ROOT/etc/svc/repository.db
sudo chown root:sys $ROOT/etc/svc/repository.db
sudo chmod 0600 $ROOT/etc/svc/repository.db
rm -f $SVCCFG_REPOSITORY


#RPi4 device add
sudo rem_drv -b $ROOT pl011
sudo rem_drv -b $ROOT ns16550a
sudo add_drv -b $ROOT -i "arm,pl011" ns16550a
sudo add_drv -b $ROOT -i "brcm,bcm2711-emmc2" bcm2711-emmc2

#Fix rootfs for NFS
echo "$NFSIP:$ROOT - / nfs - no -" | sudo tee -a $ROOT/etc/vfstab

#Fix missing RTC for Rpi contacting the NFS server for rdate during the boot
#note - services svc:/network/time:dgram, svc:/network/time:stream must be enabled on NFS server
echo "/usr/bin/rdate $NFSIP" | sudo tee $ROOT/etc/init.d/rdate
sudo chown root:sys $ROOT/etc/init.d/rdate
sudo chmod 744 $ROOT/etc/init.d/rdate
sudo ln $ROOT/etc/init.d/rdate $ROOT/etc/rc2.d/S10rdate

# Create a boot_archive manually, because tooling
(cd $ROOT;
sudo mkisofs -quiet -graft-points -dlrDJN -relaxed-filenames -o ./platform/armv8/boot_archive \
$(boot/solaris/bin/extract_boot_filelist -R $ROOT -p aarch64 boot/solaris/filelist.ramdisk | \
(while read file; do [[ -e $file ]] && echo $file; done) | \
awk '{printf("/%s=./%s\n", $1, $1);}'))

#cp illumos-gate/proto/root_aarch64/platform/QEMU,virt-4.1/inetboot.bin qemu-setup

# Prepare installation scripts for ZFS
sudo mkdir $ROOT/var/install
sudo cp tools/dev.tar $ROOT/var/install