Linux2.6.39 for Utu2440(3)

TurnToJPG -->


Building Filesystems

Use following script for building the basic filesystem:

$ cat mkrootfs 
#!/bin/sh
echo "------Create rootfs directons start...--------"
mkdir rootfs
cd rootfs
echo "--------Create root,dev....----------"
mkdir bin boot dev etc home lib mnt proc root sbin sys tmp usr var  www
mkdir etc/init.d etc/rc.d etc/sysconfig
mkdir usr/sbin usr/bin usr/lib usr/modules
echo "make node in dev/console dev/null"
mknod -m 666 dev/console c 5 1
mknod -m 666 dev/null c 1 3
mkdir mnt/etc mnt/jffs2 mnt/yaffs mnt/data mnt/temp
mkdir var/lib var/lock var/run var/tmp
chmod 1777 tmp
chmod 1777 var/tmp
echo "-------make direction done---------"

Run it and you will get an folder which contains the newly created directory structure.

$ sudo ./mkrootfs 
------Create rootfs directons start...--------
--------Create root,dev....----------
make node in dev/console dev/null
-------make direction done---------
$ ls rootfs 
bin  boot  dev  etc  home  lib  mnt  proc  root  sbin  sys  tmp  usr  var  www

After making the filesystem, you should install all of the kernel modules into your fs:

$ make modules_install ARCH=arm INSTALL_MOD_PATH=The_PATH_TO_YOUR_ROOTFS

BusyBox

Busybox provides almost all of the tools used in system, first we should download and cross-compile it.

$ wget http://www.busybox.net/downloads/busybox-1.22.1.tar.bz2
$ tar xjvf busybox-1.22.1.tar.bz2
$ cd busybox-1.22.1
$ vim Makefile
+ CROSS_COMPILE ?= arm-linux-
# bbox: we may have CONFIG_CROSS_COMPILER_PREFIX in .config,
$ make menuconfig

Parameters:

Build Options---> Build BusyBox as a static binary(no shared libs)
Installation Options--> Busybox installation prefix(See following pictures)
Linux Module Utilities-->  Default directory containing modules(/lib/modules)
Linux System Utilities --->
[*]Support /etc/mdev.conf
[*]Support command execution at device addition/removal
Init Utilities --->
"Support reading an inittab file"
"Support running commands with a controlling-tty"


/images/busyboxinstall.jpg
Then Make and make install:

$ make && make install

Now list the rootfs you have created you could see a new file named linuxrc is located under the / directory. Also you will see lots of executable files under the /bin which links to the /bin/busybox.

Startup Configuration

Create the /etc/group file:

$ cat etc/group
root:*:0:
daemon:*:1:
bin:*:2:
sys:*:3:
adm:*:4:
tty:*:5:
disk:*:6:
lp:*:7:lp
mail:*:8:
news:*:9:
u p:*:10:
proxy:*:13:
kmem:*:15:
dialout:*:20:
fax:*:21:
voice:*:22:
cdrom:*:24:
floppy:*:25:
tape:*:26:
s o:*:27:
a io:*:29:
sshd:*:74:
ppp:x:99:
500:x:500:plg
501:x:501:fa

Edit the /etc/passwd file:

$ cat etc/passwd
root::0:0:root:/:/bin/sh
ftp::14:50:FTP User:/var/ftp:
bin:*:1:1:bin:/bin:
daemon:*:2:2:daemon:/sbin:
nobody:*:99:99:Nobody:/:
sky::502:502:Linux User,,,:/home/sky:/bin/sh

Add the hostname:

$ cat etc/sysconfig/HOSTNAME 
utu2440

Edit the inittab file:

$ cat etc/inittab
#etc/inittab
::sysinit:/etc/init.d/rcS

# Start an "askfirst" shell on /dev/tty2-4
console::askfirst:-/bin/sh
tty2::askfirst:-/bin/sh
tty3::askfirst:-/bin/sh
tty4::askfirst:-/bin/sh

# /sbin/getty invocations for selected ttys
tty4::respawn:/sbin/getty 38400 tty5
tty5::respawn:/sbin/getty 38400 tty6


::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a –r
$ chmod 777 etc/init.d/rcS

Edit etc/init.d/rcS, this file will be executed everytime we bootup the linux system:

$ cat etc/init.d/rcS
#!/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
runlevel=S 
prevlevel=N
umask 022 
export PATH runlevel prevlevel
echo "----------mount all----------------"
mount -a 
echo /sbin/mdev>/proc/sys/kernel/hotplug
mdev -s
### Added from utu2440

trap ":" INT QUIT TSTP
##################################
#/bin/mount -t tmpfs tmpfs /dev
#/bin/mount -t sysfs sysfs /sys

################################## 
mkdir /dev/pts
/bin/mknod /dev/pts/0 c 136 0
/bin/mknod /dev/pts/1 c 136 1
/bin/mknod /dev/pts/2 c 136 2
/bin/mknod /dev/pts/3 c 136 3
/bin/mknod /dev/pts/4 c 136 4
/bin/mknod /dev/pts/5 c 136 5


/bin/mount -t devpts devpts /dev/pts
#/bin/mount -t proc none /proc
ln -s /dev/ts0 /dev/h3600_tsraw
/sbin/ifconfig eth0 10.0.0.15
/usr/sbin/telnetd -l /bin/login
echo "After telnetd"
/usr/bin/tty>/root/tty.txt

Create a new fstab file:

$ cat etc/fstab 
#device mount-point  type       option      dump  fsck  order
proc      /proc             proc      defaults        0      0
none     /tmp              ramfs     defaults       0       0
sysfs     /sys              sysfs      defaults        0      0
mdev    /dev              ramfs     defaults        0       0

Testing filesystem

Set the nfs boot options:

utu-bootloader=>>>setenv bootargs 'console=ttySAC0 init=/linuxrc root=/dev/nfs nfsroot=10.0.0.11:/media/nfs/rootfs,proto=tcp,nolock ip=10.0.0.15:10.0.0.1:10.0.0.1:255.255.255.0:www.yctek.com:eth0:off'
utu-bootloader=>>>setenv bootargs 'console=ttySAC0 init=/linuxrc root=/dev/nfs nfsroot=10.0.0.11:/media/nfs/rootfs,proto=tcp,nolock ip=10.0.0.15'

then we could boot into the nfs based filesystem.

Please press Enter to activate this console. NET: Registered protocol family 10

[root@www ~]# 
[root@www ~]# uname -a
Linux www 2.6.39 #6 Mon Oct 20 16:12:43 CST 2014 armv4tl GNU/Linux