Boot Loader
3 Boot Loader .7 Configuring and Building Boot Loaders
3.7.6 Reconfiguring Boot Loader Memory Layout for 32-Bit VxWorks
There are several common cases for which you need to reconfigure the memory layout for a 32-bit VxWorks boot loader, which include the following:
■ If you create a custom boot loader, you will probably need to redefine the link address.
■ If you increase the size of the persistent memory region for a VxWorks image beyond the default, you must also reconfigure the boot loader’s memory layout with a persistent memory region of the same size. Doing so may also require adjusting the link address of the boot loader. (Persistent memory is used for error records and core dumps.)
■ If the VxWorks image is too big for the default boot loader memory layout, and would therefore overwrite the boot loader.
Figure 3-2 illustrates the relationship between the boot loader, VxWorks, and persistent memory in RAM. Note that for the IA architecture, the locations of the boot loader and VxWorks are reversed.
Redefining the Boot Loader Link Address for Custom Boot Loaders
In general, the link address for a custom boot loader must changed if the image is not the same size as the default boot loader image. If the boot loader image is larger, you need to be sure that it will not conflict with memory that has been
Figure 3-2 RAM Layout of Boot Loader, VxWorks, and Persistent Memory
Persistent
Boot Loader
VxWorks Image
loaded here
RAM
RAM_LOW_ADRS LOCAL_MEM_LOCAL_ADRS RAM_HIGH_ADRS
sysMemTop( ) LOCAL_MEM_LOCAL_ADRS + LOCAL_MEM_SIZE
Memory
(image + heap)
boot loader link address
VxWorks link address
3 Boot Loader 3.7 Configuring and Building Boot Loaders
reserved above it. If the boot loader image is smaller, you should move the link address upwards so as to not waste memory that would otherwise be unused.
As illustrated in Figure 3-2, the link address for a VxWorks image of any type (vxWorks, vxWorks_rom, and so on) is RAM_LOW_ADRS and the link address for a boot loader image of any type is RAM_HIGH_ADDRS.
A VxWorks image project (VIP), however, uses RAM_LOW_ADDRS as the link address regardless of the type of image you are creating (either the boot loader or VxWorks itself. That is, it uses RAM_LOW_ADDRS as the link address even if you are creating a boot-loader image with a boot-loader configuration profile.
You must therefore substitute the BSP’s value for RAM_LOW_ADDRS with the BSP’s value for RAM_HIGH_ADRS when you create a boot loader based on a boot-loader configuration profile. To do so, perform the following steps:
1. If the RAM_LOW_ADDRS and RAM_HIGH_ADRS link addresses are defined as macros in installDir/vxworks-6.x/target/config/bspDir/config.h, comment out those definitions. You must do so because definitions in config.h override definitions in CDF files.
2. If they are not already there, add the link address parameters to the appropriate BSP CDF file.
3. Set RAM_LOW_ADDRS to the value of RAM_HIGH_ADRS (using the values from config.h if they were not provided in a CDF file).
4. Then set RAM_HIGH_ADRS to (RAM_LOW_ADDRS+ maxBootAppImageSize).
The following example of CDF parameter definitions uses conditional statements to set the link addresses:
Parameter RAM_HIGH_ADRS { NAME Bootrom Copy region
DEFAULT (INCLUDE_BOOT_RAM_IMAGE)::(0x01E00000) \ (INCLUDE_BOOT_APP)::(0x02000000) \ (0x01C00000)
}
Parameter RAM_LOW_ADRS {
NAME Runtime kernel load address
DEFAULT (INCLUDE_BOOT_RAM_IMAGE)::(0x01C00000) \ (INCLUDE_BOOT_APP)::(0x01E00000) \ (0x00100000)
}
For information about creating and working with CDF files, see 19. Custom Components and CDFs.
NOTE: For most BSPs that define link address parameters in a CDF, they are in 20bsp.cdf, but for some they are in 10bsp.cdf.
! CAUTION: If link address definitions are not made in the correct file, the boot loader will not be configured properly, it will not load to the correct place in RAM, and the boot process will fail.
component provides support for persistent memory; for more information about persistent memory itself, see 18.2.2 Configuring the Persistent Memory Region, p.444.
If you increase the size of the persistent memory region for VxWorks beyond the default, you must also create and install a new boot loader with the same
PM_RESERVED_MEM value. By default the size is set to six pages of memory.
If you do not, the boot loader (image plus heap) overlays the area of VxWorks persistent memory that extends beyond its own when the system reboots, and any data that may have been stored in the overlapping area will be corrupted. For a simple illustration of this problem, see Figure 3-3.
Note that when you change the value of the PM_RESERVED_MEM for the boot loader, you need to change the value of RAM_HIGH_ADRS if there is insufficient room for the boot loader itself between RAM_HIGH_ADRS and sysMemTop( ). If you do so, also be sure that there is sufficient room for the VxWorks image itself between RAM_LOW_ADRS and RAM_HIGH_ADRS.
! WARNING: Not properly configuring the boot loader (as described above) could corrupt the persistent memory region when the system boots.
Figure 3-3 RAM Layout Snapshots
Persistent
Boot Loader Boot Loader Memory Layout
VxWorks Memory Layout
Area of VxWorks persistent memory overwritten by boot loader at reboot sysMemTop( )
RAM_LOW_ADRS LOCAL_MEM_LOCAL_ADRS RAM_HIGH_ADRS
sysMemTop( ) LOCAL_MEM_LOCAL_ADRS + LOCAL_MEM_SIZE
Persistent
VxWorks Memory
Memory
(image + heap)
(image + sys mem)
3 Boot Loader