Professional Documents
Culture Documents
Building The Ultimate Debian SD Card For Linux With Kernel 3.4 For A20-OLinuxino-MICRO
Building The Ultimate Debian SD Card For Linux With Kernel 3.4 For A20-OLinuxino-MICRO
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 dont 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 buildessential 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
when this finishs 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
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.67+
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 prebuilt 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