Linux-Sunxi is changing the 3.4 Kernel with amazing speed, about 20-30 patches apply every day, few days ago we made our Debian image3 based on 3.4.53 and now few days later the kernel is 3.4.61+ so we blog based on this snapshot but if you try few days later things may change again. From the patches I see the development is focused on adding CedarX (VPU acceleration), Mali400 GPU and NAND support, and cleaning old code.
1. Setup of the toolchain
We use Linux debian 3.2.0-4-686-pae #1 SMP Debian 3.2.41-2+deb7u2 i686 GNU/Linux on our server to generate the images, it may or it may not work on other distributions if you follow the instructions below.
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 http://www.emdebian.org/debian squeeze main
in the file below:
/etc/apt/sources.list
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 3d2fc4e8ff764209a8249c3b52dc937f3a106a7f
Download u-boot sourses:
# git clone -b sunxi https://github.com/linux-sunxi/u-boot-sunxi.git
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:
/home/user/a20_kernel_3.4/#
3. Building kernel sources for Olinuxino-A20-Micro
The Allwinner Linux-Sunxi community Kernel is maintained by Alejandro Mery aka mnemoc on Freenode irc. You can find him in #linux-sunxi or #olimex channel, if something is broken with the Linux Kernel you can contact him or use http://linux-sunxi.org/Mailing_list
Kernel sources for A20 are available on GitHub. Note that the following building is made with the revision below:
# git rev-parse --verify HEAD 8388cf06936aaf05342fb912ed6fc1a3b04e5afb
You can download the kernel sources using the following command:
# git clone https://github.com/linux-sunxi/linux-sunxi -b stage/sunxi-3.4
After the download go to the kernel directory
# cd linux-sunxi/
Here you need from a20 configuration file – olinuxinoa20_defconfig. The file contains all kernel module settings.
Download olinuxinoa20_defconfig https://docs.google.com/file/d/0B-bAEPML8fwldEVvU1hCZ29DODQ/edit?usp=sharing
then copy olinuxinoa20_defconfig file to configs directory:
# cp olinuxinoa20_defconfig linux-sunxi/arch/arm/configs/.
and make:
# make ARCH=arm olinuxinoa20_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 some patches which are still not merged in 3.4:
the first patch is related with PWM:
download the patch sunxi-pwm.patch from https://docs.google.com/file/d/0B-bAEPML8fwlLVRucUJwamFQWHc/edit?usp=sharing
and apply the patch:
# patch -p0 < sunxi-pwm.patch
The second patch is realted with I2C speed and it is not mandatory. 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 from https://docs.google.com/file/d/0B-bAEPML8fwlbnFyVnZHczJjVDQ/edit?usp=sharing
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.61+ 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 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.61+
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:
- p
will list your partitionsif there are already partitions on your card do:
- d enter 1
if you have more than one partitition press d while delete them all - create the first partition, starting from 2048
n enter p enter 1 enter enter +16M - create second partition
n enter p enter 2 enter enter enterthen 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: 0x00000000Device Boot Start End Blocks Id System
/dev/sdg1 2048 34815 16384 83 Linux
/dev/sdg2 34816 7774207 3869696 83 Linux - 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/sdg 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 from https://docs.google.com/file/d/0B-bAEPML8fwlbENYRHVJVXhrUmM/edit?usp=sharing
# 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_fs.tgz from https://docs.google.com/file/d/0B-bAEPML8fwlZ3E1SnVNMDk4d2s/edit?usp=sharing
mount your sd card EXT3 FS partition:
# mkdir /mnt/sd # mount /dev/sdX2 /mnt/sd
and unarchive the rootfs
# tar xzvf debian_34_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/3.4.43+/ # 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.61+/ /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
Note that if you want to use the Olimex’s USB-WIFI module(https://www.olimex.com/Products/Modules/Ethernet/MOD-WIFI-RTL8188)
you need to install realtek firmware
for example:
connect LAN cable to the board
# dhclient eth0 # apt-get install firmware-realtek
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
The ready made image-4 is here:
https://docs.google.com/file/d/0B-bAEPML8fwleDJMaG5reWZZeDQ/edit?usp=sharing
Henrik Nordström
Sep 18, 2013 @ 11:01:03
Please keep script.fex updated in sunxi-boards.
OLIMEX Ltd
Sep 18, 2013 @ 11:07:14
the problem I see is that there are set of many scripts now for the different HDMI resolutions, LCDs etc, we made shell script which now allow user to select what video output and what resolution and modify the script.fex dynamically as the touchscreen info also have to be resized.
any idea how to update this to sunxi-boards?
Philippe Van Hecke
Sep 18, 2013 @ 12:00:07
Very nice work ! and thanks for sharing this.
Arokux
Sep 18, 2013 @ 16:23:04
Can you please add a link to this post to this page?
http://linux-sunxi.org/A20-OLinuXino
Thanks,
Arokux
OLIMEX Ltd
Sep 18, 2013 @ 16:46:24
sure, which reminds me to put it also on our wiki 🙂
goldyfruit
Oct 30, 2013 @ 16:03:10
The tar about the rootfs is corrupt. 🙂
gustav
Nov 02, 2013 @ 01:15:18
Hi, I get
make: *** No rule to make target `a20-OLinuXino_MICRO’. Stop.
when trying to compile the uboot, any suggestions?
I’m rather sure I didn’t misspell
OLIMEX Ltd
Nov 02, 2013 @ 01:21:26
they changed it to lowercase 😦
gustav
Nov 03, 2013 @ 12:39:32
i tried
# make a20-olinuxino_micro CROSS_COMPILE=arm-linux-gnueabihf-
still no luck,
gustav
Nov 03, 2013 @ 13:00:33
and a bunch of other variations with upper/lower, both scores and cases..
even changed ‘micro’ to ‘m’ as it is defiened in the boards folder.
gustav
Nov 03, 2013 @ 13:18:57
pk got it, sorry for spamming
oh-oh (@Socketuning)
Nov 18, 2013 @ 15:46:25
I’m totally stuck
/bin/bash: arm-linux-gnueabihf-gcc: Kommando nicht gefunden.
meaning bash can’t find arm-linux-gnueabihf-gcc.
I set up a clean debian wheezy plus embedian repo, gcc-4.7-arm-linux-gnueabihf is installed. Is there a way to resolve this short of thousands of softlinks?
zboonet
Dec 26, 2013 @ 11:29:07
Hi ! 🙂
Santa just brought me an A20-OLinuXino-MICRO, but I’m stucked in dependencies problems in the first step of this tutorial.
I updated the /etc/apt/sources.list file xith following line :
deb http://www.emdebian.org/debian wheezy main
Installed the emdebian-archive-keyring :
root@nuptse /home/nuptse # apt-get install emdebian-archive-keyring
And at last, I cannot install the toolchain.
root@nuptse /home/nuptse # apt-get install gcc-4.7-arm-linux-gnueabi ncurses-dev uboot-mkimage build-essential git binutils-arm-linux-gnueabi libgomp1-armel-cross
Reading package lists… Done
Building dependency tree
Reading state information… Done
Note, selecting ‘libncurses5-dev’ instead of ‘ncurses-dev’
build-essential is already the newest version.
git is already the newest version.
libncurses5-dev is already the newest version.
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
binutils-arm-linux-gnueabi : Depends: libc6 (>= 2.14) but 2.13-38 is to be installed
libgomp1-armel-cross : Depends: gcc-4.8-base-armel-cross (= 4.8.2-1) but it is not installable
E: Unable to correct problems, you have held broken packages.
Any idea ?
zboonet
Dec 27, 2013 @ 23:19:58
Finally sorted it out by adding this line to /etc/apt/sources.list
deb http://www.emdebian.org/debian/ unstable main
andy ryan
Feb 21, 2014 @ 00:22:49
hi guys, there’s no crontab command in this release. am i missing something?
thanks
andy
andy ryan
Feb 21, 2014 @ 00:43:46
aha, fixed by ‘apt-get install cron’ which also loads exim4 and mailx. first time i’ve ever had to load cron separately from a linux distro.
elvis
Mar 03, 2014 @ 19:19:27
Hi, I’m having trouble on the first steps. I’ve installed the toolchain, but getting errors with this command:
# git rev-parse –verify HEAD
3d2fc4e8ff764209a8249c3b52dc937f3a106a7f
fatal: Needed a single revision
if i skip the “git rev-parse –verify HEAD” commands and proceed, everithing go ok, i finish the procedure, write the results to the microSD card (8GB, class 10).
when I insert the mSD to the board, the hdmi monitor stays off, i only see that after some seconds the mouse is turned on and the “LED1” is turned on (greed).
after that, nothing happens.
I have also tried to use this: linaro_13_4_aolinuxino-a20.img
wrote to the mSD with:
dd if=/linaro_13_4_aolinuxino-a20.img of=/dev/sdb
after some seconds, i can see the penguin at the left corner but just for 3 seconds, and than monitor goes down.
any help would be appreciated
andi
May 01, 2014 @ 16:41:21
elvis how do you resolve the problem???? i have the same problem…i see the 2 pinguins fo 5 minutes and after the screen goes down…
andi
Apr 30, 2014 @ 18:43:08
Hi, can someone help me?? what i have to do?? i don’t understand where is the problem….
root@andi:/home/andi/a20_kernel_3.4/u-boot-sunxi-sunxi# make A20-OLinuXino_MICRO_config CROSS_COMPILE=arm-linux-gnueabihf-
Configuring for A20-OLinuXino_MICRO – Board: sun7i, Options: A20_OLINUXINO_M,CONS_INDEX=1,STATUSLED=226,SPL,SUNXI_EMAC
root@andi:/home/andi/a20_kernel_3.4/u-boot-sunxi-sunxi# make A20-OLinuXino_MICRO CROSS_COMPILE=arm-linux-gnueabihf-
GEN include/autoconf.mk.dep
GEN include/autoconf.mk
make: *** No rule to make target `A20-OLinuXino_MICRO’. Stop.
root@andi:/home/andi/a20_kernel_3.4/u-boot-sunxi-sunxi#
alejandrocentauri
May 08, 2014 @ 18:58:36
hi Andi! do you mean the penguins when using linaro_13_4_aolinuxino-a20.img?
It worked! just have to wait some minutes and it will boot up!
I logged in to ubuntu, but couldn’t use the internet conneciton!
I’m still not able to boot the official image, does anybody used it?
Filippo Makrov Carandente
Jul 10, 2014 @ 01:58:09
this should solve uboot (2014) build errors
#configure uboot
$ make ‘A20-OLinuXino_MICRO’_config CROSS_COMPILE=arm-linux-gnueabihf-
#build uboot
$ make CROSS_COMPILE=arm-linux-gnueabihf-
##source http://www.wiki.xilinx.com/Build+U-Boot
sqt
Sep 25, 2014 @ 13:53:18
They keep changing the config file. Now it’s ‘A20-OLinuXino-Micro’
Its better to check in the boards.cfg for the correct name and then add ‘_config’ at the end … like this
make A20-OLinuXino-Micro_config CROSS_COMPILE=arm-linux-gnueabihf-
Hope this information would help someone….
Byron Seto
Jan 14, 2015 @ 10:09:55
Thank you that fixed it for me!
Ilja Lebedevs
Aug 21, 2014 @ 20:18:43
Sorry, the file you have requested does not exist.
On google drive defconfig!
olinuxinoa20_defconfig
Frans Bijma
Aug 27, 2014 @ 18:01:14
rootfs is also missing 😦
Mike Moy
Aug 29, 2014 @ 17:51:56
Allot of complaints here, are they fixing any of them ?
Also, this page does not load properly in firefox. It clips the right side of the page.
lauhub
Sep 20, 2014 @ 11:53:07
Is the following file of for olinuxinoA20_defconfig ?
wget https://raw.github.com/hehopmajieh/OLinuXino-A20/master/olinuxinoA20-3.4_defconfig -O arch/arm/configs/olinuxinoA20_defconfig
Vinicius Mauricio
Jan 15, 2015 @ 20:09:52
Hi,
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