First steps

When I have free time I experiment with my A20-OLinuXino-MICRO board a lot. Sometimes those experiments lead to a screwed filesystem on SD card, ubootable or unstable system. Writing a fresh and working image to the SD card is unevitable but then all previously made modifications are lost. I decided to keep track of the most common changes I made.

  • Exstending filesystem

My Arch Linux ARM image is less than 1 GB in size and my uSD card is 8GB so I have almost 7 GB unallocated space on the card after I write the Linux image to it. There are multiple ways to extend the partition and FS, that is what I use:

[root@alarm-a20 ~]# fdisk /dev/mmcblk0
Welcome to fdisk (util-linux 2.26.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): d
Selected partition 1
Partition 1 is deleted

Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-15564799, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-15564799, default 15564799):
Using default value 15564799
Partition 1 of type Linux and of size 7.4 GiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@alarm-a20 ~]# shutdown -r now
[root@alarm-a20 ~]# resize2fs /dev/mmcblk0p1

  • Minimize writing to SD card
  1. Disable systemd journald logging to filesystem (uSD card):

Edit /etc/systemd/journald.conf, uncomment Storage option and change it to none


2. Change pacman cache directory to /tmp:

Edit /etc/pacman.conf, uncomment CacheDir option and change it to /tmp/cache/pacman/pkg/

CacheDir    = /tmp/cache/pacman/pkg/

  • Colorify the console
  1. More colors in pacman output:

Edit /etc/pacman.conf, uncomment Color option

2. More colors in bash – to be filled later

  • Change time zone
[root@alarm-a20 ~]# timedatectl set-timezone Europe/Sofia 


Posted in Uncategorized | Tagged , , , , | Leave a comment

Overclocking memory on A20-OLinuXino-MICRO – part 2

Unfortunately my board is not running stable with 480MHz RAM clock, actually it is crashing quite often. Several other A20-OLinuXino customers wrote a comment below my blog post that their boards are also not stable with that memory speed. That is why I decided to dig deeper in the u-boot configuration. Why u-boot? Because u-boot initializes the memory subsystem of the board and all memory configuration of the board is there – memory speed (in MHz), CAS latency, bus width, etc… The file for A20-OLinuXino-MICRO is located in board/sunxi/dram_a20_olinuxino_m.c in u-boot-sunxi source. Two important options can be changed – clock and cas.
Memory clock – default is 384 MHz, can be a number that divides to 24 with remainder 0, e.g. 360, 384, 408, 432, 456, 480, 504, 528.
CAS latency – lower is better, default is 9, can be 9, 8, 7, 6.
My board is currently running with memory speed of 408 MHz and CAS Latency 6, stable for 10 days without any issues.
It seems like the integrated memory controller just cannot run reliably with higher memory speed, but lowering the CAS latency of the memory is just fine.
Another option that is good to be enabled for A20-OLinuXino is the FAST_MBUS, more info in the following 2 commits:
It is currently enabled by default for Cubieboard 2, Cubietruck and other Allwinner A20 based boards.
All you have to do is to edit the boards.cfg file in the u-boot-sunxi source and add FAST_MBUS options to the A20-OLinuXino-MICRO entry:
“Active arm armv7 sunxi – sunxi A20-OLinuXino_MICRO sun7i:A20_OLINUXINO_M,CONS_INDEX=1,STATUSLED=226,SPL,SUNXI_EMAC,FAST_MBUS
Recompile and install the modified u-boot as shown in the preious blog post:

Good luck!

Posted in Uncategorized | Tagged , , , , | Leave a comment

Mining crypto coins with A20-OLinuXino-MICRO?

Crypto coin craze is still going strong with Bitcoin price reaching $880 (up from ~$15 twelve months ago).
Everyday there is a new crypto coin being released to the masses.
I just wanted to test whether the SoC in my A20-OLinuXino-MICRO is powerful enough to dig the virtual gold.
Unfortunately the Mali 400 GPU doesn’t have OpenCL support, so one can mine coins only with the CPU – dual core Cortex A7.
I installed pooler’s cpuminer from AUR and below you can see the results:
1. Bitcoin (and all other SHA256 based coins):

