Skip to main content

Raymii.org Logo (IEC resistor symbol)logo

Quis custodiet ipsos custodes?
Home | About | All pages | RSS Feed | Gopher

Olimex OlinuXino a10 Lime uBoot, Kernel and root image guide

Published: 20-12-2014 | Author: Remy van Elst | Text only version of this article


Table of Contents


olimex

The Olimex OlinuXino A10 LIME is an amazing, powerfull and cheap open source ARMdevelopment board. It costs EUR 30, and has 160 GPIO. This guide is a cleaned upversion of theirs with instructions to build your own kernel and u-boot image onUbuntu 14.04

Buy the board here: and see my other tutorials and a small image here:https://raymii.org/s/tags/olimex.html

If you like this article, consider sponsoring me by trying out a Digital OceanVPS. With this link you'll get $100 credit for 60 days). (referral link)

The original guide can be found here:

This guide has been adapted to work on Ubuntu 14.04, some package names,instructions and commands were incorrect. Also, all the files are not on Googledrive anymore, but on my servers. The original bad english has been cleaned upto be less bad. The guide however is of less quality than you normally get fromme.

For Allwinner Kernel related questions please ask on Linux Sunxi Mailing List inGoogle Groups: https://groups.google.com/forum/#!forum/linux-sunxi

For Uboot related questions please ask on Linux Sunxi Mailing List in GoogleGroups: https://groups.google.com/forum/#!forum/linux-sunxi


Contents

Install required packages

Install the toolchain and other required development packages:

apt-get updateapt-get install gcc-4.7-arm-linux-gnueabihf ncurses-dev build-essential git u-boot-tools gcc-arm-linux-gnueabihf

If you want to cross compile on Debian instead of Ubuntu, you need the followingset of packages:

apt-get install binutils-arm-linux-gnueabihf ncurses-dev build-essential git u-boot-tools gcc-arm-linux-gnueabihf

Create a working directory and go in to it:

mkdir A10_kernel_3.4/cd A10_kernel_3.4/

Building Uboot

u-boot is the bootloader, it is a GRUB alternative for small/embedded systems.

Download u-boot sources:

git clone -b sunxi https://github.com/linux-sunxi/u-boot-sunxi.gitcd u-boot-sunxi/

Note that this guide was written with the revision below:

git rev-parse --verify HEAD44b53fd3928f15c34993ec8c6b8c2efcb79769ee

Start the uboot build:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- distcleanmake ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- A10-OLinuXino-Lime_configmake ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-

At the end of the process you should have at least the following files:

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

Go back into the working directory:

cd ..

Building the kernel

Kernel sources for A10 are available on GitHub. Use git to download the kernelsources for the board:

git clone https://github.com/linux-sunxi/linux-sunxicd linux-sunxi/

Note that this guide was written with the revision below:

git rev-parse --verify HEADe37d760b363888f3a65cd6455c99a75cac70a7b8

The following file contains all the kernel config settings. If you've ever builtyour own kernel you can use make menuconfig etc to change the settings. Fornow, download it:

wget https://raymii.org/s/inc/downloads/olinux/a10/a10lime_defconfig

Their kernel contains weird choices, for example iptables is not available, butwireless drivers are. You can save space on the kernel by removing things likethat. If you want to run it as a server, you need to compile most of the networksettings back in. I use the following config, with network stuff included sothat I can use lxc containers on the board (veth, bridge and vlansupport etc.):

wget https://raymii.org/s/inc/downloads/olinux/a10/kernel_config_raymii

Copy a10lime_defconfig file to config directory:

cp a10lime_defconfig linux-sunxi/arch/arm/configs/# or my config:cp kernel_config_raymii linux-sunxi/arch/arm/configs/

Prepare the config file:

make ARCH=arm a10lime_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

You can add or remove different modules for the different peripherials in thekernel with menuconfig. Be careful with this as it may cause the kernel to notwork properly.

Compile the kernel:

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

The result after a while should be like this:

Image Name:   Linux-3.4.90+Created:      Fri Jun 13 16:28:39 2014Image Type:   ARM Linux Kernel Image (uncompressed)Data Size:    4447440 Bytes = 4343.20 kB = 4.24 MBLoad Address: 40008000Entry Point:  40008000Image arch/arm/boot/uImage is ready

