Cubieboard2

The Cubieboard2 is another mini PC platform, this one is based on the Allwinner A20 SoC, containing a dual core ARM Cortex A7 processor and more, see diagram below. It is close to the PhoenixA20 where the PhoenixA20 has additional WiFi and Bluetooth but is slightly larger.

Running Cubian, the OS is largely the same as used for the Raspberry Pi (Debian armhf) meaning you can benefit from the large community around the RPI. Compared to the RPI, Cubieboard has two cores instead of one core and an SATA connector.

Hardware

Some specs:
  • AllWinner A20 SoC (ARM Cortex A7 dual core @ 1 GHz CPU, with dual Mali 400MP GPU.
  • 1GB DDR3 memory.
  • 4 GB NAND Flash on-board, one MicroSD slot and a SATA port or two MicroSD slots and a SATA port
  • HDMI 1080p output
  • 10/100 ethernet connector
  • 2x USB Host, 1x USB OTG, 1x CIR.
  • 96 extend pin including I²C, SPI and LVDS, an expander board is available
  • Dimensions: 10 cm x 6 cm

Block diagram of the A20 processor:

You can get a Cubieboard2 dual-card from $52 (nov 2014)

Operating system (old)

The regular Cubieboard2 with NAND Flash comes with Android pre-installed, but we want to run a Linux OS on it.

Installation of Cubian OS on microSD card

==============================================================
(!) Important note: (december 2016):
- Cubian is based on debian wheesy, a stable but old version of Debian. Domotiga 1.0.23 requires gambas 3.7 or higher (ubuntu dependency). However, several people reports difficulties to compile gambas. The compilation is fine, but segmentation errors occur while running.
- It is difficult - impossible? - to update Cubian to Debian Jessie. The actual stable version of debian.
--> the upgrade process for jessie is failing on udev package. (https://framasphere.org/posts/566269)
--> a workaround is suggested in http://www.cubieforums.com/index.php/topic,528.msg24088.html#msg24088: create this dir

/etc/udev/kernel-upgrade

--> however, before reboot or dist-upgrade command a kernel update is necessary... And even then, lots of package require manual correction in order to work.
- the Cubian distribution seems not very active. In other words, updates are not expected in the near future.

Sollution? Armbian. See below.

====================== end important note ===================

These steps describe the process to run Cubian (which is Debian for Cubieboards) from an microSD card.
I have some difficulties getting it boot from NAND. There are post indicating that I have to flash it first
by using one of the flash tools like Phoenix- or LiveSuit. Will try that later.

1. Download the pre-made SD-card images using bittorrent using the link you can find under http://cubian.org/downloads/.
Choose the Desktop version unless you know what you are doing

2. Extract the image from the archive.
You can use Ubuntu's standard Archive Manager GUI or install a command line tool like 'p7zip-full'.

3. Insert the microSD card, the size must be at least 4GB but better 8GB or more. Use Class 10 or better to get the best performance.
Make sure it isn't mounted, and check for correct disk device with 'dmesg'
In this example the sd is assigned to /dev/sdd

$ sudo dd if=~/Downloads/Cubian-desktop-x1-a20-hdmi.img of=/dev/sdd bs=4096; sudo sync

4. Now insert the card into the Cubieboard2, and connect power.
Once the device has booted you should see a login prompt. The default username/password is cubie/cubie.
Now use 'ifconfig' to get the IP address of the board and SSH into it.

Linux Cubian 3.4.43+ #9 SMP PREEMPT Wed Sep 4 12:35:29 CST 2013 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.

5. Update the packages

$ sudo -i
# apt-get update && apt-get upgrade

5b. Set default locale
If you get warnings like: 'perl: warning: Setting locale failed.'
Reconfigure locale and set it to 'en_EN'

# dpkg-reconfigure locales
Select locale to install (nl_NL.UTF-8)
Set 'en_EN' to default.

6. Install the Cubieboard tools

# wget -O - http://packages.cubian.org/cubian.gpg.key | apt-key add -
# apt-get update && apt-get install cubian-update

7. Run update tool

# cubian-update

*** Performing self-update
*** Cubian updater v1.1.1 http://cubian.org
*** Updating firmware
*** Updating kernel
*** Updating modules
*** Depmod 3.4.43+
*** Updating fs
*** Updating bootloader on SD-Card
*** Update success, A reboot is needed for changes to take effects

8. Reboot

# reboot

NOTE: The installation process is completed here to run Cubian from microSD.

Installation of Cubian OS on NAND

The following steps describe how to install it on the NAND chip.
While it seems to install it OK, my Cubieboard will not boot from it.
I leave the notes here for later reference.

9. Install and run NAND installation script

$ sudo -i
# apt-get install cubian-nandinstall
# cubian-nandinstall

This will completely destory your data on /dev/nand, Are you sure to continue? y
2048+0 records in
2048+0 records out
1048576 bytes (1,0 MB) copied, 0,388459 s, 2,7 MB/s

*** Plese reboot then run this script again after the system is up ***

reboot now? y

10. Remove microSD card and reboot

# reboot

11. ReRun nand-install command again

$ sudo -i
# cubian-nandinstall

Updating the system

See http://cubiana73.informatick.net/steps/updates for a nice overview.
Summarized:

$ sudo apt-get update          # Update database of available packages
$ sudo apt-get upgrade         # Upgrade available packages to newest versions
$ sudo cubian-update           # Upgrade Cubian-specific files (configs, kernel)
$ sudo apt-get clean           # Clear apt-cache to have more free space on SD card

Domotiga setup

For this, follow the step as documented for the Raspberry Pi:

Enabling an additional UART

To use a Z-Wave RaZberry or to interface with other equipment using a serial port it can be handy to enable an additional UART. For this, see configuring-the-gpio-and-uart-on-the-cubieboard and cubieboard-and-arduino-via-uart, section Cubieboard side:

Convert script.bin to a human-readable format:

$ sudo bin2fex script.bin cubieboard.fex
$ sudo vi/nano cubieboard.fex

Change the [uart_para5] section to:

[uart_para5]
uart_used = 1
uart_port = 5
uart_type = 2
uart_tx = port:PH06<4><0><default><default>
uart_rx = port:PH07<4><0><default><default>

Update script.bin:

$ sudo ./fex2bin cubieboard.fex script.bin

UART5 can be accessed from U14, the 48 pin connector closest to the SATA connector:
  • pin 37 is UART5_RX
  • pin 45 is UART5_TX
  • pin 42 is GND
  • pin 44 is 3.3V
See for more information:

Running Domotiga or Gambas remotely

If you have a setup where the Cubieboard is not having monitor attached and you still want to see graphical output there are at least three options:
  • X11 over SSH
  • VNC
  • RPC

X11 over SSH

If you connect to your cubieboard client using ssh, you can indicate it should also forward X11, so ssh -P 36000 -X <cubieboard>; this should work out-of-the box if your desktop is a Linux PC, for Windows you might need something like MobaXterm, see RE: Very small font on Raspberry Pi.

The good thing about this is that windows just pop up on the machine you connect from (server), the bad thing is that things are not reacting so smoothly: When I started Domotiga (client) or Gambas on the cubieboard, the window pops up nicely but I can not really not resize it because after moving it a few pixels it freezes for some seconds.

For things like gvim or tkdiff this is however working great.

If your desktop

NB: If you get tired off typing everything -P 36000 you can add to ~/.ssh/config (replacing cubieboard by the name or address of your server):

Host cubieboard
    Port 36000

VNC

This seems to be the default method for remote GUI access, see Work remotely using VNC for instructions.

For me, VNC's snappiness was not good, it was slower than expected.

XRPC

XRPC uses VNC to transport data but does not "dumbly" transport images but information about controls, fonts, and other similar graphical primitives, see What's the difference between RDP vs VNC?

Pretty simple to install:

$ sudo apt-get --install-suggests install xrdp
Get:1 http://ftp.debian.org/debian/ wheezy/contrib tightvnc-java all 1.2.7-8 [104 kB]
Get:2 http://ftp.debian.org/debian/ wheezy/main tightvncserver armhf 1.3.9-6.4 [731 kB]
Get:3 http://ftp.debian.org/debian/ wheezy/main xrdp armhf 0.5.0-2 [241 kB]

Setting up xrdp (0.5.0-2) ...
[....] Generating xrdp RSA keys......
Generating 512 bit rsa key...

ssl_gen_key_xrdp1 ok

saving to /etc/xrdp/rsakeys.ini

done (done).
[ ok ] Starting Remote Desktop Protocol server : xrdp sesman.

The connect from your client PC use:

$ xfreerdp -a 32 -g 1920x1040 cubieboard

Enable sound

DomotiGa can play sound and at startup by default sounds/click.wav is played.
For that DomotiGa uses aplay, but that returned an error:

$ aplay -q sounds/click.wav 
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory

Luckily there seems to be audio hardware:

$ cat /proc/asound/cards
 0 [sunxicodec     ]: sunxi-CODEC - sunxi-CODEC
                      sunxi-CODEC  Audio Codec

Found eventually that aplay only works when root:

$ sudo aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: sunxicodec [sunxi-CODEC], device 0: M1 PCM [sunxi PCM]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Then found on the Internet the tip to check the permission of /dev/dsp and /dev/snd/* and saw the were owned by root, group audio. And checking using "groups $USER" found that I was not part of the audio group, so:

$ sudo usermod -a -G audio $USER
$ groups $USER
user : user adm dialout sudo audio

Then logout and login again to make alsamixer work, your audio group membership will not be effectuated.

HDMI or Analog

See this thread, analog is card0, HDMI is card1.

Time at startup

The Cubieboard2 does not have a hardware clock on board but relies on NTP to have the right time.

This is not a good solution during reboots and downtime as after power up the network is immediately up so services that are start up at startup can be using a strange time like 1-1-1970.

A work-around for this is to use the ‘fake-hwclock’ package. The package contains scripts to save the kernel’s current clock periodically and at shutdown and restore it at boot so that the system clock keeps at least close to realtime. In combination with NTP this is a simple, cheap and reasonable accurate setup for most use-cases.

Install fake-hwclock using:

$ sudo apt-get install fake-hwclock

Backup your image

If your Cubieboard is working fine, it is a good idea to make a backup of the SD card so that when something goes wrong you can put it back.

To make a 1:1 copy of the SD card, remove the card for the Cubieboard and insert it into your normal computer (you need a slot for it).
If you are running Linux the card should be probably automatically mounted and should show up when you do a "mount -l -t ext4".

To make a copy, use something like:

sudo dd bs=1024 of=cubie-dump-YYYYMMDD.img if=/dev/sde1

Where if= gives the path of the mounted device and of= specifies the output file. The output file will be the same size as the SD card.
At the end of the copy dd will give a summary like:
8850401280 bytes (8,9 GB) copied, 486,815 s, 18,2 MB/s

So the copy took a bit more than 8 minutes and you have also an idea on what is the transfer speed that can be reached with the card.
After this you can compress the image so it uses less space. To use 7zip with ultra settings (quite slow):
7za a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on cubie-dump-YYYYMMDD.img.7z cubie-dump-YYYYMMDD.img

Resources

    Updated by: johanvandyck, Updated 7 months ago
    Access count: 75456 since 2013-01-10

    Attached Files

    nothing attached yet

    OS "Armbian"

    Armbian is a debian jessie based OS for cubieboard, PI and others.

    Full doc: see https://docs.armbian.com/User-Guide_Getting-Started/
    To download, go to https://www.armbian.com/download/ select your board and download the jessie kernel (not the vanilla).

    Install OS armbian on SD

    - copy image to SD. I used win32diskimager (https://sourceforge.net/projects/win32diskimager/) on my windows machine. I use it later on to create backup images.
    - after 2x reboot, the OS is ready to use. The OS has enlarged its partition to the entire SD card storage.
    - connect a screen and keyboard to your cubieboard2. SSH was not installed by default...
    - Install SSH (Xauth), set keyboard layout (dpkg-reconfigure console-data), set timezone (dpkg-reconfigure tzdata)

    sudo apt-get Xauth
    sudo dpkg-reconfigure console-data
    sudo dpkg-reconfigure tzdata
    

    - update your OS and reboot:
    sudo apt-get update
    sudo apt-get upgrade
    sudo shutdown -r now
    

    - if root has not access to X11 connection but a regular user works fine:
    see http://askubuntu.com/questions/135249/error-when-trying-to-run-an-app-with-sudo-or-gksudo/137584#137584
    see http://askubuntu.com/questions/414785/cant-open-gedit-as-root
    sudo /etc/sudoers
    

    and add the following line at the end and reboot.
    Defaults env_keep="XAUTHORIZATION XAUTHORITY TZ PS2 PS1 PATH LS_COLORS KRB5CCNAME HOSTNAME HOME DISPLAY COLORS" 
    sudo shutdown -r now
    

    caveat: gambas3 installation

    - it should be too easy if this was the entire installation.
    Yes: uart setup is not needed anymore,
    yes: wathdog is installed by default
    yes: jessie based installation comes for free
    No: default gambas3 is too old (3.5 instead of 3.7 or newer).

    Sollution: install gambas3 from TESTING.

    - If you didn't do so, create a backup of your SD card with diskimager... You can retry in a few minutes by rewriting your SD!
    - Way to go:
    1. install jessie gambas3 and test Xauth display.
      sudo apt-get install gambas3
      gambas3
      

      Check if gambas3 gui is showing up...
      note: check with regular user and with root user. See also remarks above.
      If not working: check if display variable is set. (result of variable could vary)
      echo $DISPLAY
      localhost 10:0
      
    2. install jessie mysql-server, mysql-client, phpmyadmin and test db access and creation
      $sudo apt-get install mysql-server mysql-client phpmyadmin
      $mysql -u root -p
      mysql> CREATE USER 'testuser'@'localhost' IDENTIFIED BY 'test123test!';
      
    3. install development packages, backup dpkg
      In theory, it is not needed to install dev packages as gamba3 comes as a standalone package. However, I found many dependencies were "forgotten" like PDF. to avoid throuble, I installed dev packages. See [[https://domotiga.nl/projects/domotiga/wiki/DomotiGa_Installation]]
    4. add testing besides jessie and create pinning rules (http://jaqque.sbih.org/kplug/apt-pinning.html)
      add testing repositories
      ~/domotiga$ sudo nano /etc/apt/sources.list
      deb http://httpredir.debian.org/debian jessie main contrib non-free
      
      deb http://httpredir.debian.org/debian jessie-updates main contrib non-free
      
      deb http://httpredir.debian.org/debian jessie-backports main contrib non-free
      
      deb http://security.debian.org/ jessie/updates main contrib non-free
      deb http://repo.ajenti.org/debian main main debian
      
      deb http://ftp.us.debian.org/debian testing main non-free contrib
      deb http://non-us.debian.org/debian-non-US testing/non-US main contrib non-free
      

      It is possible the testing/non-US repo's can't update. On the internet lots of posts give comment on that. --> No big deal.
      In order to not screw up jessie with tesing too much, pinning is invited: we give preferences to packages.
      nano /etc/apt/preferences
      Package: *
      Pin: release a=jessie
      Pin-Priority: 700
      
      Package: *
      Pin: release a=jessie-backports
      Pin: release a=jessie-updates
      Pin-Priority: 200
      
      Package: *
      Pin: release a=testing
      Pin-Priority: 100
      

      The highest pin-priority will be installed. This is jessie (stable) version. The lowest is "testing". In other words, if I don't explicitely install a testing package, the stable version is used. This way we avoid poisioning of my stable jessie installation with testing packages and not to forget dependencies.
      to test preferences, use the command
      sudo apt-cache policy <package here like gambas3>
      

      You get:
      $ sudo apt-cache policy gambas3
      gambas3:
        Installed: 3.9.1-3
        Candidate: 3.9.1-3
        Version table:
       *** 3.9.1-3 100
              100 http://ftp.us.debian.org/debian testing/main armhf Packages
              100 /var/lib/dpkg/status
           3.5.4-2 500
              500 http://httpredir.debian.org/debian jessie/main armhf Packages
      
    1. remove jessie gambas3, cleanup, reboot
      sudo apt-get --remove gambas3
      sudo apt-get autoclean
      sudo apt-check
      sudo shutdown -r now
      
    2. install testing gambas3
      sudo apt-get -t testing gambas3 
      
    3. clean up the mess: in my installation the installation of 'testing gambas3' breaks mysql. I needed to reinstall testing mysql and its dependencies like phpmyadmin.
    4. install domotiga, install domotiga as a service, create db via external client of manually.
    5. due to bug in qt5 in combination with gambas 3.9.1, domotiga full client won't startup. The servers is working fine.
      ~/domotiga> ./Domotiga3.gambas
      failed to get the current screen resources
      QXcbConnection: XCB error: 172 (Unknown), sequence: 163, resource id: 150, major code: 149 (Unknown), minor code: 20
      

    note: as time passes, I will publish more detail in the steps above...

    Johan Van Dyck.

    cubieboard2.jpg (182 KB) rdnzl, 10/01/2013 04:13 PM

    a20.png (123 KB) rdnzl, 10/01/2013 04:17 PM

    Also available in: PDF HTML TXT