CPU @ 912 MHz, RAM @ 480 MHz, ondemand governor:

$ minerd -a sha256d –benchmark
[2014-01-03 14:06:16] Binding thread 1 to cpu 1
[2014-01-03 14:06:16] 2 miner threads started, using ‘sha256d’ algorithm.
[2014-01-03 14:06:16] Binding thread 0 to cpu 0
[2014-01-03 14:06:25] thread 1: 2097152 hashes, 220.53 khash/s
[2014-01-03 14:06:26] thread 0: 2097152 hashes, 212.54 khash/s
[2014-01-03 14:06:30] thread 1: 1102665 hashes, 269.81 khash/s
[2014-01-03 14:06:30] Total: 482.35 khash/s
[2014-01-03 14:06:30] thread 0: 1062709 hashes, 260.29 khash/s
[2014-01-03 14:06:35] thread 1: 1349036 hashes, 269.81 khash/s
[2014-01-03 14:06:35] Total: 530.10 khash/s
[2014-01-03 14:06:35] thread 0: 1301454 hashes, 259.85 khash/s
[2014-01-03 14:06:40] thread 1: 1349041 hashes, 269.81 khash/s
[2014-01-03 14:06:40] Total: 529.66 khash/s
[2014-01-03 14:06:40] thread 0: 1299256 hashes, 259.72 khash/s
[2014-01-03 14:06:45] thread 1: 1349044 hashes, 269.81 khash/s
[2014-01-03 14:06:45] Total: 529.53 khash/s

CPU overclocked to 1110 MHz, RAM @ 480 MHz, ondemand governor:

$ minerd -a sha256d –benchmark
[2014-01-03 14:13:47] Binding thread 1 to cpu 1
[2014-01-03 14:13:47] 2 miner threads started, using ‘sha256d’ algorithm.
[2014-01-03 14:13:47] Binding thread 0 to cpu 0
[2014-01-03 14:13:55] thread 1: 2097152 hashes, 266.64 khash/s
[2014-01-03 14:13:55] thread 0: 2097152 hashes, 258.74 khash/s
[2014-01-03 14:13:59] thread 1: 1333180 hashes, 326.66 khash/s
[2014-01-03 14:13:59] Total: 585.40 khash/s
[2014-01-03 14:13:59] thread 0: 1293725 hashes, 316.57 khash/s
[2014-01-03 14:14:04] thread 1: 1633276 hashes, 326.66 khash/s
[2014-01-03 14:14:04] Total: 643.22 khash/s
[2014-01-03 14:14:04] thread 0: 1582833 hashes, 316.54 khash/s
[2014-01-03 14:14:09] thread 1: 1633287 hashes, 326.66 khash/s
[2014-01-03 14:14:09] Total: 643.20 khash/s
[2014-01-03 14:14:09] thread 0: 1582723 hashes, 317.21 khash/s
[2014-01-03 14:14:14] thread 1: 1633278 hashes, 326.66 khash/s
[2014-01-03 14:14:14] Total: 643.87 khash/s
[2014-01-03 14:14:14] thread 0: 1586071 hashes, 316.56 khash/s

With the current difficulty of 1418481395 and hashrate of 643 kHash/s (overclocked) you’ll mine 1 bitcoin after 12000 years 🙂
Good luck with that

2. Litecoin (and all other scrypt based coins):

CPU @ 912 MHz, RAM @ 480 MHz, ondemand governor:

$ minerd –benchmark
[2014-01-03 14:04:06] Binding thread 1 to cpu 1
[2014-01-03 14:04:06] Binding thread 0 to cpu 0
[2014-01-03 14:04:06] 2 miner threads started, using ‘scrypt’ algorithm.
[2014-01-03 14:04:17] thread 1: 4096 hashes, 0.36 khash/s
[2014-01-03 14:04:18] thread 0: 4096 hashes, 0.34 khash/s
[2014-01-03 14:04:21] thread 1: 1784 hashes, 0.42 khash/s
[2014-01-03 14:04:21] Total: 0.77 khash/s
[2014-01-03 14:04:22] thread 0: 1715 hashes, 0.41 khash/s
[2014-01-03 14:04:26] thread 1: 2125 hashes, 0.42 khash/s
[2014-01-03 14:04:26] Total: 0.83 khash/s
[2014-01-03 14:04:27] thread 0: 2038 hashes, 0.41 khash/s
[2014-01-03 14:04:31] thread 1: 2124 hashes, 0.42 khash/s
[2014-01-03 14:04:31] Total: 0.83 khash/s
[2014-01-03 14:04:32] thread 0: 2038 hashes, 0.41 khash/s
[2014-01-03 14:04:36] thread 1: 2124 hashes, 0.42 khash/s
[2014-01-03 14:04:36] Total: 0.83 khash/s
[2014-01-03 14:04:37] thread 0: 2040 hashes, 0.41 khash/s

