2010年3月14日 星期日

Madplay Music Player

Madplay Music Player

The madplay is a mp3 player, it is a command line music player without any fancy user front-end, but serve the purpose if we want an easy way to install and test our machine to listen on music.

First download a copy of libmad and libid3tag which is a dependant libraries for mpeg decoding and song's idtag access require by madplay.

unzip the file and configure the libmad, then install it into a temporary install directory.

./configure --host=arm-linux --prefix=/usr --sysconfdir=/etc --libdir=/lib --datadir=/usr/share LDFLAGS="-L/rootfs/lib" CPPFLAGS="-I/rootfs/usr/include"
make
make install DESTDIR=/install/libmad



Note, if there's a -fforce-mem compile error, just remove the CFLAGS option from the Makefile.

Two directories are created lib and usr, copy all the files from the lib directory and usr include header files to our corresponding root filesystem layout.

Now, configure and compile the libid3tag.

./configure --host=arm-linux --prefix=/usr --sysconfdir=/etc --libdir=/lib --datadir=/usr/share LDFLAGS="-L/rootfs/lib" CPPFLAGS="-I/rootfs/usr/include"
make
make install DESTDIR=/install/libid3tag



Two directories also created lib and usr.

Similarly, copy all the files from the lib directory and usr include header files to our corresponding root filesystem layout.

Configure and compile madplay.

./configure --host=arm-linux --prefix=/usr --sysconfdir=/etc --libdir=/lib --datadir=/usr/share LDFLAGS="-L/rootfs/lib" CPPFLAGS="-I/rootfs/usr/include"
make
make install DESTDIR=/install/madplay


Only usr directory is created, copy the 'madplay' bin file in usr/bin directory to our root filesystem bin directory.

Also copy a mp3 music files over.

Restart the board to test the program.

madplay music.mp3

For the Mini2440 i need a audio jack and a speaker to plug into the device in order to listen to the music.

Note, if no music coming out from the player then the kernel may not configure with the correct sound module properly.

Go to the kernel directory and start the menuconfig screen.

ARCH=arm make menuconfig

Need to configure the UDA1341 chipset which Mini2440 is equip with to enable the sound support.

Go to Device Drivers --> Sound card support --> Advance Linux Sound Architecture --> ALSO for SoC Audio support --> Select the UDA134X audio support.


--- ALSA for SoC audio support
<*> SoC Audio for the Samsung S3CXXXX chips
< > SoC AC97 Audio support for LN2440SBC - ALC650
<*> SoC I2S Audio support UDA134X wired to a S3C24XX
< > SoC I2S Audio support for TLV320AIC23 on Simtec boards
< > SoC I2S Audio support for Simtec Hermes board
< > Build all ASoC CODEC drivers


Once finished, compile the kernel and there should be a dsp and mixer device files create in the dev directory.

2010年3月11日 星期四

SDL Multimedia Library

SDL Multimedia Library

SDL is a cross platform multimedia library provide access to low level system hardware and many applications use to operate on MPEG playback.

Since it is a low level software it is usually require as a dependency library to build on other multimedia applications on our device, such as webcam and etc.

Download a copy from SDL and unzip file.

Configure the package and then compile it.

./configure --host=arm-linux --prefix=/usr --sysconfdir=/etc --libdir=/lib --datadir=/usr/share --disable-video-x11 --disable-alsatest --disable-esdtest --disable-arts LDFLAGS="-L/rootfs/lib" CPPFLAGS="-I/rootfs/usr/include"
make



Install into a temporary directory.

make install DESTDIR=/install/SDL-1.2.14


There are 2 directories lib and usr created.

Copy the libraries and header files to our root filesystem.

