Difference between revisions of "Build Bootable SD Card with Debian"

(Created page with "== Introduction == The A13-OLinuXino-WIFI board ships with pre-loaded Android 4.0.3 image on the NAND flash, so it runs out of the box and you can have access to millions of ...")
 
(update for initial page)
Line 11: Line 11:
 
== Tools required ==
 
== Tools required ==
  
- A13-OLinuXino or A13-OLinuXino-WIFI
+
* A13-OLinuXino or A13-OLinuXino-WIFI
 +
* Micro SD card larger than 2g
 +
* A method to check the system worked, VGA screen or serial cable
 +
* A computer that can run linux (These instructions do not work for windows)
 +
Note: you can install Ubuntu freely to work on a machine that currently has windows. You will have the option to boot to either windows or linux
 +
* Method to read or write to a Micro SD card from this computer.
 +
* An internet connection for the linux computer
  
- Micro SD card larger than 2g
 
  
- A method to check the system worked, VGA screen or serial cable
+
== Instructions ==
  
- A computer that can run linux (These instructions do not work for windows)
+
===Setup of the toolchain===
Note: you can install Ubuntu freely to work on a machine that currently has windows. You will have the option to boot to either windows or linux.
 
  
- Method to read or write to a Micro SD card from this computer.
+
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 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
Work in progress below
 
  
----
+
First update apt-get links by typing
  
 +
<nowiki>#apt-get update</nowiki>
  
'''Instructions'''
+
Install the toolchain by typing the following.
  
1. Setup of the toolchain
+
<nowiki># apt-get install gcc-4.6-arm-linux-gnueabi ncurses-dev uboot-mkimage build-essential git</nowiki>
  
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 so do this to make sure you are:
+
with this line you make sure you have all tools necessary for the A13 kernel and uboot build:  
  
$ sudo su
+
* 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
  
you will be asked for your password and then your prompt will change to # which means now you are super user, all next commands should be run in this mode
 
 
# apt-get install gcc-4.6-arm-linux-gnueabi ncurses-dev uboot-mkimage build-essential git
 
 
with this line you make sure you have all tools necessary for the A13 kernel and uboot build: GCC compiler, the kernel config menu, uboot make image, git and other tools for building the kernel
 
  
 
after the installation you now have all tools to make your very own A13 kernel image
 
after the installation you now have all tools to make your very own A13 kernel image
  
2. Building Uboot
+
===Building Uboot===
  
Allwinner community uboot is maintained by Henrik Nordström aka hno on #freenode irc channel.
+
The Allwinner community uboot is maintained by Henrik Nordström aka hno on #freenode irc channel.
  
 
First let’s make the directory where we will build the A13-OLinuXino Linux:
 
First let’s make the directory where we will build the A13-OLinuXino Linux:
  
# mkdir olinuxino; cd olinuxino
+
<nowiki># mkdir olinuxino
 +
# cd olinuxino</nowiki>
  
then let’s download the uboot sources from GitHub repository, note there are lot of branches but you have to use sunxi branch, the files are about 70 MB
+
Then let’s download the uboot sources from GitHub repository, note there are lot of branches but you have to use sunxi branch, the files are about 70 MB
  
# git clone -b sunxi https://github.com/hno/uboot-allwinner.git
+
<nowiki># git clone -b sunxi https://github.com/hno/uboot-allwinner.git</nowiki>
  
after the download you should have new directory
+
After the download you should have a new directory
  
# cd uboot-allwinner/
+
<nowiki># cd uboot-allwinner/</nowiki>
  
and with this command you can start the uboot build:
+
With the following command you can start the uboot build:
  
# make a13_olinuxino CROSS_COMPILE=arm-linux-gnueabi-
+
<nowiki># make a13_olinuxino CROSS_COMPILE=arm-linux-gnueabi-</nowiki>
  
as you can see A13-OLinuXino already have support configuration in Allwinner community uboot
+
As you can see A13-OLinuXino already have support configuration in Allwinner community uboot
  
at the end of the process you can check if everything is OK by
+
At the end of the process you can check if everything is OK by
  
# ls u-boot.bin spl/sunxi-spl.bin
+
<nowiki># ls u-boot.bin spl/sunxi-spl.bin</nowiki>
  
if you got these two files everything is complete, well done so far  
+
If you got these two files everything is complete, well done so far  
  