CPU overclocked to 1110 MHz, RAM @ 480 MHz, ondemand governor:

$ minerd –benchmark
[2014-01-03 14:14:20] Binding thread 0 to cpu 0
[2014-01-03 14:14:20] Binding thread 1 to cpu 1
[2014-01-03 14:14:20] 2 miner threads started, using ‘scrypt’ algorithm.
[2014-01-03 14:14:28] thread 1: 4096 hashes, 0.52 khash/s
[2014-01-03 14:14:29] thread 0: 4096 hashes, 0.50 khash/s
[2014-01-03 14:14:33] thread 1: 2577 hashes, 0.52 khash/s
[2014-01-03 14:14:33] Total: 1.01 khash/s
[2014-01-03 14:14:34] thread 0: 2477 hashes, 0.50 khash/s
[2014-01-03 14:14:38] thread 1: 2577 hashes, 0.52 khash/s
[2014-01-03 14:14:38] Total: 1.01 khash/s
[2014-01-03 14:14:39] thread 0: 2481 hashes, 0.50 khash/s
[2014-01-03 14:14:43] thread 1: 2577 hashes, 0.52 khash/s
[2014-01-03 14:14:43] Total: 1.01 khash/s
[2014-01-03 14:14:44] thread 0: 2478 hashes, 0.50 khash/s
[2014-01-03 14:14:48] thread 1: 2577 hashes, 0.52 khash/s
[2014-01-03 14:14:48] Total: 1.01 khash/s

With 1 kH/s you’ll mine around 0.1 litecoins (worth $3.4) for 1 year with the current difficulty of 3195.34:
Just enter the price of electricity in your area and board consumption under load (should be not more than 3-4 W) to see your profit (or your loss 🙂 ).

Posted in Uncategorized | Tagged , , , , , , | 1 Comment

Overclocking memory on A20-OLinuXino-MICRO

If you compare Cubieboard2 and A20-OLinuXino-MICRO you’ll probably see one big difference in memory configuration.
DRAM is clocked at 480 MHz on the former board and 384 MHz on the latter.
That is a huge 25% difference and you will probably ask why?
Maybe Olimex are using cheaper memory capable of running stable at lower speed only?No.
I’ve seen explanation in linux-sunxi IRC channel that around 20% of the A20 chips cannot run stable with memory clocked higher than 400 MHz.
I decided to raise the speed of DRAM of my board and see what are the gains.
I used a10-meminfo software which shows the current DRAM parameters of board and tinymembench for testing speed and latency of memory.

Installation is done via:

$ git clone
$ cd a10-meminfo/
# ./a10-meminfo-static | grep dram_clk
dram_clk = 384
$ cd ..
$ git clone
$ cd tinymembench/
$ su
# CFLAGS=”-march=armv7-a -mtune=cortex-a7″ make
$ ./tinymembench

Then you have to download, modify, compile and reinstall u-boot on your board.
Many of the step are already explained here:
File that needs to be modified is “board/sunxi/dram_a20_olinuxino_m.c” in u-boot-sunxi directory.
Change line “.clock = 384” to “.clock = 480”, save file and compile u-boot.
Then transfer u-boot-sunxi-with-spl.bin to /boot directory of the SD card (I used SSH).
As a final step reinstall u-boot:
# dd if=u-boot-sunxi-with-spl.bin of=/dev/mmcblk0 bs=1024 seek=8
and reboot …
Verify the change by running a10-meminfo-static and tinymembench.

Below you can find the difference in the memory performance in tinymembench:

1. Memory bandwidth tests (MB/s):


2. Memory latency tests (nanoseconds, lower is better):


Posted in Uncategorized | Tagged , , , , | 6 Comments

HOWTO Build Arch Linux ARM for A20-OLinuXino-MICRO

Yet another edit in September 2015: As of mid 2015 A20-OLinuXino-MICRO and many other Olimex AllWinner-based board are officailly supported in Arch Linux ARM


Edit: As of late 2014 it is no longer needed to setup toolchain, download and compile kernel, etc… in order to run Arch Linux ARM on your A20-OLinuXino-MICRO board.

ALARM developers provide generic AllWinner sun7i (A20), sun4i (A10) and sun5i (A13, A10s) rootfs and kernel.

There are also u-boot pacman packages for many boards including A20-OLinuXino-MICRO located here:

So here is a simplified version how to install Arch Linux ARM on your A20-OLinuXino-MICRO board:

Follow the official guide for Cubieboard 2 (Installation tab):
Execute steps 1-4.
Download u-boot package for A20-OLinuXino-MICRO, current one is available here:

Open it with Archive program such as Archive Manager, Ark, etc. Go to boot directory and extract the 3 files (uEnv.txt, script.bin, u-boot-sunxi-wth-spl.bin) on mnt/boot replacing the Cubieboard ones.

Proceed with steps 5-7 from Cubieboard2 guide (except that you need 12V power supply). Once board is up and running and connected to the Internet, install and overwrite u-boot via:

pacman -Sy uboot-a20-olinuxino-micro

End of edit

1. Setup the toolchain

You’ll need a machine running Linux or (the recommended way) – virtual machine running Linux :). For the preparation of this guide I used a VirtualBox VM running the latest stable Lubuntu x86_64 13.04. Make sure that you configure the VM with at least 1 GB memory and 10 GB virtual disk. Assign as many CPU cores as you can to the VM. That will speed up the kernel compilation considerably. It is also recommended to update the VM software packages before you proceed (apt-get update && apt-get upgrade in Debian based distros, yum update in RedHat based, etc…).The commands below are based on my Lubuntu VM setup.

To install the toolchain open a terminal in the VM and write:

$ sudo apt-get install build-essential u-boot-tools uboot-mkimage binutils-arm-linux-gnueabihf gcc-4.7-arm-linux-gnueabihf-base gcc-arm-linux-gnueabihf git wget

2. Building U-Boot

U-Boot (Universal Bootloader) is an open source, primary boot loader used in embedded devices. It is available for a number of different computer architectures, including PPC, ARM, MIPS, AVR32,x86, 68k, Nios, and MicroBlaze (source: wikipedia). U-Boot for AllWinner SoCs is maintained by the linux-sunxi community.

You can download the uboot sources from Linux-sunxi GitHub repository:

$ git clone -b sunxi

After the download is complete you should have a new directory in your home directory

$ cd u-boot-sunxi/

With the following command you start the build process for A20-OlinuXino U-Boot:

$ make A20-OLinuXino_MICRO CROSS_COMPILE=arm-linux-gnueabihf-

At the end of the compilation you can check if everything is OK by checking file:

$ ls -l u-boot-sunxi-with-spl.bin

Change to the parent (home directory) before you continue to the next step:

$ cd ..

3. Get the board specific FEX file and create script.bin

A FEX file defines various aspects of how the SoC works. It configures the GPIO pins and sets up DRAM, Display, etc parameters. You can find the useful FEX guide here:

Download the sunxi-tools:

$ git clone

Change current directory to:

$ cd sunxi-tools/

Download the A20-OLinuXino-MICRO FEX file:

$ wget

Create script.bin from the downloaded fex file:

$ ./fex2bin a20-olinuxino_micro.fex > script.bin

You can also try the reverse process – generate fex file from script.bin with bin2fex and comapare the 2 fex files (the original one and the one created after2 transformations).

Change to the parent (home directory) before you continue to the next step:

$ cd ..

4. Building Linux kernel for A20-OLinuXino

The current state of the support for AllWinner A20 by the Linux-sunxi community developers is still WIP. However, most of the stuff should work just fine. If you find a bug in the sunxi kernel you can contact the developers via