cp /install/SDL-1.2.14/lib/libSDL* .
cp /install/SDL-1.2.14/lib/pkgconfig/sdl.pc ./pkgconfig
cp /install/SDL-1.2.14/usr/bin/sdl-config /usr/local/arm/4.4.1/bin
cd ../usr/include
cp -r /install/SDL-1.2.14/usr/include/* .



Note, the sdl-config is a shell script which move to our cross-compiler bin directory because it is related to our target-compiled environment.

Modify the /rootfs/lib/libSDL.la libtool library file to point to our root directory.

libdir='/rootfs/lib'



Modify the library reference of sdl.pc in /rootfs/lib/pkgconfig directory as shown below.

prefix=/rootfs
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/usr/include


Modify the sdl-config script as below.
- change /usr to /rootfs
- change ${prefix}/include to ${prefix}/usr/include
- change /lib to ${prefix}/lib


Now, compile the testing program.

Go to test directory in /opt/SDK-1.2.14/test and configure the package.

./configure --host=arm-linux --prefix=/usr --sysconfdir=/etc --libdir=/lib --datadir=/usr/share LDFLAGS="-L/rootfs/lib" CPPFLAGS="-I/rootfs/usr/include"


Modify the Makefile.
- change the include path to start with our root directory eg. /rootfs
- change the lib path to start with -L/rootfs/lib and append -L/rootfs/lib -Wl,-rpath-link,/rootfs/lib


Compile it.

make

Finally, copy the test program to the board for testing (refer to the test/README for a list of the test program description)

I will test the testalpha program.

cd /opt/SDL-1.2.14/test
cp testalpha /rootfs/usr/local/bin
cp icon.bmp /rootfs/usr/local/bin



Restart the board to test the program.

cd /usr/local/bin
testalpha -width 240 -height 320


The above will show a smiley face and you can move it with the pen around the screen.

motion Webcam

motion Webcam on Mini2440

This is an interesting webcam library that will detect movement object on camera and start capturing the motion picture on mpeg format, there are other feature that allow capture video record into a database and also enable remote control of the webcam through xml-rpc.

The library dependencies is on SDL, ffmpeg, SDL is require because ffplay needs it and ffmpeg also require libz library to build it.

Download a copy from motion and ffmpeg.

Install the ffmpeg first which motion rely on its library.

Configure the package.

./configure --prefix=/usr --libdir=/lib --datadir=/usr/share --enable-shared --enable-cross-compile --arch=arm --cc=arm-linux-gcc --host-ldflags="-L/rootfs/lib" --host-cflags="-I/rootfs/usr/include"


then modify the config.mak in the Makefile to replace gcc, ar, ranlib to prefix it with 'arm-linux-'

Compile and install it to a temporary directory.

make
make install DESTDIR=/install/ffmpeg



There are 2 main directories lib and usr are created.

Copy all the files require to our root filesystem.


cd /install/ffmpeg/usr
cp -ar lib/* /rootfs/lib
cp -ar include/* /rootfs/usr/include
cp bin/* /rootfs/usr/local/bin
cd ../lib
cp pkgconfig/* /rootfs/lib/pkgconfig


Change all the libac* package configure files in /rootfs/lib/pkgconfig as shown below.

prefix=/usr
exec_prefix=${prefix}
libdir=/lib
includedir=${prefix}/include


Now, install the motion webcam library.

Configure the package.

./configure --host=arm-linux --prefix=/usr --sysconfdir=/etc --libdir=/lib -datadir=/usr/share --with-ffmpeg=/rootfs LDFLAGS="-L/rootfs/lib" CPPFLAGS="-I/roofs/usr/include"


Change Makefile to add CPPFLAGS = -I/rootfs/usr/include and insert the flags to all the $(CC) compile line.

Compile and install it.

make
make install DESTDIR=/install/motion



There are 2 directories etc and usr are create.

Copy all the files require to our root filesystem.

cd /install/motion/usr
cp bin/* /rootfs/usr/local/bin
cd ../etc
cp motion-dist.conf /rootfs/etc/motion.conf



Change the motion configuration file below.


ffmpeg_cap_motion off
ffmpeg_timelapse 1
target_dir /tmp/cam1


Restart the board to test the library.

First, check our usb camera is connect and recognize in our board (my is a microdia chip from GDMALL)

dmesg|grep usb

usb 1-1: new full speed USB device using s3c2410-ohci and address 2            
usb 1-1: New USB device found, idVendor=0c45, idProduct=60fc
usb 1-1: New USB device strings: Mfr=0, Product=1, SerialNumber=0
usb 1-1: Product: USB camera
usb 1-1: configuration #1 chosen from 1 choice


Note, the vendor and product id is shown above, if you don't see the message it means the kernel is not configure properly.

Start the motion webcam, it will generate a timelapse mpg output file in the /tmp/cam1 directory.


motion


Go to the output directory to convert it to avi format from the mpeg file to a suitable frame size.

ffmpeg -i 20090103-timelapse.mpg -s 240x320 foo.avi


Finally, view it on device screen.

ffplay -s 240x320 foo.avi


It can be automated to run a serial of commands above to make it as a live video.

For the server process, we can stream over the network and use the browser in our host computer to view it.

First, configure the ffserver.conf to accept flash stream format which i will view it on my pc, below is the important setting.

Fromat swf
VideoBitRate 300
VideoFrameRate 10
VideoSize 320x240
NoAudio


While the motion is still running, i will start up the stream server and use ffmpeg to redirect the motion mpg files into swf and stream it over the network.

ffserver
ffmpeg -i 20090105-timelapse.mpg -vcodec flv -s 320x240 -b
300k -r 10 http://192.168.114.190:8090/feed1.ffm


FFmpeg version 0.5.1, Copyright (c) 2000-2009 Fabrice Bellard, et al.           
configuration: --prefix=/usr --libdir=/lib --datadir=/usr/share --enable-share
libavutil 49.15. 0 / 49.15. 0
libavcodec 52.20. 1 / 52.20. 1
libavformat 52.31. 0 / 52.31. 0
libavdevice 52. 1. 0 / 52. 1. 0
built on Mar 11 2010 16:08:38, gcc: 4.4.1
Input #0, mpegvideo, from '20090105-timelapse.mpg':
Duration: 00:00:00.15, bitrate: 104857 kb/s
Stream #0.0: Video: mpeg1video, yuv420p, 320x240 [PAR 1:1 DAR 4:3], 104857 c
Mon Jan 5 06:36:25 2009 192.168.114.190 - - [GET] "/feed1.ffm HTTP/1.1" 200 825
Output #0, ffm, to 'http://192.168.114.190:8090/feed1.ffm':
Stream #0.0: Video: flv, yuv420p, 320x240, q=3-31, 300 kb/s, 1000k tbn, 10 c
Stream mapping:
Stream #0.0 -> #0.0
Press [q] to stop encoding


Note, the above message show that our input is from the motion mpeg and the output it to flv flash format.

Now, go to the pc and type http://192.168.114.190:8090/test1.swf in the browser, you will see the flash movie which is capture earlier in our motion webcam.




2010年3月7日 星期日

tslib Touch Screen

tslib Touch Screen

This is a very popular library, almost every small device test board use it to navigating on a touch screen with an GUI applications.

It can be download in tslib.

As usual, unzip the file and configure it first.

autogen.sh
echo ac_cv_func_malloc_0_nonnull=yes >config.cache
./configure --host=arm-linux --prefix=/usr --sysconfdir=/etc --libdir=/lib --datadir=/usr/share



Compile the source and install package to a temporary directory, this is to avoid overwrite any files and examine what files are install.

make
mkdir /install
make install DESTDIR=/install/tslib-1.0



Three main directories etc, lib and usr are created.

Copy all the files to our root filesystem.

cd /rootfs/lib
cp /install/tslib-1.0/lib/* .
cd ../usr
cp -a /install/tslib-1.0/usr/include .
mkdir -p local/bin
cp /install/tslib-1.0/usr/bin/* ./local/bin
cd ../etc
cp /install/tslib-1.0/etc/ts.conf .



Modify the ts.conf configuration file, to uncommend the 'module_raw input' line, the contents show as below.

module_raw input
module pthres pmin=1
module variance delta=30
module dejitter delta=100
module linear

Next, create a directory /etc/profile.d and make a shell script tslib.sh to setup the tslib environment variable settings.

export TSLIB_TSDEVICE=/dev/input/event1
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_CONFFILE=/etc/ts.conf
export TSLIB_PLUGINDIR=/lib/ts
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_CONSOLEDEVICE=none


Add job process to the system profile so that it will automatically export the settings while start up the system.

Edit the /etc/profile to append instructions below to look at the profile.d directory and run the script.

# auto shell script startup process
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
. $i
fi
done
unset i


Also, make sure to append the new /usr/local/bin directory to the search system PATH.

PATH=$PATH:/usr/local/bin


At last, change the libtool library file and pkgconfig file.

Go to /rootfs/lib change the tslib.la libdir option to '/rootfs/lib' becuase the actual location of this library is in our root filesystem.

Same goes to directory /rootfs/lib/ts for all the '.la' files (input.la is important)

One more, the tslib-0.0.pc pkgconfig file in /rootfs/pkgconfig, change the include and library reference directory show as below.

prefix=/rootfs
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/usr/include

Name: tslib
Description: Touchscreen Access Library
Version: 0.0.2
Libs: -L${libdir} -lts
Cflags: -I${includedir}


Restart the board to test the setup library.

First, use the calibrate utility to initialize and adjust the drawing boundary, it will show a crosshair on screen, touch it with a pen to finish the procedure.

ts_calibrate


Start the test program, touch on the 'Draw' box and drawing on screen is now enable.

ts_test


thttpd Web Server

thttpd Web Server

This is a open source light weight web server to implement HTTP/1.1, easy to setup with minimum effort to get it running.

Download a copy of thttpd to unzip.

Configure and compile it.

./configure --host=arm-linux
make



Note, if there is a conflicting getline error in extras/htpasswd.c change all the getline function to some other name eg. getlines to make it unique.

Copy the thttpd executable file to /rootfs/usr/sbin (this is assume the root filesystem is created in /rootfs directory).


cp thttpd /rootfs/usr/sbin


Create a thttpd.config file in the /rootfs/etc directory for its configuration settings.


dir=/www
user=root
cgipat=/cgi-bin/*
logfile=/tmp/thttpd.log
pidfile=/var/thttpd.pid


Add the command line to the rcS script to start up the http server.

# start HTTP server
thttpd -C /etc/thttpd.config


Create a directory for the web page.


mkdir -p /rootfs/www/cgi-bin


Create a simple index.html program in the www directory.


<html>
<head>
<title>Welcome html</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>


Restart the board, go to the host computer web browser and enter the url of the device ip address eg. http://192.168.114.190/index.html

Note, the board must be configured with network address over the NFS service.



However, to make our target board as a client we have to configure our host as a router which allow network traffic to be redirected to access the internet gateway, this set up assume the target and host is connected via a hub with NFS service.

First create a virtual network interface, this interface is use as a bridge to our target as a logical subnet.

ifconfig eth0:1 192.168.114.254 netmask 255.255.255.0 up

then, configure the interface routing and enable IP Forward function below.

iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface eth0 -j ACCEPT
echo "1">/proc/sys/net/ipv4/ip_forward


next, in the target bootloader environment, change serverip and gateway reference to eth0:1 IP address (eg. as above 192.168.114.254) and update the bootargs.

That's it, reboot target and it should be able to access to the internet.

2010年3月4日 星期四

Build initrd Image

Build initrd Image on Mini2440

Startup Requirement

You need to build a root filesystem.

This build will create an initial RAM disk as a permanent root filesystem in NAND.

On kernel startup, the bootloader pass the load address of initrd image to the kernel to uncompress and copy the contents of the image into RAM, then frees the memory used and mount it as the initial root file system.

In addition jffs2 and cramfs is can also be used to write to the root filesystem.



System Configuration

For the kernel to support the initial RAM disk, the kernel must be compiled with this.

Change the kernel configuration setting below.

ARCH=arm make menuconfig

Go to 'Device Drivers' --> 'Block devices' --> Select RAM disk support

<*> RAM block device support
(16) Default number of RAM disks
(8192) Default RAM disk size (kbytes)


Go to 'Device Drivers' --> 'Memory Technology Devices (MTD) support' --> Select MTD partitioning support, Command line partition table parsing, Direct char and Cahching block device

<*> MTD concatenating support
[*] MTD partitioning support
< > RedBoot partition table parsing
[*] Command line partition table parsing
< > ARM Firmware Suite partition parsing
< > TI AR7 partitioning support
*** User Modules And Translation Layers ***
<*> Direct char device access to MTD devices
-*- Common interface to block layer for MTD 'translation layers
<*> Caching block device access to MTD devices


Go to 'File systems' --> Select Extended fs support

<*> Second extended fs support
[*] Ext2 extended attributes
[*] Ext2 POSIX Access Control Lists
[*] Ext2 Security Labels
[ ] Ext2 execute in place support


Go to 'File systems' --> 'Miscellaneous filesystems' --> Select Journalling Flash File system and Compressed ROM file system support

<*> Journalling Flash File System v2 (JFFS2) support
(0) JFFS2 debugging verbosity (0 = quiet, 2 = noisy)
[*] JFFS2 write-buffering support
[ ] Verify JFFS2 write-buffer reads
<*> Compressed ROM file system support (cramfs)





Create initrd Image

First, check the size of the root file system.

du -sh /rootfs

4.0K /rootfs/var
4.0K /rootfs/mnt
4.0K /rootfs/sys
624K /rootfs/bin
4.0K /rootfs/usr/bin
4.0K /rootfs/usr/sbin
12K /rootfs/usr
4.0K /rootfs/proc
3.9M /rootfs/lib
4.0K /rootfs/sbin
4.0K /rootfs/dev
8.0K /rootfs/etc/init.d
36K /rootfs/etc
4.0K /rootfs/tmp
4.6M /rootfs

prepare a temporary storage for the RAM disk.

cd /var/lib/tftpboot
dd if=/dev/zero of=/var/lib/tftpboot/initrd.tmp bs=1k count=8192


Note, the above created a 8 megabytes empty storage which is more than sufficient to save the image.

Create a ext2 filesystem format.

mkfs.ext2 initrd.tmp 8192

mke2fs 1.41.9 (22-Aug-2009)
initrd.tmp is not a block special device.
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
2048 inodes, 8192 blocks
409 blocks (4.99%) reserved for the super user
First data block=1
Maximum filesystem blocks=8388608
1 block group
8192 blocks per group, 8192 fragments per group
2048 inodes per group

Writing inode tables: done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

Mount the filesystem to a directory.

mkdir /mnt/initrd
mount -o loop initrd.tmp /mnt/initrd


Copy the root filesystem into the directory and change the contents to 'root' ownership.

cp -a /rootfs/* /mnt/initrd
chown -R root.root /mnt/initrd


Dismount the filesystem.


umount /mnt/initrd


Compress the filesystem.


gzip -c -9 initrd.tmp>initrd.gz
ls -l initrd.*


-rw-r--r-- 1 root root 2164377 2010-03-05 16:06 initrd.gz
-rw-r--r-- 1 root root 8388608 2010-03-05 15:47 initrd.tmp


Note, the final RAM disk is only one quarter of the original file size.



Refresh the initrd Image

Power on the board into the bootloader command prompt.

Verify the table information, we need the size and offset of the root partition.

MINI2440 # mtdparts

device nand0 , # parts = 4             
#: name size offset mask_flags
0: u-boot 0x00040000 0x00000000 0
1: env 0x00020000 0x00040000 0
2: kernel 0x00500000 0x00060000 0
3: root 0x07aa0000 0x00560000 0

active partition: nand0,0 - (u-boot) 0x00040000 @ 0x00000000

defaults:
mtdids : nand0=mini2440-nand
mtdparts:

The output shows that root is at the last block and start at 0x00560000 offset address with size of 7aa0000 (about 122 megabytes).

Clean up the root partition.

MINI2440 # nand erase 560000 7aa0000

NAND erase: device 0 offset 0x560000, size 0x7aa0000            
Skipping bad block at 0x06b40000
Skipping bad block at 0x07f80000
Skipping bad block at 0x07fa0000
Skipping bad block at 0x07fc0000
Skipping bad block at 0x07fe0000

OK

Download image into the specify location, make sure you have start up the tftp server.


MINI2440 # tftp 32000000 initrd.gz

dm9000 i/o: 0x20000300, id: 0x90000a46                          
DM9000: running in 16 bit mode
MAC: 08:00:2f:00:00:02
TFTP from server 192.168.114.181; our IP address is 192.168.114.190
Filename 'initrd.gz'.
Load address: 0x32000000
Loading: T T T #################################################################
#################################################################
##################
done
Bytes transferred = 2164377 (210699 hex)

Write image to the root partition, if there is a write problem you may have to refresh the NAND from scratch.

MINI2440 # nand write.e 32000000 560000 ${filesize}

NAND write: device 0 offset 0x560000, size 0x210699             

Writing data at 0x770000 -- 100% complete.
2164377 bytes written: OK

Save the file size, it is use later to setup the boot argument.

MINI2440 # setenv initrd_size $(filesize)
MINI2440 # saveenv


Saving Environment to NAND...                                   
Erasing Nand...Writing to Nand... done


Finally, Set the boot argument to load from the initrd and save all the settings.

MINI2440 # setenv 'bootcmd nand read 32000000 60000 200000;nand read 30800000 560000 ${initrd_size};bootm'
MINI2440 # setenv bootargs initrd=0x30800000,0x${initrd_size} init=/linuxrc root=/dev/ram0 rw console=ttySAC0 mini2440=0tb
MINI2440 # saveenv


Reboot the device to run the new update version.

MINI2440 # reset

U-Boot 1.3.2-mini2440 (Feb 26 2010 - 17:34:45)                            

I2C: ready
DRAM: 64 MB
Flash: 2 MB
NAND: Bad block table not found for chip 0
Bad block table not found for chip 0
128 MiB
Found Environment offset in OOB..
USB: S3C2410 USB Deviced
In: serial
Out: serial
Err: serial
MAC: 08:00:2f:00:00:02
Hit any key to stop autoboot: 0

NAND read: device 0 offset 0x60000, size 0x200000
2097152 bytes read: OK

NAND read: device 0 offset 0x560000, size 0x2106d4
2164436 bytes read: OK
## Booting kernel from Legacy Image at 32000000 ...
Image Name:
Created: 2010-03-02 14:51:28 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2053096 Bytes = 2 MB
Load Address: 30008000
Entry Point: 30008000
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK

Starting kernel ...

Uncompressing Linux.............................................................
Linux version 2.6.32.7 (root@gmax.localdomain) (gcc version 4.4.1 (Sourcery G++0
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: MINI2440
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, (c) 2004 Simtec Electronics
S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: initrd=0x30800000,0x2106D4 init=/linuxrc root=/dev/ram0 rwb
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 58468KB available (3620K code, 420K data, 128K init, 0K highmem)
SLUB: Genslabs=11, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Hierarchical RCU implementation.
NR_IRQS:85
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttySAC0] enabled
Calibrating delay loop... 201.93 BogoMIPS (lpj=504832)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
MINI2440: Option string mini2440=0tb
MINI2440: LCD [0:240x320] 1:800x480 2:1024x768 3:240x320 4:640x480
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, (c) 2003-2004,2006 Simtec Electronics
DMA channel 0 at c4808000, irq 33
DMA channel 1 at c4808040, irq 34
DMA channel 2 at c4808080, irq 35
DMA channel 3 at c48080c0, irq 36
S3C244X: Clock Support, DVS off
S3C24XX CPU Frequency driver, s3c244x cpu support
bio: create slab at 0
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c: slave address 0x10
s3c-i2c s3c2440-i2c: bus frequency set to 98 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
Trying to unpack rootfs image as initramfs...
rootfs image is not initramfs (no cpio magic); looks like an initrd
Freeing initrd memory: 2112K
squashfs: version 4.0 (2009/01/31) Phillip Lougher
JFFS2 version 2.2. (NAND) �© 2001-2006 Red Hat, Inc.
msgmni has been set to 118
alg: No test for stdrng (krng)
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
Console: switching to colour frame buffer device 60x53
fb0: s3c2410fb frame buffer device
s3c2440-uart.0: ttySAC0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: ttySAC1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: ttySAC2 at MMIO 0x50008000 (irq = 76) is a S3C2440
brd: module loaded
at24 0-0050: 1024 byte 24c08 EEPROM (writable)
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=1, 9ns Twrph0=3 29ns, Twrph1=2 19ns
s3c24xx-nand s3c2440-nand: NAND soft ECC
NAND device: Manufacturer ID: 0xec, Chip ID: 0xf1 (Samsung NAND 128MiB 3,3V 8-b)
Creating 4 MTD partitions on "NAND 128MiB 3,3V 8-bit":
0x000000000000-0x000000040000 : "u-boot"
0x000000040000-0x000000060000 : "u-boot-env"
0x000000060000-0x000000560000 : "kernel"
0x000000560000-0x000008000000 : "root"
dm9000 Ethernet Driver, V1.31
eth0: dm9000e at c486e300,c4872304 IRQ 51 MAC: 08:00:2f:00:00:02 (chip)
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
usbcore: registered new interface driver libusual
mice: PS/2 mouse device common for all mice
input: gpio-keys as /devices/platform/gpio-keys/input/input0
s3c2440-ts s3c2440-ts: Starting
Created group ts filter len 12 depth 2 close 10 thresh 6
Created Median ts filter len 20 depth 2 dec 24
Created Mean ts filter len 4 depth 2 thresh 65535
Created Linear ts filter depth 2
s3c2440-ts s3c2440-ts: 4 filter(s) initialized
s3c2440-ts s3c2440-ts: successfully loaded
input: s3c2410 TouchScreen as /devices/virtual/input/input1
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c2410-rtc s3c2410-rtc: rtc disabled, re-enabling
s3c2410-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
i2c /dev entries driver
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
cpuidle: using governor ladder
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
s3c-sdi s3c2440-sdi: powered down.
s3c-sdi s3c2440-sdi: mmc0 - using pio, sw SDIO IRQ
Registered led device: led1
Registered led device: led2
Registered led device: led3
Registered led device: led4
Registered led device: backlight
usbcore: registered new interface driver hiddev
usbcore: registered new interface driver usbhid
usbhid: v2.6:USB HID core driver
Advanced Linux Sound Architecture Driver Version 1.0.21.
No device for DAI UDA134X
No device for DAI s3c24xx-i2s
S3C24XX_UDA134X SoC Audio driver
UDA134X SoC Audio Codec
asoc: UDA134X <-> s3c24xx-i2s mapping ok
ALSA device list:
#0: S3C24XX_UDA134X (UDA134X)
TCP cubic registered
NET: Registered protocol family 17
s3c2410-rtc s3c2410-rtc: setting system clock to 2008-12-29 06:17:58 UTC (12305)
RAMDISK: gzip image found at block 0
VFS: Mounted root (ext2 filesystem) on device 1:0.

Freeing init memory: 128K

Please press Enter to activate this console.
[root@(none) /]#



Create JFFS2 and CRAMFS Image

Alternately, JFFS2 can be used to create a root filesystem.

mkfs.jffs2 -r /rootfs -o rootfs.jffs2 -e 0x20000 -n

Or in CRAMFS format.

mkcramfs /rootfs rootfs.cramfs


Reboot the device into bootloader command prompt.

Download image into the specify location.

MINI2440 # tftp 32000000 rootfs.jffs2


Clean up the root partition.

MINI2440 # nand erase root


Write image to the root partition.

MINI2440 # nand write.e 32000000 root ${filesize}


Set the boot argument to load from the initrd and save all the settings.

MINI2440 # setenv bootcmd 'nboot.e kernel;bootm'
MINI2440 # setenv bootargs noinitrd init=/linuxrc root=/dev/mtdblock3
rootfstype=jffs2 console=ttySAC0 mini2440=0tb
MINI2440 # saveenv


Reboot the device to run the new update version.

MINI2440 # reset

U-Boot 1.3.2-mini2440 (Feb 26 2010 - 17:34:45)                              

I2C: ready
DRAM: 64 MB
Flash: 2 MB
NAND: Bad block table not found for chip 0
Bad block table not found for chip 0
128 MiB
Found Environment offset in OOB..
USB: S3C2410 USB Deviced
In: serial
Out: serial
Err: serial
MAC: 08:00:2f:00:00:02
Hit any key to stop autoboot: 0

Loading from NAND 128MiB 3,3V 8-bit, offset 0x60000
Image Name:
Created: 2010-03-02 14:51:28 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2053096 Bytes = 2 MB
Load Address: 30008000
Entry Point: 30008000
## Booting kernel from Legacy Image at 32000000 ...
Image Name:
Created: 2010-03-02 14:51:28 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2053096 Bytes = 2 MB
Load Address: 30008000
Entry Point: 30008000
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK

Starting kernel ...

Uncompressing Linux.............................................................
Linux version 2.6.32.7 (root@gmax.localdomain) (gcc version 4.4.1 (Sourcery G++0
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: MINI2440
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, (c) 2004 Simtec Electronics
S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: noinitrd init=/linuxrc root=/dev/mtdblock3 console=ttySAC02
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 60584KB available (3620K code, 420K data, 128K init, 0K highmem)
SLUB: Genslabs=11, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Hierarchical RCU implementation.
NR_IRQS:85
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttySAC0] enabled
Calibrating delay loop... 201.93 BogoMIPS (lpj=504832)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
MINI2440: Option string mini2440=0tb
MINI2440: LCD [0:240x320] 1:800x480 2:1024x768 3:240x320 4:640x480
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, (c) 2003-2004,2006 Simtec Electronics
DMA channel 0 at c4808000, irq 33
DMA channel 1 at c4808040, irq 34
DMA channel 2 at c4808080, irq 35
DMA channel 3 at c48080c0, irq 36
S3C244X: Clock Support, DVS off
S3C24XX CPU Frequency driver, s3c244x cpu support
bio: create slab at 0
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c: slave address 0x10
s3c-i2c s3c2440-i2c: bus frequency set to 98 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
squashfs: version 4.0 (2009/01/31) Phillip Lougher
JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
msgmni has been set to 118
alg: No test for stdrng (krng)
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
Console: switching to colour frame buffer device 60x53
fb0: s3c2410fb frame buffer device
s3c2440-uart.0: ttySAC0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: ttySAC1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: ttySAC2 at MMIO 0x50008000 (irq = 76) is a S3C2440
brd: module loaded
at24 0-0050: 1024 byte 24c08 EEPROM (writable)
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=1, 9ns Twrph0=3 29ns, Twrph1=2 19ns
s3c24xx-nand s3c2440-nand: NAND soft ECC
NAND device: Manufacturer ID: 0xec, Chip ID: 0xf1 (Samsung NAND 128MiB 3,3V 8-b)
Creating 4 MTD partitions on "NAND 128MiB 3,3V 8-bit":
0x000000000000-0x000000040000 : "u-boot"
0x000000040000-0x000000060000 : "u-boot-env"
0x000000060000-0x000000560000 : "kernel"
0x000000560000-0x000008000000 : "root"
dm9000 Ethernet Driver, V1.31
eth0: dm9000e at c486e300,c4872304 IRQ 51 MAC: 08:00:2f:00:00:02 (chip)
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
usbcore: registered new interface driver libusual
mice: PS/2 mouse device common for all mice
input: gpio-keys as /devices/platform/gpio-keys/input/input0
s3c2440-ts s3c2440-ts: Starting
Created group ts filter len 12 depth 2 close 10 thresh 6
Created Median ts filter len 20 depth 2 dec 24
Created Mean ts filter len 4 depth 2 thresh 65535
Created Linear ts filter depth 2
s3c2440-ts s3c2440-ts: 4 filter(s) initialized
s3c2440-ts s3c2440-ts: successfully loaded
input: s3c2410 TouchScreen as /devices/virtual/input/input1
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c2410-rtc s3c2410-rtc: rtc disabled, re-enabling
s3c2410-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
i2c /dev entries driver
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
cpuidle: using governor ladder
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
s3c-sdi s3c2440-sdi: powered down.
s3c-sdi s3c2440-sdi: mmc0 - using pio, sw SDIO IRQ
Registered led device: led1
Registered led device: led2
Registered led device: led3
Registered led device: led4
Registered led device: backlight
usbcore: registered new interface driver hiddev
usbcore: registered new interface driver usbhid
usbhid: v2.6:USB HID core driver
Advanced Linux Sound Architecture Driver Version 1.0.21.
No device for DAI UDA134X
No device for DAI s3c24xx-i2s
S3C24XX_UDA134X SoC Audio driver
UDA134X SoC Audio Codec
asoc: UDA134X <-> s3c24xx-i2s mapping ok
ALSA device list:
#0: S3C24XX_UDA134X (UDA134X)
TCP cubic registered
NET: Registered protocol family 17
s3c2410-rtc s3c2410-rtc: setting system clock to 2008-12-29 07:08:31 UTC (12305)
VFS: Mounted root (jffs2 filesystem) on device 31:3.
Freeing init memory: 128K

Please press Enter to activate this console.
[root@(none) /]#

2010年3月3日 星期三

Build Root File System

Build Root File System on Mini2440

Startup Requirement

You need to have a compiled busybox and the kernel configure with Virtual File memory, NFS client support and the kernel level autoconfiguration function.

This build will create a new Root File System using the NFS service in the host computer to expose the contents to the target system, there is other method which is build a initrd image and booting with an initial RAM disk.

This is by no means a full system setup but a simple process to boot up a Linux system on Mini2440 as a start, alternatively there are tools that will automate the cross compiling process to generate the filesystem and software packages easily - such as Buildroot, OpenEmbedded and etc. which is another stages of learning process.



Filesystem Hierarchy Standard

In order to build a Root File System i will follow the FHS rules to define the main directories and their layout content as below.
rootfs (/)
|--bin
|--dev
|--etc
| |--init.d
|--lib
|--mnt
|--proc
|--sys
|--sbin
|--tmp
|--usr
| |--bin
| |--sbin
|--var

This RFS is mount as a root directory (/).

Note, there are two components to run a Linux system: the kernel and the RFS.

In this example, busybox is use as a base to construct the minimum set of files to support the system.



Create Root Filesystem Strcuture

First, create a new root directory for our RFS, this directory is export as a NFS shared directory.

mkdir /rootfs

Copy the busybox system files into the root directory.

cd /rootfs
cp -a /usr/src/toolchain/busybox-1.16.0/_install/* .


Create the remaining FHS directories as require.

mkdir dev
mkdir -p etc/init.d
mkdir lib
mkdir mnt
mkdir proc
mkdir sys
mkdir -m 777 tmp
mkdir var


Copy the runtime libraries from the compiler system.

cd /rootfs/lib
cp -a /usr/local/arm/4.4.1/arm-none-linux-gnueabi/libc/armv4t/lib/* .


Make a serial console device as our system standard output.

cd /rootfs/dev
mknod -m 622 console c 5 1


When the kernel is running the last initialization action is to start the init program in charge of finalizing system startup by spawning various applications and running some key software components.

The operation of the init program is define in the inittab file, busybox init has the following default behaviour.

::sysinit:/etc/init.d/rcS
::askfirst:-/bin/sh
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
::shutdown:/sbin/swapoff -a
::restart:/sbin/init

Add a getty on the serial console to the above inittab, depending on the environment variable set in the bootargs (eg. console=ttySAC0) the same device to be set similarly.

::respawn:/sbin/getty -L 115200 /dev/ttySAC0 vt100


Create a rcS job file in the /rootfs/etc/init.d directory to initialize the target system.

#! /bin/sh

# Setup the bin file location and export to system PATH
PATH=/sbin:/bin:/usr/sbin:/usr/bin
umask 022
export PATH

# mount the filesystem directories
mount -a
mkdir /dev/pts
mount -t devpts devpts /dev/pts -o mode=0622

# create device nodes and directories
echo /sbin/mdev>/proc/sys/kernel/hotplug
mdev -s
mkdir /var/lock

# start logging utility services
klogd
syslogd

# set system clock from RTC
hwclock -s

# set host and config loopback interface
ifconfig lo 127.0.0.1

Create a mdev.conf file in the /rootfs/etc directory for the mdev process to do an initial update of the device files dynamically.

# system all-writable devices
full 0:0 0666
null 0:0 0666
ptmx 0:0 0666
random 0:0 0666
tty 0:0 0666
zero 0:0 0666

# console devices
tty[0-9]* 0:5 0660
vc/[0-9]* 0:5 0660

# serial port devices
s3c2410_serial0 0:5 0666 =ttySAC0
s3c2410_serial1 0:5 0666 =ttySAC1
s3c2410_serial2 0:5 0666 =ttySAC2
s3c2410_serial3 0:5 0666 =ttySAC3

# loop devices
loop[0-9]* 0:0 0660 =loop/

# i2c devices
i2c-0 0:0 0666 =i2c/0
i2c-1 0:0 0666 =i2c/1

# frame buffer devices
fb[0-9] 0:0 0666

# input devices
mice 0:0 0660 =input/
mouse.* 0:0 0660 =input/
event.* 0:0 0660 =input/
ts.* 0:0 0660 =input/

# rtc devices
rtc0 0:0 0644 >rtc
rtc[1-9] 0:0 0644

# misc devices
mmcblk0p1 0:0 0600 =sdcard */bin/hotplug
sda1 0:0 0600 =udisk * /bin/hotplug

