Set up an EdgeRouter Pro as a Baserock MIPS development machine
This page describes how to setup a Ubiquiti EdgeRouter Pro (ERPro-8) to run a Baserock development image by default. The EdgeRouter is running on a Octeon II MIPS64.
The following parts are needed:
- Ubiquiti EdgeRouter Pro (ERPro-8)
- USB flash pen drive or USB HDD (32GB or more recommended)
- Serial cable, to connect to the EdgeRouter
Prepare the boot device
Get the MIPS64 Big Endian (mips64b) or Little Endian (mips64l) Baserock build system image from download.baserock.org
Prepare your boot device, with a first partition (boot) of type FAT and a second partition for the rootfs of either type btrfs or ext4 (recommended). Recommended sizes of the partitions are 128MiB for boot and 16GiB for the root. If you're going to compile on this drive, it's suggested that you also have a /src partition of at least 100GiB, but you can do that later.
mkfs.fat -n BRBOOT /dev/sdX1
mkfs.ext4 -L baserock /dev/sdX2
Now mount the two partitions:
mkdir /mnt/rootfs
mount LABEL=baserock /mnt/rootfs
mkdir /mnt/rootfs/boot
mount LABEL=BRBOOT /mnt/rootfs/boot
And then we unpack the image.
tar xf baserock-mips64b-rootfs.tar.xz -C /mnt/rootfs/
or
tar xf baserock-mips64l-rootfs.tar.xz -C /mnt/rootfs/
Enable the root file system
echo "LABEL=baserock / ext4 defaults 0 1" >> /mnt/rootfs/etc/fstab
Finally unmount the filesystems.
umount /mnt/rootfs/boot /mnt/rootfs
Booting the system
Connect to the EdgeRouter Pro using its CONSOLE
serial port with a terminal program, eg. PuTTY. The serial parameters are 115200bps 8 bits, no parity, 1 stop bit (115k2 8N1).
Connect the boot drive to the EdgeRouter's USB port, then power on the EdgeRouter.
Interrupt U-Boot when prompted Hit any key to stop autoboot
.
Type
usb start
If you get Device NOT ready
, repeat the command. Then type
fatload usb 0:1 0x20000000 vmlinux-4.0.0-rc7-g5201645
The kernel should then load. Finally type
bootoctlinux 0 numcores=2 endbootargs mem=0 root=/dev/sda2 rootwait
Baserock should then boot to a login prompt.
If you see
request_module: runaway loop modprobe binfmt-464c
Starting init: /sbin/init exists but couldn't execute it (error -8)
request_module: runaway loop modprobe binfmt-464c
Starting init: /bin/sh exists but couldn't execute it (error -8)
Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/init.txt for guidance.
you have somehow mismatched the kernel with the rootfs. (eg. LE kernel with BE rootfs.)
The following information may be outdated.
Provisional repositories
Using these repos in build-essential.morph, core.morph and cross-bootstrap.morph together with definitions will enable you to test mips64b before being merged:
Morph
Repo: https://github.com/mossmaurice/definitions.git
Branch: baserock/simonhoinkis/mips
CPython
Repo: https://github.com/mossmaurice/cpython.git
Branch: baserock/nowster/mips
Binutils
Repo: https://github.com/mossmaurice/binutils-redhat.git
Branch: baserock/nowster/mips64
Definitions
Repo: https://github.com/nowster/definitions.git
Branch: baserock/nowster/mips
Run the ./native-bootstrap script in a chroot on Debian (https://www.debian.org/releases/stable/) and boot into the created FHS.
TODO - The following are preliminary thoughts
Flash the Baserock Development image onto the USB device
- Change the U-Boot bootcmd persistent to read the bootcmd from a FAT partition
- Flash Baserock to the USB device on a Linux machine
- Partition1: Baserock BTRFS
- Partition2: FAT for U-Boot to read the kernel and the kernel args
- Partition3: possibly SWAP?
Attach the USB device and do:
# Find the USB device
lsblk
# Download the Baserock image
wget latest-baserock.img
# Flash the Baserock partition
dd if=latest-baserock.img of=/dev/sdX
# Find a free loop device and mount the rootfs
mkdir /mnt/rootfs
losetup -f
losetup /dev/loopX latest-baserock.img
mount /dev/loopX /mnt/rootfs
# Create FAT partition on the USB device
mkdir /mnt/fat
# Create a partion with fdisk
mkfs.fat /dev/sdX2
mount /dev/sdX2 /mnt/fat
# Copy the kernel and extlinux.conf
cp /mnt/rootfs/systems/default/kernel /mnt/fat/systems/default/kernel
cp /mnt/rootfs/extlinux.conf /mnt/fat/extlinux.conf
cp /mnt/rootfs/extlinux.conf /mnt/fat/extlinux/extlinux.conf
# Unmount
umount /mnt/fat
umount /mnt/rootfs
Connect to the EdgeRouter via the serial cable and press any key to interrupt the start up:
# Change envvars to read extlinux.conf
saveenv
MIPS32
For building 32-bit code on a 64-bit kernel use the linux32
command to prefix any morph command.