A13 - Building own Debian Image for SD card - HELP!

Started by vinzer, November 19, 2013, 01:43:04 AM

Previous topic - Next topic

vinzer

 ;)
Good day!

For the past few days we trying to build a bootable image for A13 board based on the tutorials found here.
Unfortunately at this time we still not able to succeed.
All the steps one by one I described in details below.

If you have a few minutes to go through all these steps (it is alot of text, but I tried to be as detailed as possible) and say your opinion I will highly apreciate that.
At the end I also copied the Terminal messages from UART1 port during attempt to boot.

This is a LOOONG post  :P

References:
http://olimex.wordpress.com/2012/10/12/building-bootable-sd-card-with-debian-linux-image-for-a13-olinuxino/
https://github.com/OLIMEX/OLINUXINO/blob/master/SOFTWARE/A13/olinuxino-debian.pdf


Environment:
-   OlinuXino A13 board with WiFi
-   Ubuntu 13.10 under VMWare Player (under Windows7)
-   SD Card 8Gb Class10 by Lexar (card tested to run other images OK)
SD card is visible under Ubuntu without a problem.



Step1:
Getting required tools for building and compiling the Linux Kernel

Command 1: (becoming a super user)
sudo su

Command 2: (opening the sources list for editing)
nano /etc/apt/sources.list

Adding these lines at the end of the file:

##A13 Linuxino Tools
deb http://www.emdebian.org/debian/ wheezy main
deb http://www.emdebian.org/debian sid main


Command 3: (forcing all apps to be updated and upgraded by Ubuntu)
apt-get update && apt-get upgrade

The result is okay so we move forward.


Now we want to get a GCC compiler installed.

Command 4:
apt-get install gcc-4.6-arm-linux-gnueabi ncurses-dev uboot-mkimage build-essential git


Here we got a first problem:

root@ubuntu:/home/vinzer# apt-get install gcc-4.6-arm-linux-gnueabi ncurses-dev uboot-mkimage build-essential git
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'libncurses5-dev' instead of 'ncurses-dev'
Package uboot-mkimage is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  u-boot-tools

E: Package 'uboot-mkimage' has no installation candidate



Assumed that the uboot-mkimage package has been replaced by u-boot-tools so we proceed and get that package:

Command 5:
apt-get install gcc-4.6-arm-linux-gnueabi ncurses-dev u-boot-tools build-essential git

Another problem down the road:
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'libncurses5-dev' instead of 'ncurses-dev'
build-essential is already the newest version.
git is already the newest version.
libncurses5-dev is already the newest version.
u-boot-tools is already the newest version.
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
gcc-4.6-arm-linux-gnueabi : Depends: libgomp1-armel-cross (>= 4.6.3-15) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.




Now we got lots of dependency problems. After reading the document from the second link in references (at the beginning) there was found that the GCC 4.6 can be replaced by its previous version 4.5 without any problems. It however has a hf version  (hard float).
We try to get it below


Command 6:
apt-get install gcc-4.5-arm-linux-gnueabihf ncurses-dev uboot-mkimage build-essential git


Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages have been kept back:
  linux-generic linux-headers-generic linux-image-generic
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
root@ubuntu:/home/vinzer# apt-get install gcc-4.5-arm-linux-gnueabihf ncurses-dev uboot-mkimage build-essential git
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'libncurses5-dev' instead of 'ncurses-dev'
Package uboot-mkimage is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  u-boot-tools

E: Package 'uboot-mkimage' has no installation candidate



And again the brick on the road. It looks like the uboot-mkimage is replaced by u-boot-tools. We try to get the u-boot-tools package instead below


Command 7:
apt-get install gcc-4.5-arm-linux-gnueabihf ncurses-dev u-boot-tools build-essential git


Finally compiler and tools got installed okay after Command 7.

Now we need to rename the GCC folder to the default name which is used in make command.


Command 8:
mv /usr/bin/arm-linux-gnueabihf-gcc-4.5 /usr/bin/arm-linux-gnueabihf-gcc


At this point we have all tools required for the compiling of the Kernel installed.


Now we need to prepare and configure U-Boot Sunxi
First we create folder where we will compile and store our project (we use name Olinuxino-A13-3 as this is a third attempt to make an image).

