====== WIFI Testbed ====== ===== Equipment ===== Things needed to get started * Intel NUC * APU2 board * Switch * 2x Network cable * Serial cable Connect the APU board with the NUC using the Serial cable.\\ Connect the APU and NUC with the Switch using the Network cables. ===== NUC Setup ===== For this setup we used Ubuntu 16.04 LTS.\\ First off, configure the network interface to have a static IP.\\ $ sudo vim /etc/network/interfaces ... iface eno1 inet static address 192.168.111.1/24 ... Start the interface with ''sudo ifup eno1'', you should get a link-up on the switch.\\ \\ You can get output via the Serial cable by using ''screen'': $ sudo apt-get install screen $ sudo screen /dev/ttyUSB0 115200 ==== Install MAAS on the NUC ==== - Update the package index files and install MAAS\\ $ sudo apt-get update && sudo apt-get install maas - Create an admin account\\ $ sudo maas createadmin - Log in to MAAS with the admin account at http://localhost:5240/MAAS/ - Configure MAAS\\ DNS forwarder: 131.159.254.1\\ Generate and insert SSH-Key for later login into the machines\\ Set kernel parameter in **Settings**: console=ttyS0,115200n8 - Configure Subnet and enable DHCP\\ Choose the network you created in the interface configuration\\ Enable DHCP by clicking on **"Take Action"** and select **"Provide DHCP"** \\ Select the DHCP range\\ Set the Gateway IP to be the configured Interface IP (in this case 192.168.111.1) ==== Install WakeOnLan Patch for MAAS ==== - Install Etherwake\\ $ sudo apt-get install etherwake - Clone the patch repository (You might need to install git) \\ $ git clone https://github.com/yosefrow/MAAS-WoL-driver - Edit the ''maas-etherwake.diff'' and ''driver/etherwake.py'', so the query functions ''return 'unknown' ''\\ This is due to the APU board not having a BMC, that returns a power state. Therefore, we avoid a power state request in order to make the patch work.\\ ''A power state lookup is coming up and still TODO'' - We also edit the power_on function call in both files.\\ Therefore, we add the -i option in the subprocess call, so WoL functions properly. It should then look like this:\\ subprocess.call(["sudo", "etherwake", "-i", "eno1", context.get("power_mac")]) - Enable MAAS to run commands as root\\ Since etherwake uses UDP it is needed to be run as root.\\ Therefore, we run ''$ sudo visudo'' and add the line ''maas ALL= NOPASSWD: /usr/sbin/etherwake'', where ///usr/sbin/etherwake// is the result of ''which etherwake''. - Now we are ready to apply the patch with \\ $ PATCH_DIR="/usr/lib/python3/dist-packages/provisioningserver/" $ sudo patch -p1 -d ${PATCH_DIR} < maas-etherwake.diff $ sudo systemctl restart maas-rackd.service maas-regiond.service ===== APU Setup ===== Important facts on the APU2c4 Board: * It supports WakeOnLan, however it is only possible on the network interface ''net2'', next to the USB ports. * The BIOS that comes with it has PXE/network boot disabled and can be enabled manually by pressing **F10** on boot and navigating into ''[payload]setup'', where you can also make changes to the bootorder. ===== BIOS Flashing ===== Since the manufacturer default BIOS settings do not fit our purpose and we want more automation, we create our own ''coreboot.rom'' with the right default settings. Therefore, we use Docker as our build environment. ==== Docker ==== === Set up the repository === - Update the ''apt'' package index:\\ $ sudo apt-get update - Install the following packages to make use a repository over HTTPS:\\ $ sudo apt-get install apt-transport-https ca-certificates curl software-properties-common - Add Docker's official GPG key:\\ $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - - Verify the correctness of the key with the fingerprint ''9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88'', by searching for the last 8 characters of the fingerprint:\\ $ sudo apt-key fingerprint 0EBFCD88 - Set up the ''**stable**'' repository:\\ $ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" === Install Docker CE === - Update the package index:\\ $ sudo apt-get update - Install the latest version of Docker CE:\\ $ sudo apt-get install docker-ce Now we are ready to create our build image. === Building Docker image === - Get the Dockerfile from the pcengines git-repository: $ mkdir apu2-docker && cd apu2-docker $ wget https://raw.githubusercontent.com/pcengines/apu2-documentation/master/Dockerfile - Build Ubuntu LTS 14.04 based container image:\\ $ sudo docker build -t pc-engines/apu2 . Now we have an image, which we can create containers with as our build environment. === Building the firmware === - Create working directory:\\ $ mkdir apu_coreboot && cd apu_coreboot - Clone PC Engines firmware repository:\\ $ git clone -b coreboot-4.6.x https://github.com/pcengines/coreboot.git $ git clone https://github.com/pcengines/apu2-documentation.git - Run Docker container with correct working directory:\\ $ docker run --rm -v ${PWD}:/workdir -t -i pc-engines/apu2 bash - Configure coreboot (inside the container):\\ $ cd /workdir/coreboot $ make menuconfig 1. select ''Mainboard'' > ''Mainboard vendor'' = ''PC Engines''\\ 2. select ''Mainboard'' > ''Mainboard model'' = ''APU2'' - Configure coreboot bootorder:\\ 1. Edit ''/workdir/coreboot/src/mainboard/pcengines/apu2/variants/apu2/bootorder'': # Boot from harddisk first, PXE second 1 /pci@i0cf8/*@11/drive@0/disk@0 2 /rom@genroms/pxe.rom ... # Enable PXE boot by default pxen1 2. Edit ''/workdir/coreboot/src/mainboard/pcengines/apu2/bootorder_def'' as in 1.\\ 3. Edit ''/workdir/coreboot/src/mainboard/pcengines/apu2/bootorder_map'' accordingly: 1 c mSATA 2 f iPXE - Edit ''/workdir/coreboot/payloads/external/iPXE/ipxe/src/menu.ipxe'' to autoboot from net2:\\ Replace every line with **autoboot net0** with **autoboot net2**. - Build crossgcc: make crossgcc-i386 - Build coreboot: make The finished ''coreboot.rom'' should now be located /workdir/coreboot/build . === Flashing the firmware === Create a bootable USB stick (preferred: version 2.0) with [[https://pcengines.ch/howto.htm#TinyCoreLinux|TinyCore Linux]] \\ ''Note'': You might need to edit the provided label of the USB stick according to the /takemehome.sh on the booted TinyCore image. Ours pointed to the wrong label and thus couldn't find the proper folder (on the USB stick) for autostart.sh execution.\\ ''Also'': You might need to create a empty takemehome.txt file on the USB stick, so the takemehome script works properly. Therefore check the takemehome.sh again and edit accordingly.\\ Edit the **autostart.sh** on the USB stick to execute the flash command: flashrom -w coreboot.rom -p internal You can also edit in beep commands, to check for proper execution of the flash command. Then simply plug the USB stick into the APU Board, let it boot from it and wait for the flash to finish.