Building Debian SD card for Linux with Kernel 3.4 from scratch for A10S-OLinuXino-MICRO


Image

This is step by step instruction how to build Debian for A10S-OLinuXino with Kernel 3.4

In Kernel 3.4 image several major bugs are fixed like: XFCE4 problems with USB-Ethernet-AX88772B, the WIFI instability, GPIO, USB support etc which were with problems in the earlier image.

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 ncurses-dev uboot-mkimage build-essential git

This will install: 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

Create working directory

# mkdir /home/user/a10s_kernel_3.4

where user is your user in your linux machine

# cd a10s_kernel_3.4

Download toolchain:

# wget https://launchpad.net/linaro-toolchain-binaries/trunk/2013.01/+download/gcc-linaro-arm-linux-gnueabihf-4.7-2013.01-20130125_linux.tar.bz2

Extract toolchain:

tar jxfv gcc-linaro-arm-linux-gnueabihf-4.7-2013.01-20130125_linux.tar.bz2

Add toolchain dir to $PATH

export PATH=/home/user/a10s_kernel_3.4/gcc-linaro-arm-linux-gnueabihf-4.7-2013.01-20130125_linux/bin:$PATH

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:

You should be in the following directory

/home/user/a10s_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-A10S-Micro board u-boot is tested with the next branch:

# git rev-parse --verify HEAD
8a4621c488f33089d831168bfa5bae210a5684c8

Download u-boot sourses:

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

After the download you should have a new directory u-boot-sunxi

# cd u-boot-sunxi/

With the following command you can start the uboot build:

# make a10s-olinuxino-m 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/a10s_kernel_3.4#

3. Building kernel sources for A10S-OLinuXino-Micro

The Allwinner Linux Kernel is maintained by Linux-Sunxi community , if something is broken with the Linux Kernel you can report to  http://linux-sunxi.org/Mailing_list

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

# git rev-parse --verify HEAD
9ee9fc5f0988df5677f0f142b5b88a8988d283d7

You can download the kernel sources using the following command:

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

After the download go to the kernel directory

# cd linux-sunxi/

Here you need from a10s configuration file – a10s_defconfig. The file contains all kernel module settings.

Download a10s_defconfig https://drive.google.com/file/d/0B-bAEPML8fwlOHVQS0VMZEV1WE0/edit?usp=sharing

# wget https://drive.google.com/file/d/0B-bAEPML8fwlOHVQS0VMZEV1WE0/edit?usp=sharing

then copy a10s_defconfig file to configs directory:

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

and make:

# make ARCH=arm a10s_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:
the first patch is related with hcd_axp:

download the patch hcd_axp.patch from https://drive.google.com/file/d/0B-bAEPML8fwlRGxPZXpBWlVodkk/edit?usp=sharing

# wget https://drive.google.com/file/d/0B-bAEPML8fwlRGxPZXpBWlVodkk/edit?usp=sharing

and apply the patch:

# patch -p0 < hcd_axp.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://drive.google.com/file/d/0B-bAEPML8fwlOG1lZlVuSEpURlU/edit?usp=sharing

# wget https://drive.google.com/file/d/0B-bAEPML8fwlOG1lZlVuSEpURlU/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:

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/a10s_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/a10s_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://drive.google.com/file/d/0B-bAEPML8fwlYkItdU1TTm1VN0E/edit?usp=sharing

# wget https://drive.google.com/file/d/0B-bAEPML8fwlYkItdU1TTm1VN0E/edit?usp=sharing
# cp script.bin /mnt/sd
# sync
# umount /dev/sdX1

The default script.bin file is configured with HDMI resolution 720p/50. If you whant to use A10S-OLinuXino-MICRO board with 4.3”, 7” or 10” LCD then you have to use
the script.bin file from the corresponding directory of scripts_A10s.7z archive. You can download it from https://drive.google.com/file/d/0B-bAEPML8fwlY3llVDJxelY3d28/edit?usp=sharing

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/a10s_kernel_3.4/

download debian rootfs – debian_34_fs_a10s.tgz from https://drive.google.com/file/d/0B-bAEPML8fwlR0N2MEJ5WExYM1U/edit?usp=sharing

# wget https://drive.google.com/file/d/0B-bAEPML8fwlR0N2MEJ5WExYM1U/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_a10s.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/a10s_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.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 A10S-OLinuXino-Micro

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

default username/password is : root / olimex

The complete Debian image with Kernel 3.4 is available for download from our WIKI.