Make sure that we are in the root of the user folder:
root@ubuntu:/home/vinzer#

Command 9:
mkdir Olinuxino-A13-3
cd Olinuxino-A13-3



Now we need to download U-Boot Sunxi to our folder


Command 10:
git clone -b sunxi https://github.com/linux-sunxi/u-boot-sunxi.git

Download succeeded. Now we have new u-boot-sunxi folder under our project folder Olinuxino-A13-3

Open this folder.

Command 11:
cd u-boot-sunxi


Now we need to compile u-boot image.
Since we got the hf version command should be written accordingly

Command 12:
make a13-olinuxino CROSS_COMPILE=arm-linux-gnueabihf-

As soon as compilation ends we need to check if actual output has been produced by the compiler

Command 13:
ls u-boot.bin spl/sunxi-spl.bin


and the response is: spl/sunxi-spl.bin  u-boot.bin

At this point we are done with u-boot image


Now we need to download, configure and compile Kernel.

Make sure we are in the project folder:
root@ubuntu:/home/vinzer/Olinuxino-A13-3#


Downloading the Kernel

Command 14:
git clone https://github.com/linux-sunxi/linux-sunxi.git


Once downloaded we simply step in to the Linux-Sunxi folder

Command 15:
cd linux-sunxi

Now we need to create default .config file for Kernel build.


Command 16:
make ARCH=arm a13_defconfig


In order to change the configuration of the Kernel before build we may use configuration utility
It can be called by command: make ARCH=arm menuconfig

In our case we DO NOT change any configuration and keep it as per default.

If GPIO pins of the board need to work we need to open .config file with for example nano editor and fine the line:
# SUN4I_GPIO_UGLY is not set
Change this line to
SUN4I_GPIO_UGLY=y  (this means that the particular config is included in the build)

Saving .config file after that is the next step.

Now we compile the Kernel. We did not do any changes to .config except GPIO pins and we expect that the default configuration for the A13 board will fire up the board.


Command 17:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- uImage



Our response from the compiler is:

Image Name:   Linux-3.4.67
Created:      Mon Nov 18 12:13:59 2013
Image Type:   ARM Linux Kernel Image (uncompressed)
Data Size:    4166808 Bytes = 4069.15 kB = 3.97 MB
Load Address: 40008000
Entry Point:  40008000
Image arch/arm/boot/uImage is ready




Once compilation is done we build modules (drivers) for Kernel via two commands


Command 18:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=out modules
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=out modules_install


At this moment we have both uboot image and Kernel image ready for deploy to SD card.




Now we preparing SD card. In our case it is Lexar 8Gb Class 10 card. Card has been tested with other working image (default A13 image from manufacturer) and confirmed to work.

Using fdisk we want to delete all partitions from the card, create two new partitions and format them appropriately. Size of the first partition is 16MB and the second is all the rest of the card space.
First partition file system type is vfat and the second partition type of file system is: ext3

Before processing with the fdisk we check the name of the media (SD card) in the system.
We use utility called gparted (For installation we type: apt-get install gparted).

Found that our SD card has a system name: sdb
Partition one will be sdb1 and partition two will be sdb2 afterwards.






Command 19:
fdisk /dev/sdb

Command d will delete existed partitions (d 1, d 2, d 3 and whatever is there)

Command p will show current status of the card
Once all partitions are deleted from the card we have:

Disk /dev/sdb: 8010 MB, 8010072064 bytes
247 heads, 62 sectors/track, 1021 cylinders, total 15644672 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: 0x000c176e

Device Boot      Start         End      Blocks   Id  System



Command n will create new partitions.

We do:
n (partition 1, primary, default start sector 2048, end sector 34815 or +16M)
n (partition2, primary, default start sector 34816 and until the end of the space on the card)


Again command p:

Disk /dev/sdb: 8010 MB, 8010072064 bytes
247 heads, 62 sectors/track, 1021 cylinders, total 15644672 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: 0x000c176e

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048       34815       16384   83  Linux
/dev/sdb2           34816    15644671     7804928   83  Linux


All looks okay, we may apply changes to the card.



w (to write the changes to the card)
Now we leave fdisk and formatting the partitions.

We got however the message:

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.



