Compartilhar via


Optimize Modules and Files (Compact 2013)

3/26/2014

This topic discusses ways to arrange your files in ROM for optimal ROM size and system performance.

During the build process, the Make Binary Image Tool (Makeimg.exe) uses a number of Binary Image Builder (.bib) Files to determine which modules and files to include in the OS image, and where to place these components within ROM. The build system merges all of the individual feature .bib files into the ce.bib file, which is in your flat release directory. Because the build places all of the files that are listed in the MODULES section and the FILES section of the ce.bib file into nk.bin, ce.bib is a good place to start investigating ROM usage.

For an overview of the build process, see Build System Overview. For more information about the ce.bib file, including the MODULES and FILES sections, see Ce.bib File and the ROM Image.

Arrange Files in ROM

You arrange your files in ROM by listing them in one of two sections of the feature .bib file — MODULES or FILES — and using the correct option parameters. It is important that you select the appropriate section for your code and data, because this choice affects the trade-off between ROM usage, RAM consumption, and performance.

The following table shows the sections of the .bib configuration file in which different file types belong.

Section

File types

Additional notes

MODULES

  • Code binaries
  • DLL files
  • Executable files
  • Uncompressed files

Executable files in the MODULES section that are not compressed are executed in place.

Files in the MODULES section are not compressed by default.

FILES

  • Audio files
  • Data files
  • Non-executable files
  • Resource DLL files
  • Bitmaps that are compressed by default

Managed code must be located in the FILES section because the kernel does not load managed code. Instead, the .NET Compact Framework opens managed code as a memory-mapped file.

Files in the FILES section are compressed by default.

You can improve OS response time and optimize memory usage by correctly managing OS files in the .bib configuration file. Keep in mind that there is always a trade-off between image size and memory usage. For example, you can reduce image size by placing all of your files in the FILES section of the .bib configuration file, because they are compressed by default. However, performance will be slower because the system must uncompress the files and, for executable files, link and load (locate) them, before use.

As you determine which section of the .bib configuration file to list a file in, consider the file type and how frequently the system accesses the file. If the system does not access the file frequently, do not compress it. Instead, use the file cache to keep the data in RAM so the system can access the data without accessing the actual file.

 

MODULES section

Makeimg strips extra information from the executable files listed in the MODULES section, and modifies addresses of executable modules for loading in the target device (a process referred to as fixing up) in ROM. You should place all of your executable files in the MODULES section. (It would not make sense to put non-executable files under MODULES because Makeimg cannot fix them up.) When you put your executable files in the MODULES section, you improve your system because:

  • Fix-up improves startup time. At run time when the OS starts, the kernel need not spend time relocating the modules.
  • Fix-up saves ROM. When Makeimg strips out the record-keeping parts of executable files, the size of the modules in ROM is reduced.

 

FILES section

By default, files in the FILES section are compressed, but you can choose to leave them uncompressed. To leave a file uncompressed, give it a U attribute in its .bib file.

Consider the following advantages and disadvantages of using compression:

  • Compression saves ROM. A compressed file occupies less space in ROM.
  • Compression impacts performance. If the OS uses a file frequently, and the file is compressed, the OS must repeatedly decompress the file at run time. You can reduce decompression time, and its impact on performance, by enabling the file cache.
  • Compression increases RAM consumption. Compressed files increase RAM consumption because the CPU must allocate memory to hold the decompressed data. When you tune the paging pools as described in Optimize Runtime Performance, you can balance ROM size and RAM usage by limiting memory consumption to a given size.

Note

Managed code is considered non-executable because it is not native code, so Makeimg cannot fix it up. Therefore, you should list managed code in the FILES section. For example, a .NET DLL file looks like an executable file, but it is not, and therefore should be listed under FILES.

In This Section

See Also

Concepts

Optimize ROM Size