Linux2.6.39 for utu2440

Kernel Preparation

First download the kernel source from kernel.org:

$ wget https://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.39.tar.bz2
$ tar xjvf lnux-2.6.39.tar.bz2

Change the Makefile:

$ cat Makefile
export KBUILD_BUILDHOST := $(SUBARCH)
ARCH		?= $(SUBARCH)
CROSS_COMPILE	?= $(CONFIG_CROSS_COMPILE:"%"=%)

# Added our own cross-compiler here.
ARCH		?= arm
CROSS_COMPILE	?= arm-linux-
# End of added own cross-compiler. 

Change the pltf input clock:

$ vim  arch/arm/mach-s3c2440/mach-smdk2440.c
static void __init smdk2440_map_io(void)
{
	s3c24xx_init_io(smdk2440_iodesc, ARRAY_SIZE(smdk2440_iodesc));
	//s3c24xx_init_clocks(16934400);
	// Change the input clock adjust to utu2440
	s3c24xx_init_clocks(12000000);
	s3c24xx_init_uarts(smdk2440_uartcfgs, ARRAY_SIZE(smdk2440_uartcfgs));
}

Change the machine code(this code is the same as the bootloader’s parameter, bootloader transfer 5244 to Linux Kernel.

$ vim arch/arm/tools/mach-types 
s3c2440			ARCH_S3C2440		S3C2440			5244

Change the Nand flash partitions:

$ vim  arch/arm/plat-s3c24xx/common-smdk.c
static struct mtd_partition smdk_default_nand_part[] = {
	// partition for utu2440
	[0]= {
		.name = "bootloader", 
		.size = 0x00040000,
		.offset = 0x00000000,
	},
	[1]= {
		.name = "kernel", 
		.size = 0x00060000,
		.offset = 0x00200000,
	},
	[2]= {
		.name = "root", 
		.size = 0x00260000,
		.offset = 0x03dac000,
	}
	

};

static struct s3c2410_platform_nand smdk_nand_info = {
	.tacls		= 0,
	.twrph0		= 30,
	.twrph1		= 0,


Begin to configure:

# export PATH=/opt/cross/arm-linux-gcc_4.3.2/bin:$PATH
# vim Makefile
//ARCH                 ?= $(SUBARCH)
//CROSS_COMPILE     ?=
ARCH                 ?= arm
CROSS_COMPILE     ?= arm-linux-
# make s3c2410_defconfig
# make menuconfig
System Type-> ARM system type(Samsung S3C2410, S3C2412, ......
S3C2410 Machines  --->    [*] SMDK2410/A9M2410
S3C2440 AND S3C2442 Machines ---> [*] SMDK2440     [*] SMDK2440 with S3C2440 CPU module 
Kernel Features  --->   [*] Use the ARM EABI to compile the kernel

Then make all V=1
Generate uImage:

# cp arch/arm/boot/zImage ./
[root@TrustyArch linux-2.6.39]# mkimage -A arm -O linux -n $(date --iso-8601=seconds) -C NONE -a 0x30008000 -e 0x30008000 -d zImage uImage
Image Name:   2014-10-18T20:27:54+0800
Created:      Sat Oct 18 20:27:54 2014
Image Type:   ARM Linux Kernel Image (uncompressed)
Data Size:    2094940 Bytes = 2045.84 kB = 2.00 MB
Load Address: 30008000
Entry Point:  30008000

Now copy the uImage to the tftp directory for testing

tftpd on ubuntu

For updating the kernel on s3c2440 board, I have to setup the tftpd server.

tftpd server

Install tfpd-hpa:

sudo apt-get install tftpd-hpa

Setup the directory name and edit the /etc/default/tftpd-hpa:

root@joggler:/etc# cat /etc/default/tftpd-hpa 
# /etc/default/tftpd-hpa

TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/media/nfs/rootfs"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="--secure"

Then restart the server:

service tftpd-hpa restart

Other commands:

service tftpd-hpa status
service tftpd-hpa stop
service tftpd-hpa start
service tftpd-hpa restart
service tftpd-hpa force-reload

Testing

In the same machine, use following commands for testing the tftpd server(Make sure you have the get.txt under the root directory of your tftpd specified directory):

$ tftp localhost
tftp> get get.txt
tftp> quit

utu2440

Test the utu2440’s load_kernel function.
Copy the corresponding kernel file in tftpd server:

$ cp s3c_kernel/uImage_T5_480x272_ts ./uImage
$ chmod 777 uImage

First set the ipaddr for utu2440’s uboot:

utu-bootloader=>>>setenv ipaddr 10.0.0.15
utu-bootloader=>>>ping 10.0.0.1
dm9000 i/o: 0x18000300, id: 0x90000a46 
MAC: 00:0c:20:02:0a:5b
host 10.0.0.1 is alive

then set the server’s address to 10.0.0.11(that’s joggler with tftpd server enabled), use printenv for inspecting your configuration:

utu-bootloader=>>>setenv ipaddr 10.0.0.15
utu-bootloader=>>>printenv
ipaddr=10.0.0.15
serverip=10.0.0.11

View the embedded ‘install-kernel’ command:

utu-bootloader=>>>printenv
install-kernel=tftp 30000000 uImage;nand erase 60000 200000;nand write.i 30000000 60000 0
utu-bootloader=>>>run install-kernel
dm9000 i/o: 0x18000300, id: 0x90000a46 
MAC: 00:0c:20:02:0a:5b
TFTP from server 10.0.0.11; our IP address is 10.0.0.15
Filename 'uImage'.
Load address: 0x30000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         ##############################
done
Bytes transferred = 1483468 (16a2cc hex)

NAND erase: device 0 offset 0x60000, size 0x200000
Erasing at 0x25c000 -- 100% complete.
OK

NAND write: device 0 offset 0x60000, size 0x0

Writing data at 0x1ca200 -- 100% complete.
 1483776 bytes written: OK
utu-bootloader=>>>boot

Yes now you could compile your own kernel for utu2440.

Blueman

Since I installed the ArchLinux around 3 months ago, but I am too busy to enable the bluetooth headset, now I am free finally, so this is the steps for enable the bluetooth headset.

Software Installation

Install blueman:

$ sudo pacman -S blueman
$ sudo pacman -S bluez-utils bluez-libs python2-pybluez

Wait, this method is not OK for current bluez5, so I need to switch to other method.
Use official website, named"Bluetooth headset” on ArchLinux Wiki.

Bluez5/Pulseaudio

Install packages:

$ sudo pacman -S pulseaudio-alsa bluez bluez-libs bluez-utils
$ systemctl start bluetooth

Building Android On Server

New LXC Machine

Building Android need a Ubuntu machine, so I created the LXC machine which runs Ubuntu.
Install the bootstrap:

zypper in bootstrap

Then create the Ubuntu LXC via:

export LANG=en_US.UTF-8
Linux59:~ # lxc-create -n Ubuntu_Container -t /usr/share/lxc/templates/lxc-ubuntu

Start the container, username and password are ubuntu:

lxc-start -n Ubuntu_Container

Configure the LXC Machine

Better we have the static IP, and let the Container startup when machine boot.

Static IP Configuration

Change the network configuration via modifying the /etc/network/interfaces:

auto eth0

# Enable it for dhcp
#iface eth0 inet dhcp

# Enable them for static IP address
iface eth0 inet static
address 1xx.xxx.xxx.159
netmask 255.255.255.0
network 1xx.xxx.xxx.0
broadcast 1xx.xxx.xxx.255
gateway 1xx.xxx.xxx.1

Then next time you login into the machine, it hold the address of 159.

Start Together With Host Machine

Create a new definition file of systemd under the /usr/lib/systemd/system directory:

Linux59:/usr/lib/systemd/system # cat lxc\@.service
[Unit]
Description=%i LXC
After=network.target

[Service]
Type=forking
ExecStart=/usr/bin/lxc-start -d -n %i
ExecStop=/usr/bin/lxc-stop -n %i

[Install]
WantedBy=multi-user.target

Linux59:/usr/lib/systemd/system # pwd
/usr/lib/systemd/system

Let Ubuntu_Container runs when system bootup.

# systemctl enable lxc@Ubuntu_Container.service
ln -s '/usr/lib/systemd/system/lxc@.service' '/etc/systemd/system/multi-user.target.wants/lxc@Ubuntu_Container.service'

Update

visudo to change the settings:

ubuntu  ALL=(ALL:ALL) ALL
Defaults env_keep = "http_proxy https_proxy ftp_proxy"

Enable proxy for apt-get:

$ cat /etc/apt/apt.conf
Acquire::http::Proxy "http://127.0.0.1:9001";

Update the system and install some packages:

$ sudo apt-get update
$ sudo apt-get install tmux openjdk-7-jdk
$ sudo update-alternatives --config java && sudo update-alternatives --config javac
$ sudo apt-get install git gnupg flex bison gperf    zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev   libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386   libgl1-mesa-dev  mingw32 tofrodos   python-markdown libxml2-utils xsltproc zlib1g-dev:i386
$ sudo apt-get install build-essential 
$ sudo apt-get install g++-multilib
$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

Configuration on USB

Create following file:

ubuntu@Ubuntu_Container:~$ cat /etc/udev/rules.d/51-android.rules 
# adb protocol on passion (Nexus One)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e12", MODE="0600", OWNER="ubuntu"
# fastboot protocol on passion (Nexus One)
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0fff", MODE="0600", OWNER="ubuntu"
# adb protocol on crespo/crespo4g (Nexus S)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e22", MODE="0600", OWNER="ubuntu"
# fastboot protocol on crespo/crespo4g (Nexus S)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e20", MODE="0600", OWNER="ubuntu"
# adb protocol on stingray/wingray (Xoom)
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", ATTR{idProduct}=="70a9", MODE="0600", OWNER="ubuntu"
# fastboot protocol on stingray/wingray (Xoom)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="708c", MODE="0600", OWNER="ubuntu"
# adb protocol on maguro/toro (Galaxy Nexus)
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0600", OWNER="ubuntu"
# fastboot protocol on maguro/toro (Galaxy Nexus)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e30", MODE="0600", OWNER="ubuntu"
# adb protocol on panda (PandaBoard)
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d101", MODE="0600", OWNER="ubuntu"
# adb protocol on panda (PandaBoard ES)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="d002", MODE="0600", OWNER="ubuntu"
# fastboot protocol on panda (PandaBoard)
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d022", MODE="0600", OWNER="ubuntu"
# usbboot protocol on panda (PandaBoard)
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d00f", MODE="0600", OWNER="ubuntu"
# usbboot protocol on panda (PandaBoard ES)
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d010", MODE="0600", OWNER="ubuntu"
# adb protocol on grouper/tilapia (Nexus 7)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e42", MODE="0600", OWNER="ubuntu"
# fastboot protocol on grouper/tilapia (Nexus 7)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e40", MODE="0600", OWNER="ubuntu"
# adb protocol on manta (Nexus 10)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee2", MODE="0600", OWNER="ubuntu"
# fastboot protocol on manta (Nexus 10)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee0", MODE="0600", OWNER="ubuntu"

Building

Enable git proxy

Configure the git configuration:

ubuntu@Ubuntu_Container:~$ git config --global user.email "xxx@gmail.com"
ubuntu@Ubuntu_Container:~$ git config --global user.name "xxx"

Compile the connect.c for getting the cross-firewall tool.

$ gcc -o connect connect.c
$ sudo mv connect /usr/bin
$ sudo chmod  777 /usr/bin/connect
$ cat /usr/bin/myproxy 
/usr/bin/connect -H 127.0.0.1:9001 $@
$ sudo chmod 777 /usr/bin/myproxy

Let your git authenticated by github, please refers to the following article:
http://kkkttt.github.io/blog/2014/10/14/verified-to-github/

Then add the proxy setting in .gitconfig:

[core]
	gitproxy = /usr/bin/myproxy


Preparation

Install repo:

   57  echo $PATH
/home/ubuntu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
   58  curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
   59  chmod a+x ~/bin/repo

Make a new directory for holding the source code:

$ mkdir ~/code
$ repo init -u https://android.googlesource.com/platform/manifest

sync the repository:

$ repo sync

Build

Set the environment variables:

. build/envsetup.sh
lunch 

In lunch you could select whatever you like.
Then make via following command:

make -j 8

Trouble-shooting:

Your version is: java version "1.7.0_65".
The correct version is: Java SE 1.6.

Ok, we change the java version via:

$ sudo apt-get install software-properties-common
$ sudo apt-get install python-software-properties
Add the PPA:
$ sudo add-apt-repository ppa:webupd8team/java
Update the repo index:
$ sudo apt-get update
$ sudo apt-get install oracle-java6-installer

After installation, update the java version via:


$ sudo update-alternatives --config java
[sudo] password for ubuntu: 
There are 3 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-6-oracle/jre/bin/java          1062      auto mode
  1            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/java-6-oracle/jre/bin/java          1062      manual mode
  3            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1051      manual mode

Press enter to keep the current choice[*], or type selection number: 

Now you could run building.

###Trouble Shooting Build error:

If you are building an old version of android probably you’ll have this error

host C++: obbtool <= frameworks/base/tools/obbtool/Main.cpp
:0:0: error: “_FORTIFY_SOURCE” redefined [-Werror]
:0:0: note: this is the location of the previous definition
cc1plus: all warnings being treated as errors
To fix this, edit build/core/combo/HOST_linux-x86.mk and replace:

HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0
with

HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
And that’s it.

When you meet “error: reference ‘counts’ cannot be declared ‘mutable’", install gcc/g++ 4.4 and re-compiling.

$ sudo apt-get install gcc-4.4 g++-4.4  g++-4.4-multilib gcc-4.4-multilib
make CC=gcc-4.4 CXX=g++-4.4

View the CPU ranking:
http://itianti.sinaapp.com/index.php/cpu

490	Intel Core i5-2520M @ 2.50GHz		3537
851	Intel Xeon 5160 @ 3.00GHz		2047

View Result

Since we use the remote machine, we have to enable the vncserver, first install it via:

sudo apt-get install vnc4server

Install lubuntu-desktop as the default X:

sudo apt-get install lubuntu-desktop

Serial Port on BBB

Serial Port Settings

Use following settings for the serial monitor software:

The default serial port settings for the board are:
Baud 115,200
Bits 8
Parity N
Stop Bits 1
Handshake None

Connection

The serial port in BBB is listed as following:
/images/BBBSerial.jpg