Create a fstab filesystem table in the /rootfs/etc directory to mount the system directories.
# device mount-point type options dump fsck order
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
tmpfs /dev tmpfs defaults 0 0
tmpfs /tmp tmpfs defaults 0 0
var /var tmpfs defaults 0 0

Create a group file in /rootfs/etc directory.

grep root /etc/group>group

Create a password file in /rootfs/etc directory.

grep root /etc/passwd>passwd

Create a system wide 'profile' in /rootfs/etc directory.

USER="`id -un`"                                                 
LOGNAME=$USER
PS1='[\u@\h \W]\# '
PATH=$PATH
HOSTNAME=`/bin/hostname`
export USER LOGNAME PS1 PATH HOSTNAME

Create a /rootfs/etc/issue to add a welcome prompt to the console login.

Welcome to Mini2440
Kernel \r on an \m (\l)



Finally, create a resolv.conf file in /rootfs/etc directory to configure the DNS address to access the internet with your service provider network domain and ip address.

search internet.com.tw
nameserver 192.168.55.244
nameserver 168.95.1.1



Start up the NFS Server

Edit /etc/exports to configure the RFS as a shared directory.

/rootfs *(rw,sync,no_root_squash)

Start up the server.

service nfs restart

Verify the NFS server is running.

showmount -e 192.168.114.181

