Embedded Linux Applications: An Overview
By Darrick Addison2005-04-30
Installing TinyLogin and Login Dependencies
TinyLogin (see the Resources section to install it) will give us the following tools in less than 35Kb:
/bin/addgroup,/bin/adduser,/bin/delgroup,/bin/deluser,/bin/login,/bin/su,/sbin/getty,/sbin/sulogin,/usr/bin/passwd.
Please refer to your main distribution doc or man pages for a full description of those commands.
Step 12. Configuring TinyLogin
From the TinyLogin README: TinyLogin is modularized to help you build only the components you need, thereby reducing binary size. To turn off unwanted TinyLogin components, simply edit the file tinylogin.def.h and comment out the parts you do not want using C++ style (//) comments.
Step 13. Installing TinyLogin
After the build is complete, a tinylogin.links file is generated, which is then used by make install to create symlinks to the tinylogin binary for all compiled-in functions. By default, make install will place a symlink forest into pwd /_install unless you have defined the PREFIX environment variable.
Step 14. Installing Sysvinit and start-stop daemon
After the kernel is done loading, it tries to run the init program to finalize the boot process. Now:
1. Unpack the Sysvinit archive
2. Go to the src directory
3. Copy the init executable in $EMBPART/sbin
The Sysvinit package also offers a C version of the start-stop-daemon in the contrib directory.
1. Compile it
2. Copy the file in $EMBPART/usr/sbin
Step 15. Configuring Sysvinit
Sysvinit needs a configuration file named inittab, which should be placed in $EMBPART/etc. Here is the one used in the LEM distribution:
# /etc/inittab: init(8) configuration.Step 16. Creating initial boot scripts
# $Id: inittab,v 1.6 1997/01/30 15:03:55 miquels Exp $
# Modified for LEM 2/99 by Sebastien HUET
# default rl.
id:2:initdefault:
# first except in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS
# single-user mode.
~~:S:wait:/sbin/sulogin
# /etc/init.d executes the S and K scripts upon change
# 0:halt 1:single-user 2-5:multi-user (5 may be X with xdm or other) 6:reboot.
l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
# CTRL-ALT-DEL pressed.
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -r now
# Action on special keypress (ALT-UpArrow).
kb::kbrequest:/bin/echo "Keyboard Request--edit /etc/inittab to let this work."
# /sbin/mingetty invocations for runlevels.
1:2345:respawn:/sbin/getty 9600 tty1
2:23:respawn:/sbin/getty 9600 tty2
#3:23:respawn:/sbin/getty tty3 #you may add console there
#4:23:respawn:/sbin/getty tty4
As seen in the inittab file, Sysvinit needs additional scripts in its own directories.
Step 17. Creating the necessary directories and base files
Use the following command to create the directories:
cd $EMBPART/etcGo to the unpacked Sysvinit source directory
mkdir rc0.d rc1.d rc2.d rc3.d rc4.d rc5.d rc6.d init.d rcS.d rc.boot
Copy the debian/etc/init.d/rc to:$EMBART/etc/init.d
Go to the $EMBPART/etc/init.d/
Create a new file rcS like those in LEM:
#!/bin/shCopy run-parts from your distro to $EMBPART/bin.
PATH=/sbin:/bin:/usr/sbin:/usr/bin
runlevel=S
prevlevel=N
umask 022
export PATH runlevel prevlevel
/etc/default/rcS
export VERBOSE
# Trap CTRL-C only in this shell so we can interrupt subprocesses.
trap ":" 2 3 20
# Call all parts in order.
for i in /etc/rcS.d/S??*
do
[ ! -f "$i" ] && continue
case "$i" in
*.sh)
(
trap - 2 3 20
. $i start
)
;;
*)
$i start
;;
esac
done
# run the files in /etc/rc.boot
[ -d /etc/rc.boot ] && run-parts /etc/rc.boot
Step 18. Adding base scripts
A lot of the commands being used here are UNIX/Linux commands that set, export, etc. paths that are embedded inside of a UNIX shell script.
<!-reboot---------------------------------------------->Create a new file reboot containing the following:
#!/bin/shCreate a new file halt containing the following:
PATH=/sbin:/bin:/usr/sbin:/usr/bin
echo -n "Rebooting... "
reboot -d -f -i
<!-halt---------------------------------------------->
#!/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
halt -d -f -i -p
<!-mountfs---------------------------------------------->
Tutorial Pages:
» From Wrist Watches to Cluster-Based Supercomputers
» Emergence of Embedded Systems
» Advantages/Disadvantages of Using Linux for Your Embedded System
» Software and Hardware Requirements
» Hardware Platform Options
» Real-Time Embedded Linux Applications
» Configuration Procedures
» Creating a Bootdisk
» Installing TinyLogin and Login Dependencies
» Summary
» Resources
First published by IBM DeveloperWorks
| Related Tutorials: » How to Install PHP 5 on Linux » How to Install Apache 2 on Linux » How to Install MySQL 5.0 on Linux » SMB Caching » Mound --Bind » Tar Wild Card Interpretation |