To stay safe we remove the card from the reader first, rebooted the Ubuntu virtual machine next and after reboot reinserted the card. Need to make sure that the new configuration is taken in to the account.

In despite after reboot and after card is reinserted we still may see an old files (old image files) on the SD card.

We now unmounts partitions of the SD card and format these:

Command 20:
umount /dev/sdb1
umount /dev/sdb2



Now we format both partitions

Command 21:
mkfs.vfat /dev/sdb1
mkfs.ext3 /dev/sdb2



After SD card is ready we downloading the Debian Distribution

Make sure we are in the project folder:
root@ubuntu:/home/vinzer/Olinuxino-A13-3#



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

Once downloaded we need to unzip this archive directly to the second partition of the SD card
Mounting back the second partition (ext3) and unzipping the files to it (/mnt)


Command 23:
mount /dev/sdb2 /mnt
cd /mnt


Command 24:
gunzip -c /home/vinzer/Olinuxino-A13-3/mele_debian_armhf_minimal.cpio.gz | cpio -i


This takes some time to process.

Once done we synchronize the filesystem and unmounts the partition 2.

Command 25:
cd ..
sync
umount /mnt



Now the Debian distribution is copied to the second partition of the SD card.


Now mounting partition 1 of the SD card and copying Kernel uImage to this partition

Command 26:
mount /dev/sdb1 /mnt
cd /mnt
cp /home/vinzer/Olinuxino-A13-3/linux-sunxi/arch/arm/boot/uImage /mnt/




Now we write the boot partition uBoot

Make sure that we are in /home/vinzer/Olinuxino-A13-3/u-boot-sunxi folder

Command 27:
dd if=spl/sunxi-spl.bin of=/dev/sdb bs=1024 seek=8

Response received:
18+1 records in
18+1 records out
18944 bytes (19 kB) copied, 0.0806756 s, 235 kB/s


Command 28:
dd if=u-boot.bin of=/dev/sdb bs=1024 seek=32

Response received:
182+1 records in
182+1 records out
186692 bytes (187 kB) copied, 0.0975358 s, 1.9 MB/s



Synchronizing and unmounting partition 1 now

Command 29:
sync
umount /mnt



Again mounting partition 2 and copying over the Kernel to it

Command 30:
mount /dev/sdb2 /mnt
cp -a /home/vinzer/Olinuxino-A13-3/linux-sunxi/out/lib/modules/3.4.67/ /mnt/lib/modules/
umount /mnt







Next and last thing we do is we connect the SD card to Windows7 machine, there we will see only the first FAT partition.
We download the script.bin file from:
https://github.com/OLIMEX/OLINUXINO/blob/master/SOFTWARE/A13/script.bin

and simply copy it to the root of the first partition on SD card next to the uImage file.



Next we insert the SD card to the A13 board's SD card reader and connect VGA display.
Power up the board and here we stuck. The red light led comes on and nothing on VGA nor LCD (7") display.
The board is powered up but no boot happening.


In the Terminal we see the following:

U-Boot SPL 2013.10-rc2-08405-gb322f67 (Nov 18 2013 - 11:31:35)
Board: A13-OLinuXino
DRAM: 512 MiB
CPU: 1008000000Hz, AXI/AHB/APB: 3/2/2
spl: not an uImage at 1600
spl: not an uImage at 80
### ERROR ### Please RESET the board ###



It looks like our uImage is not visible for the A13 bootloader.
Why was done wrong ? Where is the mistake in the process ?
How is it possible to debug that ?


I think the possible problems are in:

- Problem with the .config file. Maybe this file has something wrong by default ? .config whis is used is 3.4.67 Kernel Configuration

- Problem with the way how image is written to the SD card because of the virtual machine under Windows7 and the way how Ubuntu accessing the SD card

These are the only two things come to my mind.

Please help  :)

vinzer

After searching and reading WiKi I was able to find the reason for the error during the boot.
The first problem was in the way how we wrote the u boot

Insteed of:
dd if=u-boot.bin of=/dev/sdb bs=1024 seek=32

we should use:
dd if=u-boot.img of=/dev/sdc bs=1024 seek=40

This is according to: https://github.com/linux-sunxi/u-boot-sunxi/wiki


