Bib file parsing for wince
Bib is called binary image Builder, bib files are used in the final makeimage phase of the wince compilation process, and the purpose of the bib file is to instruct the build system how to build a binary image. All bib files are merged into a ce.bib file, and the package tool Romimage.exe determines which files are eventually included in the wince image based on the descriptions in the bib file, and the bib file also determines the allocation of wince device memory, such as defining wince Image occupies which block of memory, which memory (Framebuffer) is used, and so on.
The bib file consists of 4 items: Memory,config,modules and files, and their functions are as follows:
⑴memory:
Defines the relevant settings for memory, typically in the 0\platform\smdkxx\files\config.bib file. The wince build system knows what memory is RAM, which memory is ROM, and how large it is, through the memories. The format of the memory entry is as follows:
MEMORY
NAME Start Address Memory Size Type
which
Name: This name of memory, there is no special rules, but it is best to use this name we can know the purpose of this memory, the name must be unique, such as the name of the following.
Start Address: Represents the start of this memory, expressed in hexadecimal numbers, such as the runtime image below the starting address of the memory used by NK is 0x8c200000.
Memory size: In hexadecimal numbers, such as 0x01800000 (24M) in Config.bib below, the size of the secondary memory needs to be specified according to the NK size of its own system, and if it is a Chinese system, this size should be increased.
Type: The types of this memory segment have the following optional types:
①fixupvar: Initializes the global variables in the kernel for the makeimage phase of WinCE compilation.
②nandimage: When creating an image with Binfs, the WinCE kernel on the NAND device redirects to the area in RAM, and when the system accesses that area (this block of RAM), BINFS is responsible for accessing the corresponding location on the NAND device. and return the data to the system, in fact, in the NAND device above the implementation of the XIP function. For example, the Development Board has NAND flash, then you can mark this memory as the Nandimage type. If bootloader supports BINFS, then the bin file placed in NAND flash can support local execution XIP (by default only nor Flash is supported for local execution), and this memory must also be aligned.
③ram: Specifies that this memory is RAM and defines the area of RAM used by the wince system, which wince system can use to execute programs and hold RAM file systems. This memory must be continuous, here is a point to note that from a hardware point of view, this block of memory can not span two SDRAM, that is to say, the entire area of space must be on a piece of hardware SDRAM.
④ramimage: Specifies that this memory is used to load the wince image (that is, nk.bin), and the image will be copied to this memory area after the wince is actually started. An image can have only one contiguous ramimage region.
⑤reserved: This area of memory will be reserved, generally used for framebuffer or DMA buffer, or a piece of shared memory for Eboot pass parameters to the wince system, wince will not use this memory.
⑥extension: Defines a region of wince image as the data region of the ROMHDR EXTENSION.
As shown in the Config.bib file below
The following is the Wince500\platform\smdk2440\files\config.bib file of our company's products
MEMORY
NK 8c200000 01800000 Ramimage
Ram 8da00000 04d00000 RAM
; Common RAM Areas
AUD_DMA 8c002000 00002000 RESERVED
DRV_GLB 8c010000 00010000 RESERVED
SD_DMA 8c028000 00008000 RESERVED
edbg 8c030000 00020000 RESERVED
CAMERA 8c087487 000a0000 RESERVED
DISPLAY 8c183000 0007d000 RESERVED
/*****************************************************************/
This section indicates that 24MB space starting from address 0x8c200000 is used to store runtime impact (Nk.bin); 77M memory from 0x8da00000 is a ram area that can be used by applications The memory from 0x8c002000 to 0x8c200000 is reserved, mainly for the sound and display of the DMA area.
/*****************************************************************/
⑵config: This is an additional option, typically defined in the Config.bib file, to tell the build system how to generate a run-time image in the following format:
CONFIG
Item=parameter
Item more commonly used are:
①autosize: The default value is on, and if wince image is in RAM, this option allows automatic allocation of RAM that is not used by wince image to the WinCE operating system, which is used as the RAM for the wince system.
②profile: Specifies whether the structure and symbols used for performance splitting (profile) are included in the wince image, and the default value is off.
③bootjump: Specifies the jump address of the system at startup and jumps to the address of the startup function by default.
④compression: Specifies whether the build system compresses the writable portion of the wince image. If this section is compressed, then the WinCE runtime compresses the decomposition into RAM and, if not compressed, copies the portion directly into RAM.
⑤kernelfixups: Specifies whether the build system will relocate the writable region of the kernel. The default is on to reposition the writable region of the kernel to the starting address of the RAM.
⑥ramflags: Specifies some bitmask of kernel attributes that can be combined
0x01: Disables on-demand paging so that a module is fully loaded into RAM before it is run.
0X02: Indicates disabling full Kernel (fully kernel mode).
0X10: Indicates that only files placed in the modules block in the bib file are trusted.
0x20: Indicates that the kernel does not empty the x86 TLB.
0x40: The DLL is loaded according to the address in the DLL's/base link option, so that the DLL can be loaded into a predefined address.
⑦romstart: Refers to the wince image's starting address in memory, such as the 0x8c200000 below.
⑧romwidth: Specifies the width of the data bus, which can be 8, 16, or 32.
8: Indicates that the build system divides the wince image into 4 files, which are stored in 8-bit byte.
16: Indicates that the build system will divide the entire wince image into two files.
32: Indicates that the build system will use the entire wince image as a file.
⑨romsize: Specifies the size of the wince image.
⑩fsrampercent: Defines the percentage of memory used by the file system, and the default value is 0x80808080.
Byte 0: The first 2MB, each 1MB contains a multiple of 4KB.
Byte 1: The first 2MB, each 1MB contains a multiple of 4KB.
Byte 2: The first 2MB, each 1MB contains a multiple of 4KB.
Byte 3: The remaining memory, a multiple of 4KB contained in each 1MB.
Part of the Config.bib file:
CONFIG
Compression=on
Kernelfixups=on
/**************************************************/
This code specifies the writable portion of the build system compression wince image and repositions the writable portion of WinCE image.
/***************************************************/*
IF Imgprofiler
Profile=on
ENDIF
IF Imgprofiler!
Profile=off
ENDIF
/*****************************************************/
If the environment variable Imgprofiler is set, the profile is started.
/*******************************************************/
IF imgtrustromonly
IF Imgnotallkmode
Romflags=12
/*************************************/
Represents disabling full Kernel (fully kernel mode) and trusting only files in the bib file that are placed in the modules block.
/***************************************/
ENDIF
IF Imgnotallkmode!
ROMFLAGS=10//Indicates that only files placed in the modules block in the bib file are trusted.
ENDIF
ENDIF
IF imgtrustromonly!
IF Imgnotallkmode
romflags=2//indicates disabling full Kernel (fully kernel mode).
ENDIF
IF Imgnotallkmode!
Romflags=0
ENDIF
ENDIF
romstart=8c200000
Romwidth=32
romsize=01500000
fsrampercent=0x08080808
⑶modules and files
These two lists all the modules and files included in the wince image, and how the modules and files are loaded into memory, as shown in the following format:
MODULES
Name Path Memory Type
Name: The filename of this file, such as the file name of a DLL or EXE file.
Path: is the full path and name of the file to be packaged, typically the release directory of the WinCE project.
Memory: Specifies which part of the memories that this file is placed in.
Type: Types of files, commonly used in the following categories:
①s: Represents a System file.
②h: Represents a hidden file.
③u: Indicates that this file is not compressed.
④d: Indicates that this file cannot be debugged.
⑤n: Indicates that this file is not trusted.
⑥m: Indicates that the on-demand paging is forbidden for this file.
The following content is part of the Platform.bib file
MODULES
; Name Path Memory Type
IF Bsp_nodisplay!
S3c2440disp.dll $ (_flatreleasedir) \s3c2440disp.dll NK SH
ENDIF Bsp_nodisplay!
/*****************************************************/
If the SMDK2440 DOS batch file under the xxx:\wince500\platform\smdk2440 directory is set to: Set Bsp_nodisplay = 1, then the build system will not be packaged S3c2440disp.dll to wince Image (Nk.bin).
/***********************************************************/
Backlite.dll $ (_flatreleasedir) \backlite.dll NK SH
Camera.dll $ (_flatreleasedir) \camera.dll NK SH
AVOUT.dll $ (_flatreleasedir) \avout.dll NK SH
/**********************************************************/
Based on the above, the build system packs the Backlite.dll, Camera.dll, and AVOUT.dll in the _flatreleasedir directory into WinCE image, puts them in NK memory, and designates them as system files and hidden files.
/**********************************************************/
FILES
; Name Path Memory Type
Events.wav $ (_flatreleasedir) \events.wav NK H
LoadGuid.exe $ (_flatreleasedir) \loadguid.exe NK U
PowerApp.exe $ (_flatreleasedir) \powerapp.exe NK U
Usbcnect.lnk $ (_flatreleasedir) \usbcnect.lnk NK U
Usbcnect.exe $ (_flatreleasedir) \usbcnect.exe NK U
The bib file supports conditional compilation, and we can optionally package some modules into the wince image by setting environment variables. Generally in the BSP, for some of the driver module environment variables we use if to determine the condition, and for the WinCE system module, is generally sysgen variable, should be used to judge the @cesysgen if.
Among the most common in our BSP development are Stepldr.bib, Eboot.bib, Config.bib, Platform.bib, and Project.bib, which include:
Project.bib: The file is configured primarily for the current OS Design.
Platform.bib: This file contains hardware-related files, mainly driver-based.
Config.bib: This file describes the memory configuration of the wince system.
Eboot.bib: This file describes the configuration of the wince system's eboot memory.
Stepldr.bib: This file describes the configuration of the wince system's nboot memory.
Paper 37:wince's bib file parsing