Building the Ultimate Debian SD card for Linux with Kernel 3.4 for A20-OLinuxino-MICRO



EDIT: there is newer image with hardware accelerated video:


This is step by step instruction how to Build Debian for A20-OLinuXino with Kernel 3.4

We call this image ULTIMATE as it supports all hardware features and fix all known bugs to the moment 🙂

The built image ready to write on SD card will be linked on our wiki in a hour, these steps below are just for Linux geeks who want to know how things happend and want to do Debian distribution by themself or to modify it.

1. Setup of the toolchain

You should make sure you have the tools for building the Linux Kernel and install them if you don’t have them. To install new software you should be with super user rights on your Linux machine, so do this type in a terminal.

$ sudo su

you will be asked for your password and then your prompt will change to # which means you are now the super user, all future commands should be run in this mode.

First update apt-get links by typing

# apt-get update

Install the toolchain by typing the following.

# apt-get install gcc-4.7-arm-linux-gnueabihf ncurses-dev uboot-mkimage build-essential git

This will install: GCC compiler used to compile the kernal, The kernel config menu
uboot make image which is required to allow the SD card to book into the linux image, Git which allows you to download from the github which holds source code for some of the system, Some other tools for building the kernel

Note that if you use debian may be you will need to add

deb squeeze main

in the file below:


after the installation you now have all tools to make your very own A20 kernel image!

2. Building Uboot

The Allwinner Linux-Sunxi community uboot is maintained by Henrik Nordstrom aka hno on Freenode irc. You can find him in #linux-sunxi or #olimex channels, if something with uboot is broken he is your man 🙂

First let’s make the directory where we will build the A20-OLinuXino-Micro linux:

# mkdir a20_kernel_3.4/
# cd a20_kernel_3.4/

Then let’s download the uboot sources from GitHub repository, note there are lot of branches but you have to use sunxi branch.
Note that the OLinuXino-A20-Micro board u-boot is tested with the next branch:

# git rev-parse --verify HEAD

Download u-boot sourses:

# git clone -b sunxi

After the download you should have a new directory

# cd u-boot-sunxi/

With the following command you can start the uboot build:

# make a20-olinuxino_micro CROSS_COMPILE=arm-linux-gnueabihf-

At the end of the process you can check if everything is OK by

# ls u-boot.bin u-boot-sunxi-with-spl.bin spl/sunxi-spl.bin
spl/sunxi-spl.bin u-boot.bin u-boot-sunxi-with-spl.bin

If you got these files everything is complete, well done so far

# cd ..

You should be in the following directory


3. Building kernel sources for Olinuxino-A20-Micro

The Allwinner Linux-Sunxi community Kernel developers can be reached on

Kernel sources for A20 are available on GitHub. Note that the following building is made with the revision below:

# git rev-parse --verify HEAD

You can download the kernel sources using the following command:

# git clone

After the download go to the kernel directory

# cd linux-sunxi/

Here you need from a20 configuration file – a20_defconfig. The file contains all kernel module settings.

Download a20_defconfig then copy a20_defconfig file to configs directory:

# cp a20_defconfig linux-sunxi/arch/arm/configs/.

and make:

# make ARCH=arm a20_defconfig

The result should be:

configuration written to .config

If you wish to make your changes in the kernel configuration do:

# make ARCH=arm menuconfig

The menuconfig changes a .config text file, which you can view/edit even with a text editor like vi,nano.

With this command you can add or remove different modules for the different peripherials in the kernel. Be careful when use this as this may cause the kernel to not work properly.

Note that before compiling kernel you have to do a patch realted with I2C speed. The patch changes i2c speed from 200kHz to 100kHz.

If you want to use some of olimex’s i2c modules on UEXT then you need from this patch.

download the patch sunxi-i2c.patch and apply the patch:

# patch -p0 < sunxi-i2c.patch

Now you can continue with kernel image compiling

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

when this finish’s you will have uImage ready and the result should be:

Image Name: Linux-3.4.67+
Created: Mon Sep 16 13:39:04 2013
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 5450904 Bytes = 5323.15 kB = 5.20 MB
Load Address: 40008000
Entry Point: 40008000
Image arch/arm/boot/uImage is ready

Now you can build the kernel modules:

# 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

DONE! At this point you have uboot 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

in our case the directory with modules is:


4. Format and setup the SD-card

We suggest 4GB class 10 micro sd-card but you can use any card between 2GB and 16GB.

First we have to make the correct card partitions, this is done with fdisk.

Plug SD card into your SD card reader and enter in the terminal

# ls /dev/sd

