Installing Debian Bookworm on the GlobalScale MOCHAbin
I backed the kickstarter for the MOCHAbin back in 2021 and mine arrived towards the end of 2022. I didn't do anything with it for a little while assuming there'd be some more documentation and updates for the slightly crusty Ubuntu 18.04 image and custom kernel it shipped with, but this hasn't appeared, and there's been very little in documentation which is a shame. Most annoyingly the kernel for this hasn't been updated for 2 years.
The hardware is interesting, based around at Marvell ARMADA 7040 1.4GHZ Quad Core A72 ARM processor, 10G SFP+ cage and some ethernet ports. There's also onboard m.2 for (SATA only) SSD support, another m.2 for a PCIE wireless card and a SATA port. It seems there are a few design compromises though:
- The group of 4 ethernet ports share a 2.5Gbps link to the CPU.
- The 1G RJ45 port and SFP cage are shared, so you can't use both.
- The 10G interface does have 10G to the CPU, but at best you'll get 3.5Gps out of the other ports, plus whatever you can get out of the wifi, if you use it.
This is fine for me, but something to be aware of.
I decided I wanted to try and get Debian Bookworm working with a more recent kernel, especially as the Marvell 7040 has mainline kernel support now. The debian install part was fairly simple, but getting the stock kernel working was a bit more painful as the default kernel that comes with the mochabin doesn't use an initrd. It turns out it's possible to make it use the debian initramfs though.
This is probably easier if you put the debian Debian on a separate SSD, but I repartitioned the internal MMC leaving 2GB with the original Ubuntu 18.04 Ubuntu install (/dev/mmcblk0p1) and a second partition for the Debian install (/dev/mmcblk0p2). The easiest way to shrink the 1st partision would be to boot off a USB stick or something. I used tmpfs and pivot_root, but I wouldn't recommend this unless you know what you're doing.
If you're installing to a separate SSD it'll likely be /dev/sda instead of /dev/mmcblk0
Install the tools you'll need to repartition / install:
apt install debootstrap parted
Partition the disk. This will be /dev/sda if you're using an SSD rather than the internal MMC.
parted --align=opt /dev/mmcblk0
mkpart
primary
2049M (in my case)
100% (use the remaining space)
Format and mount the filesystem:
mkfs.ext4 /dev/mmcblk0p2
mkdir /mnt/target
mount /dev/mmcblk0p2 /mnt/target
Install debian. You'll need to refer to 'testing' as the ancient ubuntu doesn't know about bookworm yet. Use armhf rather than arm64 if you want the 32bit OS.
debootstrap --arch arm64 testing /mnt/target http://ftp.uk.debian.org/debian
mount -t proc /proc /mnt/target/proc/
mount -t sysfs /sys /mnt/target/sys/
mount -o bind /dev /mnt/target/dev/
chroot /mnt/target /bin/bash
You're now logged in to the chroot. You can configure and install some things:
sed -i 's/testing/bookworm/g' /etc/apt/sources.list
apt update
apt install vim locales u-boot-tools
dpkg-reconfigure tzdata
dpkg-reconfigure locales
Set a root password so you can log in on the console:
passwd
Create a hook script to update the u-boot initrd when debian rebuilds the initramfs:
cat > /etc/kernel/postinst.d/zz-uboot << EOF
#!/bin/bash
version="$1"
# passing the kernel version is required
if [ -z "${version}" ]; then
echo >&2 "W: did not pass a version number"
exit 2
fi
mkimage -A arm64 -O linux -T ramdisk -d /initrd.img /boot/initrd >&2
EOF
chmod 755 /etc/kernel/postinst.d/zz-uboot
Install the stock debian kernel:
apt install linux-image-arm64
cp /usr/lib/linux-image-6.1.0-9-arm64/marvell/armada-7040-mochabin.dtb /boot/
You should also have a /boot/initrd file generated by the script in the previous step.
Create a symlink to the current kernel with the name u-boot is already expecting to use.
ln -s /vmlinuz /boot/Image
Reboot, then press a key to interrupt when instructed. Make a note of the existing settings:
printenv
You might also want to increase the bootdelay to make getting back into the u-boot menu easier:
setenv bootdelay 5
saveenv
I had my bootargs/bootcmd set to these for the supplied ubuntu image:
bootargs=$console root=/dev/mmcblk0p1 rw rootwait net.ifnames=0 biosdevname=0
bootcmd=mmc dev 0; ext4load mmc 0:1 $kernel_addr_r $image_name;ext4load mmc 0:1 $fdt_addr_r $fdt_name; booti $kernel_addr_r - $fdt_addr_r
Set new boot args for the next reboot. Don't run saveenv at this point - if it goes wrong, powercycle and the old defaults will be restored.
setenv bootargs '$console root=/dev/mmcblk0p2 rw rootwait net.ifnames=0 biosdevname=0'
setenv bootcmd 'mmc dev 0; ext4load mmc 0:2 $kernel_addr_r $image_name;ext4load mmc 0:2 $fdt_addr_r $fdt_name;ext4load mmc 0:2 $initrd_addr /boot/initrd; booti $kernel_addr_r $initrd_addr $fdt_addr_r'
If you're booting off an SSD then your device won't be mmc 0:2, you'll want 'scsi scan; scsi dev 0; ext4load scsi 0:1...
Worth checking your env variables match what mine were:
fdt_name=boot/armada-7040-mochabin.dtb
image_name=boot/Image
console=console=ttyS0,115200 earlycon=uart8250,mmio32,0xf0512000
Type 'boot' to start the boot process, then log in with the 'root' user and the password you set earlier.
I configured the single ethernet 'WAN' port for testing purposes in /etc/network/interfaces - this is eth2.
auto eth2
iface eth2 inet static
address 192.168.6.12/24
gateway 192.168.6.1
And remember to set nameservers in /etc/resolv.conf:
nameserver 192.168.6.3
nameserver 192.168.6.4
Run ifup eth2, and you should have networking.
The group of 4 ports seem to be lan0 to lan3 hanging off the switch chip attached to the 2.5Gbps eth1 interface, and the 10G SFP port is eth0. eth2 is shared between the 'WAN' 1G port and the 1G SFP cage.
Install ssh:
apt install openssh-server
You'll want to create another user and probably also set up ssh keys in /root/.ssh/authorized_keys - password auth is disabled for the root user.
Once you're happy it boots reliably, you'll want to reboot, reinterrupt u-boot, redo the setenv lines, then run:
saveenv
which will make the change persistent. Finally:
boot
To reboot back into your working device.
You'll probably want to update /etc/apt/sources.list as te format has changed slightly in bookworm:
deb http://deb.debian.org/debian bookworm main non-free-firmware
deb-src http://deb.debian.org/debian bookworm main non-free-firmware
deb http://deb.debian.org/debian-security/ bookworm-security main non-free-firmware
deb-src http://deb.debian.org/debian-security/ bookworm-security main non-free-firmware
deb http://deb.debian.org/debian bookworm-updates main non-free-firmware
deb-src http://deb.debian.org/debian bookworm-updates main non-free-firmware