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

(update for initial page)
(Completed Initial page)
Line 105: Line 105:
  
 
The menuconfig created a .config text file, which you can view/edit even with a text editor like vi
 
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:
 
if you want to use GPIOs for instance they are not enabled by default and you can do this by adding:
Line 118: Line 112:
 
then you can contiue with:
 
then you can contiue with:
  
# make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage
+
<nowiki># make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage</nowiki>
  
when this finish you will have uImage ready and you can build the kernel modules:
+
when this finish's you will have uImage ready and you can build the kernel modules:
  
# make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- INSTALL_MOD_PATH=out modules
+
<nowiki># make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- INSTALL_MOD_PATH=out modules</nowiki>
  
# make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- INSTALL_MOD_PATH=out modules_install
+
<nowiki># make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- INSTALL_MOD_PATH=out modules_install</nowiki>
  
 
DONE! At this point you have uboot and kernel builds ready.
 
DONE! At this point you have uboot and kernel builds ready.
  
4. Make the SD-card
+
===Format and setup the SD-card===
  
 
First we have to make the correct card partitions, this is done with fdisk.
 
First we have to make the correct card partitions, this is done with fdisk.
  
Plug SD card on your SD card reader and do
+
Plug SD card into your SD card reader and enter in the terminal
  
# ls /dev/sd
+
<nowiki># ls /dev/sd</nowiki>
  
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:
+
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.
  
# fdisk -u=sectors /dev/sdX
+
Once you know which device is your sdcard like sda use this text instead of the sdX name in the references below:
 +
 
 +
<nowiki># fdisk -u=sectors /dev/sdX</nowiki>
  
 
then do these steps:
 
then do these steps:
Line 154: Line 150:
 
3. n p 1
 
3. n p 1
  
create first partition, starting from 2048 and ending to 34815
+
create the first partition, starting from 2048 and ending to 34815
  
 
4. beginning 2048 end 34815
 
4. beginning 2048 end 34815
Line 183: Line 179:
 
7. w
 
7. w
  
now we have to prepare the file system on the card:
+
now we have to format the file system on the card:
  
the first partition should be vfat as this is FS which Allwinner bootloader understands
+
the first partition should be vfat as this is FS which the Allwinner bootloader understands
  
# mkfs.vfat /dev/sdX1
+
<nowiki># mkfs.vfat /dev/sdX1</nowiki>
  
 
the second should be normal Linux EXT3 FS
 
the second should be normal Linux EXT3 FS
  
# mkfs.ext3 /dev/sdX2
+
<nowiki># mkfs.ext3 /dev/sdX2</nowiki>
  
5. Debian rootfs
+
===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.
+
The Linux Kernel and Uboot are ready, now we have the Linux distribution rootfs, 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
 
exit the kernel directory
  
# cd ..
+
<nowiki># cd ..</nowiki>
  
 
download debian rootfs:
 
download debian rootfs:
  
# wget http://hands.com/~lkcl/mele_debian_armhf_minimal.cpio.gz
+
<nowiki># wget http://hands.com/~lkcl/mele_debian_armhf_minimal.cpio.gz</nowiki>
  
 
mount your sd card EXT3 FS partition:
 
mount your sd card EXT3 FS partition:
  
# mount /dev/sdX2 /mnt
+
<nowiki># mount /dev/sdX2 /mnt</nowiki>
  
# cd /mnt/
+
<nowiki># cd /mnt/</nowiki>
  
 
and unarchive the rootfs
 
and unarchive the rootfs
  
 +
<nowiki>
 
# gunzip -c /home/user/olinuxino/mele_debian_armhf_minimal.cpio.gz | cpio -i
 
# gunzip -c /home/user/olinuxino/mele_debian_armhf_minimal.cpio.gz | cpio -i
 +
</nowiki>
 +
where "user" is the user name of your root user
  
 +
<nowiki>
 
# cd ..
 
# cd ..
 +
</nowiki>
  
 +
<nowiki>
 
# sync
 
# sync
 +
</nowiki>
  
 +
<nowiki>
 
# umount /mnt
 
# umount /mnt
 +
</nowiki>
  
 
at this point you have Debian on your SD card second partition
 
at this point you have Debian on your SD card second partition
  
6. Write Uboot and Kernel you build  
+
===Write Uboot and Kernel you build===
  
