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
http://archlinuxarm.org/platforms/armv7/allwinner/a20-olinuxino-micro
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:
http://os.archlinuxarm.org/armv7h/alarm/
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):
http://archlinuxarm.org/platforms/armv7/allwinner/cubieboard-2
Execute steps 1-4.
Download u-boot package for A20-OLinuXino-MICRO, current one is available here:
http://os.archlinuxarm.org/armv7h/alarm/uboot-a20-olinuxino-micro-2014.04-10-armv7h.pkg.tar.xz
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 https://github.com/linux-sunxi/u-boot-sunxi.git
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:
http://linux-sunxi.org/Fex_Guide
Download the sunxi-tools:
$ git clone https://github.com/linux-sunxi/sunxi-tools
Change current directory to:
$ cd sunxi-tools/
Download the A20-OLinuXino-MICRO FEX file:
$ wget https://github.com/linux-sunxi/sunxi-boards/raw/master/sys_config/a20/a20-olinuxino_micro.fex
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 http://linux-sunxi.org/Mailing_list
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 https://github.com/linux-sunxi/linux-sunxi -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 https://raw.github.com/hehopmajieh/OLinuXino-A20/master/olinuxinoA20-3.4_defconfig -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
~/linux-sunxi/out/lib/modules/3.4.xx
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 http://archlinuxarm.org/os/ArchLinuxARM-sun7i-latest.tar.gz
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:
Pingback: Arch Linux image for A20-OLinuXino | olimex
Pingback: Overclocking memory on A20-OLinuXino-MICRO | A20-OLinuXino-MICRO stories
after
$ wget https://github.com/linux-sunxi/sunxi-boards/raw/master/sys_config/a20/a20-olinuxino_micro.fex
u have to do
make fex2bin
and than u can ->
Create script.bin from the downloaded fex file:
$ ./fex2bin a20-olinuxino_micro.fex > script.bin
fex2bin…
sudo apt-get install libusb-1.0-0-dev
then a $: make
and fex2bin is there..
During toolchain-install i get:
– Package ‘uboot-mkimage’ has no installation candidate.
(I manage to install all other packages without problem)
During Building Uboot i get:
– Makefile:485: *** “System not configured – see README”. Stop.
I have tried to build on Lubuntu and Ubuntu (13.10, both 32 and 64 under VBox).
– Any suggestions to what I do wrong (or a workaround)?
I used Lubuntu 13.04 64bit.
Anyway, I don’t really think it is needed unless you want to create boot.scr to specify additional kernel parameters. However, this can also be achieved with uEnv.txt
So just skip it.
I used these commands to build uboot :
$ make A20-OLinuXino_MICRO_config
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4
I’m using Arch Linux to do my cross compilation. Great article anyway 🙂
When you create Alarm image, are you’re sure that the command is $ sudo dd if=/dev/sdb of=alarm-a20.img bs=1M
I would say it is $ sudo dd of=/dev/sdb if=alarm-a20.img bs=1M
Regards,
/dev/sdb is the second presented volume on the virtual machine, so the text in my blog post is correct (this is how you create the image).
If you want to write the image to a microSD card, then ‘$ sudo dd if=alarm-a20.img of=/dev/sdb bs=1M’ is correct (if /dev/sdb is your uSD card).
ok thks for your answer. I didn’t catch the point that at the end of all commands your are making a fresh image. That explains why you use twice dd command
Can you put a tutorial without virtual machine? What are the instructions for archlinux natively?
Thanks
Never tried building image on my Arch Linux host.
You can check linux-sunxi wiki pages, e.g. this one to install Linaro toolchain
Hi,
please inform me the Allwinner A10 related board files the kernel tree(arch/am) and let me know the filename of SOC configuration for this chip