After rebuilding the image and rewriting data to the SD card board still does not boot, however moves further in to the booting process, both red and green leds comes on and we have another error in terminal:

U-Boot 2013.10-rc2-08405-gb322f67 (Nov 18 2013 - 16:09:55) Allwinner Technology

CPU:   Allwinner A13/A10s (SUN5I)
Board: A13-OLinuXino
I2C:   ready
DRAM:  512 MiB
MMC:   SUNXI SD/MMC: 0
In:    serial
Out:   serial
Err:   serial
Hit any key to stop autoboot:  0
reading uEnv.txt
** Unable to read file uEnv.txt **
Failed to mount ext2 filesystem...
** Unrecognized filesystem type **
Failed to mount ext2 filesystem...
** Unrecognized filesystem type **
reading boot.scr
** Unable to read file boot.scr **
Failed to mount ext2 filesystem...
** Unrecognized filesystem type **
Failed to mount ext2 filesystem...
** Unrecognized filesystem type **
reading script.bin
26604 bytes read in 5 ms (5.1 MiB/s)
reading uImage
4167000 bytes read in 217 ms (18.3 MiB/s)
Unknown command 'watchdog' - try 'help'
sun5i#

vinzer

#2
Very strange case...
Even after I completelly reformatted both partitions on SD card, made the card bootable by applying:

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

and finally copied uImage and script.bin from other fully working image
once I start the board I still have in terminal:


Unknown command 'watchdog' - try 'help'


Where this 'watchdog' command comes from ? Who sends it?
Please suggest if you aware of this.

U-Boot SPL 2013.10-rc2-08405-gb322f67 (Nov 18 2013 - 19:13:33)
Board: A13-OLinuXino
DRAM: 512 MiB
CPU: 1008000000Hz, AXI/AHB/APB: 3/2/2
spl: not an uImage at 1600


U-Boot 2013.10-rc2-08405-gb322f67 (Nov 18 2013 - 19:13:33) Allwinner Technology

CPU:   Allwinner A13/A10s (SUN5I)
Board: A13-OLinuXino
I2C:   ready
DRAM:  512 MiB
MMC:   SUNXI SD/MMC: 0
In:    serial
Out:   serial
Err:   serial
Hit any key to stop autobot:  0
reading uEnv.txt
** Unable to read file uEnv.txt **
Failed to mount ext2 filesystem...
** Unrecognized filesystem type **
Failed to mount ext2 filesystem...
** Unrecognized filesystem type **
reading boot.scr
** Unable to read file boot.scr **
Failed to mount ext2 filesystem...
** Unrecognized filesystem type **
Failed to mount ext2 filesystem...
** Unrecognized filesystem type **
reading script.bin
28156 bytes read in 5 ms (5.4 MiB/s)
reading uImage
Invalid FAT entry
2048 bytes read in 5 ms (399.4 KiB/s)
Unknown command 'watchdog' - try 'help'
sun5i

JohnS

I suspect it's part of the command line inside u-boot.  To check, interrupt the boot once you see the early messages and then look at u-boot's environment.

If it's that, I think the u-boot you've built will need a change or maybe you could do it via a uEnv.txt

John

vinzer

Hello John,

Thank you for your ideas.

I did an experiment earlier today and it shows that the problem is somewhere in uImage. This is exactly my problem I think.


What I did during experiment was:

1.   I took completely new 8Gb SD card (class 10 good quality one).
2.   Properly fdisk it and after that properly formatted SD card (two partitions as per instructions)
3.   Compiled a new uImage
4.   Properly installed boot sectors to the SD card partition 1 (dd if=u-boot-sunxi/u-boot-sunxi-with-spl.bin of=/dev/sdb bs=1024 seek=8)
5.   Copied to the first partition of the card script.bin file
6.   Second partition is empty and clean for now. So my SD card contains ONLY uImage and script.bin
7.   Started up the board with this image.

I expected to have some info about Booting Kernel followed by Missing Kernel or similar error message related to Kernel.

Instead I got this messages in the terminal:

U-Boot SPL 2013.10-rc2-08405-gb322f67 (Nov 19 2013 - 12:43:54)
Board: A13-OLinuXino
DRAM: 512 MiB
CPU: 1008000000Hz, AXI/AHB/APB: 3?2/2
spl: not an uImage at 1600


