Cubieboard and Debian
For lowish power linux web dev / media / storage etc servers you cant really go past mini-itx atom boards. However, 10-20W is about where they operate. But datalogging applications, such as power monitoring 24/7, require much lower power consumption. While Intel's next generation atom (due sept 13) has expectations of being something of an ARM killer, in the mean time, ARM is where its at.
The obvious candidate, rPi, has an incredible 700,000 board user base, so must be doing something right. But when i asked around, two of the more featureful A10 boards for their cost stood out, both have dedicated (not via usb) 100M Ethernet, 1G ram, 4G on board flash, and 3G sata. Those specs are attractive. The Cubieboard seems well spec'ed for our purpose, has headers for hacking. The Mele has no headers, but has wifi and a nice wee case. Neither have particularly strong user communitys. There are bucket loads of others, but for lots of reasons, my money is still on silvermont.
But for our present purpose, based on reported power consumption of 1-2W, I decide to start with cubieboard. The below is mostly notes to self about installing debian on the cubieboard. The one we ordered from miniand, arrived inside 2 weeks using the $10 international shipping option, NZD 75 all up.
While Debian maintains a few arm ports the field is moving to armhf. Debian currently only officially supports a small number of older embedded devices such as sheevaplug. However a lots of community supported builds are available. For the purposes of this intial test setup, i decide to use cubian. The cubian image is a basic "standard system" image, although the mali graphics driver is still enabled. In order to free up the mali ram we will probaly need either a new kernal or romans headless image .
For now im just going to run the thing off a few different throwaway uSD cards, until i decide which img is best. Or until debian catchup with the state of play in the embedded world. Or silvermont. Or whether a credit card sized computer can actually do real work. Which ever comes first
Cubieboard general resources:
- info: linux-sunxi.org/Cubieboard
- images linux-sunxi.org/Bootable_OS_images
- documentation docs.cubieboard.org
- wiki www.cubiebook.org
- list serv: groups.google.com/forum/#topic/cubieboard
- forum: www.cubieforums.com
Booting it up
Instructions: www.github.com/cubieplayer/Cubian/wiki/Get-started-Cubian
OS Download: www.cubian.org/downloads (i used r3, but r8 is now out)
Disk imager: www.sourceforge.net/projects/win32diskimager
Youll also need 7zip,winscp, putty, and a RJ45 patch cord, know what to do with them.
A 4GB or better uSD. Class 10 is recomended.
The image is 4GB, highly compressed to 90MB with 7zip.
The seven key steps:
1. Insert 4GB or better uSd (using uSD-SD adpter), in a laptop with SD reader
2. Write the cubian image to it using win32diskimager or similar
3. Insert uSD into cubie
4. Connect cubie to LAN with ethernet patch cord.
5. Connect supplied power cable, 4mm/1.8mm dc to usb. Wait 60 seconds until blue led starts flashing.
6. Go to your LAN router interface, look under LAN, ARP table/client ips or similar to get the IP address of the cubie
7. Use putty to connect to that ip, port 36000, username cubie, password cubie
A normal boot process looks like:
- red led means power connected, always on
- green led flashs during boot (and shutdown), off normally
- blue led flashs intermitantly for about 2 minutes post boot.
After about a minute or two the blue led should go out. If it continues to flash according to the manual this means that the board failed to estabish a ethernet link. Evidently the odd board has had a hardware issue with the LAN crystal.
Our work environment
First the basics, enable the root user, and add another user with ssh cert.
cubie@Cubian: sudo passwd root
cubie@Cubian: su
root@Cubian:# adduser myname #on debian adduser is an improved version of useradd
root@Cubian:# usermod -a -G www-data myname
root@Cubian:# mkdir /home/myname/.ssh
{nows a good time to install your /home/myname/.ssh/authorized_keys} using winscp
Hardware wise, on board flash is not mounted, mmc flash in two partitions 2/3s of which is mounted as /, the rest is swap. Theres 1GB or ram, a quarter of which is reserved for the graphics. So room for improvement here and there. Heres a summary:
root@cubie:# uname -a
Linux cubie 3.4.43 #20 PREEMPT Wed Jun 26 01:21:21 CST 2013 armv7l GNU/Linux
cat /etc/debian_version
7.0
root@Cubian:# free -m
total used free shared buffers cached
Mem: 812 109 702 0 5 49
-/+ buffers/cache: 55 757
root@Cubian:# df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 2.5G 589M 1.8G 25% /
/dev/root 2.5G 589M 1.8G 25% /
devtmpfs 407M 0 407M 0% /dev
tmpfs 82M 212K 82M 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 358M 0 358M 0% /run/shm
root@Cubian:# fdisk -l
Disk /dev/nand: 4085 MB, 4085252096 bytes
Disk /dev/nanda: 16 MB, 16777216 bytes
Disk /dev/nandb: 16 MB, 16777216 bytes
Disk /dev/nandc: 33 MB, 33554432 bytes
Disk /dev/nandd: 536 MB, 536870912 bytes
Disk /dev/nande: 536 MB, 536870912 bytes
Disk /dev/nandf: 16 MB, 16777216 bytes
Disk /dev/nandg: 33 MB, 33554432 bytes
Disk /dev/nandh: 134 MB, 134217728 bytes
Disk /dev/nandi: 2743 MB, 2743074816 bytes
Disk /dev/mmcblk0: 3965 MB, 3965190144 bytes
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 2048 5199871 2598912 83 Linux
/dev/mmcblk0p2 5199872 7198719 999424 82 Linux swap / Solaris
root@Cubian:# blkid
/dev/nanda: SEC_TYPE="msdos" LABEL="Volumn" TYPE="vfat"
/dev/nandd: UUID="57f8f4bc-abf4-655f-bf67-946fc0f9f25b" TYPE="ext4"
/dev/nande: UUID="57f8f4bc-abf4-655f-bf67-946fc0f9f25b" TYPE="ext4"
/dev/nandh: UUID="57f8f4bc-abf4-655f-bf67-946fc0f9f25b" TYPE="ext4"
/dev/nandi: LABEL="CUBIEBOARD" UUID="BB88-07B2" TYPE="vfat"
/dev/mmcblk0p1: UUID="fe9b6aa1-f5a2-4585-b861-0412bc407d47" TYPE="ext4"
/dev/mmcblk0p2: UUID="1d3cf367-d285-49d4-87ca-f5beacd4df4f" TYPE="swap"
Todo: Sort partitions on the sd card if the card is bigger than 4gb.
Todo: Use fdisk to fill the remaining space and mount as /home.
Todo: install to nand, mount the os readonly, ramdisk for /tmp, and /var/log
Todo: new part for /home on mmc.
Network
Change hostname and timezone:
root@Cubian:# nano /etc/hostname
cubie
The device has no RTC battery, and out of the box ntp isnt installed. It sets the time using ntpdate at boot.
root@Cubian:# dpkg-reconfigure tzdata
root@Cubian:# date
Sun Aug 4 16:55:02 NZST 2013
Next we need to set a static IP. Set these up to your network. Ill assume the use of 192.168.0.3.
Do it carefully else youll lose ethernet when you reboot. Given thats possibly all you have thats going to suck.
root@Cubian:# nano /etc/network/interfaces
auto lo
iface lo inet loopback
allow-hotplug eth0
iface eth0 inet static
address 192.168.0.3 #cubie
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.4 #router
root@Cubian:# reboot
It takes a tad less than a minute to reboot. Once we have our shell back we are good to go.
Packages
So now its time to install a lamp stack and whatnot so we can get on with the business of power monitoring.
First setup our local debian repository:
root@cubie:# nano /etc/apt/sources.list
#change the primary entry to (for NZ)
deb http://ftp.nz.debian.org/debian/ wheezy main
root@cubian:# apt-get update && apt-get upgrade
Install a lamp stack. Well give lighty a go, its pretty easy:
root@cubie:# apt-get install mysql-server lighttpd
root@cubie:# apt-get install php5-common php5-cgi php5
"Note it's important to install php-cgi in the order listed above. If you try to install php5 without first installing the php5-cgi package then it will install Apache as well, which we don't want for this light-weight lighttpd server." -- www.penguintutor.com/linux/light-webserver
Continuing...
root@cubie:# apt-get install php5-mysql php5-gd
root@cubie:# lighty-enable-mod fastcgi-php
root@cubie:# /etc/init.d/lighttpd restart
Php setup:
root@cubie:# rm -rf /var/www/
root@cubie:# mkdir -vp /home/www-data/html
root@cubie:# ln -s /home/www-data/html /var/www
root@cubie:# echo '' > /home/www-data/html/index.php
root@cubie:# chown myname:myname -R /home/www-data/
root@cubie:# nano /etc/php5/cgi/php.ini
#for dev environment
display_errors = On
Mysql database setup:
root@cubie:#mysql -u root -p
create database blackbox;
grant ALL privileges on blackbox.* to cubie@localhost identified by 'secret';
exit;
Couple of missing utils, and remove some of the junkware that seems to come with recent releases of cubian:
root@cubie:# apt-get install less bzip2
root@cubie:# apt-get remove ajenti usbmount udevil avahi-daemon
root@cubie:# apt-get autoremove
When thats all done, open up a browser on a computer in your LAN, if everythings gone OK youll get a phpinfo page at http://192.168.0.3/. All joy and happiness.
SD card issues
SD cards are very unforgiving of sudden powerdowns. Make 100% certain you have a reliable power supply for the board. And be very careful to always power the board down gracefully...
root@cubie:#shutdown -h now
If you do not, you will find that your sd card dies very quickly (weeks). Many dev board users have struggled with SD cards. However the one here has been well powered and has survived 18 months of 24/7 uptime.
Nonetheless without mitigation measures with our script writing sql data every 60seconds, that little SD card isnt gona last long. Two possible solutions are:
- use a small ssd on the sata port
- creative reliance on a readonly root filesystem, ramdisks, and period rsyncs to sd,
I expect to write more about this in a future article.
Power consumption
While rationally i knew it would be low, i wasnt ready for the reality of 1.25 watts. At 25 volts 50mA barely registers on the 10amp scale. I'll re-measure it on the 5V side, or with a higher resolution amp scale, after ive disabled the mali graphics system. That figure as well as including mali, also includes the power losses from the dc-dc converter.
Impressions
What do i think? It was quick and easy to get going in about an hour or two.
Sure debian doenst officially support these devices, so you cant just install it as you would normally, but once it is installed, the complete debian system is available as usual, and theres a few good wheezy images already built for the cubie.
I wouldnt describe the thing as greased lightning, theres 1/10 second pauses working at the console over ssh. There's a dual core version, if speed is an issue. But the cubie1 renders webpages not much slower than atom does.
If it proves to be reliable, itll do the job just fine.
2014-06-01
www.zoneblue.nz/cms/page.php?view=cubieboard-and-debian