Design Philosophy / Build process
Generic OpenWrt with mender app and u-boot - non mender load created (with mender if selected in config)
generic openwrt image post-processed to become mender image
post-processing: mender disk layout created, distribution specific config, files and apps added
reason: we use generic openwrt for multiple products, post processing differentiates
This (post processing) approach also makes if fairly easy to port to other OpenWrt architectures. Amlogic S912 (proprietary) also ported.
Prequisites:
Mender, openwrt build host prerequisites
20-40GB free space for openwrt checkout, build
mkdir your_openwrt_build_dir; cd your_openwrt_build_dir (…/ from where git will place openwrt)
wget http://www.rossco.org/Downloads/OpenWrt/openwrt-mender-v1.0.0.tar.gz
tar -zxvf openwrt-mender-v1.0.0.tar.gz
It is highly recommended to examine the various scripts prior to running them
Install Mender host build packages. If using Centos 7+, run install_build_tools.sh else, determine how to install tools for your OS
Checkout required openwrt version, run: ./get_openwrt.sh
Patch openwrt for mender, run: ./openwrt_to_mender.sh
cd openwrt
OpenWrt Configuration (make menuconfig, already done by openwrt_to_mender.sh, change after, if required)):
Target System: Allwinner A1x/A20/A3x
SubTarget: Allwinner A64
Target Profile: Nanopi NEO2 (H5) (may work with other H5 dreivitaves)
Target Images-> Boot Partition Size: 20M
Target Images-> Root partition size: 3650M (assumes 8GB Flash, Total Sectors: 15523840)
Advanced Configuration -> ToolChain Options->GCC Compiler Version->GCC 7.X (other versions may work, untested)
Advanced Configuration -> C Library Implementation: Use glibc (crucial)
Utilities->mender->selected as builtin ()
Utilities->jitter-rngd->selected as builtin () (entropy source, to avoid slow boot)
OpenWrt Mender Configuration (make menuconfig):
Utilities->mender->Configuration (alter to taste):
() ServerURL # Mender update server URL
() ServerCertificate # If used
(/dev/mmcblk0p2) RootfsPartA
(/dev/mmcblk0p3) RootfsPartB
(86400) UpdatePollIntervalSeconds
(86400) InventoryPollIntervalSeconds
(30) RetryPollIntervalSeconds
Mender Variables, MENDER_* Configuration, if defaults need to be changed.
Before running openwrt_to_mender.sh (set as defaults)
edit: Custom/package/boot/uboot-sunxi/files/config_mender_defines.h
cp Custom/package/boot/uboot-sunxi/files/config_mender_defines.h
package/boot/uboot-sunxi/files/config_mender_defines.h
After running openwrt_to_mender.sh (set before build)
edit: package/boot/uboot-sunxi/files/config_mender_defines.h
Build Openwrt (with above configuration)
make, get a jug of coffee
if, during build, configuration questions arise, answer defaults to all
Flash Openwrt-Mender
Change the following variables in mender_flashdisk.sh to match your tastes / infrastructure:
BASE_NAME # What your distribution is called
DIST_DEST_DIR # Directory or cifs mount point of your package repository
MENDER_SERVER # URL of mender update server
MENDER_SERVER_UID # User ID for mender update server login
MENDER_SERVER_PASS # Password for mender update server login
TOTAL_SECTORS # Default SD sectors 15523840 for 8GB SD. Use fdisk to determine if different SD size
Place SD card in USB adapter, identify SD disk, IE; sde
To create image, flash SD and upload mender rootfs artifact:
./mender_flashdisk.sh disk
To only create image and upload mender rootfs artifact:
./mender_flashdisk.sh
Full mender image (for distribution and flashing by other means):
/tmp/mender/mender-neo2-openwrt-$(build_date).zip
Enjoy;
Bill Ross
www.rossco.org
If this post was useful to you, please press like, or leave a thank you note to the contributor who put valuable time into this and made it available to you. It will be much appreciated!