This Pad describes the process of rebuilding the Kernel for EdgeMAX ER-e50 Devices (ER-X, ER-X-SFP, EP-R6) to add BATMAN Advanced support
- Requiremets
- Download Ubiquiti GPL Archive: https://www.ubnt.com/download/edgemax/edgerouter-x-sfp/default/edgerouter-er-xer-x-sfpep-r6-firmware-v180
- Download Buildroot 2016.02: https://buildroot.org/download.html
- Download batman-adv, batctl and alfred sources: https://downloads.open-mesh.org/batman/releases
- Install u-boot-tools binfmt-support qemu qemu-user-static debootstrap lzma-alone
- Build MIPS Toolchain
- Extract buildroot and change to extracted folder
- make menuconfig
- Target
- Target Architecture = MIPS (little endian)
- Target Architecture Variant = mips 32r2
- Use soft-float = True
- Build option
- Host dir = /opt/buildroot/2016.02
- needs to be created manually
- Toolchain
- GCC compiler Version = gcc 4.9.x
- make
- Crosscompile Kernel
- Extract Ubiquiti sources
- Change to extracted folder (usually ./sources)
- extract kernel sources and change to extraced folder
- replace .config with https://gist.github.com/belzebub40k/5f3d7cb946a19d5271823f81cd28f8a7#file-kernel-config-ffmwu
- sadly the supplied kernel only supprts gzip as output format so we need to patch it
- append MIPS Toolchain to $PATH
- export PATH=$PATH:/opt/buildroot/2016.02/usr/bin
- Build kernel/u-boot image
- make ARCH=mips CROSS_COMPILE=mipsel-linux- uImage.lzma
- Boot image via TFTP
- Setup TFTP server and copy uImage to root folder
- Connect USB to TTL adapter: https://wiki.openwrt.org/toh/ubiquiti/ubiquiti_edgerouter_x_er-x_ka#photos
- Parameters: 57600 8N1
- Press '4' during boot to get u-boot prompt
- set your IP address to to the one defined in u-boot serverip or modify it (if you modifiy it also modify u-boots own address in ipaddr to the same subnet)
- boot uImage
- tftpboot ${fileaddr} uImage.lzma
- bootm
- Crosscompile batman-adv
- extract source tarball and change to extracted folder
- build with UBNT kernel sources
- KERNELPATH needs to be set to the folder from 3.3.
- make ARCH=mips KERNELPATH=~/tmp/source/kernel
- copy ./net/batman-adv/batman-adv.ko to EdgeOS
- load module
- sudo insmod ./batman-adv.ko
- Crosscompile userland applications
- Debootstrap Debian Wheezy MIPSel
- debootstrap --foreign --arch mipsel wheezy debian_armel_wheezy http://ftp.debian.org/debian/
- cp /usr/bin/qemu-mipsel-static debian_mipsel_wheezy/usr/bin/
- LC_ALL=C chroot debian_mipsel_wheezy/
- /debootstrap/debootstrap --second-stage
- apt-get install build-essential pkg-config
- Build packages as described in their READMEs
==== TODO =====
- try to compile with similar toolchain as Ubiquiti does (buildroot-2012.11.1 gcc 4.6.x)
- currently it does not compile under Debian 8 because gcc4.6 is to old
- should work with Debian 7 (debootstrap + chroot)
- integrate in EdgeOS
- generate modified firmware images