3. Building the Kernel
+
===Building the Kernel===
  
 
The Allwinner community Kernel is maintained by Alejandro Mery aka mnemoc on #freenode irc channel.
 
The Allwinner community Kernel is maintained by Alejandro Mery aka mnemoc on #freenode irc channel.
Line 79: Line 84:
 
Let’s first go back from uboot directory
 
Let’s first go back from uboot directory
  
# cd ..
+
<nowiki># cd ..</nowiki>
  
then download the Kernel sources, you should use  allwinner-v3.0-android-v2 branch, the sources are about 700 MB so you will have to wait a bit longer with this download:
+
Then download the Kernel sources, you should use  allwinner-v3.0-android-v2 branch, the sources are about 700 MB so you will have to wait a bit longer with this download:
  
# git clone https://github.com/amery/linux-allwinner.git
+
<nowiki># git clone https://github.com/linux-sunxi/linux-sunxi.git</nowiki>
  
after the download go to the kernel directory
+
After the download go to the kernel directory
  
# cd linux-allwinner/
+
<nowiki># cd linux-sunxi/</nowiki>
  
and compile the a13_configuration:
+
Compile the a13_configuration:
  
# make ARCH=arm a13_defconfig
+
<nowiki># make ARCH=arm a13_defconfig</nowiki>
  
 
as you see A13-OLinuXino have pre-made configuration in the community kernel sources
 
as you see A13-OLinuXino have pre-made configuration in the community kernel sources
  
# make ARCH=arm menuconfig
+
<nowiki># make ARCH=arm menuconfig</nowiki>
  
with this command you add/remove different modules for the different peripherials in the kernel, be careful when use this as this may make the kernel not working
+
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
 +
 
 +
The menuconfig created a .config text file, which you can view/edit even with a text editor like vi
 +
 
 +
----
 +
Work in progress below
 +
 
 +
----
  
the menuconfig created .config text file, which you can view/edit even with text editor like vi
 
  
 
if you want to use GPIOs for instance they are not enabled by default and you can do this by adding:
 
if you want to use GPIOs for instance they are not enabled by default and you can do this by adding:

Revision as of 01:25, 21 December 2012

Introduction

The A13-OLinuXino-WIFI board ships with pre-loaded Android 4.0.3 image on the NAND flash, so it runs out of the box and you can have access to millions of applications of Google Play.

For those who want to use and develop on this board with Linux this wiki explains step by step instructions to create an SD-card image that boots Debian on A13-OLinuXino. Big thanks to Dimitar Gamishev who initially demonstrated the whole build process.

Note: The content is largely taken from this page of instructions

building bootable sd card with debian linux image for a13 olinuxino

Tools required

  • A13-OLinuXino or A13-OLinuXino-WIFI
  • Micro SD card larger than 2g
  • A method to check the system worked, VGA screen or serial cable
  • A computer that can run linux (These instructions do not work for windows)

Note: you can install Ubuntu freely to work on a machine that currently has windows. You will have the option to boot to either windows or linux

  • Method to read or write to a Micro SD card from this computer.
  • An internet connection for the linux computer


Instructions

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 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.6-arm-linux-gnueabi ncurses-dev uboot-mkimage build-essential git

with this line you make sure you have all tools necessary for the A13 kernel and uboot build:

  • 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


after the installation you now have all tools to make your very own A13 kernel image

Building Uboot

The Allwinner community uboot is maintained by Henrik Nordström aka hno on #freenode irc channel.

First let’s make the directory where we will build the A13-OLinuXino Linux:

# mkdir olinuxino # cd olinuxino

Then let’s download the uboot sources from GitHub repository, note there are lot of branches but you have to use sunxi branch, the files are about 70 MB

# git clone -b sunxi https://github.com/hno/uboot-allwinner.git

After the download you should have a new directory

# cd uboot-allwinner/

With the following command you can start the uboot build:

# make a13_olinuxino CROSS_COMPILE=arm-linux-gnueabi-

As you can see A13-OLinuXino already have support configuration in Allwinner community uboot

At the end of the process you can check if everything is OK by

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

If you got these two files everything is complete, well done so far

Building the Kernel

The Allwinner community Kernel is maintained by Alejandro Mery aka mnemoc on #freenode irc channel.

Let’s first go back from uboot directory

# cd ..

