This is Gentoo's testing wiki. It is a non-operational environment and its textual content is outdated.

Please visit our production wiki at https://wiki.gentoo.org

MIPS/ERLite-3

From Gentoo Wiki (test)
< MIPS
Jump to:navigation Jump to:search
Resources

The EdgeRouter Lite (ERLite-3) is an MIPS64 router (MIPS64r2, Cavium Octeon) with 512 MB of RAM, which uses a (removable) USB pendrive for storage. This document describes how to run Gentoo on this device.

EdgeRouter Lite original packaging
EdgeRouter Lite (inside)

What's is provided

GPL Sources

Ubiquiti provides a GPL archive containing the sources of all open-source software that runs on this router. The GPL archive can be found here [1]

The Processor

system type             : UBNT_E100 (CN5020p1.1-500-SCP)
processor               : 0
cpu model               : Cavium Octeon+ V0.1
BogoMIPS                : 1000.00
wait instruction        : yes
microsecond timers      : yes
tlb_entries             : 64
extra interrupt vector  : yes
hardware watchpoint     : yes, count: 2, address/irw mask: [0x0ffc, 0x0ffb]
isa                     : mips1 mips2 mips3 mips4 mips5 mips64r2
ASEs implemented        :
shadow register sets    : 1
kscratch registers      : 0
core                    : 0
VCED exceptions         : not available
VCEI exceptions         : not available
processor               : 1
cpu model               : Cavium Octeon+ V0.1
BogoMIPS                : 1000.00
wait instruction        : yes
microsecond timers      : yes
tlb_entries             : 64
extra interrupt vector  : yes
hardware watchpoint     : yes, count: 2, address/irw mask: [0x0ffc, 0x0ffb]
isa                     : mips1 mips2 mips3 mips4 mips5 mips64r2
ASEs implemented        :
shadow register sets    : 1
kscratch registers      : 0
core                    : 1
VCED exceptions         : not available
VCEI exceptions         : not available

The USB Flash Drive

The details of the USB flash drive that comes with this board are the following:

USB Details

'"`UNIQ--pre-00000000-QINU`"'

Partitioning

The USB flash drive on the board has two partitions. A small FAT32 one for the Linux Kernel image and a big ext3 one containing the root filesystem in a squashfs file. The squashfs file is in the GPL archive as well.

Note
Although it is possible to replace the supplied USB memory stick with another one, be careful as not all of them work. If you managed to find one that works please edit this page to list the 'lsusb -v' output for that USB flash drive. This is the reason why this guide only focuses on the nfsroot configuration.
 Original USB stick
 ID 13fe:4100 Kingston Technology Company Inc
 
 Working replacements:

 Samsung 64GB USB 3.0 Flash Drive Fit (MUF-64BB/AM)
 https://www.amazon.com/gp/product/B013CCTNKU  
 ID 090c:1000 Silicon Motion, Inc. - Taiwan (formerly Feiya Technology Corp.)
 SanDisk Cruzer Fit 32GB USB 2.0 Low-Profile Flash Drive- SDCZ33-032G-B35
 http://www.amazon.com/gp/product/B00812F7O8
 ID 0781:5571 SanDisk Corp. Cruzer Fit
 
 Kingston Digital USB 3.0 DataTraveler Mini (Cyan) (DTM30/32GB)
 http://www.amazon.com/dp/B00GGD10ZE
 ID 0951:1666 Kingston Technology
 SanDisk Ultra Fit 128GB USB 3.0 Flash Drive (SDCZ43-128G-G46) 
 https://www.amazon.com/gp/product/B00YFI1EBC
 ** Note: you may need to prepend 'usb reset;sleep 3;' to the bootcmd to make this boot reliably !!
 
 Kingston Digital DataTraveler SE9 8GB USB 2.0 (DTSE9H/8GBZET)
 http://www.amazon.com/dp/B00DYQYJ3Q
 http://www.amazon.cn/dp/B006W8U2MU (Amazon.CN link for China users)
 scsi 0:0:0:0: Direct-Access     Kingston DataTraveler 2.0 1.00 PQ: 0 ANSI: 4
 sd 0:0:0:0: [sda] 15148608 512-byte logical blocks: (7.75 GB/7.22 GiB)
 sd 0:0:0:0: [sda] Write Protect is off
 sd 0:0:0:0: [sda] Mode Sense: 45 00 00 00
 sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DP  O or FUA
  sda: sda1 sda2 sda3
 sd 0:0:0:0: [sda] Attached SCSI removable disk