Then press two times <TAB> you will see a list of your sd devices like sda sdb sdc note that some of these devices may be your hard disk so make sure you know which one is your sd card before you proceed as you can damage your HDD if you choose the wrong sd-device. You can do this by unplugging your sd card reader and identify which “sd” devices remove from the list.

Once you know which device is your sdcard like sda use this text instead of the sdX name in the references below:

# fdisk /dev/sdX

then do these steps:

1. p

will list your partitions

if there are already partitions on your card do:

2. d enter 1

if you have more than one partitition press d while delete them all

3. create the first partition, starting from 2048

n enter p enter 1 enter enter +16M

4. create second partition

n enter p enter 2 enter enter enter

then list the created partitions:

p enter

if you did everything correctly on 4GB card you should see something like:

Disk /dev/sdg: 3980 MB, 3980394496 bytes
123 heads, 62 sectors/track, 1019 cylinders, total 7774208 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System

/dev/sdg1 2048 34815 16384 83 Linux
/dev/sdg2 34816 7774207 3869696 83 Linux

7. w

write changes to sd card
now we have to format the file system on the card:

the first partition should be vfat as this is FS which the Allwinner bootloader understands

# mkfs.vfat /dev/sdX1

the second should be normal Linux EXT3 FS

# mkfs.ext3 /dev/sdX2

5. Write the Uboot and sunxi-spl.bin

You should be in /home/user/a20_kernel_3.4/# directory
Note that you have to write u-boot-sunxi-with-spl.bin in /dev/sdX (not sdX1 or sdX2)

# dd if=u-boot-sunxi/u-boot-sunxi-with-spl.bin of=/dev/sdX bs=1024 seek=8

6. Write kernel uImage you build to the SD-card

You should be in the directory below

/home/user/a20_kernel_3.4/# directory 
# mount /dev/sdX1 /mnt/sd

copy the Kernel uImage to root directory in partition 1

# cp linux-sunxi/arch/arm/boot/uImage /mnt/sd

7. Write script.bin file

script.bin is a file with very important configuration parameters like port GPIO assignments, DDR memory parameters, Video resolution etc,

download the script.bin file

# cp script.bin /mnt/sd
# sync
# umount /dev/sdX1

8. Debian rootfs

The Linux Kernel and Uboot are ready, now we have need from Linux distribution rootfs.

Basically the only difference between the different Linux distributions is the rootfs, so if you put Debian rootfs you will have Debian, if you put Ubuntu rootfs it will be Ubuntu etc.

How to build one is a long topic, the good thing is that there are many already pre-built so we can just download one and use.

exit the kernel directory

# cd ..

You should be in the directory below

# /home/user/a20_kernel_3.4/

download debian rootfs – debian_34_67_fs.tgz

mount your sd card EXT3 FS partition:

# mkdir /mnt/sd
# mount /dev/sdX2 /mnt/sd

and unarchive the rootfs

# tar xzvf debian_34_67_fs.tgz -C /mnt/sd
# ls /mnt/sd

the right result should be:

bin dev home lost+found mnt proc run selinux sys usr
boot etc lib media opt root sbin srv tmp var

Now you have to replace the new generated kernel modules from

/home/user/a20_kernel_3.4/linux-sunxi/out/lib/modules/ to the new debian file system

# rm -rf /mnt/sd/lib/modules/*
# cp -rfv linux-sunxi/out/lib/modules/3.x.xx+/ /mnt/sd/lib/modules/

where x.xx is the kernel version

in our case:

# cp -rfv linux-sunxi/out/lib/modules/3.4.67+/ /mnt/sd/lib/modules/

replace /lib/firmware folder with the generated /linux-sunxi/out/firmware

#rm -rf /mnt/sd/lib/firmware/
#cp -rfv linux-sunxi/out/lib/firmware/ /mnt/sd/lib/
# sync
# umount /mnt/sdX2

at this point you have Debian on your SD card second partition and
you have an SD card ready to boot debian on A20-OLinuXino-Micro

Connect USB-SERIAL-CABLE-F to UEXT Tx.Rx and GND, or connect a HDMI screen. Put the SD-card in A20-OLinuXino-Micro and apply 6-16V power, you should see Uboot and then Kernel messages on the console

default username/password is : root / olimex