Export list for 192.168.114.181:
/rootfs *

Reboot the device to run the system.

Restarting system�

U-Boot 1.3.2-mini2440 (Feb 26 2010 - 17:34:45)

I2C: ready
DRAM: 64 MB
Flash: 2 MB
NAND: 128 MiB
Found Environment offset in OOB..
USB: S3C2410 USB Deviced
In: serial
Out: serial
Err: serial
MAC: 08:00:2f:00:00:02
Hit any key to stop autoboot: 0

Loading from NAND 128MiB 3,3V 8-bit, offset 0x60000
Image Name:
Created: 2010-03-02 14:51:28 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2053096 Bytes = 2 MB
Load Address: 30008000
Entry Point: 30008000
## Booting kernel from Legacy Image at 32000000 ...
Image Name:
Created: 2010-03-02 14:51:28 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2053096 Bytes = 2 MB
Load Address: 30008000
Entry Point: 30008000
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK

Starting kernel ...

Uncompressing Linux.............................................................
Linux version 2.6.32.7 (root@gmax.localdomain) (gcc version 4.4.1 (Sourcery G++0
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: MINI2440
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, (c) 2004 Simtec Electronics
S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: console=ttySAC0 noinitrd init=/sbin/init mini2440=0tb rootf
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 60664KB available (3572K code, 388K data, 128K init, 0K highmem)
SLUB: Genslabs=11, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Hierarchical RCU implementation.
NR_IRQS:85
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttySAC0] enabled
Calibrating delay loop... 201.93 BogoMIPS (lpj=504832)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
MINI2440: Option string mini2440=0tb
MINI2440: LCD [0:240x320] 1:800x480 2:1024x768 3:240x320 4:640x480
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, (c) 2003-2004,2006 Simtec Electronics
DMA channel 0 at c4808000, irq 33
DMA channel 1 at c4808040, irq 34
DMA channel 2 at c4808080, irq 35
DMA channel 3 at c48080c0, irq 36
S3C244X: Clock Support, DVS off
S3C24XX CPU Frequency driver, s3c244x cpu support
bio: create slab at 0
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c: slave address 0x10
s3c-i2c s3c2440-i2c: bus frequency set to 98 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
squashfs: version 4.0 (2009/01/31) Phillip Lougher
JFFS2 version 2.2. (NAND) �© 2001-2006 Red Hat, Inc.
msgmni has been set to 118
alg: No test for stdrng (krng)
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
Console: switching to colour frame buffer device 60x53
fb0: s3c2410fb frame buffer device
s3c2440-uart.0: ttySAC0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: ttySAC1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: ttySAC2 at MMIO 0x50008000 (irq = 76) is a S3C2440
brd: module loaded
at24 0-0050: 1024 byte 24c08 EEPROM (writable)
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=1, 9ns Twrph0=3 29ns, Twrph1=2 19ns
s3c24xx-nand s3c2440-nand: NAND soft ECC
NAND device: Manufacturer ID: 0xec, Chip ID: 0xf1 (Samsung NAND 128MiB 3,3V 8-b)
Creating 4 MTD partitions on "NAND 128MiB 3,3V 8-bit":
0x000000000000-0x000000040000 : "u-boot"
0x000000040000-0x000000060000 : "u-boot-env"
0x000000060000-0x000000560000 : "kernel"
0x000000560000-0x000008000000 : "root"
dm9000 Ethernet Driver, V1.31
eth0: dm9000e at c4860300,c4864304 IRQ 51 MAC: 08:00:2f:00:00:02 (chip)
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
usbcore: registered new interface driver libusual
mice: PS/2 mouse device common for all mice
input: gpio-keys as /devices/platform/gpio-keys/input/input0
s3c2440-ts s3c2440-ts: Starting
Created group ts filter len 12 depth 2 close 10 thresh 6
Created Median ts filter len 20 depth 2 dec 24
Created Mean ts filter len 4 depth 2 thresh 65535
Created Linear ts filter depth 2
s3c2440-ts s3c2440-ts: 4 filter(s) initialized
s3c2440-ts s3c2440-ts: successfully loaded
input: s3c2410 TouchScreen as /devices/virtual/input/input1
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c2410-rtc s3c2410-rtc: rtc disabled, re-enabling
s3c2410-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
i2c /dev entries driver
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
cpuidle: using governor ladder
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
s3c-sdi s3c2440-sdi: powered down.
s3c-sdi s3c2440-sdi: mmc0 - using pio, sw SDIO IRQ
Registered led device: led1
Registered led device: led2
Registered led device: led3
Registered led device: led4
Registered led device: backlight
usbcore: registered new interface driver hiddev
usbcore: registered new interface driver usbhid
usbhid: v2.6:USB HID core driver
Advanced Linux Sound Architecture Driver Version 1.0.21.
No device for DAI UDA134X
No device for DAI s3c24xx-i2s
S3C24XX_UDA134X SoC Audio driver
UDA134X SoC Audio Codec
asoc: UDA134X <-> s3c24xx-i2s mapping ok
ALSA device list:
#0: S3C24XX_UDA134X (UDA134X)
TCP cubic registered
NET: Registered protocol family 17
s3c2410-rtc s3c2410-rtc: setting system clock to 2008-12-27 10:22:30 UTC (12303)
eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
IP-Config: Complete:
device=eth0, addr=192.168.114.190, mask=255.255.255.0, gw=192.168.114.1,
host=mini2440, domain=, nis-domain=(none),
bootserver=255.255.255.255, rootserver=192.168.114.181, rootpath=
Looking up port of RPC 100003/2 on 192.168.114.181
Looking up port of RPC 100005/1 on 192.168.114.181
VFS: Mounted root (nfs filesystem) on device 0:13.
Freeing init memory: 128K

Please press Enter to activate this console.
[root@mini2440 /]#


2010年3月2日 星期二

Update Kernel Image

Update Kenel Image on Mini2440

Startup Requirement

You need to have a working installed bootloader in the target system, set the switch to NAND BOOT and reset the board into the command prompt.

This update will override the old kernel image.

This also assume that you have a compiled kernel in a directory called tftpboot and managed to configure the host computer as a tftp server.


Refresh Kernel

First check the size of the uImage file.

ls -l /var/lib/tftpboot/uImage
-rw-r--r-- 1 root root 2053160 2010-03-02 22:51 uImage

Verify the table information, we need the size and offset of the kernel partition.

MINI2440 # mtdparts

device nand0 , # parts = 4                            
#: name size offset mask_flags
0: u-boot 0x00040000 0x00000000 0
1: env 0x00020000 0x00040000 0
2: kernel 0x00500000 0x00060000 0
3: root 0x07aa0000 0x00560000 0

active partition: nand0,0 - (u-boot) 0x00040000 @ 0x00000000

defaults:
mtdids : nand0=mini2440-nand
mtdparts:

The output shows that kernel is at the third block and start at 0x00060000 offset address with size of 500000.

Clean up the kernel partition.

MINI2440 # nand erase 60000 500000

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

Download image into the specify location, make sure you have start up the tftp server.

MINI2440 # tftp 32000000 uImage

dm9000 i/o: 0x20000300, id: 0x90000a46                               
DM9000: running in 16 bit mode
MAC: 08:00:2f:00:00:02
TFTP from server 192.168.114.181; our IP address is 192.168.114.190
Filename 'uImage'.
Load address: 0x3200000
Loading: T T #################################################################
#################################################################
##########
done
Bytes transferred = 2053160 (1f5428 hex)
Write image to the kernel partition, if there is a write problem you may have to refresh the NAND from scratch.

MINI2440 # nand write.e 32000000 60000 ${filesize}

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

Writing data at 0x255000 -- 100% complete.
2053160 bytes written: OK

Verify the number of bytes written is correct (2053160 in this example).

At last, set the boot command to load from the kernel block and save all the settings.

MINI2440 # setenv bootcmd 'nboot.e kernel;bootm'
MINI2440 # saveenv


Reboot the device to run the new update version.

MINI2440 # reset

You will see the bootloader starting up the kernel image and it will stop running at the system initialization stage because we have not yet build a root filesystem.

U-Boot 1.3.2-mini2440 (Feb 26 2010 - 17:34:45)                        

I2C: ready
DRAM: 64 MB
Flash: 2 MB
NAND: 128 MiB
Found Environment offset in OOB..
USB: S3C2410 USB Deviced
In: serial
Out: serial
Err: serial
MAC: 08:00:2f:00:00:02
Hit any key to stop autoboot: 0

Loading from NAND 128MiB 3,3V 8-bit, offset 0x60000
Image Name:
Created: 2010-03-02 14:51:28 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2053096 Bytes = 2 MB
Load Address: 30008000
Entry Point: 30008000
## Booting kernel from Legacy Image at 32000000 ...
Image Name:
Created: 2010-03-02 14:51:28 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2053096 Bytes = 2 MB
Load Address: 30008000
Entry Point: 30008000
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK

Starting kernel ...

Uncompressing Linux.............................................................
Linux version 2.6.32.7 (root@gmax.localdomain) (gcc version 4.4.1 (Sourcery G++0
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: MINI2440

2010年3月1日 星期一

Update U-boot Image

Update U-boot Image on Mini2440

Startup Requirement

You need a BIOS to bootstrap the target system (the supervivi bootloader is use in this example from the Mini2440 package), set the switch to NOR BOOT and reset the board.

This update will get rid of the QTopia demo applications completely because NAND is scrub.

This also assume you have a compiled u-boot already in a directory called tftpboot and managed to configure the host computer as a tftp server.


Setup Terminal Connection

The most common way to communicate with an embedded system is to use a terminal emulation on the host to communicate through an RS232 serial port with the target system.

There are two main terminal software picocom and minicom can be used, picocom is rather superior to minicom these days, due to the fact that setting is specify easily at the command line, no weird menus and modem initialise needed, but minicom is easier to setup, once configure it's ready to run.

Configure the minicom below when the board is plugged on the main serial port.

minicom -s
  1. Move the cursor bar to 'Serial port setup' and press 'ENTER'
  2. Press 'A' to enter COM port device (eg. '/dev/ttyS0' or '/dev/ttyUSB0')
  3. Press 'E' to change the communication parameters, press 'E' and 'Q' to select '115200 bps' and '8N1' respectively
  4. Press 'F' to set Hardware Flow Control to 'No'
  5. Press 'ENTER' to accept the setting
  6. Save setup as dfl
Type minicom to test the connection, if successful the output message is display below.
Welcome to minicom 2.3

Option: I18n
Compiled at Jul 26 2009, 22:02:36.
Port /dev/ttyS0

Instead, use picocom to connect it directly.

picocom -b 115200 /dev/ttyS0 --send-cmd "sx -vv"
picocom v1.4

port is : /dev/ttyS0
flowcontrol : none
baudrate is : 115200
parity is : none
databits are : 8
escape is : C-a
noinit is : no
noreset is : no
nolock is : no
send_cmd is : sx -vv
receive_cmd is : rz -vv

Terminal ready

When the port is connected, reboot the device, the BIOS in the target system will start up the supervivi main menu program, quit from the menu will take us to the command line mode below.
##### FriendlyARM BIOS 2.0 for 2440 #####
[x] format NAND FLASH for Linux
[v] Download vivi
[k] Download linux kernel
[y] Download root_yaffs image
[a] Absolute User Application
[n] Download Nboot for WinCE
[l] Download WinCE boot-logo
[w] Download WinCE NK.bin
[d] Download & Run
[z] Download zImage into RAM
[g] Boot linux from RAM
[f] Format the nand flash
[b] Boot the system
[s] Set the boot parameters
[u] Backup NAND Flash to HOST through USB(upload)
[r] Restore NAND Flash from HOST through USB
[q] Goto shell of vivi
Enter your selection: q
Supervivi>

When in the prompt screen, proceed to download u-boot image into the ram.



Load U-boot into RAM

This will download the image into the memory via a COM port from picocom.

First check the size of the u-boot.bin file.

ls -l /var/lib/tftpboot/u-boot.bin
-rwxr-xr-x 1 root root 232316 2010-02-28 16:41 /var/lib/tftpboot/u-boot.bin
Set a longer timeout for the download connection.

Supervivi> param set xmodem_timeout 100000000

Load the image with the specify address and number of bytes to transfer, when downloading type 'Control A' and 'Control S' to prompt for a filename then enter the u-boot.bin file require.

Supervivi> load ram 0x32000000 232316 x
Ready for downloading using xmodem...
Waiting...

*** file: /var/lib/tftpboot/u-boot.bin
sx -vv /var/lib/tftpboot/u-boot.bin
Sending /var/lib/tftpboot/u-boot.bin, 1814 blocks: Give your local XMODEM receive command now.
Bytes Sent: 232320 BPS:9808

Transfer complete

*** exit status: 0


The same can be done with minicom, the USB is use to transfer the file image below.

Supervivi> load ram 0x32000000 232316 u

On the other screen, start the download with the s3c2410_boot_usb program.

Run U-boot from RAM

Once the u-boot image is downloaded, specify the address to run in the memory location.

go 0x32000000
go to 0x32000000
argument 0 = 0x00000000
argument 1 = 0x00000000
argument 2 = 0x00000000
argument 3 = 0x00000000

U-Boot 1.3.2-mini2440 (Feb 26 2010 - 17:34:45)

I2C: ready
DRAM: 64 MB
Flash: 2 MB
NAND: 128 MiB
Found Environment offset in OOB..
USB: S3C2410 USB Deviced
In: serial
Out: serial
Err: serial

when uboot run successfully, proceed to srub the nand section.


Flashing U-boot

The supervivi bootloader is use to download the image and requires that the board is connect to the host via a USB port, set the switch to NOR BOOT and reboot the device, the main menu will show up on the serial console, press 'q' to go to the prompt shell.

Load the image with the number of bytes to transfer (232316 bytes in this example), a pending message is display waiting for the download program to begin.

Supervivi> load flash 0 232316 u

On the other screen, start up the USB download program.

s3c2410_boot_usb u-boot.bin

When download program is running, an output message is display below - just ignore the last error.
csum = 0xb97e
send_file: addr = 0x33f80000, len = 0x00038b7c
Error downloading program

When download is finish, the serial console output message is display below.
USB host is connected. Waiting a download.
Now, Downloading [ADDRESS:30000000h,TOTAL:232326]
RECEIVED FILE SIZE: 232326 (32KB/S, 7S)
Downloaded file at 0x30000000, size = 232316 bytes
Found block size = 0x00040000
Erasing... ... done
Writing... ... done
Written 232316 bytes

Set the switch to NAND BOOT and reboot the device to run the new update version.


Check Factory Bad Blocks

The NAND usually comes with some bad blocks, we can check the NAND information and verify those 'already bad' blocks.

MINI2440 # nand info
Device 0: NAND 128MiB 3,3V 8-bit, page size 2048, sector size 128 KiB

MINI2440 # nand bad
Device 0 bad blocks:                       
06b40000
07f80000
07fa0000
07fc0000
07fe0000


Scrub the NAND

When there are bad blocks in NAND, u-boot will complaints about it so it is better to clean the NAND completely to detect any new bad blocks and create an up-to-date table.

Note, do not reset the board until the u-boot is reinstalled, or you need to use supervivi to reinstall u-boot via a USB port.

MINI2440 # nand scrub
NAND scrub: device 0 whole chip              
Warning: scrub option will erase all factory set bad blocks!
There is no reliable way to recover them.
Use this command only for testing purposes if you
are sure of what you are doing!

Really scrub this NAND flash? y
Erasing at 0x6a20000 -- 83% complete.
NAND 128MiB 3,3V 8-bit: MTD Erase failure: -5
Erasing at 0x7fe0000 -- 100% complete.
Bad block table not found for chip 0
Bad block table not found for chip 0
OK

MINI2440 # nand bad
Device 0 bad blocks:                         
06b40000
07f80000
07fa0000
07fc0000
07fe0000

Format is done, there are no additional bad blocks found.

Create a bad block table, it will write a record to the last blocks of the flash so that the kernel can find it.

MINI2440 # nand createbbt
Create BBT and erase everything ?  y
Skipping bad block at 0x06b40000
Skipping bad block at 0x07f80000
Skipping bad block at 0x07fa0000
Skipping bad block at 0x07fc0000
Skipping bad block at 0x07fe0000

Creating BBT. Please wait ...Bad block table not found for chip 0
Bad block table not found for chip 0
Bad block table written to 0x07fe0000, version 0x01
Bad block table written to 0x07fc0000, version 0x01


Default U-boot Partition

By default u-boot uses a default set of variables, lets check where is the location of a u-boot partition.

MINI2440 # mtdparts
device nand0 , # parts = 4     
#: name size offset mask_flags
0: u-boot 0x00040000 0x00000000 0
1: env 0x00020000 0x00040000 0
2: kernel 0x00500000 0x00060000 0
3: root 0x07aa0000 0x00560000 0

active partition: nand0,0 - (u-boot) 0x00040000 @ 0x00000000

defaults:
mtdids : nand0=mini2440-nand
mtdparts:

The above information indicates u-boot starts at 0x0 offset address with a size of 40000 and the environment at 0x00040000 with a size of 20000 written in the NAND.

U-boot comes the above 'dynamic' environment partition located in the NAND first block after the u-boot partition, it can be arranged by specifying the address of the location, u-boot will takes care of the "bad" environment block and relocate it somewhere further the chip.

Set the default location of an environment.

MINI2440 # dynenv set 40000
device 0 offset 0x40000, size 0x7fc0000       
45 4e 56 30 - 00 00 04 00

Save the environment variables to the specify location.

MINI2440 # saveenv
Saving Environment to NAND...                 
Erasing Nand...Writing to Nand... done


Configure Network Address

The board does not have a valid MAC address in the EEPROM, it relies on the bootloader to create one and the IP address is also set as default.

Optionally, set the MAC address if you got one.

MINI2440 # set ethaddr 08:00:2f:00:00:02


Define the device network address.

MINI2440 # set ipaddr 192.168.114.190
MINI2440 # set serverip 192.168.114.181
MINI2440 # set gateway 192.168.114.1



Set the boot command as an argument pass to the kernel system.

MINI2440 # setenv bootargs console=ttySAC0 noinitrd init=/sbin/init mini2440=0tb root=/dev/nfs nfsroot=$(serverip):/rootfs ip=$(ipaddr)::$(gateway):$(netmask):mini2440:eth0:off
MINI2440 # saveenv


Note, the above nfsroot variable will boot up the kernel image with a root filesystem over the NFS.


Print out the variables to check all settings are correct.

MINI2440 # printenv
bootargs=root=/dev/mtdblock3 rootfstype=jffs2 console=ttySAC0,115200
bootcmd=
bootdelay=3
baudrate=115200
netmask=255.255.255.0
usbtty=cdc_acm
mtdparts=mtdparts=mini2440-nand:256k@0(u-boot),128k(env),5m(kernel),-(root)
mini2440=mini2440=0tb
bootargs_base=console=ttySAC0,115200 noinitrd
bootargs_init=init=/sbin/init
root_nand=root=/dev/mtdblock3 rootfstype=jffs2
root_mmc=root=/dev/mmcblk0p2 rootdelay=2
root_nfs=/mnt/nfs
set_root_nfs=setenv root_nfs root=/dev/nfs rw nfsroot=${serverip}:${root_nfs}
ifconfig_static=run setenv ifconfig ip=${ipaddr}:${serverip}::${netmask}:mini240
ifconfig_dhcp=run setenv ifconfig ip=dhcp
ifconfig=ip=dhcp
set_bootargs_mmc=setenv bootargs ${bootargs_base} ${bootargs_init} ${mini2440} }
set_bootargs_nand=setenv bootargs ${bootargs_base} ${bootargs_init} ${mini2440}}
set_bootargs_nfs=run set_root_nfs; setenv bootargs ${bootargs_base} ${bootargs_}
mtdids=nand0=mini2440-nand
partition=nand0,0
mtddevnum=0
mtddevname=u-boot
ethaddr=08:00:2f:00:00:02
ipaddr=192.168.114.190
serverip=192.168.114.181
gateway=192.168.114.1

Environment size: 1115/131068 bytes

Note: if you flashing a new bootloader do not reboot, continue to complete the following step.


Update U-boot Partition

After flashing the first u-boot, it can be used to upgrade to a new version by overriding the existing one, tftp is use to download the image into the memory map location and then write to the NAND.

First, start up the tftp server and make sure the setup IP address of the device is correct.

/etc/rc.d/init.d/xinetd start

Verify the tftp server is running.

netstat -anu

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
udp 0 0 0.0.0.0:69 0.0.0.0:*

Download image into the specify location.

MINI2440 # tftp 32000000 u-boot.bin
dm9000 i/o: 0x20000300, id: 0x90000a46           
DM9000: running in 16 bit mode
MAC: 08:00:2f:00:00:02
TFTP from server 192.168.114.181; our IP address is 192.168.114.190
Filename 'u-boot.bin'.
Load address: 0x32000000
Loading: T T T ################
done
Bytes transferred = 232316 (38b7c hex)

Clean up the u-boot partition.

MINI2440 # nand erase 0 40000

NAND erase: device 0 offset 0x0, size 0x40000    
Erasing at 0x20000 -- 100% complete.
OK

Write image to the u-boot partition

MINI2440 # nand write.e 32000000 0 ${filesize}
NAND write: device 0 offset 0x0, size 0x38b7c    

Writing data at 0x38800 -- 100% complete.
232316 bytes written: OK

At last, set the environment offset and save all the settings

MINI2440 # dynenv set env
MINI2440 # saveenv


Reboot the device to run the new update version.

MINI2440 # reset
U-Boot 1.3.2-mini2440 (Feb 26 2010 - 17:34:45)   

I2C: ready
DRAM: 64 MB
Flash: 2 MB
NAND: 128 MiB
Found Environment offset in OOB..
USB: S3C2410 USB Deviced
In: serial
Out: serial
Err: serial
MAC: 08:00:2f:00:00:02
Hit any key to stop autoboot: 0
MINI2440 #