The Moxa UC-8100 line of "industrial IoT gateways", such as the Moxa UC-8112-LX, can be a good solution for on-site data acquisition. To get the most out of them we want to enable them to run snaps, like https://snapcraft.io/ammp-edge. Unfortunately, as of writing, the latest v2.0 firmware provided with these devices does not support this, for two main reasons:
- The pre-installed OS is Debian 8, while
snapdrequires at least Debian 9.
- The stock kernel does not include SquashFS support, and does not have the required
The steps for rectifying these shortcomings are roughly as follows:
Compiling and installing a custom kernel
The following commands assume you're doing this on the Moxa device itself, though for more expedient results you'll want to cross-compile on something more powerful. Also note that in order to build the kernel you'll need a couple of GB of free space, which is more than the built-in storage of the UC-8112-LX.
Get in touch with Moxa support and request (1) the source code for the latest kernel firmware, and (2) a version of the u-boot bootloader (
u-boot.img) that will load with a custom kernel. For some reason neither of these is available for download directly from the Moxa website (though older kernel sources are).
Put the bootloader aside for now and untar the kernel source
tar -xjf uc8100_v2.0_source.tar.bz2 cd am335x-linux-4.1/
- Grab the kernel build tools
sudo apt install build-essential bc libncurses5-dev liblz4-tool u-boot-tools
- Use the default supplied configuration, but modify the following required configuration options in
- Device drivers > Character devices >
[*] Support multiple instances of devpts
- File systems > Miscellaneous filesystems >
[M] SquashFS 4.0. Also
[*] Include support for XZ compressed file system
Save the configuration to the default
- Clean up a random glitch that would otherwise lead to a
fatal error: dt-bindings/gpio/gpio.h: No such file or directory(from https://support.criticallink.com/redmine/projects/armc8-platforms/wiki/Mityarm-linux-stable_)
cd arch/arm/boot/dts/include/ ln -s ../../../../../include/dt-bindings . cd ../../../../..
- Build the relevant bits, namely: kernel image for u-boot, device tree binary, and SquashFS kernel image.
make uImage make moxa-uc8100.dtb make M=fs/squashfs
Note that there's no real need to build the rest of the modules, as these are already included with the stock image.
u-boot.imgbootloader which I was provided by Moxa support was for an older version of the firmware (and an older kernel version), and therefore did not support (or at least look for) the device tree file. Trying to boot my custom
uImagethat way led to the system hanging after the
Starting kernel ...message. Enabling low-level debug in the kernel image produced the following cryptic message:
Error: unrecognized/unsupported machine ID (r1 = 0x00000e05). Available machine support: ID (hex) NAME ffffffff Generic DT based system ffffffff Generic AM43 (Flattened Device Tree) ffffffff Generic AM33XX (Flattened Device Tree) Please check your kernel config and/or bootloader.
Anyway, it came out to be down to the device trees.
The way to fix the situation is to append the DTB to the uImage file itself. Based on https://community.nxp.com/thread/315543, the following should accomplish that for our situation:
cd arch/arm/boot cat ./zImage ./dts/moxa-uc8100.dtb > zImage_with_dtb mkimage -A arm -O linux -T kernel -C none -a 0x80008000 -e 0x80008000 -d zImage_with_dtb uImage
- Now mount the boot partition of the image you want to "upgrade" (e.g.
/dev/mmcblk0p1). Copy the final
~/am335x-linux-4.1/arch/arm/boot/uImagefile there. Also grab the custom
u-boot.imgfile you got from Moxa support and copy it to the boot partition. (after having backed up the originals...)
Related to this, note that the following is what you would likely get if trying to use a custom-compiled kernel with the locked-down u-boot bootloader in the stock Moxa firmware:
## Booting kernel from Legacy Image at 80007fc0 ... Bad Header Checksum ERROR: can't get kernel image!
This appears to be by design, though is not really documented.
Boot up the new kernel. Hopefully everything goes without a hitch.
Finally, install the SquashFS module:
cd /lib/modules/4.1.0-ltsi-rt-uc8100+/ sudo mkdir extra sudo cp ~/am335x-linux-4.1/fs/squashfs/squashfs.ko extra/ sudo depmod
Check that it loads ok with
sudo modprobe squashfs and
Upgrade to Debian 9
Note that Moxa support also indicated they'll be releasing Debian 9-based firmware in mid-2018. For the time being, doing an in-place upgrade from Debian 8 to 9 appears to work decently well, following instructions similar to https://www.rootusers.com/how-to-upgrade-debian-8-jessie-to-debian-9-stretch/. Specifically:
- Make sure the existing Debian 8 is completely up-to-date.
sudo apt-get update && sudo apt-get upgrade -y
- Change the package sources from Jessie (8) to Stretch (9):
sudo sed -i 's/jessie/stretch/g' /etc/apt/sources.list
This may mess with the Moxa-specific sources, but didn't appear to lead to issue in my case (if you ignore the Moxa repository GPG error thrown when doing the update in the next step).
- Go through the following again as many times as is necessary to get all packages upgraded:
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y reboot sudo apt-get autoremove && sudo apt-get autoclean
(again, repeat if necessary)
You should now be able to
sudo apt-get install snapd -y
sudo snap install hello-world