U-Boot 2013.10-rc2-08405-gb322f67 (Nov 19 2013 - 12:43:54) Allwinner Technology

CPU:   Allwinner A13/A10s (SUN5I)
Board: A13-OLinuXino
I2C:   ready
DRAM:  512 MiB
MMC:   SUNXI SD/MMC: 0
In:    serial
Out:   serial
Err:   serial
Hit any key to stop autoboot:  0
reading uEnv.txt
** Unable to read file uEnv.txt **
Failed to mount ext2 filesystem...
** Unrecognized filesystem type **
Failed to mount ext2 filesystem...
** Unrecognized filesystem type **
reading boot.scr
** Unable to read file boot.scr **
Failed to mount ext2 filesystem...
** Unrecognized filesystem type **
Failed to mount ext2 filesystem...
** Unrecognized filesystem type **
reading script.bin
28156 bytes read in 5 ms (5.4 MiB/s)
reading uImage
4098504 bytes read in 214 ms (18.3 MiB/s)
Unknown command 'watchdog' - try 'help'
sun5i# 


So at the end I have a prompt sun5i# - which I assume is the bootloader or uImage prompt.
I can type messages in terminal  and board respond.

This means that my problem is not even in the Kernel because my bootloader not even trying to load up a Kernel.

This is something wired...  :o I do not understand the reason of such problem.
Is there any way to diagnose the booting sequence and see what is booted ?
Where is the script file which controlling the booting sequence is located under /u-boot-sunxi ??

Finally I do not understand what is wrong with my uBoot

I did as follows:

1. git clone -b sunxi https://github.com/linux-sunxi/u-boot-sunxi.git
2. make a13-olinuxino CROSS_COMPILE=arm-linux-gnueabihf-
3. dd if=u-boot-sunxi/u-boot-sunxi-with-spl.bin of=/dev/sdb bs=1024 seek=8
4. cp linux-sunxi/arch/arm/boot/uImage /mnt

:-\


jwischka

Do you have watchdog support enabled in the kernel? Toggle the setting and see if it boots.

vinzer

I "solved" the problem I think....

Since it was related to the u-boot as I thought I decided to go step by step:


1. Took another working SD card image.

2. Boot from it to make sure that image works (I took original A13 image by Olimex)

3. I deleted all files from first partition of the working image and run following commands:

dd if=u-boot-sunxi/u-boot-sunxi-with-spl.bin of=/dev/sdb bs=1024 seek=8
cp linux-sunxi/arch/arm/boot/uImage /mnt


This let me test my uImage and script.bin.

After this step board booted OKAY

4. I deleted all files from second partition of the working SD card image and run the following commands:

tar -xzvf /home/vinzer/Olinuxino-A13-1/debian_fs_olimex.tar.gz
cp -rfv /home/vinzer/Olinuxino-A13-1/linux-sunxi/out/lib/modules/3.4.67/ /mnt/lib/modules/


This let me check if my Kernel and rootfs are okay.

After this board booted up OKAY


Now I do not understand what is the issue with my SD card - did I used fdisk improperly or something else.
The only difference between my image on the non working SD card and this working SD card is the way how it was prepared. My card was done manually with fdisk while the working card is taken from image.

Probably the problem is in the Ubuntu and its GUI shell which was running during the time when I used fdisk for SD card preparation.... not sure yet


Question here: I got my image boot up and prompt for login and password came up in the terminal :) means there is not terminal application installed in the image yet ? Or this is a standard part of the image and I just have to change that in .config file ? I also understand that for LCD display to work I have to tune up my .config

;)

AxR

I had the same problem on A10 Lime board.

I fix the problem rebuilting the boot.src file.

To create boot.scr
first make a u-boot script boot.cmd with the u-boot commands you need for booting your system.

An example follows:
setenv bootargs console=ttyS0 root=/dev/mmcblk0p1 rootwait panic=10 ${extra} ext2load mmc 0 0x43000000 boot/script.bin ext2load mmc 0 0x48000000 boot/uImage bootm 0x48000000

Then translate this to a boot.scr by using the mkimage command
mkimage -C none -A arm -T script -d boot.cmd boot.scr

Andrea