The memory before block 2048 is nonempty. Use dd to copy the first 2048 blocks.

A more comprehensive and detailed guide for swapping the original USB flash drive could be found at this thread on Ubiquiti forum.

Default USB partitioning

'"`UNIQ--pre-00000003-QINU`"'

The Linux Kernel

The Linux kernel that comes with the board is a modified 2.6.32.13 one. If you ever want to rebuild it yourself from the GPL archive, you need a mips64-octeon-linux-gnu toolchain that comes with the Cavium SDK. Typical distro toolchains (mips64-unknonwn-*) will fail to compile these kernel sources with errors like these:

root #make ARCH=mips CROSS_COMPILE=mips64-unknown-linux-gnu-
Error: Opcode not supported on this processor: octeon (mips64r2) `saa $6,($7)
Error: Opcode not supported on this processor: octeon (mips64r2) `saa $9,($7)
Error: Opcode not supported on this processor: octeon (mips64r2) `saa $3,($7)

The RootFS

This router comes with Debian 6.0.6

FILE /etc/debian_version
6.0.6

Preparing the Gentoo MIPS64 RootFS

Getting the MIPS64 stage3 tarball

The ERLite-3 uses a 64-bit MIPS64r2 Big-Endian Cavium Octeon processor. So the stage3 we want for this board is a mip64-* one. For this guide, we will pick a glibc based one.

root #mkdir /mnt/erlite-3/
root #tar xvjf stage3-mips64_multilib-20130715.tar.bz2 -C /mnt/erlite-3
root #rm stage3-mips64_multilib-20130715.tar.bz2

Getting the latest portage snapshot

root #tar xjvpf portage-latest.tar.bz2 -C /mnt/erlite-3/usr
root #rm portage-latest.tar.bz2

Configure /etc/fstab

If you are going to use NFSroot to boot your ERLite-3 board, you need to edit the /dev/ROOT entry in your fstab like this

FILE /mnt/erlite-3/etc/fstab
<ip_of_nfs_server>:/mnt/erlite-3 / nfs rw,auto,async,tcp,noatime,vers=3  0 1

Reset root password

In order to be able to login after the first boot, you need to reset the root password. For this edit the /mnt/erlite-3/etc/shadow file and remove the '*' from the second column.

Important
Remember to set your root password once you have successfully boot your board for the first time.

Building the toolchain

The are many different ways to build a mips64 toolchain. We will use the Gentoo sys-devel/crossdev script to build one.

root #emerge --ask crossdev

Create a cross toolchain for MIPS64 (big-endian system):

root #crossdev -t mips64-unknown-linux-gnu

Make sure you read this [2] and this [3] to understand how to use crossdev in your day-to-day development.

The MIPS64 Linux Kernel

Getting the Kernel

We will use the Linux Kernel from the Linus' git repo for now, but there might be other repos more suitable for this board out there. If you find one, please edit this guide as appropriate.

root #mkdir /mnt/erlite-3-kernel ; cd /mnt/erlite-3-kernel
root #git clone --depth 1 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
root #cd linux

Building the Kernel

root #ARCH=mips CROSS_COMPILE=mips64-unknown-linux-gnu- make cavium_octeon_defconfig
root #ARCH=mips CROSS_COMPILE=mips64-unknown-linux-gnu- make
root #ARCH=mips CROSS_COMPILE=mips64-unknown-linux-gnu- make modules_install INSTALL_MOD_PATH=/mnt/erlite-3/

Booting Up

NFS Boot

Install and Configure the TFTP Server

The TFTP server will be used to load the new kernel image on the board. For this, you need the net-ftp/tftp-hpa package.

root #emerge --ask tftp-hpa

Edit the /etc/conf.d/in.tftpd file as appropriate:

FILE /etc/conf.d/in.tftpd
# /etc/init.d/in.tftpd

# Path to server files from
# Depending on your application you may have to change this.
# This is commented out to force you to look at the file!
#INTFTPD_PATH="/var/tftp/"
#INTFTPD_PATH="/tftpboot/"
INTFTPD_PATH="/mnt/erlite-3/kernel/"

# For more options, see in.tftpd(8)
# -R 4096:32767 solves problems with ARC firmware, and obsoletes
# the /proc/sys/net/ipv4/ip_local_port_range hack.
# -s causes $INTFTPD_PATH to be the root of the TFTP tree.
# -l is passed by the init script in addition to these options.
INTFTPD_OPTS="-R 4096:32767 -s ${INTFTPD_PATH}"

And start the service (add it to the default runlevel if you wish)

root #rc-update add in.tftpd default (optional)
root #/etc/init.d/in.tftpd start

Install and Configure the NFS Server

The NFS Server will export the (previously extracted and prepared) stage3 (/mnt/erlite-3) to the ERLite-3 board.

In order to use your PC as an NFS server, you need the following kernel options to be enabled:

KERNEL
File Systems --->
    Network File Systems --->
        <*> NFS server support
        -*-   NFS server support for NFS version 3

You also need to build and configure the net-fs/nfs-utils as follows:

root #emerge --ask nfs-utils

Then edit the /etc/exportfs as follows:

FILE /etc/exports
# /etc/exports: NFS file systems being exported.  See exports(5).
/mnt/erlite3/ 192.168.1.2(async,rw,no_root_squash,no_subtree_check)
root #rc-update add nfs default (optional)
root #/etc/init.d/nfs start

Prepare U-Boot for NFS boot

U-boot is pre-configured as follows:

U-Boot configuration

'"`UNIQ--pre-0000000A-QINU`"'

For NFS boot, we need to set the following variables:

ipaddr : IP for the ERLite-3 board (e.g. 192.168.1.2)
serverip : IP for the PC acting as tftp server (e.g. 192.168.1.3)
bootcmd : We need to override the existing 'bootcmd' command with one suitable for tftp boot

For this, use the following commands in the u-boot command line (Press Ctrl-C to interrupt the boot process)

setenv ipaddr 192.168.1.2
setenv serverip 192.168.1.3
setenv bootcmd 'tftpboot $loadaddr vmlinux; bootoctlinux $loadaddr coremask=0x3 ip=192.168.1.2::192.168.1.254:255.255.255.0:edge:eth0:off root=/dev/nfs nfsroot=192.168.1.3:/mnt/erlite-3/,tcp,vers=3

And now save the new configuration

saveenv

Now, it is time to reset the router and boot into your shiny new Gentoo MIPS64 rootfs.

Serial output

'"`UNIQ--pre-0000000D-QINU`"'

USB Boot

Successful boot from USB drive is confirmed on vanilla kernel 3.11_rc4, same is true fo Kernel 3.17. A kernel configuration file is available at https://github.com/xypron/kernel-edgerouter.

Important
There is still a high chance of kernel panic during SOFT reboots of device, if it is booted from USB, at least for kernel 3.11.*.
Important
Kernel 3.13 has some nasty bug in Octeon USB driver, details [here]
Console

'"`UNIQ--pre-00000010-QINU`"'
Related options in kernel config

'"`UNIQ--pre-00000013-QINU`"'

Kernel command line parameters can be adjusted through U-boot.

Kernel cmdline

'"`UNIQ--pre-00000016-QINU`"'