![]() |
|
||||
LynxOS User's Guide |
Creating Kernel Downloadable Images (KDIs)
LynxOS supports creating Kernel Downloadable Images (KDIs) with the mkimage utility. KDIs combine the LynxOS kernel and its associated applications into bootable images designed for easy downloading onto development targets.
Overview
Users can create application-ready embedded systems that include the LynxOS kernel and customized application into bootable images, which can then be implemented in one of the following ways:
- Burned into Flash
- Put onto distribution media (Floppy or CD-ROM)
- Booted over a network
- Maintained on hard drives
A LynxOS kernel image is a special boot file that always contains LynxOS, but may also contain a RAM-based file system (called a RAM disk) with minimal files for operating system functions and applications.
mkimage - the LynxOS KDI Creation Utility
The mkimage utility creates a single file - a bootable kernel downloadable image (KDI) - with some or all of the following LynxOS components:
- The LynxOS kernel
- A memory image of a RAM disk with a specified initial set of files
- The text segments of applications loaded at initialization time
The mkimage utility creates the image with attributes that users set in a specification file. By defining the fields in the specification file, users can create customized images for their specific development targets. For more information on specification files, see "Creating a Specification File".
The mkimage Syntax and Features
The syntax for mkimage is as follows:
- The mkimage utility lets users create bootable kernel downloadable images in any directory, with any number of specification files.
- Provided that all of the specification files are accessible, users do not need root privileges to run mkimage.
- The mkimage utility runs on both native LynxOS systems or cross development hosts.
LynxOS Kernel
Users can specify that mkimage should use the current LynxOS kernel in /lynx.os when building the KDI. However, users are most likely to create a custom kernel for use in their specific image. For example, users may choose to remove any unused device drivers from the kernel to reduce the size of the kernel, and as a result, of the final image.
(See Chapter 7, "Customizing the Default LynxOS Kernel Configuration" for more information on creating custom kernels.)
To save space, mkimage does not expand the bss section of the kernel in the image. The bss section is expanded and initialized to zeros by kernel code. The starting execution address is always 32 (0x20) bytes after the start of the image in memory.
Embedded File Systems
Embedded file system images can be one of two types:
- An image that may be used as the root file system contained in, or referenced by, the kernel image.
- A stand-alone file system image that may be mounted as an additional file system after LynxOS is up and running. The mkimage utility prepares both standalone, and kernel root file systems.
Embedded Root File Systems
Embedded root file systems can be one of the following three types:
The mkimage utility may be used to create a memory-based root file system. LynxOS accesses this file system using its RAM disk driver. The memory-based file system may physically reside in RAM, ROM or flash memory, depending on how the image is used and created for the target machine. Depending on the set of utilities put into the image, the image may function as a minimal application target or as a complete LynxOS development system.
If the major and minor numbers of a disk drive attached to a target system are specified, that drive may be used as the root file system for the kernel downloadable image (KDI). A disk-based root file system behaves identically to a kernel root file system booted from disk.
For kernels appropriately generated, the image does not contain or reference a file system.
Embedded Stand-Alone File System Images
An embedded standalone file system image is memory-based and may be accessed through the LynxOS RAM disk driver. The file system image may reside in any type of physical memory but is most likely to be in ROM or flash memory. No provision for moving the embedded file system image to RAM is provided by the LynxOS kernel. Application text segments may or may not be resident as required (see "Resident Text Segments" below).
Resident Text Segments
Applications may have resident (execute in place - XIP) text images in an embedded memory-based file system. In a normal file system, the text segment of an application is copied from the file system to RAM for execution. In a memory-based file system, the text segment is copied from the memory-resident file system to memory. Resident text applications do not require this copying process, which in turn, reduces run-time RAM memory requirements. The considerations that should be taken into account when deciding to use resident text are as follows:
- The type of memory the resident text is in
- Required execution speed
- RAM constraints
- Type of embedded file system
When the execution speed of the application is most important, the text of the image should reside in RAM, because, in general, any type of ROM is slower than RAM. There are several ways to accomplish this, depending on how the KDI or File System Image (FSI) is specified, and the type of memory the image resides in.
When the application is in the root FSI, and the KDI is in RAM, resident text should be used to ensure optimal execution speed and RAM conservation.
When the application is in the root FSI and the KDI is in some sort of ROM, the text may or may not need to be resident. When the text is specified as resident and text=ram is also specified, the resident text of the application (and all other resident text applications) is copied to RAM by the kernel during kernel initialization. When the text is not specified resident, the kernel loads the applications text to RAM from the file system at execution, identically to the application text residing on a disk drive. Since there is no provision to move resident text segments to RAM in a standalone FSI, a non-resident text segment is the only way to have the application run out of RAM from a standalone FSI residing in some sort of ROM.
When the root or standalone FSI resides in ROM and execution speed is a priority, leaving the application text segments in the non-resident files system conserves the greatest amount of memory. This causes the kernel to load the text segments on demand into RAM from the FSI. Alternately, when the root FSI resides in RAM, using resident text for applications conserves the greatest amount of memory.
Creating a KDI Image
Procedure Overview
The same basic steps are used to create images for the entire range of boot applications, for network booting to ROM booting:
- Configure a LynxOS kernel with the desired functionality.
- Create a specification file for mkimage that defines the LynxOS kernel to use and any applications to include.
- Run mkimage.
- Test the image.
- Put the image into the target environment.
For information on network booting the image, please read "Network Booting Diskless Clients with LynxOS" in the LynxOS Networking Guide.
The following steps detail creating a Kernel Downloadable Image (KDI). These steps are also explained in the subsections that follow:
- Enable the RAM disk driver in CONFIG.TBL.
- Make any other modifications to files such as uparam.h and Makefile.
- Create a new kernel with make a.out.
- Create a specification file with desired attributes.
- Run mkimage.
For information on creating a remotely bootable kernel (including sample scripts), see "Network Booting Diskless Clients with LynxOS" in the LynxOS Networking Guide.
Enabling the RAM Disk Driver
To enable the RAM disk driver, users must uncomment (by removing the # sign) the line I:ramdisk.cfg in the CONFIG.TBL file.
Modifying Kernel Parameters
One way to reduce the size of a kernel is to remove all superfluous drivers; see Chapter 7, "Customizing the Default LynxOS Kernel Configuration" for examples.
Creating a Specification File
The example specification file in the mkimage.spec man page can be used as a template for creating a specification file.
Some important attributes of mkimage.spec are as follows:
Testing Kernel Images
Users can use the LynxOS preboot utility to directly test the kernel images made with mkimage (see the preboot man page for the specific commands used on different platforms). For example, to test the kernel image /tmp/test/images/image1 created on a LynxOS x86 machine, perform the following steps:
Booting KDIs
The following sections provide details on:
Booting Images over a Network
To network boot LynxOS (also called to netboot), the image file is stored on a remote server and copied over the network into the RAM of a remote node by the firmwareresident TFTP boot code. Generally, the node is diskless.
Because everything is in RAM, the boot code gives control to the loaded operating system, which in turn, configures the attached RAM disk as its root file system. In this case, because all the executables are in RAM, it is useful if they are executed directly without being copied again into RAM. Thus, the TEXT segments of the executables are loaded as part of system initialization at boot time, rather than on demand from the root file system.
In the remote boot configuration, the RAM memory map is sequential, as shown in the figure below:
INT Vectors OS TEXT Segment OS DATA Segment OS bss Segment OS Symbols RAM Disk File System Application TEXT Segments
Example RAM Memory Map
Booting Images from ROM
The firmwareresident ROM boot code always passes control to the ROM-based kernels. At this point, depending on the options defined in the specification file, all or portions of the image are moved to RAM. LynxOS always moves the DATA and bss sections to RAM.
LynxOS sets up the memory map such that some portions are mapped into ROM and other portions are mapped into RAM. This is required in order to fully utilize the contents of ROM, without copying them into RAM. The previous figure shows an example of this mapping scheme. The LynxOS kernel text segments, root file system, and resident text segments are all in ROM, as shown in the figure below.
![]()
Example Memory Map ConfigurationAs shown in the figure above, the first pages, containing the interrupt and exception vectors, are mapped into RAM. The next few pages are mapped into ROM for the OS TEXT section. The following few pages are mapped into RAM for the OS DATA section (copied from ROM), for the OS bss section (initialized in RAM), and for OS symbols (copied from ROM). The root file system and resident TEXT segments are mapped to ROM.
If the root file system is readonly and the application needs a writable file system, the image must contain a script to create a writable RAM disk. The script should invoke the mkramdisk utility to create the writable RAM disk after the system is up and running.
See also the section "Creating Bootable Installation Media".
KDI Build Templates
To simplify the KDI development process, LynuxWorks provides a KDI build template directory, and a tar file (xx.kdi.tar.gz) of the KDI build template, on the ODE CD-ROM. The build template and the tar.gz files are located in the kdi and tar_images directories, respectively.
The kdi directory allows users to easily build their own KDIs for execution on target hardware. A KDI build template essentially consists of all the binary and source files required to develop a custom application for the user's target system using LynxOS.
The /demo/demo.bsp_name and tar_images/xx.demo_bsp_name.tar.gz directories have prebuilt versions of these KDIs, which can be loaded onto a user's system for evaluation and demonstration.
The sections that follow demonstrate how to set up a KDI project area, build a KDI, and download and execute it on a target. Because the project scripts are written in Bourne Shell, these build steps can be followed on any cross development or native development system.
Template Conceptual Overview
LynuxWorks provides KDI directories to give users a set of templates from which they can jump-start their own development of KDIs. The scripts automate the process of creating a project directory, copying a kernel build directory, installing the appropriate device drivers, building the kernel, selecting the appropriate files from the LynxOS distribution, and generating a KDI.
Included KDI Build Templates
The following table describes the KDIs that are provided with LynxOS.
Build Template Summary Contains development and networking utilities that provide a minimal configuration for development. Includes the following utilities:The developer demo can be used with host system IDEs VisualLynux and CodeWarrior. The Developer KDI is documented in the section "Example--Building, Booting, and Using the developer KDI". Simple configuration demonstrating a full kernel, RAM/ROM file system and a small hello_world.cpp applicationSince this is a minimal KDI, users must power down the system to end the demo. This KDI contains basic networking and disk utilities that can be loaded onto a target board with FTP.install.kdi performs these steps:1. Determines what disk you have2. Partitions the disk using mkpart.3. Prepares a file system on the disk (if needed) and mounts it. Starts disk swapping (if needed).4. Uses FTP to retrieve tar images.5. Extracts tar images.5. Makes device nodes and sets up networking. This KDI creates a simple TCP/IP configuration, demonstrating the use of rlogin.
On the target board, boot the KDI and log in as root. Use rlogin to log into a system on the network. Use either the hostname (if available in /etc/hosts) or IP address:rlogin <hostname | ip_address>From another system, rlogin to the target. This KDI provides a basic root file system for a target board. This KDI does not contain a RAM disk file system, but boots directly from the hard disk instead. The KDI defaults to mount /dev/ide.2a. If the file system requires a different device, the KDI must be rebuilt to use that device. This KDI demonstrates the use of the WISH shell to create an X Windows-based user interface to the target board. A simple interactive window is displayed to let the user browse several files on the file system.
Use the following instructions to set up tkwish:1. On the target board, set the DISPLAY variable to point to the X server. If there is an entry in the /etc/hosts file for the X server machine, use the hostname of the system. Otherwise, use the IP address:DISPLAY=<hostname | ip_address>:0.0export DISPLAY2. On the X server, enable remote clients:xhost +3. On the target board system, type demo.tkwish.4. On the X server use the mouse to point and click. This KDI provides an interactive demonstration of processes and threads for LynxOS. Type q to quit the demo.
kdi Directory Structure
The kdi directory includes the following files and directories:
KDI Build Directories
Additionally, there is a distinct ordering of the KDI build subdirectories. LynuxWorks uses the naming scheme xy.name, according to functionality and complexity. x, y, and name are defined as follows:
Restrictions
This demonstration harness assumes that a single user is building the KDI. It also assumes that the building of demo KDIs is done one at a time, since all demo KDIs share the same BSP directory where kernels are built; therefore, two KDI directories cannot be built in parallel.
Getting Started
A shell script, PROJECT.sh, is provided to automate the setup process. Before running this script, users must have already installed LynxOS from the distribution CD-ROMs onto the system's hard disk, or have mounted it from a CD-ROM; and have sourced the SETUP.bash or SETUP.csh scripts provided.
These scripts set up the PATH environment variable, and also set ENV_PREFIX to point to the distribution directory. ENV_PREFIX must be set correctly for PROJECT.sh to work.
To set up ENV_PREFIX, source the SETUP.bash or SETUP.csh scripts provided in the LynxOS release directory. To verify that ENV_PREFIX is set correctly, enter the following command, which lists the LynxOS distribution:
If ENV_PREFIX is set correctly, then execute the PROJECT.sh script by entering the following command:
The following screen output is displayed:
Enter a location on disk where the user has write permission (/tmp/newproj is the default) with at least 10 MB of free space available (30 MB is recommended). The following output is displayed:
If a machine name and an IP address for the target board has been selected, enter y. The PROJECT.sh script goes through the process of modifying the rc.network file for the specified target. If n is entered, then the rc.network file that gets configured into the system's KDIs interactively prompts the user for the machine name and IP address at boot-time as follows:
Once all questions have been answered, PROJECT.sh proceeds to set up the customized KDI build environment, copying the appropriate files.
Building KDIs
To begin building KDI demos, change the working directory to /tmp/newproj/11.hello, and issue a make all command; the following steps are executed:
This step creates a local copy of CONFIG.TBL, which is used by the kernel Makefile to configure device drivers as either in or out. This CONFIG.TBL file is copied to the local Board Support Package (BSP) directory (where the kernel is linked) each time the user issues a make command in this /tmp/newproj/ll.hello directory.
This step creates a local copy of the uparam.h header file. This file is used to specify the size of user-modifiable kernel data structures and resources.
Like CONFIG.TBL, the uparam.h file is copied to the local BSP build directory each time a make command is issued in the /tmp/newproj/ll.hello directory.
This is a hook that allows a KDI build directory to do any special local processing. Look at the desc.* file for details.
This step changes directory to the ./bsp.* directory, and makes the kernel, using the CONFIG.TBL and uparam.h files from the KDI build directory.
This step is run from within the KDI build directory. The mkimage tool is invoked using the KDI mkimage specification file to pull together the appropriate kernel components and applications.
Look at hello.kdi in /tmp/newproj. An output similar to the following is displayed:
The KDI can now be downloaded and executed on the target. For more information on demo KDIs and loading KDI images onto the target, see the appropriate LynxOS Board Support Guide.
Example--Building, Booting, and Using the developer KDI
The Developer KDI includes development and networking components that provide a development environment on a target board. This section describes how to create, boot, and user the Developer KDI. This example uses the following configurations:
Parameter Host Target Platform Red Hat Linux 7.2
LynxOS 4.0 Cross Developmentpc_680 Force PowerCore 680 Hostname IP Address Ethernet Address Not needed.
Configuring the Developer KDI
The default configuration of the Developer KDI contains many utilities that provides a wide range of functionality for a variety of development tasks. The default configuration of the Developer KDI can change by editing the developer.spec file to add or remove functionality in the KDI.
Removing Unnecessary Components
The size of the Developer KDI demo may be too large for some systems. The default configuration is close to 10 MB. Unnecessary components can be removed from the default KDI image by commenting out the lines in developer.spec and rebuilding the kernel.
Enabling Required Components
Several components are not included in the default KDI. To enable the following components, uncomment the required lines in the developer.spec file:
- Linux ABI Compatibility Layer (multiple files)
- SpyKer Kernel Event Trace Analyzer (spyker target file)
- Total View
- VisualLynux
- CodeWarrior
Check the developer.spec file and uncomment any files that are required by these utilities to enable them in the Developer KDI.
Rebuilding the KDI
After editing the developer.spec file, rebuild the kernel.
Configuring the Linux Cross Development Host
TFTP is required by the target to load the developer.kdi. Use the following instructions to enable tftp on the host system:
- In the disable field, type "no" to enable tftp.
- In the server_args field type "/tftpboot". The following provides a sample tftp file.
Sample TFTP Configuration File
- Restart the xinetd services:
Booting the KDI
At the PowerBoot> prompt, type in the following command to netboot the KDI:
For this example, type the following:
Using the KDI
The Developer KDI can be used in a variety of ways. With the Apache component enabled in the developer KDI, a browser can open an http connection to the target. For example:
![]()
Apache Web Server Running on TargetThis HTTP demonstration provides an example of the different types of development that can be done on the target.
Default Usernames and Passwords
The Developer KDI includes user accounts used to access the target board. LynuxWorks IDEs VisualLynux and CodeWarrior can connect to the target board and perform various development tasks. The following table provides the user name and passwords for these utilities:
Default Username and Passwords in the Developer KDI Component Username Password FTP VisualLynux CodeWarrior TotalView
ROMing Issues
The tools and steps used to burn an image into a PROM are specific to the target hardware. Depending on the PROM burner and target hardware, users may be able to burn the image file as is (with no conversion to an intermediary file format) into a PROM. Refer to the specific hardware documentation for more information.
The GNU objcopy utility may be used to convert the image to the file format required by the user; see the objcopy man page for further information.
Generating PROM Images on x86 Systems
Building the Jump Code
BIOS limitations on the x86 architecture require that a small object module, rkjump, be used to boot up and load a LynxOS kernel from ROM. It must be available within the address range 640 KB to 1 MB at system power up. On most BIOS types, rkjump must reside in the address range 0xC0000 to 0xDFD00 on a 0x200 byte boundary.
After taking control from the system BIOS, the rkjump module initializes the Segment Descriptor Registers, sets the CPU to protected mode, and transfers control to the ROM segment containing the LynxOS image.
rkjump is very specific to the memory architecture and must be tuned to the specific target's needs. The sources and build environment for rkjump are in /src/bin/rkjump386. Before building the rkjump module, users must define the kernel image ROM address in the rkconfig.h file in the /src/bin/rkjump386 directory.
For example, if the kernel image has been created with a load address of 0x00100000, users must specify an address of + 0x20 in /src/bin/rkjump/rkconfig.h. The rkjump module then needs to be rebuilt by entering the following commands:
Change the value of RKJUMP_ADDRESS as follows:
Exit the vi text editor, and enter the following commands:
Converting the Jump Code
After building the customized rkjump for the image being created, use the GNU objcopy utility to prepare the file for transfer to ROM.
Converting the Kernel Image
Convert the kernel image created with mkimage into hex format using the GNU objcopy utility.
Creating Bootable Installation Media
LynxOS facilitates creating bootable installation floppy disks for x86 platforms, and bootable CD-ROMs for x86 and PowerPC platforms; "Creating a Bootable x86 Floppy" and "Creating a Bootable x86 or PowerPC CD-ROM" below detail this, respectively.
Creating a Bootable x86 Floppy
LynxOS users can create bootable LynxOS installation floppies for x86 systems on formatted 1.44 MB disks (for more information on formatting floppies, see "Formatting Floppy Disks" and the fmtflop man page).
To create a bootable LynxOS installation floppy disk, perform the following steps:
- Place a formatted 1.44 MB floppy disk in the x86 system's floppy drive.
- Run the build script by entering the following command line:
The /sys/romkit/installation/Build script assumes that no file systems are mounted on the /mnt directory. Users need be sure that /mnt is available for use before using the script. If a file system is mounted on /mnt, the following command unmounts it:
For more information on mounted file systems, see the mount man page.
Creating a Bootable x86 or PowerPC CD-ROM
LynxOS users can create a bootable LynxOS installation CD-ROM for either x86 or PowerPC systems.
To create a LynxOS installation CD-ROM for either x86 or PowerPC platforms, perform the following steps as root:
Creating CD-ROM Image on Host
- Create a directory on a file system partition that has enough free disk space to unload all of the desired tar.gz image files by entering the following command:
- Locate the desired tar.gz image files (originally in the /tar_images directory on the ODE CD-ROM). The following are the required tar.gz image files:
bsp_name is the type of Board Support Package (BSP) and xxxxx is the LynuxWorks naming scheme for the KDI build subdirectories. (See "KDI Build Directories".)
- Change the working directory to /media/dev and create device nodes in /media/dev with the following command:
- Change the working directory back to /media and copy the kernel file located in /media/sys/lynx.os/a.out to /media/lynxos:
Creating the CD-ROM
- Ensure that the CD-ROM is read as bootable by entering the following command (where platform is one of either x86 or ppc):
- Create the ISO formatted image using the mkisofs command (see the mkisofs man page for further information):
- Use the cdwrite utility to write the bootable iso_image to a recordable CD-ROM (see the cdwrite man page for further information) by entering the following command:
$ cdwrite -i iso_image -r -v -s speed cdr_device
![]() LynuxWorks, Inc. 855 Branham Lane East San Jose, CA 95138 http://www.lynuxworks.com 1.800.255.5969 |
![]() |
![]() |
![]() |
![]() |