Difference between revisions of "Build Bootable SD Card with Debian"
(→Format and setup the SD-card) |
(→Building Uboot) |
||
(11 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | + | 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 on Google Play. | |
− | + | There are also prebuilt SD card images that will boot to debian, they are linked to on the main A13 wiki page. These are suitable for anyone that doesn't want special kernel options. | |
− | 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. | + | For those who want to use and develop on this board with Linux and require non standard kernel configurations 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 | Note: The content is largely taken from this page of instructions | ||
[http://olimex.wordpress.com/2012/10/12/building-bootable-sd-card-with-debian-linux-image-for-a13-olinuxino/ building bootable sd card with debian linux image for a13 olinuxino] | [http://olimex.wordpress.com/2012/10/12/building-bootable-sd-card-with-debian-linux-image-for-a13-olinuxino/ building bootable sd card with debian linux image for a13 olinuxino] | ||
+ | |||
+ | [http://linux-sunxi.org/FirstSteps U-boot Sunxi Wiki with detailed info] | ||
== Tools required == | == Tools required == | ||
Line 36: | Line 38: | ||
Install the toolchain by typing the following. | Install the toolchain by typing the following. | ||
− | <nowiki># apt-get install gcc-4.6-arm-linux-gnueabi ncurses-dev uboot-mkimage build-essential git</nowiki> | + | <nowiki># apt-get install gcc-arm-linux-gnueabihf ncurses-dev uboot-mkimage build-essential git</nowiki> |
+ | |||
+ | <nowiki># Older (prior to 2013): apt-get install gcc-4.6-arm-linux-gnueabi ncurses-dev uboot-mkimage build-essential git</nowiki> | ||
with this line you make sure you have all tools necessary for the A13 kernel and uboot build: | with this line you make sure you have all tools necessary for the A13 kernel and uboot build: | ||
Line 60: | Line 64: | ||
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 | ||
− | <nowiki># git clone -b sunxi https://github.com/ | + | <nowiki># git clone -b sunxi https://github.com/linux-sunxi/u-boot-sunxi.git</nowiki> |
After the download you should have a new directory | After the download you should have a new directory | ||
Line 68: | Line 72: | ||
With the following command you can start the uboot build: | With the following command you can start the uboot build: | ||
− | <nowiki># make a13_olinuxino CROSS_COMPILE=arm-linux-gnueabi | + | <nowiki># make CROSS_COMPILE=arm-linux-gnueabihf- A13-OLinuXino_config</nowiki><br/> |
+ | <nowiki># make CROSS_COMPILE=arm-linux-gnueabihf-</nowiki> | ||
+ | |||
+ | <nowiki># (Older (prior 2013): make a13_olinuxino CROSS_COMPILE=arm-linux-gnueabi</nowiki><br/> | ||
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 | ||
Line 76: | Line 83: | ||
<nowiki># ls u-boot.bin spl/sunxi-spl.bin</nowiki> | <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 |
===Building the Kernel=== | ===Building the Kernel=== | ||
Line 289: | Line 296: | ||
default username/password is : root / password | default username/password is : root / password | ||
+ | |||
+ | == Software Links == | ||
+ | |||
+ | [http://linux-sunxi.org/Linux Linux Sunxi] to build latest Kernel yourself | ||
+ | |||
+ | [http://linux-sunxi.org/U-boot U-boot] to build community U-boot | ||
+ | |||
+ | [http://olimex.wordpress.com/2012/10/12/building-bootable-sd-card-with-debian-linux-image-for-a13-olinuxino/ Building bootable Debian SD card for A13-OLinuXino] Original step by step instructions how to make SD card image with above Kernel and U-boot | ||
+ | |||
+ | [https://www.olimex.com/forum/index.php?topic=518.0 Forum post ] with yet another more up to date explanation how to build SD card |
Latest revision as of 19:34, 8 June 2014
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 on Google Play.
There are also prebuilt SD card images that will boot to debian, they are linked to on the main A13 wiki page. These are suitable for anyone that doesn't want special kernel options.
For those who want to use and develop on this board with Linux and require non standard kernel configurations 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
U-boot Sunxi Wiki with detailed info
Contents
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-arm-linux-gnueabihf ncurses-dev uboot-mkimage build-essential git
# Older (prior to 2013): 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/linux-sunxi/u-boot-sunxi.git
After the download you should have a new directory
# cd uboot-allwinner/
With the following command you can start the uboot build:
# make CROSS_COMPILE=arm-linux-gnueabihf- A13-OLinuXino_config
# make CROSS_COMPILE=arm-linux-gnueabihf-
# (Older (prior 2013): 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
Software Links
Linux Sunxi to build latest Kernel yourself
U-boot to build community U-boot
Building bootable Debian SD card for A13-OLinuXino Original step by step instructions how to make SD card image with above Kernel and U-boot
Forum post with yet another more up to date explanation how to build SD card