< Exit > < Help > │ └─────────────────────────────────────────────────────────────────────────┘
To save on space, a hierarchical listing of options that must be selected is shown below.
Busybox Settings General Configuration Show terse applet usage messages Store applet usage messages in compressed form Use the devpts filesystem for Unix98 PTYs (/proc/self/exe) Path to BusyBox executable Build Options Build BusyBox as a static binary (no shared libs) Build with Large File Support Do you want to build BusyBox with a Cross Compiler (/opt/arm-2007q3/bin/arm-none-linux-gnueabi-) Cross Compiler prefix Coreutils basename cat chmod cp cut echo false head hostid ln ls mkdir mkfifo mknod mv pwd rm sync tail touch true uname yes Console Utilities clear reset Editors awk sed vi Finding Utilities find grep Init Utilities init (keep the defaults that come with this selection) Support running commands with a controlling-tty poweroff, halt, and reboot mesg Login/Password Management Utilities Use internal password and group functuions getty login (de-select Support for /etc/securetty) Linux Module Utilities insmod rmmod lsmod modprobe Support version 2.6.x Linux kernels Linux System Utilities dmesg mdev Support /etc/mdev.conf Support command execution at device addition/removal mkswap more mount swaponoff umount umount –a option Networking Utilities hostname ifconfig ping telnet telnetd Process Utilities kill killall pidof ps Shells ash (keep all the defaults) Expand prompt string ---Bourne Shell Options Command line editing History saving Tab completion Fancy shell prompts System Logging Utilities syslogd klogd
To build BusyBox, simply type in make at the command line.
After a few minutes the compile should be complete. When compilation is
complete install BusyBox to the target directory. The make and install
commands are show below:
[root@localhost busybox-1.2.2.1]# make [root@localhost busybox-1.2.2.1]# make CONFIG_PREFIX=/home/user/target install
Configure the New Target Root File System
Looking at the newly built root file system, there are only three
subdirectories of binaries and a symbolic link of bin/busybox to
linuxrc. More directories must be created before the file system can be
used. Some device nodes should be created, too.
[root@localhost bin]# cd /home/user/target/ [root@localhost target]# dir total 28 drwxr-xr-x 2 root root 4096 Nov 21 10:20 bin lrwxrwxrwx 1 root root 11 Nov 21 10:20 linuxrc -> bin/busybox drwxr-xr-x 2 root root 4096 Nov 21 10:20 sbin drwxr-xr-x 4 root root 4096 Nov 21 10:20 usr [root@localhost target]#
Create the dev, dev/pts, etc, etc/init.d, lib, mnt, opt, proc, root,
sys, tmp, var, and var/log directories. Also create the device node for
the initial console.
[root@localhost target]# mkdir dev [root@localhost target]# mknod dev/console c 5 1 [root@localhost target]# mkdir dev/pts [root@localhost target]# mkdir etc [root@localhost target]# mkdir etc/init.d [root@localhost target]# mkdir lib [root@localhost target]# mkdir mnt [root@localhost target]# mkdir opt [root@localhost target]# mkdir proc [root@localhost target]# mkdir root [root@localhost target]# mkdir sys [root@localhost target]# mkdir tmp [root@localhost target]# mkdir var [root@localhost target]# mkdir var/log
Since 2.6.11 the debugfs has been introduced and so you may
optionally create a directory called debug for mounting the debugfs.
[root@localhost target]# mkdir debug
To have the /proc and /dev/pts file systems mounted at boot time, the
file etc/fstab must be created in the etc directory. Use an editor to
create the file. The example below uses vi to create the file. The two
lines to enter into fstab are shown below the vi fstab line.
[root@localhost target]# cd etc [root@localhost etc]# vi fstab proc /proc proc defaults 0 0 none /dev/pts devpts mode=0622 0 0
The login utilities use the files group, hosts, and passwd in the etc
directory for logging in. For now, only root needs to be defined in
group and passwd while hosts just needs to have localhost defined. The
contents of the three files are show below:
[root@localhost etc]# vi group root:x:0:root [root@localhost etc]# vi passwd root::0:0:root:/root:/bin/ash [root@localhost etc]# vi hosts 127.0.0.1 localhost
The kernel starts “/sbin/init” after it boots (actually the kernel
attempts to execute several known programs until one succeeds). Init
reads the etc/inittab file to determine what to do at start up,
shutdown, or when a user logs in. These inittab files can get quite
complicated. A simple one is shown below:
[root@localhost etc]# vi inittab ::sysinit:/etc/init.d/rcS # /bin/ash # # Start an "askfirst" shell on the serial port ttyS0::askfirst:-/bin/ash # Stuff to do when restarting the init process ::restart:/sbin/init # Stuff to do before rebooting ::ctrlaltdel:/sbin/reboot ::shutdown:/bin/umount -a -r ::shutdown:/sbin/swapoff -a
The “sysinit” line tells init to run the /etc/init.d/rcS script to set up the system. The rest are self explanatory.
A simple etc/init.d/rcS file could assume file systems existed in
the kernel and would simply mount the mount points as needed. A more
complicated one would test for the existence of file systems and if
found, mount them; if not found, find ways to still get the system
booted.
The author has taken the etc/init.d/rcS and mdev.conf files from
the V2.6.22.18-OMAP3 release for a simple example. The rcS script will
test for the existence of file systems and mount them accordingly. The
1.11.1 version of BusyBox does not create a link for /bin/sh so change
any /bin/sh to /bin/ash. The contents are shown below:
[root@localhost etc]# vi init.d/rcS #!/bin/sh # --------------------------------------------- # Common settings # --------------------------------------------- HOSTNAME=OMAP3EVM VERSION=1.0.0 hostname $HOSTNAME # --------------------------------------------- # Prints execution status. # # arg1 : Execution status # arg2 : Continue (0) or Abort (1) on error # --------------------------------------------- status () { if [ $1 -eq 0 ] ; then echo "[SUCCESS]" else echo "[FAILED]" if [ $2 -eq 1 ] ; then echo "... System init aborted." exit 1 fi fi } # --------------------------------------------- # Get verbose # --------------------------------------------- echo "" echo " System initialization..." echo "" echo " Hostname : $HOSTNAME" echo " Filesystem : v$VERSION" echo "" echo "" echo " Kernel release : `uname -s` `uname -r`" echo " Kernel version : `uname -v`" echo "" # --------------------------------------------- # MDEV Support # (Requires sysfs support in the kernel) # --------------------------------------------- echo -n " Mounting /proc : " mount -n -t proc /proc /proc status $? 1 echo -n " Mounting /sys : " mount -n -t sysfs sysfs /sys status $? 1 echo -n " Mounting /dev : " mount -n -t tmpfs mdev /dev status $? 1 echo -n " Mounting /dev/pts : " mkdir /dev/pts mount -t devpts devpts /dev/pts status $? 1 echo -n " Enabling hot-plug : " echo "/sbin/mdev" > /proc/sys/kernel/hotplug status $? 0 echo -n " Populating /dev : " mkdir /dev/input mkdir /dev/snd mdev -s status $? 0 # --------------------------------------------- # Disable power management # (Requires sysfs support in the kernel) # --------------------------------------------- echo -n " Disabling Power mgmt : " echo -n "1" > /sys/power/cpuidle_deepest_state status $? 1 # --------------------------------------------- # Turn off LCD after 1 hour of inactivity # (Requires sysfs support in the kernel) # --------------------------------------------- echo -n " Turn off LCD after 1 hour : " echo -n "3600" > /sys/power/fb_timeout_value status $? 1 # --------------------------------------------- # Mount the default file systems # --------------------------------------------- echo -n " Mounting other filesystems : " mount -a status $? 0 # --------------------------------------------- # Set PATH # --------------------------------------------- export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin # --------------------------------------------- # Start other daemons # --------------------------------------------- echo -n " Starting syslogd : " /sbin/syslogd status $? 0 echo -n " Starting telnetd : " /usr/sbin/telnetd status $? 0 # --------------------------------------------- # Done! # --------------------------------------------- echo "" echo "System initialization complete." # --------------------------------------------- # Start demo app # --------------------------------------------- #if [[ -x /etc/init.d/demo_start ]]; then # echo " Starting Demo Application..." # /etc/init.d/demo_start & # sleep 5 #fi
Please note that in more recent kernels (2.6.29 and newer) the sysfs
entries shown above to disable power management and control the LCD
inactivity timeout shown above have been removed. For latest details on
using OMAP Power Management in Linux please refer to .
To automatically mount the debugfs on start-up the following can
be added to the above rcS file. Please note that the debugfs needs to be
selected in the kernel configuration and built into the kernel before
you can mount it. The below script checks to see if the debugfs is
supported by the kernel before attempting to mount the file-system. To
enable the debugfs run "make menuconfig" and go to "Kernel Hacking" and
select "Debug Filesystem".
cat /proc/filesystems | grep -q debugfs if [ $? -eq 0 ] ; then echo -n " Mounting /debug : " mount -n -t debugfs none /debug status $? 1 fi
After saving the file, change its access permissions so that it is executable for all.
[root@localhost etc]# vi mdev.conf audio 0:5 0666 console 0:5 0600 control.* 0:0 0660 @/bin/mv /dev/$MDEV /dev/snd/ dsp 0:5 0666 event.* 0:0 0600 @/bin/mv /dev/$MDEV /dev/input/ fb 0:5 0666 nfs 0:5 0770 null 0:0 0777 pcm.* 0:0 0660 @/bin/mv /dev/$MDEV /dev/snd/ rtc 0:0 0666 tty 0:5 0660 tty0* 0:5 0660 tty1* 0:5 0660 tty2* 0:5 0660 tty3* 0:5 0660 tty4* 0:5 0660 tty5* 0:5 0660 tty6* 0:5 0660 ttyS* 0:5 0640 urandom 0:0 0444 zero 0:0 0666
Add the Shared Libraries Applications will Require
Various applications will be built using the libraries in the tool
chain so the runtime libraries must be copied to the root file system.
Care should be taken to only copy the libraries that are required so
that the root file system does not grow based on unused libraries. This
note will simply demonstrate how to copy all the shared libraries to
the root file system and strip out any debug information from the
libraries.
In the Code Sourcery tool chain, most of the libraries are found
in the /opt/arm-2007q1/arm-none-linux-gnueabi/libc/lib directory.
Simply copy these files to the root file system, maintaining symbolic
links and then strip out unneeded debug information.
[root@localhost user]# cd /home/user/target/lib [root@localhost lib]# cp –r /opt/arm-2007q1/arm-none-linux-gnueabi/libc/lib/* . [root@localhost lib]# arm-none-linux-gnueabi-strip *
Some libraries might be in other directories in the tool chain; those
would have to be found on a “trial and error” basis when applications
do not load because of a missing shared library.
A minimal, working root file system has now been built. It will
boot, but does not have kernel modules yet. These will be added later
after testing.
Mounting the Root File System over NFS
In this scenario, the target device and the host system are connected
via Ethernet, either directly through a crossover cable or to a hub or
switch. The host must export the target file system through NFS and the
NFS server daemon must be running. For configuring and running NFS on a
Linux PC, see the HOWTOs at any Linux Documentation Internet site. In
this simple example, the exported file system is /home/user/target and
anybody can mount it via NFS. The /etc/exports file is shown below
/home/user/target *(rw,no_root_squash)
On the target side, the u-boot environment variable bootargs must be
set to boot from NFS and contain the mount address of the root file
system. In the example below, the NFS server is at IP address
192.168.1.104.
[root@OMAP3EVM /] # setenv bootargs mem=64M ip=dhcp noinitrd console=ttyS0,115200n8 root=/dev/nfs rw nfsroot=192.168.1.104:/home/user/target,nolock,rsize=1024,wsize=1024 [root@OMAP3EVM /] # saveenv
After booting the kernel, the final boot messages should look similar to below.
Sending DHCP requests .<6>eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1 ., OK IP-Config: Got DHCP answer from 255.255.255.255, my address is 128.247.107.23 IP-Config: Complete: device=eth0, addr=128.247.107.23, mask=255.255.254.0, gw=128.247.106.2, host=128.247.107.23, domain=am.dhcp.ti.com, nis-domain=(none), bootserver=255.255.255.255, rootserver=128.247.107.35, rootpath= Looking up port of RPC 100003/2 on 128.247.107.35 Looking up port of RPC 100005/1 on 128.247.107.35 VFS: Mounted root (nfs filesystem). Freeing init memory: 136K init started: BusyBox v1.11.1 (2008-10-05 04:40:51 CDT) starting pid 288, tty : '/etc/init.d/rcS' System initialization... Hostname : OMAP3EVM Filesystem : v1.0.0 Kernel release : Linux 2.6.22.18-omap3 Kernel version : #12 Mon Oct 6 01:22:49 CDT 2008 Mounting /proc : [SUCCESS] Mounting /sys : [SUCCESS] Mounting /dev : [SUCCESS] Mounting /dev/pts : [SUCCESS] Enabling hot-plug : [SUCCESS] Populating /dev : [SUCCESS] Disabling Power mgmt : [SUCCESS] Turn off LCD after 1 hour : [SUCCESS] Mounting other filesystems : [SUCCESS] Starting syslogd : [SUCCESS] Starting telnetd : [SUCCESS] System initialization complete. Please press Enter to activate this console.
Creating and Booting a RAMDISK
A ramdisk is simply an ext2 file system. The tools to build one are
shipped with just about every Linux distribution. The steps to build
the ramdisk from the target file system are as follows:
Change directory to the /home/user directory.
Use the dd utility to create a 16M file of “zero” that will contain the file system.
Use mke2fs to create the empty file system in the file from 2.
Mount the file to a mount point using the loop device.
Use tar to create an archive from the target and pipe it into tar to extract the target to the mount point.
Un-mount the file.
Copy it to the /tftpboot directory so that u-boot can download it to the target device.
[root@localhost user]# cd /home/user [root@localhost user]# dd if=/dev/zero of=rd-ext2.bin bs=1k count=16384 [root@localhost user]# mke2fs –F –m0 rd-ext2.bin [root@localhost user]# mount –t ext2 rd-ext2.bin /mnt –o loop [root@localhost user]# tar –C target –cf - . | tar –C /mnt –xf – [root@localhost user]# umount /mnt [root@localhost user]# cp rd-ext2.bin /tftpboot
To boot the kernel with the root file system on the ramdisk, the
u-boot environment variable “bootargs” must be modified. The “bootargs”
variable contains information that gets passed to the kernel at boot up
time and has information such as memory size, ip address, where the
root file system is, what kind of file system it is, etc. For this
note, a TI OMAP 3530 EVM is used so all RAM and flash addresses are
specific to that platform.
Start up a terminal program on the host and turn on the target.
It is assumed that u-boot has already been flashed to the target board.
The ramdisk will be downloaded to RAM at address 0x81600000 and is 16M
in size. At the u-boot prompt, change the bootargs variable as follows:
[root@OMAP3EVM /] # setenv bootargs mem=88M ip=dhcp console=ttyS0,115200n8 root=/dev/ram0 rw initrd=0x81600000,16M ramdisk_size=16384 [root@OMAP3EVM /] # saveenv
All the text should be entered as one line.
Now download the kernel to 0x80000000 and the ramdisk to 0x81600000 and then boot the kernel.
[root@OMAP3EVM /] # tftp 81600000 rd-ext2.bin [root@OMAP3EVM /] # tftp 80000000 uImage [root@OMAP3EVM /] # bootm
After the kernel boots, the terminal should show the usual boot up
messages and then finally indicates that the filesystem is mounted as a
RAMDISK.
RAMDISK: ext2 filesystem found at block 0 RAMDISK: Loading 16384KiB [1 disk] into ram disk... done. VFS: Mounted root (ext2 filesystem). Freeing init memory: 136K init started: BusyBox v1.11.1 (2008-10-05 04:40:51 CDT) starting pid 287, tty : '/etc/init.d/rcS' System initialization... Hostname : OMAP3EVM Filesystem : v1.0.0 Kernel release : Linux 2.6.22.18-omap3 Kernel version : #12 Mon Oct 6 01:22:49 CDT 2008 Mounting /proc : [SUCCESS] Mounting /sys : [SUCCESS] Mounting /dev : [SUCCESS] Mounting /dev/pts : [SUCCESS] Enabling hot-plug : [SUCCESS] Populating /dev : [SUCCESS] Disabling Power mgmt : [SUCCESS] Turn off LCD after 1 hour : [SUCCESS] Mounting other filesystems : [SUCCESS] Starting syslogd : [SUCCESS] Starting telnetd : [SUCCESS] System initialization complete. Please press Enter to activate this console.
MTD Partitions
Before discussing flash file systems, “MTD partitions” must be
explained. A flash device must be partitioned on an embedded device
just as a hard disk must be partitioned on a Linux PC. On a Linux PC
there would be a partition for /boot, a swap partition, a /usr
partition, etc. For the embedded device the partitions are usually just
for the boot loader, its environment variables, the kernel, and a flash
file system.
There is no “fdisk” for flash devices like there is for a hard
disk. Instead, the partitioning is done in software. The exact file
that does the partitioning is different based on the chip, board, CPU,
and Linux source code. For this note, the board used is the TI OMAP
3530 EVM and the kernel source is from the SDK1.0.0 release. The file
containing the MTD driver and partitions is
linux/kernel_org/2.6_kernel/arch/arm/mach-omap2/board-omap3evm-flash.c.
Looking at the file, the structure omap_partitions[ ] contains the partition table for the H4 board.
static struct mtd_partition omap3evm_onenand_partitions[] = { { .name = "X-Loader-ONENAND", .offset = 0, .size = 4 * (64 * 2048), .mask_flags = MTD_WRITEABLE /* force read-only */ }, { .name = "U-Boot-ONENAND", .offset = MTDPART_OFS_APPEND, .size = 14*(64*2048), .mask_flags = MTD_WRITEABLE /* force read-only */ }, { .name = "Boot Env-ONENAND", .offset = MTDPART_OFS_APPEND, .size = 2*(64*2048), }, { .name = "Kernel-ONENAND", .offset = MTDPART_OFS_APPEND, .size = 40*(64*2048), }, { .name = "File System - ONENAND", .offset = MTDPART_OFS_APPEND, .size = MTDPART_SIZ_FULL, },
};
The boot loader has a partition size of 256k. The u-boot environment
variables fit in a 128k partition for ES1.0 or 256k for ES2.0. The
kernel partion is 2M while what is left is used for a file system.
When the kernel boots and the driver loads, device nodes are
created based on the partitions. The device nodes take on the form
/dev/mtdblock/x or /dev/mtdblockx.
Flash Physical Adress Range Bank Device Node Partition Name 0x00080000-0x00020000 1 /dev/mtdblock0 "X-Loader-NAND" 0x001c0000-0x00020000 1 /dev/mtdblock1 "U-Boot-NAND" 0x00040000-0x00020000 1 /dev/mtdblock2 "Boot Env-NAND" 0x00500000-0x00020000 1 /dev/mtdblock3 "Kernel-NAND" 0x0f880000-0x00020000 1 /dev/mtdblock4 "File System - NAND"
The physical address is set by u-boot. Look at the file
u-boot/include/asm/arch/cpu.h to see the flash physical address
mappings:
/* GPMC Mapping */ # define FLASH_BASE 0x10000000 /* NOR flash (aligned to 256 Meg) */ # define FLASH_BASE_SDPV1 0x04000000 /* NOR flash (aligned to 64 Meg) */ # define FLASH_BASE_SDPV2 0x10000000 /* NOR flash (aligned to 256 Meg) */ # define DEBUG_BASE 0x08000000 /* debug board */ # define NAND_BASE 0x10000000 /* NAND addr (actual size small port)*/ # define PISMO2_BASE 0x18000000 /* PISMO2 CS1/2 */ # define ONENAND_MAP 0x20000000 /* OneNand addr (actual size small port */
Creating and Booting a JFFS2 Root File System
Since jffs2 is used only on flash devices, a standard Linux
distribution does not have the tools to make a jffs2 file system. The
Internet site
explains where and how to obtain the latest source to MTD code and file
systems. mkfs.jffs2 is the tool needed to build a jffs2 file system
and the source is in this code. All of the MTD code will be downloaded
but only the code to build mkfs.jffs2 is built.
The source code is maintained in a CVS tree. CVS is version
control software and is usually installed when the Linux distribution is
installed. CVS does not work across firewalls so a direct connection to
the Internet is required. From the command line enter the following:
[root@localhost user]# cd /home/user/build [root@localhost build]# cvs –d :pserver:anoncvs@cvs.infradead.org:/home/cvs login CVS password: anoncvs [root@localhost build]# cvs –d :pserver:anoncvs@cvs.infradead.org:/home/cvs co mtd
There should now be a mtd directory under /home/user/build. The
source to mkfs.jffs2 is found in the util directory under mtd. To build
mkfs.jffs2 simply change directory to mtd/util and enter “make
mkfs.jffs2”. When the build is complete, copy the mkfs.jffs2 file to
the /sbin directory; that is where the other utilities that make file
systems reside.
[root@localhost build]# cd mtd/util [root@localhost util]# make mkfs.jffs2 [root@localhost util]# cp mkfs.jffs2 /sbin
With the mkfs.jffs2 utility built and in place it is now time to make
the jffs2 file system from of the target directory. Change to the
/home/user directory and enter the mkfs.jffs2 command below. Probably
the most important argument to the utility is the erase block size. For
the NAND part on the OMAP3530 EVM board the erase block is 128k
Consult either u-boot, the kernel, or the data manual for the flash part
used to find the erase block size.
[root@localhost util]# cd /home/user [root@localhost util]# mkfs.jffs2 -lqnp –e 128 -r target -o /tftpboot/rd-jffs2.bin
By building the file in the /tftpboot directory, the step of copying
it over is eliminated.
The file must now be written into flash at a specific location.
In u-boot, the flash file system will get flashed to the physical
address 0x780000 and will be mounted by the kernel from /dev/mtdblock4.
The steps to perform this are:
Unprotect the flash area where the file system will reside.
Erase that area.
Download the rd-jffs2.bin file.
Write it to flash.
Modify bootargs to support a JFFS2 file system as root on /dev/mtdblock4.
Save the environment variables.
NOTE: (Not up to date - based on a different kernel – see SDK1.0.0 reprogramming scripts:
C:\OMAP35x_SDK_1.0.0\board_utilities\scripts\ reflash-samsung.txt)
[root@OMAP3EVM /] # onenand unlock 0x0 0x8000000 [root@OMAP3EVM /] # mw.b 0x81600000 0xff 0x1400000 [root@OMAP3EVM /] # onenand erase block 60-1023 [root@OMAP3EVM /] # tftpboot 0x81600000 rd-jffs2.bin [root@OMAP3EVM /] # onenand write 0x81600000 0x780000 0x1400000 [root@OMAP3EVM /] # setenv bootargs mem=88M noinitrd ip=dhcp console=ttyS0,115200n8 root=/dev/mtdblock4 rootfstype=jffs2 [root@OMAP3EVM /] # saveenv
Boot the kernel and near the end of boot-up the following messages should be seen:
IP-Config: Gateway not on directly connected network. VFS: Mounted root (jffs2 filesystem). Freeing init memory: 136K eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1 init started: BusyBox v1.11.1 (2008-10-05 04:40:51 CDT) starting pid 288, tty : '/etc/init.d/rcS' System initialization... Hostname : OMAP3EVM Filesystem : v1.0.0 Kernel release : Linux 2.6.22.18-omap3 Kernel version : #1 Tue Jul 1 17:16:34 IST 2008 Mounting /proc : [SUCCESS] Mounting /sys : [SUCCESS] Mounting /dev : [SUCCESS] Mounting /dev/pts : [SUCCESS] Enabling hot-plug : [SUCCESS] Populating /dev : [SUCCESS] Disabling Power mgmt : [SUCCESS] Turn off LCD after 1 hour : [SUCCESS] Mounting other filesystems : [SUCCESS] Starting syslogd : [SUCCESS] Starting telnetd : [SUCCESS] System initialization complete. Please press Enter to activate this console.
Creating and Booting a CRAMFS Root File System
Since CRAMFS is another embedded file system, the host Linux
distribution might not have the mkcramfs utility. The source to the
cramfs tools can be found at . As usual, download, build, and install them.
The first step is to edit the etc/init.d/rcS file so that the
logging daemons do not get started. Since CRAMFS is a read-only file
system, the serial console would be filled with errors as these loggers
try to write messages to disk. After that, change to the /home/user
directory and use the mkcramfs utility to create the file image. The –v
argument only says to be verbose and display messages as the file
system is built.
[root@localhost home]# cd /home/user [root@localhost user]# mkcramfs –v target /tftpboot/rd-cramfs.bin
By building the file in the /tftpboot directory, the step of copying it over is eliminated.
The file must now be written into flash at a specific location.
In u-boot, the flash file system will get flashed to the physical
address 0x780000 and will be mounted by the kernel from /dev/mtdblock4.
The steps to perform this are:
Unprotect the flash area where the file system will reside.
Erase that area.
Download the rd-cramfs.bin file.
Write it to flash.
Modify bootargs to support a CRAMFS file system as root on /dev/mtdblock4.
Save the environment variables.
[root@OMAP3EVM /] # onenand unlock 0x0 0x8000000 [root@OMAP3EVM /] # mw.b 0x81600000 0xff 0x1400000 [root@OMAP3EVM /] # onenand erase block 60-1023 [root@OMAP3EVM /] # tftpboot 0x81600000 rd-cramfs.bin [root@OMAP3EVM /] # onenand write 0x81600000 0x780000 0x1400000 [root@OMAP3EVM /] # setenv bootargs mem=88M noinitrd ip=dhcp console=ttyS0,115200n8 root=/dev/mtdblock4 rootfstype=cramfs [root@OMAP3EVM /] # saveenv
Boot the kernel and near the end of boot-up the following messages should be seen:
NOTE: (Not up to date - based on a different kernel)
VFS: Mounted root (cramfs filesystem) readonly. Freeing init memory: 136K Mounting proc : OK Mounting sysfs : OK Mounting /dev : OK Creating local mdev devices System initialization... Hostname : OMAP3EVM Filesystem : v1.0.0 Kernel release : Linux 2.6.22.18-omap3 Kernel version : #1 Tue Jul 1 17:16:34 IST 2008 Mounting devpts : OK Setting up networking Configuring lo : OK Mounting filesystems : OK System initialization complete. Please press Enter to activate this console.
Enhancing the Root File System
The root file system built contains only the bare minimum files to
operate. Kernel driver modules have not been added yet. Also, as
applications are built and added, the shared libraries used by the
applications will need to be added. The file system will get larger
when these files are added.
Add the Kernel Driver Modules to the Root File System
Any drivers built as modules need to be added to the target root file
system. This is fairly simple; after building the kernel, build the
modules, and then use the same kernel Makefile to install the files to
the target.
[root@localhost 2.6_kernel]# make modules [root@localhost 2.6_kernel]# make INSTALL_MOD_PATH=/home/user/target modules_install
After the second make is performed, the kernel modules will be copied
to the /home/user/target/lib/modules directory. One problem still
exists – the modules still have debug information so they are larger
than they need to be. When debug information is no longer needed, use
the arm-none-linux-gnueabi-strip utility to remove it. Unfortunately
the strip utility does not have a recursive option to go into each
directory and strip the driver. If there are only a few drivers, the
find utility can be used to find each .o file recursively and then pass
the file name to strip. An example is shown below.
[root@localhost user]# cd /home/user/target/lib/modules [root@localhost modules]# arm-none-linux-gnueabi-strip `find . –name “*.ko”`
Note that the ` character is the “tick” key that is on the left-hand side of the keyboard and is a lowercase ~.
RAMDISK Considerations
As files get added to the target root file system, the image size
will grow beyond 16M. The kernel must be configured to the new RAMDISK
size and re-built. See section “3.3 Configure the Linux Kernel for
RAMDISK support” for more information on how to change the RAMDISK size
in the kernel. The amount of RAM used for the RAMDISK should not be too
big so that the kernel has enough RAM to load and run programs. For
example, on a board with only 32M RAM, a 20M RAMDISK would only leave
12M for the kernel to use. This could cause a shortage of memory for
programs to run.
If a development platform has more then 32M, then that should also be
reflected in the u-boot environment variable “bootargs”. For example,
assume a development platform now has 64M of RAM. The bootargs variable
could be changed from “mem=32M” to “mem=64M”. A RAMDISK of 20M would
no longer be a problem.
One last hint on keeping the RAMDISK image small. Use the
arm-none-linux-gnueabi-strip program to strip off unneeded headers and
debug information once an application or driver has been fully debugged
and ready for inclusion in the image.
Trouble Shooting
If you are having problems booting the kernel please refer to for help.
Comments
UBIFS Root
So, how can I configure e.g. my Beagle to have its 256 MByte NAND be
managed by UBI, root on UBIFS, and boot without an MMC card?
Naruto1980 said ...
SanjeevPremi said ...
The swap space can be enabled at run-time
Though most of the steps described in this page are 'host-side', this
information is related. Can be included appropriately in the topic
above:
Identify the space available for creating a swapfile.
A general guideline is to create this file 2x the size of available RAM; but it isn't rule.
Create a swap file (e.g. /swap/swapfile):
# dd if=/dev/zero of=/swap/swapfile bs=1024 count=256
# mkswap /swap/swapfile
# swapon /swap/swapfile