18 Comments (+add yours?)

  1. John
    Oct 29, 2013 @ 08:53:14

    Useful

    Reply

  2. davidefa
    Oct 30, 2013 @ 17:20:31

    in section “3. Building kernel sources..”
    the following 2 lines:
    # 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 mo
    are not displayed correctly ( don’t know if is a problem of my browser ) should read:
    # 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

    Reply

  3. Trackback: Building Debian SD card for Linux with Kernel 3.4 from scratch for A10S-OLinuXino-MICRO | Debian-News.net - Your one stop for news about Debian
  4. Vcelak
    Nov 05, 2013 @ 12:44:31

    How about touchscreen support?

    Reply

  5. Trackback: Building Debian SD card for Linux with Kernel 3.4 from scratch for A10S-OLinuXino-MICRO | Debian InfoDebian Info - Just another James n Sheri.com site
  6. Trackback: How to compile a Linux kernel for the OLinuXino A10S | Malaya Digital Blog
  7. Vcelak
    Nov 06, 2013 @ 17:38:19

    I’ve tested this image and USB keyboard is working only, when I connect it after booting – if it remain connected all the time and you reboot or power cycle the board, then keyboard is not recognized.

    ehci_irq: port change detect
    ehci_irq: port change detect
    The port change to OHCI now!
    usb 3-1: new low-speed USB device number 10 using sw-ohci
    usb 3-1: device descriptor read/64, error -62
    usb 3-1: device descriptor read/64, error -62
    usb 3-1: new low-speed USB device number 11 using sw-ohci
    usb 3-1: device descriptor read/64, error -62
    usb 3-1: device descriptor read/64, error -62
    usb 3-1: new low-speed USB device number 12 using sw-ohci
    usb 3-1: device not accepting address 12, error -62
    usb 3-1: new low-speed USB device number 13 using sw-ohci
    usb 3-1: device not accepting address 13, error -62
    hub 3-0:1.0: unable to enumerate USB device on port 1
    ehci_irq: port change detect
    ehci_irq: port change detect
    The port change to OHCI now!
    usb 3-1: new full-speed USB device number 14 using sw-ohci
    usb 3-1: device descriptor read/64, error -71
    usb 3-1: device descriptor read/64, error -71
    usb 3-1: new full-speed USB device number 15 using sw-ohci
    usb 3-1: device descriptor read/64, error -71
    usb 3-1: device descriptor read/64, error -71
    usb 3-1: new full-speed USB device number 16 using sw-ohci
    usb 3-1: device not accepting address 16, error -62
    usb 3-1: new full-speed USB device number 17 using sw-ohci
    usb 3-1: device not accepting address 17, error -62
    hub 3-0:1.0: unable to enumerate USB device on port 1

    Reply

  8. Vcelak
    Nov 07, 2013 @ 15:41:49

    Update:
    When I use USB HUB – powered from olimexino, then all devices work well. No matter if this is keyboard, mouse, webcam… Without HUB only one try from 20 times worked.

    Reply

  9. Vcelak
    Nov 07, 2013 @ 15:48:28

    Also rebooting is not working well – sometimes it reboot, sometimes it hangs, later will I post dmesg.

    Reply

  10. Lam
    Nov 12, 2013 @ 07:19:45

    I followed your instruction, but the LCD display nothing, just black.I use LCD7” and script.bin for 480×800.I don’t know why.please help me! thanks

    Reply

    • Vcelak
      Nov 12, 2013 @ 10:52:49

      Dear Lam, have you connected serial cable to board – to check, if it is correctly booting and starting kernel?

      Reply

  11. Sjef
    Nov 18, 2013 @ 22:51:20

    It works, but kworker eats half of the CPU continuously from boot-up onwards. At a loss as to why?

    Reply

  12. FallingLeaf
    Nov 19, 2013 @ 11:04:51

    Dear all,
    I can not mount the partition 1 (in my case is sdb1) after run the following command:
    dd if=u-boot-sunxi/u-boot-sunxi-with-spl.bin of=/dev/sdg bs=1024 seek=8
    The error is: mount: you must specify the filesystem type
    then I tried to run with file system type: mount /dev/sdb1 /mnt/sd -t vfat
    I got another error:
    mount: wrong fs type, bad option, bad superblock on /dev/sdb1,
    missing codepage or helper program, or other error
    In some cases useful info is found in syslog – try
    dmesg | tail or so
    I currently use 2GB micro SD
    Please help me

    Reply

  13. GregoryK
    Mar 09, 2014 @ 04:38:47

    what “-j4″ is doing ?
    # make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4 uImage

    Reply

  14. Hugoc
    Jul 16, 2014 @ 20:21:45

    Hello, I’m trying to get Debian on an old MK802-a10s.
    Got to Section 2, instruction “make a10s-olinuxino-m CROSS_COMPILE=arm-linux-gnueabihf-”

    The result is:
    Makefile:479: *** System not configured – See README ***

    So, according to README, I should try something like “make a10s-olinuxino-m_config” or “make mk802_config” or even “make a10s_config”, but none worked. Maybe they’ve dropped a10s-olinuxino support?

    Reply

  15. Trackback: How To Build A List From Scratch | MakeMoneyInDirectMail.com

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 549 other followers

%d bloggers like this: