Partager via


Determine Module or File Size in ROM (Compact 2013)

3/26/2014

This topic discusses how to determine the size of a file or module in ROM.

The sizes of the modules and files that you see in the flat release directory might not be the same as they are in ROM. During creation of the run-time image, extra information is stripped from modules, and their addresses are modified for loading in the target device. In addition, files are often compressed in ROM.

Module and File Size Information Sources

Two sources of module and file size information are available: nk.bin and the flat release directory (RelDir). Later sections in this topic discuss the advantages and disadvantages of both.

You can view nk.bin information in two ways: with the Viewbin Tool and with Platform Builder. The Viewbin tool provides the same information as Platform Builder, but as a command-line tool it can be incorporated into build scripts, and you can use its output in subsequent reports or automated analysis tools. On the other hand, you may find Platform Builder easier to use because it is built into Visual Studio.

Tip

To create a text file of the contents of any of the nk.bin nodes in Platform Builder, right-click the node and select View as Text.

Find the Size of a Module

The sizes of the modules listed in the flat release directory might not be the same as the sizes of the modules as they appear in ROM. This is because the build system parses some modules into sections, fixes up their addresses, and possibly distributes their contents differently in ROM than in the original file.

NK.bin

You can determine the ROM footprint of individual modules directly from nk.bin by extracting module information from nk.bin into an object report. The object report contains detailed information about all of the individual modules and files. To generate the report, use Viewbin with the –o command-line option.

The following object report excerpt describes ipconfig.exe.

Analyzing ROM Size - ModuleInfo

 

The time stamp and file size of ipconfig.exe are identical to Viewbin output when it is run with the -t command-line option. (These values are also the same as the ipconfig.exe file information in the flat release directory.) To generate additional information that you can use to calculate the exact amount of space that ipconfig.exe occupies in ROM, use the -o option.

When Makeimg fixes up a module, it may spread the module out in ROM by dividing it into sections, where each section corresponds to a region of memory. In the Viewbin -o report, the details for each module include an entry for object count (e32_objcnt), which indicates the number of sections for that module. This is the number of areas in which Makeimg spreads that module out within ROM.

The Viewbin -o report then lists some information for each section of the module: o32_rom[0], o32_rom[1], and so on.

Each section contains an entry for physical size (o32_psize), which is the exact size of that region in ROM. You can add the sizes to obtain the exact ROM footprint of the module. The preceding excerpt shows that ipconfig.exe is spread into two regions of ROM. The sizes of the two regions are 0x4000 bytes and 0x112 bytes, respectively, which makes the total size 0x4112 (16,658 bytes).

Tip

You could create a tool that parses the report and adds the o32_psize values so that you can list the total ROM footprint size for each module.

 

RelDir

You can also look at the module size in the flat release directory, but be aware that when a module ends up in ROM, its size is different than its original size in the flat release directory. This occurs for two reasons:

  • Information removal. The Makeimg step removes the portable executable (PE) header and section table before it does the fix-up. Because Makeimg adds only the useful information to the ROM image, the size of the module is reduced a bit.
  • Page alignment. In ROM, the page size is 4 KB. Therefore, if the .text section of a module is 4 KB + 1 byte, for example, it occupies 8 KB in ROM. This factor can increase the module size, in this case by nearly a factor of two.

File size tradeoffs

For files listed in the FILES section of ce.bib, the size in ROM is more straightforward; it depends only on whether a file is compressed:

  • If a file is uncompressed, its size in the flat release directory is the same as in ROM.
  • If the file is compressed, its footprint in ROM is smaller.

Note

Using compression is a trade-off. When you use it, the file size in ROM is smaller, but the load time is longer because the kernel decompresses the file as it loads it into RAM.

Viewbin

You can find the exact size of compressed and uncompressed files by using Viewbin with the -o command-line option. The report generated with this option lists details for modules and files, with modules listed first and file information at the bottom of the report. There is one line for each file. The fourth column in the line shows the size of compressed files (an entry of 0 indicates that the file is uncompressed). The fifth column shows the uncompressed size of all of the files. The following excerpt provides an example of some of these details.

Analyzing ROM Size - FileInfo

 

In the preceding excerpt, the files wince.nls, tahoma.ttf, and menusel.wav are uncompressed. The other files are compressed. For example, the compressed size of ceconfig.h is 5,598 bytes. Before compression, it was 25,481 bytes (the file size in the flat release directory).

RelDir

You can find the size of uncompressed files in the flat release directory. However, note the following:

  • If a file is compressed, its size in the flat release directory is not the same as its size in ROM.
  • The flat release directory does not contain all of the files included in the ROM image. For example, font files appear in the %_WINCEROOT%\public\common\oak\files directory.

Platform Builder

The following procedure outlines how to view module or file information in Platform Builder.

To view module or file size in Platform Builder

  1. In Visual Studio, on the File menu, click Open, and then click File.

  2. In the Open File dialog box, navigate to the release directory for your project.

  3. Select nk.bin, and then click Open.

  4. On the NK.bin editor tab, select the (All files) node. The content pane displays a list of all files and modules in nk.bin, along with information about each, such as file name, file size, and section (MODULES or FILES).

See Also

Concepts

Analyze ROM Size