Then download the Kernel sources, you should use allwinner-v3.0-android-v2 branch, the sources are about 700 MB so you will have to wait a bit longer with this download:

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

After the download go to the kernel directory

# cd linux-sunxi/

Compile the a13_configuration:

# make ARCH=arm a13_defconfig

as you see A13-OLinuXino have pre-made configuration in the community kernel sources

# make ARCH=arm menuconfig

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

The menuconfig created a .config text file, which you can view/edit even with a text editor like vi


Work in progress below



if you want to use GPIOs for instance they are not enabled by default and you can do this by adding:

SUN4I_GPIO_UGLY = y inside .config

then you can contiue with:

  1. make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage

when this finish you will have uImage ready and you can build the kernel modules:

  1. make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- INSTALL_MOD_PATH=out modules
  1. make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- INSTALL_MOD_PATH=out modules_install

DONE! At this point you have uboot and kernel builds ready.

4. Make the SD-card

First we have to make the correct card partitions, this is done with fdisk.

Plug SD card on your SD card reader and do

  1. ls /dev/sd

then press two times <TAB> you will see 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 proceed as you can damage your HDD if you choose wrong sd-device once you know which device is your sdcard like sda use it instead the sdX name in the references below:

  1. fdisk -u=sectors /dev/sdX

then do these steps:

1. p

will list your partitions

if there are already partitions on your card do:

2. d 1

to delete them all

3. n p 1

create first partition, starting from 2048 and ending to 34815

4. beginning 2048 end 34815

create second partition

5. n p 2 enter enter

then list the created partitions:

6. p

if you did everything correctly you should see something like:

Disk /dev/sdX: 2001 MB, 2001731584 bytes 42 heads, 41 sectors/track, 2270 cylinders, total 3909632 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: 0×00000000

Device Boot Start End Blocks Id System /dev/sdX1 2048 34815 16384 83 Linux /dev/sdX2 34816 3909631 1937408 83 Linux

then write the partititons to the card

7. w

now we have to prepare the file system on the card:

the first partition should be vfat as this is FS which Allwinner bootloader understands

  1. mkfs.vfat /dev/sdX1

the second should be normal Linux EXT3 FS

  1. mkfs.ext3 /dev/sdX2

5. Debian rootfs

Linux Kernel and Uboot are ready, now we have the Linux distribution rootfs, how to build one is 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

  1. cd ..

download debian rootfs:

  1. wget http://hands.com/~lkcl/mele_debian_armhf_minimal.cpio.gz

mount your sd card EXT3 FS partition:

  1. mount /dev/sdX2 /mnt
  1. cd /mnt/

and unarchive the rootfs

  1. gunzip -c /home/user/olinuxino/mele_debian_armhf_minimal.cpio.gz | cpio -i
  1. cd ..
  1. sync
  1. umount /mnt

at this point you have Debian on your SD card second partition

6. Write Uboot and Kernel you build

  1. mount /dev/sdX1 /mnt/

copy the Kernel uImage to root directory in partition 1

  1. cp linux-allwinner/arch/arm/boot/uImage /mnt/.

download script.bin from: https://github.com/OLIMEX/OLINUXINO/blob/master/SOFTWARE/A13/script.bin

and copy in same directory with uImage

script.bin is text file with very important configuration parameters like port GPIO assignments, DDR memory parameters, Video resolution etc, by changing these parameters in the script.bin you can configure your Linux without need to re-compile your kernel again and again this is smart way Allwinner provide for tweaking A13 Linux Kernel

write the Uboot

  1. cd uboot-allwinner/
  1. dd if=spl/sunxi-spl.bin of=/dev/sdX bs=1024 seek=8
  1. dd if=u-boot.bin of=/dev/sdX bs=1024 seek=32
  1. sync
  1. umount /mnt

and copy the Kernel modules for partition 2

  1. mount /dev/sdX2 /mnt
  1. cd ..
  1. cp -a linux-allwinner/out/lib/modules/3.0.42+/ /mnt/lib/modules/.
  1. umount /mnt

that’s all folks! now you have SD card ready to boot debian on A13-OLinuXino.

Connect USB-SERIAL-CABLE-F to UEXT Tx.Rx and GND, put the SD-card in A13-OLinuXino(-WIFI) and apply power supply, you should see Uboot and then Kernel messages on the console

default username/password is : root / password

Have fun!