43 Comments (+add yours?)

  1. Kristijan
    Nov 05, 2013 @ 19:38:17

    A great manual. Can you offer the same for “Ultimate Android”?


  2. Asbjørn Mikkelsen
    Nov 05, 2013 @ 19:52:49

    Is this the same as release 5 that is available from the wiki page?
    Is the Mali-drivers going to be added on this anytime?


  3. A20 fan
    Nov 05, 2013 @ 19:54:59

    Are drivers for CSI camera modules included in this release?


  4. Kenny
    Nov 05, 2013 @ 20:39:22

    It would be great to see the same tutorial with a 3.12 kernel now that it should have support.


  5. Philippe Van Hecke
    Nov 05, 2013 @ 21:16:45

    spi support ?


  6. Franco
    Nov 06, 2013 @ 11:47:17

    When a tutorial for upgrading from previous Debian SD without formatting?


  7. cmaurice
    Nov 06, 2013 @ 12:45:37

    Thanks for this. Could you say a little about the rootfs used in the build?


  8. tm
    Nov 28, 2013 @ 15:03:42

    Building the rootfs would be in interesting part. Maybe even using emdebian.


  9. Seth Williams
    Dec 19, 2013 @ 07:56:07

    Hey Olimex, that was a very detailed and informative tutorial. Thanks a lot for sharing. We too have some advanced Linux tutorials on our website ( that your readers can refer to.


  10. zboonet
    Dec 27, 2013 @ 23:18:18

    Hey !

    I’ve had issues on installing the toolchain. Package gcc-4.7-arm-linux-gnueabihf was not found, and I had dependency problems.

    It has been solved by putting the following line in /etc/apt/sources.list
    deb unstable main



  11. CheniX
    Jan 16, 2014 @ 17:14:01

    Not possible just to install in the MEM? I have 4G on the board


  12. codeninja89
    Jan 28, 2014 @ 08:40:33

    I have a A20 based tablet (Android!). I guess the steps given here will be sufficient to boot a SD card on the tablet, right? I have to pull my tablet’s script.bin and write it to thte boot partition along with the uboot image. I just want to clarify that what I’m understanding is right.


    • OLIMEX Ltd
      Jan 28, 2014 @ 09:44:48

      yes, image generation should work for any A20 device if you can describe correctly the hardware in the script.bin file


      • codeninja89
        Jan 29, 2014 @ 12:47:25

        done!! Booted Ubuntu 12.04 on an Android A20 based tablet. Still can’t figure out how to get a GUI (I’m stuck at “localhost login:” prompt). I guess, I will try the debian image. I hope that works.

        There are a few steps where I had to deviate from your instructions. I’ll write a blog post tonight and link it here so that others may find it usefull too.

  13. codeninja89
    Jan 30, 2014 @ 12:52:42

    Ok, so I’m a kinda writer and my blog posts have a personal story/experience to go with something technical. So whatever… here it is:

    I had to make several deviations from yor method… mine is more generic. For instance, a20_defconfig does not work. I had to use sun7i_defconfig (as per Linux-SunXi wiki). I’m pretty sure that it will work on any tablet running an A20 processor.


  14. Ray Smith
    Feb 21, 2014 @ 23:11:31

    I’m not understanding why I can’t just download an iso and write it to a memory card. can you explain?


  15. Pete
    Feb 26, 2014 @ 13:12:37

    Looks like this build process doesn’t work any more (3 months after it was written).
    Adding the
    and re-running apt-get update now produces the following:
    root@A20:~# apt-get update
    Hit wheezy Release.gpg
    Get:1 squeeze Release.gpg [198 B]
    Hit wheezy Release
    Hit squeeze Release
    Ign squeeze Release
    Hit wheezy/main Sources
    Hit wheezy/contrib Sources
    Hit wheezy/non-free Sources
    Hit wheezy/main armhf Packages
    Hit wheezy/contrib armhf Packages
    Hit wheezy/non-free armhf Packages
    Hit wheezy/contrib Translation-en
    Hit wheezy/main Translation-en
    Hit wheezy/main Translation-es
    Hit wheezy/non-free Translation-en
    Err squeeze/main armhf Packages
    404 Not Found
    Ign squeeze/main Translation-en_US
    Ign squeeze/main Translation-en
    Ign squeeze/main Translation-es
    Fetched 198 B in 2s (90 B/s)
    W: GPG error: squeeze Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY B5B7720097BB3B58
    W: Failed to fetch 404 Not Found
    E: Some index files failed to download. They have been ignored, or old ones used instead.
    and the apt-get install fails, as a consequence:
    root@A20:~# apt-get install gcc-4.7-arm-linux-gnueabihf ncurses-dev uboot-mkimage build-
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    Note, selecting ‘libncurses5-dev’ instead of ‘ncurses-dev’
    E: Unable to locate package gcc-4.7-arm-linux-gnueabihf
    E: Couldn’t find any package by regex ‘gcc-4.7-arm-linux-gnueabihf’
    E: Unable to locate package build
    Time for an Ultimate ultimate build, perhaps? This time with NAND support included, please.


  16. Filippo
    Mar 04, 2014 @ 00:49:18

    Hi there, this is a really good tutorial.
    The only thing is missed in my opinion is the settings for the script.bin file using fex from sunxi-tools…
    I have a question: after SD creation Debian start, by default, with XFCE as root, I created another user but how I can set the system to start with XFCE login shell to select with which user login?


  17. Armando B.
    Mar 05, 2014 @ 18:25:53

    Hi, i trying to build branch sunxi-next or reference-3.10 but i have a config file problem. I used multi_v7_defconfig but when i ‘make modules’ i obtain few modules. Could be shared a config file like this a20_defconfig that is good for one of this branch ?


  18. Trackback: Building A20-OLinuXino-MICRO Debian image with hardware accelerated video | olimex
  19. Trackback: croos compiling arm-linux-gnueabihf
  20. Joshua Bellamy-Henn
    Jun 07, 2014 @ 10:20:59

    I have created some builds scripts out of this tutorial, see:


  21. fdap
    Oct 19, 2014 @ 20:04:24

    Hi, I m really a newbie in programming a board and I recently bought an olinuxino a20 micro 4g board. As far as I know, Android is already loaded on NAND but I would like to work with Debian instead.
    I downloaded the Debian image from the Olimex wiki and used win32 disk imager to write that image on the micro sd card. I didn’t bought the serial cable F from the Olimex, I just did it by myself. Now I am trying to work with the Olinuxino for the first time using Ubuntu on my laptop. I connected the serial cable, inserted the sd card in the board and applied the power. I tried with minicom, picocom and screen but I can’t make the installation start and actually I don’t receive anything from the board. I realize that for most of you this is really a stupid question but, since I am a newbie I really don’t know what I am doing wrong.
    Can somebody please help me?


  22. emile
    Nov 15, 2014 @ 14:21:44


    I’m not on a debian-like distribution so I created a repository with a Dokerfile and some scripts in order to build sunxi kernel/tools and create a minimal debian rootfs:
    I have two comments:
    – the patch sunxi-i2c.patch is not even necessary with the last version of Linux sunxi kernel
    – the github u-boot-sunxi project is not up to date with so A20-OLinuXino-Lime2_defconfig file is not found for configuration before compilation ( that will cause make: *** No rule to make target… error)

    Thanks for the tutorial !


  23. dod
    Dec 03, 2014 @ 10:19:35

    A piece of advice for uboot noob like me…

    The list of supported boards change quite often. Before compiling uboot, you must find the relevant definition for an olinux board:

    $ perl -ae ‘print $F[6],”\n” if /olinux/i;’ boards.cfg

    Choose the name that matches your boards and use it to configure uboot by running “make _config”:

    $ make A20-OLinuXino-Lime_config

    Then compile uboot:

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

    Note: you can use the perl oneliner to find other boards by replacing “olinux” with your board name in the regular expression (between the ‘/’ characters)

    Hope this helps


  24. dod
    Dec 03, 2014 @ 11:14:12

    Rats, wordpress garbled my text. When you find your board name, you should run “make «board_name»_config”, not just “make _config”


  25. Vinicius Mauricio
    Jan 15, 2015 @ 20:09:57

    I have a error when i try start the uboot build:
    I try this:

    # make A20-OLinuXino-Micro_config CROSS_COMPILE=arm-linux-gnueabihf-
    # make CROSS_COMPILE=arm-linux-gnueabihf-

    Buy i have this result:
    CHK include/config/uboot.release
    CHK include/generated/version_autogenerated.h
    CHK include/generated/timestamp_autogenerated.h
    UPD include/generated/timestamp_autogenerated.h
    HOSTCC tools/dumpimage.o
    HOSTCC tools/image-host.o
    HOSTCC tools/mkenvimage.o
    HOSTCC tools/mkimage.o
    HOSTLD tools/mkenvimage
    HOSTLD tools/dumpimage
    HOSTLD tools/mkimage
    make[1]: *** No rule to make target `arch/arm/cpu/armv7/cache_v7.o’, needed by `arch/arm/cpu/armv7/built-in.o’. Stop.
    make: *** [arch/arm/cpu/armv7] Error 2


  26. PaceyIV
    Apr 26, 2015 @ 23:42:58

    This post is still valid or there is something new?


  27. Trackback: olimex A20 lime2 debian jessie image with 3.4.103 kernel, 2D H264 acceleration | Yoann's Blog
  28. Trackback: Expanding ext3/ext4 linux file system (Debian, on A20-OlinuXino-MICRO, ARM) | Блогът на Пламен Стоев

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: