Installation is as straightforward as copying the image to an SD card and booting - I documented the installation procedure on the openSUSE Wiki.
Releases prior to Build350 exhibit boot issues due to the U-Boot
device-tree path. However, this has been fixed in recent builds.

Kernel

The Linux kernel currently shipped with the openSUSE image does not include support for acting as a USB mass storage gadget, nor does it include Ceph RBD support. In order to obtain these features, and also reduce the size of the base image, I built a mainline Linux kernel (4.4-rc4) using a minimal custom kernel configuration:

This build procedure takes a long time to complete. Cross compilation could be used to improve build times.
I plan on publishing a USB gadget enabled ARM kernel on the Open Build Service in the future, which would allow for simple installation via zypper - watch this space!

Ceph RADOS Block Device (RBD) mapping

To again save space, I avoided installation of user-space Ceph packages by using the bare kernel sysfs interface for RBD image mapping.
The Ceph RBD kernel module must be loaded prior to use:

# modprobe rbd

Ceph RADOS block devices can be mapped using the following command:

# echo -n "${MON_IP}:6789 name=${AUTH_NAME},secret=${AUTH_SECRET} " \

"${CEPH_POOL} ${CEPH_IMG} -" > /sys/bus/rbd/add

$MON_IP can be obtained from ceph.conf. Similarly, the $AUTH_NAME and $AUTH_SECRET credentials can be retrieved from a regular Ceph keyring file.$CEPH_POOL and $CEPH_IMG correspond to the location of the RBD image.

A locally mapped RBD block device can be subsequently removed via:

# echo -n "${DEV_ID}" > /sys/bus/rbd/remove

$DEV_ID can be determined from the numeric suffix assigned to the /dev/rbdX device path.

Images can't be provisioned without the Ceph user-space utilities installed, so should be performed on a separate system (e.g. an OSD) prior to mapping on the Cubietruck. E.g. To provision a 10GB image:

# rbd create --size=10240 --pool ${CEPH_POOL} ${CEPH_IMG}

With my Cubietruck connected to the network via the ethernet adapter, I observed streaming read (/dev/rbd -> /dev/null) throughput at ~37MB/s, and the same value for streaming writes (/dev/zero -> /dev/rbd). Performance appears to be constrained by limitations of the Cubietruck hardware.

USB Mass Storage Gadget

The Linux kernel mass storage gadget module is configured via configfs. A device can be exposed as a USB mass storage device with the following procedure:

$DEV corresponds to a /dev/X device path, which should be a locally mapped RBD device path. The module can however also use local files as backing for USB mass storage.

Boot-Time Automation

By default, Cubietruck boots when the board is connected to a USB host via the mini-USB connection.
With RBD image mapping and USB mass storage exposure now working, the process can be run automatically on boot via a simple script: rbd_usb_gw.sh
Furthermore, a systemd service can be added:

Finally, this service can be triggered by Wicked when the network interface comes online, with the following entry added to /etc/sysconfig/network/config:

POST_UP_SCRIPT="systemd:rbd-mapper@.service"

Boot Performance Optimisation

A significant reduction in boot time can be achieved by running everything from initramfs, rather than booting to the full Linux distribution.
Generating a minimal initramfs image, with support for mapping and exposing RBD images is straightforward, thanks to the Dracut utility:

The rbd_usb_gw.sh script is installed into the initramfs image as a Dracut emergency hook, which sees it executed as soon as initramfs has booted.

To ensure that the network is up prior to the launch of rbd_usb_gw.sh, the kernel DHCP client (CONFIG_IP_PNP_DHCP) can be used by appending ip=dhcp to the boot-time kernel parameters. This can be set from the U-Boot bootloader prompt:

=> setenv append 'ip=dhcp'

=> boot

The new initramfs image must be committed to the boot partition via:

# cp myinitrd /boot/

# rm /boot/initrd

# sudo ln -s /boot/myinitrd /boot/initrd

Note: In order to boot back to the full Linux distribution, you will have to mount the /boot partition and revert the /boot/initrd symlink to its previous target.

Future Improvements

Support configuration of the device without requiring console access

Run an embedded web-server, or expose a configuration filesystem via USB

6 comments:

Is there smaller hardware available to support this ?I can think about the size of USB armory, FST-01, .... In one side USB type A, and in the other side RJ45.Even with USB2 - 100Mbps Ethernet would already be a first start.

The Zsun WiFi SD Card Reader (https://wiki.hackerspace.pl/projects:zsun-wifi-card-reader) could be made to work with a bit of HW and SW hacking. Other alternatives include the NanoPi M1 (http://nanopi.io/nanopi-m1.html), and the ODROID-C2 (http://www.hardkernel.com/main/products/prdt_info.php?g_code=G145457216438).

That said, I still consider C.H.I.P the most promising at this stage, especially given the $9 price tag.

I've been trying unsuccessfully for over 3 days to get the image to boot following the instructions provided on https://en.opensuse.org/HCL:Cubietruck. All I get is a black screen. It appears that the "current" image on the site and all the mirrors are corrupt when trying to boot using my 5 64GB SD cards. I can only boot when programming the image to and 7 year old 2G SD card. The command that I am using to put the data on the card is the one giving in the instructions: xzcat openSUSE-Tumbleweed-ARM-JeOS-cubietruck.armv7l-2016.06.12-Build2.10.raw.xz | dd bs=4M of=/dev/sde iflag=fullblock oflag=direct; syn

What might I be doing wrong? I was able to program the same 64GB card back in early April using the XFCE image that was available at the time, but since then there is only the JeOS image from June 25th available, and it won't boot from my 64 GB cards. What might I be doing wrong?

There's a good chance that the jeos image doesn't include display support. I'd suggest that you contact the opensuse-arm mailing list to resolve these issues.For this project I wasn't using the VGA/HDMI outputs at all - only ssh (by default, the image requests an IP address via DHCP) and UART (see https://linux-sunxi.org/Cubietruck#Adding_a_serial_port).

Hi, I managed to get it resolved by trying a different USB card reader. I am not sure why the card reader really makes such a difference, because I am otherwise able to transfer fils to and from the same SD cards without corruption. I confirmed this by checking the MD5 sums of files being saved to and from the cards.