Building Small Embedded Linux System PDF
Building Small Embedded Linux System PDF
ABSTRACT
This application note demonstrates NOR kernel building and board setup using the
DaVinci DM644x Digital Evaluation Module (DVEVM) package. The goal is to build the
smallest possible kernel using the MontaVista® Linux Support Package (LSP) with
support for an HTTP server, a TCP/IP stack, and necessary drivers for Ethernet and
UART for the serial debug terminal. The kernel resides in NOR flash and uses a RAM
disk-based file system, which is also stored on flash.
This setup is found in embedded devices such as routers and print servers, and can be
used as a starting point for more sophisticated implementations such as I/O monitors,
web cams, and multimedia players.
The application note includes the following sections:
• Overview of the required hardware and software available
• Building the kernel
• Building the RAM disk file system
• Setting up the application
• Storing to flash
Contents
1 Overview ............................................................................................. 2
2 Feature Selection and Kernel Build Steps ...................................................... 3
3 Building an Initial RAM Disk File System ........................................................ 6
4 Application Support ................................................................................. 8
5 Copying Information to NOR Flash ............................................................. 10
6 Boot Up ............................................................................................. 13
7 Summary ........................................................................................... 14
8 References ......................................................................................... 14
Appendix A .............................................................................................. 15
List of Figures
1 Loadable Module Support ......................................................................... 4
2 Disable File Systems ............................................................................... 5
3 Index of Mozilla Firefox ............................................................................ 9
4 EVM Boot-Up Screen ............................................................................. 13
5 Web Screen Connected to the DVEVM Web Server ......................................... 13
List of Tables
1 Required DVEVM Hardware Features ........................................................... 2
2 Required DVEVM Software Packages ........................................................... 3
3 Configuration Summary ............................................................................ 3
4 Linux Packages for the RAM Disk File System ................................................. 7
5 Memory Placement of Bootloader, Kernel and RAM Disk in DVEVM NOR Flash ....... 12
1 Overview
To create a standalone and bootable Embedded Linux System, three main pieces of software must be
flashed on the EVM:
• A bootloader, u-Boot in this case
• A Linux kernel with built-in drivers for DaVinci DM644x devices
• An ARM-target Linux file system containing the shell, application and run-time support utilities and
stacks
This section quickly reviews the DVEVM, including required hardware and software components.
Note: The DVEVM and DVSDK-L or -3L software packages may have slightly different kernel
config and build commands. Always check the documentation that comes with the package
such as the DVEVM Release Notes, the DVEVM Quick Start Guide or DVEVM Getting
Started Guide (SPRUE66) for updated information regarding the exact commands for the
build steps. The following steps are for the kernel tree from the DVEVM software package.
1. On the host Linux workstation, go to the base directory of the kernel tree:
host $ cd /home/user/working/lsp/ti-davinci
2. Launch the Linux kernel configuration utility:
host $ make ARCH=arm CROSS_COMPILE=arm_v5t_le- xconfig
3. Under Loadable module support, uncheck the Enable loadable module support to disable the module
loading feature. See Figure 1.
4. Under Device Drivers → Generic Driver Options, uncheck the Select only drivers that don’t need
compile-time external firmware and Prevent firmware from being built boxes to disable firmware
loading features.
12. Under Device Drivers → File systems → DOS/FAT/NT Filesystems, uncheck the MSDOS fs support
and VFAT (Windows 95) fs support boxes to disable Windows file system support.
13. Under Device Drivers → File systems→Miscellaneous filesystems, uncheck the Compressed ROM file
system support (cramfs) box to disable cramfs file system support.
14. Under Device Drivers → File systems → Network File Systems, uncheck the NFS file system support,
NFS server support, and SMB file system support boxes to disable network file systems support.
15. Under Device Drivers → File systems→Partition Types, uncheck the Advanced Partition Selection box
to disable partition support on the hard disk.
16. Under Device Drivers → Graphics Support, uncheck the Support for frame buffer devices box to
disable Linux frame buffer support.
17. Under Device Drivers → Sound, uncheck the Sound card support box to disable Linux sound support.
18. Under Device Drivers → USB Support, uncheck the Support for Host-side USB and Inventra USB
Highspeed Dual Role Controller Support boxes to disable USB driver support.
Note: The DVEVM and DVSDK-L or -3L software packages may have different kernel
configurations and build commands. Always check the documentation that comes with the
package such as the DVEVM Release Notes, the DVEVM Quick Start Guide or DVEVM
Getting Started Guide (SPRUE66) for the exact commands for the build steps. The following
steps are for the kernel tree from the DVEVM software package.
1. If not already logged in as user, then log in as user prior to building the kernel.
2. Build the Linux kernel with this command:
host$ make ARCH=arm CROSS_COMPILE=arm_v5t_le- uImage
Note that the above kernel configuration disables most of the peripheral support, except for the networking
stack, Ethernet, and Serial drivers. If additional applications are required beyond the ones used in this
application report, other supporting features may need to be enabled.
The generated kernel, the u-boot compatible compressed binary file uImage, is located under the
arch/arm/boot directory. Copy this file to the /tftpboot directory so that it can be flashed later on the
DVEVM.
In the next step, you will build a RAM disk file system to save to flash.
Note: Cross-building these packages provided here or from the GNU source trees is beyond the
scope of this application report. Please consult the appropriate document or embedded Linux
books on how to perform these tasks.
Several options are available to complete this step, including using an existing RAM disk, or building one
for your needs.
Note: In later releases of the DVSDK packages the sample RAM disk image is located at:
<dvsdk install dir>/<PSP dir>/bin
In this directory, the RAM disk file is called ramdisk.gz (about 2.1 MB gunzipped). In run time, it occupies
about 6.3 MB in DDR. This file system contains some unnecessary utilities for this project, but is
appropriate for a typical embedded system.
4 Application Support
This section describes how to add a small web server (thttpd) to the initial RAM disk file system and
configure it for the DVEVM.
The web server thttpd is a simple, small, portable, fast, and secure HTTP server with the following
features:
• Simple: It handles only the minimum information necessary to implement HTTP/1.1.
• Small: It has a small run-time size, because it allocates memory conservatively and does not fork.
• Portable: It compiles cleanly on most Unix-like operating systems, including FreeBSD, SunOS 4,
Solaris 2, BSD/OS, Linux, and OSF.
• Fast: In typical use, it is as fast as the best full-featured servers (Apache, NCSA, Netscape). Under
extreme loads, it is much faster.
• Secure: It protects the web server machine against attacks and break-ins from other sites.
2. Write the index.html file and copy it to the initial RAM disk file system. For information on the
index.html file used in this demo please refer to Appendix A.
host $ cp index.html /mnt/def_cd/ram0/opt/dvevm/web
3. Write the cgi scripts and copy them to the cgi-bin directory of the initial RAM disk file system. For
information on the cgi scripts used in this demo please refer to Appendix A.
host $ mkdir -p /mnt/def_cd/ram0/opt/dvevm/web/cgi-bin
host $ cp <cgi files> /mnt/def_cd/ram0/opt/dvevm/web/cgi-bin/
4. Copy the TI graphics used by the index.html file to the RAM disk file system. These graphics are
located in the DVEVM/DVSDK software package, which can be downloaded from
www.ti.com/dvevmupdates.
host $ cp <dvevm/dvsdk install dir>/examples/web/*.gif
/mnt/def_cd/ram0/opt/dvevm/web
Note: For later releases of the DVEVM/DVSDK software the location of the TI graphics files may
look like <dvsdk install dir>/examples/<device>/web
5. Edit a file called startweb.sh and add the following script lines to start the web server:
#!/bin/sh
# script to start web server
echo "Start web service..."
/opt/dvevm/web/thttpd -d /opt/dvevm/web -c "/cgi-bin/*"
6. Copy this script to the /etc/init.d directory of the RAM disk to make it part of the boot-up sequence:
host $ cp startweb.sh /mnt/def_cd/ram0/etc/init.d
host $ chmod +x /mnt/def_cd/ram0/etc/init.d/startweb.sh
host $ cd /mnt/def_cd/ram0/etc/rc.d/rcS.d
host $ ln –s ../init.d/startweb.sh S42startweb
7. Finally, recompress this RAM disk for flashing:
host $ cd /mnt/def_cd
host $ umount /mnt/def_cd/ram0
host $ gzip ramdisk
host $ cp ramdisk.gz /tftpboot
The U-Boot code and data are stored in the first five sectors, starting at 0x2000000. Note that the
trailing (RO) indicates that the sectors are read-only or protected from erasing and writing. The Linux
kernel image should be saved to the 0x2050000 location, the first free sector after U-Boot.
Note: For Intel NOR Flash chips you should use flash address 0x2060000, which is the first start
address after U-Boot, rather than 0x2050000. The following commands should be adjusted
to use this address.
Note: The destination address 0x2119224 is derived from adding the kernel size 0xc9224 to the
start address 0x2050000. This is so that the RAM disk image is written in the flash sectors
after the kernel.
Copy to Flash.../done
The cp (copy) command is used to copy the Linux kernel image in RAM into the accessible flash
memory. The arguments are the source address, the destination address, and the length. The .b
extension on the cp command specifies a byte-wise copy.
8. Protect the flash from writing:
DVEVM # protect on 0x2050000 +0x2FBCA3
The protect command makes the flash sector read-only, to ensure that the kernel image and RAM disk
file system are not accidentally overwritten.
9. Set the U-Boot Command and Linux Kernel Command Line:
Note: For Intel NOR Flash chips use flash address 0x2060000 instead of 0x2050000
Table 5. Memory Placement of Bootloader, Kernel and RAM Disk in DVEVM NOR Flash
Address Content
0x0200 0000 – 0x0204 FFFF u-boot and u-boot parameters (327 KB)
0x0205 0000 – 0x0211 9223 uImage – Linux kernel (823KB)
0x0211 9224 – 0x0234BCA3 Compressed RAM disk (2.1MB)
0x0234BCA4 – 0x02FF FFFF Unused (12.70MB)
6 Boot Up
This section requires the completion of Section 5. It describes how to access the web server and log in to
the EVM.
1. Power on the EVM board. On successful boot-up, it prompts for login. See Figure 4.
2. Log in as root.
3. Open the web browser on the host machine and connect to the EVM.
4. Connect to the EVM web server by typing the EVM IP address in the URL address box. See Figure 5.
5. Click on the Memory usage link. The web page displays the output of the cat /proc/meminfo command.
6. Click on the Kernel Config options link. The web page displays the .config file used to build the kernel
image.
7. Click on the Kernel boot log link. The web page displays the output of the dmesg command.
7 Summary
This application report described kernel configuration and build steps using the DaVinci DVEVM software
package. A small kernel feature set was selected and an http server package was added to a RAM disk to
use as the root file system. The kernel and RAM disk were subsequently flashed to the NOR flash
memory, where u-boot, the boot loader, also resided. You then started this system and demonstrated that
a web browser can connect to the DVEVM running this kernel and http server.
As mentioned in the abstract, this type of setup can be used as a starting point for an embedded Linux
system development with the DaVinci DM644x EVM. Other features can be added, such as:
• NOR flash file system, like a jffs2 file system, to provide persistent local storage.
• The V4L2 driver, so that video images can be captured and compressed using a encoder running on
the DSP of the DM644x device. This can turn the DVEVM into a video server.
8 References
• Davinci-DM644x Evaluation Module Technical Reference, Spectrum Digital, 508165-0001. For the
latest version visit the Spectrum Digital web site at www.spectrumdigital.com
• DVEVM Getting Started Guide (SPRUE66). For the latest version of the software, check the
www.ti.com/dvevmupdates site.
Appendix A
<STYLE TYPE="text/css">
BODY,H1,H2,H3,H4,H5,H6,P,CENTER,TD,TH,UL,DL,DIV {
font-family: Geneva, Arial, Helvetica, sans-serif;
}
H1 {
text-align: center;
}
CAPTION { font-weight: bold }
</STYLE>
</HEAD>
<BODY>
<table width=100%>
<tr>
<td bgcolor="black" width="1"><a href="http://www.ti.com"><img border=0
src="tilogo.gif"></a></td>
<td bgcolor="red"><img src="titagline.gif"></td>
</tr>
</table>
<H1>Welcome!</H1>
<P>
DaVinci Technology from TI makes the next generation of digital video and
audio end-equipment applications possible. Learn more at The DaVinci Effect
<A HREF="http://www.thedavincieffect.com">website</A>.
</P>
<P>
This web page is being served from an HTTP server running on the
ARM926 processor of the DM6446 SoC on the DaVinci DVEVM board. For the
latest news and software updates on the DVEVM, see the DVEVM
<A HREF="http://www.ti.com/dvevmupdates">website</A>.
</P>
<UL>
<LI> <A HREF="/cgi-bin/memory">Memory usage</A> </LI>
<LI> <A HREF="/cgi-bin/log">Kernel boot log</A> </LI>
<LI> <A HREF="/cgi-bin/config">Kernel Config options</A> </LI>
</UL>
</BODY>
</HTML>
EOF
echo
echo "# free -b"
free -b
echo
echo "# ps -el"
ps -el
2. Edit a file called memory and add the following script lines to create the kernel boot log script :
#!/bin/sh
EOF
echo
echo "#dmesg"
dmesg
3. Edit a file called memory and add the following script lines to create the kernel config options script :
#!/bin/sh
EOF
rm -rf /tmp/config*
cp /proc/config.gz /tmp
gzip -d /tmp/config.gz
cat /tmp/config
4. Make the scripts executable:
chmod +x memory
chmod +x log
chmod +x config