Kernel sources for A20 are available on GitHub. There are many git branches, but I suppose the most effort is given to sunxi-3.4 tree. You can download the source using the following command:

$ git clone -b sunxi-3.4

After the download is complete go to the kernel directory:

$ cd linux-sunxi/

Now you need A20 kernel configuration file –A20Olinuxino_defconfig. The file contains all kernel module settings. I cannot find an official one so I used the defconfig provided by Dimitar Gamishev (HeHoPMaJIeH):

$ wget -O arch/arm/configs/A20olinuxino_defconfig

Generate a .config file with:

$ make ARCH=arm A20olinuxino_defconfig

If you would like to disable/enable additional kernel modules you can also execute (Note: you need also “ncurses-dev” package):

$ make ARCH=arm menuconfig

Compile the kernel and modules. This will take from 10 minutes to 2+ hours depending on the speed of your computer and/or the number of processor cores that you assigned to the virtual machine:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4 uImage

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4 INSTALL_MOD_PATH=out modules

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4 INSTALL_MOD_PATH=out modules_install

At this point you have kernel image and kernel modules.

The uImage file is located in ~/linux-sunxi/arch/arm/boot/

The kernel modules are located in


where 3.x.xx is kernel version

Don't forget to switch to the parent (home) directory when you are ready with the kernel image and modules compilation:
$ cd ..

5. Build an Arch Linux ARM image (the dirty way)

Download the latest Arch Linux ARM image for sun7i (AllWinner A20) architecture. This image only supports Cubieboard 2 for now, but I hope that A20-OLinuXino will be supported too in the near future.

$ wget

You can write the rootfs, kernel, u-boot, etc… directly on a microSD card, but I prefer a more flexible way:

  • Power down the virtual machine

  • Present a new virtual disk with size 900 MB to the VM.

  • Start the VM

  • Now you have a second drive (/dev/sdb) which you can use as a virtual SD card 🙂

Create partition on /dev/sdb:

$ sudo fdisk /dev/sdb

Press n for new, accept the defaults, write changes to disk with w

Fortmat the partition with ext4 filesystem:

$ sudo mkfs.ext4 -m 1 /dev/sdb1

Create directory in your home directory where you’ll mount the image:

$ mkdir mnt

Mount /dev/sdb1:

$ sudo mount /dev/sdb1 mnt/

Untar the ALARM image:

$ sudo tar -C mnt/ -zxf ArchLinuxARM-sun7i-latest.tar.gz

Change current directory to mnt/boot:

$ cd mnt/boot

Overwrite the files in boot with the files produced in the previous steps:

$ sudo rm uEnv.txt

$ sudo cp ../../sunxi-tools/script.bin .

$ sudo rm u-boot.bin

$ sudo rm sunxi-spl.bin

$ sudo cp ../../u-boot-sunxi/u-boot-sunxi-with-spl.bin .

$ sudo cp ../../linux-sunxi/arch/arm/boot/uImage .

Install the boot loader:

$ sudo dd if=u-boot-sunxi-with-spl.bin of=/dev/sdb bs=1024 seek=8

Switch to ~/mnt/usr/lib/modules and remove the 2 directories:

$ cd ../usr/lib/modules

$ sudo rm -rf 3.3.0-2-ARCH/ extramodules-3.3—sun7i/

Copy the modules that you compiled in step 4 here:

$ sudo cp -aRv ../../../../linux-sunxi/out/lib/modules/* .

Remove the following 2 directories from pacman (Arch package manager) config:

$ sudo rm -rf ~/mnt/var/lib/pacman/local/linux-sun7*

$ sudo rm -rf ~/mnt/var/lib/pacman/local/uboot-cub*

Else on the next update the wrong kernel/uboot will overwrite yours.

Unmount the Arch filesystem:

$ sudo umount mnt/

Create ALARM image:

$ sudo dd if=/dev/sdb of=alarm-a20.img bs=1M

That’s it! Now you have an unofficial ALARM image for your beloved A20-OlinuXino-MICRO 🙂

Default username/password is : root / root

You can find prebuild images in the Olimex forum thread:

Posted in Uncategorized | Tagged , , , , , | 13 Comments