# mount /dev/sdX1 /mnt/
+
<nowiki># mount /dev/sdX1 /mnt/</nowiki>
  
 
copy the Kernel uImage to root directory in partition 1
 
copy the Kernel uImage to root directory in partition 1
  
# cp linux-allwinner/arch/arm/boot/uImage /mnt/.
+
<nowiki># cp linux-allwinner/arch/arm/boot/uImage /mnt/.</nowiki>
  
download script.bin from: https://github.com/OLIMEX/OLINUXINO/blob/master/SOFTWARE/A13/script.bin
+
download the script.bin from:  
  
and copy in same directory with uImage
+
[https://github.com/OLIMEX/OLINUXINO/blob/master/SOFTWARE/A13/script.bin https://github.com/OLIMEX/OLINUXINO/blob/master/SOFTWARE/A13/script.bin]
  
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
+
and copy it to the same directory as uImage
 +
 
 +
script.bin is a 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
 
write the Uboot
  
 +
<nowiki>
 
# cd uboot-allwinner/
 
# cd uboot-allwinner/
 +
</nowiki>
  
 +
<nowiki>
 
# dd if=spl/sunxi-spl.bin of=/dev/sdX bs=1024 seek=8
 
# dd if=spl/sunxi-spl.bin of=/dev/sdX bs=1024 seek=8
 +
</nowiki>
  
 +
<nowiki>
 
# dd if=u-boot.bin of=/dev/sdX bs=1024 seek=32
 
# dd if=u-boot.bin of=/dev/sdX bs=1024 seek=32
 +
</nowiki>
  
 +
<nowiki>
 
# sync
 
# sync
 +
</nowiki>
  
 +
<nowiki>
 
# umount /mnt
 
# umount /mnt
 +
</nowiki>
 +
  
 
and copy the Kernel modules for partition 2
 
and copy the Kernel modules for partition 2
 
+
<nowiki>
 
# mount /dev/sdX2 /mnt
 
# mount /dev/sdX2 /mnt
 +
</nowiki>
  
 +
<nowiki>
 
# cd ..
 
# cd ..
 +
</nowiki>
  
 +
<nowiki>
 
# cp -a linux-allwinner/out/lib/modules/3.0.42+/ /mnt/lib/modules/.
 
# cp -a linux-allwinner/out/lib/modules/3.0.42+/ /mnt/lib/modules/.
 +
</nowiki>
  
 +
<nowiki>
 
# umount /mnt
 
# umount /mnt
 +
</nowiki>
  
that’s all folks! now you have SD card ready to boot debian on A13-OLinuXino.
+
Now you have an 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
+
Connect USB-SERIAL-CABLE-F to UEXT Tx.Rx and GND, or connect a VGA screen. Put the SD-card in A13-OLinuXino(-WIFI) and apply power, you should see Uboot and then Kernel messages on the console
  
 
default username/password is : root / password
 
default username/password is : root / password
 
Have fun!
 

Revision as of 02:52, 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

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:

# make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage

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

# make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- INSTALL_MOD_PATH=out modules

# 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.

Format and setup the SD-card

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 -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 the 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 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

Debian rootfs

The Linux Kernel and Uboot are ready, now we have the Linux distribution rootfs, 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 ..

download debian rootfs:

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

mount your sd card EXT3 FS partition:

# mount /dev/sdX2 /mnt

# cd /mnt/

and unarchive the rootfs

# gunzip -c /home/user/olinuxino/mele_debian_armhf_minimal.cpio.gz | cpio -i where "user" is the user name of your root user

# cd ..

# sync

# umount /mnt

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

Write Uboot and Kernel you build

# mount /dev/sdX1 /mnt/

copy the Kernel uImage to root directory in partition 1

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

download the script.bin from:

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

and copy it to the same directory as uImage

script.bin is a 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

# cd uboot-allwinner/

# dd if=spl/sunxi-spl.bin of=/dev/sdX bs=1024 seek=8

# dd if=u-boot.bin of=/dev/sdX bs=1024 seek=32

# sync

# umount /mnt


and copy the Kernel modules for partition 2 # mount /dev/sdX2 /mnt

# cd ..

# cp -a linux-allwinner/out/lib/modules/3.0.42+/ /mnt/lib/modules/.

# umount /mnt

Now you have an SD card ready to boot debian on A13-OLinuXino.

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

default username/password is : root / password