Partager via


Filter BSP dirs, .bib, and .reg Files (Compact 7)

3/12/2014

By correctly filtering dirs, .bib and .reg files, you can create robust BSPs that work regardless of the Sysgen or catalog items that you select for your OS design. This is an important aspect of constructing a robust BSP.

How to Filter

While you will probably only have to write a few lines of filtering markup per driver or component, determining the correct lines is not easy. The algorithm is as follows.

For each driver/platform-specific component, perform the following:

  1. Examine the sources files in the component for libraries that the component uses.
  2. Look at the Cesysgen\makefiles in the public tree to determine the makefile rules that govern inclusion of the libraries in $(SG_OUTPUT_ROOT).
  3. Look at the Sysgen rules in Public\cebase\oak\misc to determine which modules trigger the makefile rules, and set appropriate conditions for the rules.

Filtering Example

This example applies this algorithm to Platform\iMX313DS\src\drivers\sdhc.

Look for Libraries in the Sources Files

The sources file here links with Sdcardlib.lib, Sdhclib.lib, and Sdbus.lib from $(_SYSGENOAKROOT). You must add a condition on MODULES variables that bring these libraries in. You must also investigate Sdhc_mxarm11_fsl_v1.lib and make sure that it does not depend on any additional MODULES. Sdhc_mxarm11_fsl_v1.lib is built in Platform\common\src\soc\Freescale\mxarm11_fsl_v1\SDHC. Fortunately, it does not link with any libraries. Therefore, you add no conditioning.

Determine the Makefile Rules

Next, determine which makefile rules bring in Sdcardlib.lib, Sdhclib.lib, and Sdbus.lib. Each of these libraries has a makefile rule whose name is that of the library: sdcardlib, sdhclib, and sdbus. In the makefile, the sdcardlib and sdhclib rules are set by default in the driverlibs rule. Therefore, they are always available, regardless of Sysgen settings. However, sdbus is not part of driverlibs or any other automatic inclusion rule (be careful not to confuse Sdbus.lib with Sdbus_lib.lib, the latter of which is included). Therefore, you must look for an sdbus module being set in Public\cebase\oak\misc.

Set the Conditions

In Public\cebase\oak\misc\winceos.bat, you can see that sdbus is added to the list of CE_MODULES when SYSGEN_SDBUS==1. Therefore, you must condition the driver on CE_MODULES_SDBUS. You must set conditions in the following three places:

  1. Platform\iMX313DS\src\drivers\dirs.

    # \@CESYSGEN IF CE_MODULES_SDBUS
        SDHC          \
    # \@CESYSGEN ENDIF CE_MODULES_SDBUS
    

    Condition the building of the sdhc directory. If you do not condition at this point, the build will fail when SYSGEN_SDBUS is not set. The link phase will fail when Build.exe tries to build the sdhc directory and finds that Sdbus.lib is not available.

  2. Platform\iMX313DS\files\platform.bib.

    ; @CESYSGEN IF CE_MODULES_SDBUS
        sdhc.dll        $(_FLATRELEASEDIR)\sdhc.dll                    NK  SHK
    ; @CESYSGEN ENDIF CE_MODULES_SDBUS
    

    Condition the inclusion of Sdhc.dll. If you do not condition at this point, the build will attempt to include Sdhc.dll, even when it has not been built (per the conditioning in the dirs file). The makeimg phase will fail because Sdhc.dll cannot be found.

  3. Platform\iMX313DS\files\platform.reg.

    ; @CESYSGEN IF CE_MODULES_SDBUS
    #include "$(_TARGETPLATROOT)\SRC\DRIVERS\SDHC\sdhc_arm11.reg"
    ; @CESYSGEN ENDIF CE_MODULES_SDBUS
    

    Condition the registry specific to Sdhc.dll. If you do not condition at this point, you will unnecessarily bloat the registry, and will also try to load Sdhc.dll when the image loads. This will not cause image boot failure, but it will consume extra cycles during boot.

See Also

Concepts

Improve The Build Process