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 slabat 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 /]#
Hi Charles,
回覆刪除Very nice work!... This blogs is amazing.
I just want to suggest you to change the name of this chapter because "Build Root File System" makes people thinking in Buildroot. Perhaps "Building a Root file system"...
By the way, you should also have some investigation in this blog about Buildroot, it's a plus ;)
Best regards,
Sérgio Gonçalves
(you can delete my post, it's not related to the page's content)
Sergio, thanks for the commend, Building a Root...seems relevant, the Buildroot is the next step and perhaps i'll write one for this.
回覆刪除dear
回覆刪除my bin folder all the file having link to executable
my rootfs size is 2.5 MB wheather it is valid or not