Compile the kernel modules:

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

After the compilations are finished the uImage file is located in:

linux-sunxi/arch/arm/boot/

The kernel modules are located in:

linux-sunxi/out/lib/modules/3.x.xx

where 3.x.xx is kernel version

in our case the directory with modules is:

linux-sunxi/out/lib/modules/3.4.90+

Format and setup the SD-card

First we have to partition the SD card with fdisk. Plug SD card into your SDcard reader. Use a command like dmesg to get the correct device. If you selectthe wrong device you might overwrite your own hard drive, so make sure you havethe correct one.

Start fdisk on the correct device:

fdisk /dev/sdX

List the partitions:

p

If there are already partitions on the card you should delete them. This willerase the data on the SD card:

d 1

If you have more than one partitition press d again and provide the number, like2, 3 etc.

Create the first partition, starting from 2048

np1# enter twice+16M

Create the second partition

np2 # enter three times

List the created partitions:

p 

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

Disk /dev/sdX: 3980 MB, 3980394496 bytes123 heads, 62 sectors/track, 1019 cylinders, total 7774208 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000   Device Boot      Start         End      Blocks   Id  System/dev/sdX1            2048       34815       16384   83  Linux/dev/sdX2           34816     7774207     3869696   83  Linux

Write it to the SD card:

w

Create the file system on the first partition. This should be vfat as this isfilesystem which the Allwinner bootloader understands:

mkfs.vfat /dev/sdX1

The second should be a Linux ext4 partition:

mkfs.ext4 /dev/sdX2

Writing the bootloader and related files

You should be in the ~/A10 kernel 3.4/ folder.

The image u-boot-sunxi-with-spl.bin should be written to the device /dev/sdX(not a partition like sdX1 or sdX2).

Use dd to write the image we built earlier to the sd card:

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

Mount the first partition:

# mkdir /mnt/sdmount /dev/sdX1 /mnt/sd

Copy the kernel uImage to root directory of partition 1:

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

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

Download the file and place it on the SD card:

wget -O /mnt/sd/script.bin https://raymii.org/s/inc/downloads/olinux/a10/script.bin

boot.scr has the uboot commands to load script.bin, kernel, initrd, set kernelparameters and booting the device.

If you want to change it you can read this guide:

Download boot.scr and place it on the SD card:

wget -O /mnt/sd/boot.scr https://raymii.org/s/inc/downloads/olinux/a10/boot.scr

Unmount the partition:

syncumount /dev/sdX1

Debian rootfs

You can download my own image from here: https://raymii.org/s/articles/OlimexA10-OLinuXino-LIME minimal debian 7_image.html. It is smaller than theOlimex image, but has no GUI etc. The standard olimex Debian image is quitelarge and has weird software choices.

The image provided by Olimex is mirrored here. Download it:

wget https://2162bb74000a471eb2839a7f1648771a.objectstore.eu/olimex/a10_lime_debian_3_4_90_rel_3.tgz

Mount the second partition on the SD card:

mount /dev/sdX2 /mnt/sd

Unpack the rootfs to the SD card:

tar xzvf a10_lime_debian_3_4_90_rel_3.tgz -C /mnt/sd

The unpacked filesystem looks like below:

# ls /mnt/sdbin   dev  home  lost+found  mnt  proc  run   selinux  sys  usrboot  etc  lib   media       opt  root  sbin  srv      tmp  var

You have to replace the new generated kernel modules from ~/A10_kernel_3.4/linux-sunxi/out/lib/modules/ to the debian file system we've just unpacked:

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.90+/ /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/

Unmount the SD card:

syncumount /mnt/sdX2

Connect USB-SERIAL-CABLE-F to UEXT Tx.Rx and GND, or connect a HDMI screen. Putthe SD-card in A10-OLinuXino-Lime and apply 5V power, you should see Uboot andthen Kernel messages on the console.

The default username/password is : root / olimex

Tags: allwinner, arm, articles, debian, gpio, minimal, olimex, olinuxino, raspberry-pi