3.1.7. Waf Tool HALCoGen

The tool is located in tools/waf-tools.

Implements a waf tool to use TI HALCoGen (https://www.ti.com/tool/HALCOGEN)

class f_hcg.NodeStructure(xml_file_path)

Bases: object

Holds all relevant information on generated files based on a HALCoGen configuration file

parse_xml()

Parses information on generated files from the HALCoGen configuration file.

f_hcg.configure(conf)

configuration step of the TI HALCoGen Code Generator.

  1. checks wether the platform is Win32 or not, as HALCoGen is only supported on Win32.

  2. searches for the HALCoGen program

  3. Adds the include path of the F021 Flash API to INCLUDES

f_hcg.fix_gen_hal_incs(self)

Add path to HALCoGen generated header files to every build

class f_hcg.hcg_compiler(*args: Any, **kwargs: Any)

Bases: waflib.Task.

Class to implement running the HALCoGen code generator

color = 'PINK'

color in which the command line is displayed in the terminal

Type

str

ext_out = ['.h', '.c', '.asm']

task produces headers therefore it must run before c-tasks

Type

list of string

keyword()

displayed keyword when generating sources from a HALCoGen project

run()

Runs the HALCoGen code generator

  1. Copy the HALCoGen sources to the build directory

  2. Run HALCoGen

  3. Get CPU clock frequency that is set by HALCoGen from FreeRTOSConfig.h and copy it to our configuration file

  4. Copy the HALCoGen sources again to the output directory. This needs to be done, as HALCoGen re-writes the timestamp of the HALCoGen file when the tool is run. With this step the sources and build directory are synchronized.

vars = ['HALCOGEN', 'HALCOGEN_SRC_INPUT']

variables this task depends on

Type

list of string

f_hcg.process_hcg(self, node)

creates HALCoGen task if a hcg input file and a corresponding dil file exists and binds it to the f_hcg.hcg_compiler class.

See Fig. 3.4 for a simplified representation of how the input output relation is calculated.

digraph HCG_AND_DIL_TO_SOURCES {
    compound=true;
    rankdir=LR;
    nd_halcogen [label="HALCoGen.exe", style=filled, fillcolor=green];
    nd_hcg          [label="*.hcg", style=filled];
    nd_dil          [label="*.dil", style=filled];
    nd_gen_sources  [label="source/*.c", style=filled];
    nd_gen_headers  [label="include/*.h", style=filled];
    nd_cpu_freq     [label="include/config_cpu_clock_hz.h", style=filled];
    nd_log          [label="*.log", style=filled];
    subgraph cluster_cmd {
        label = "Command Line";
        rank=same;
        nd_input           [label="HALCOGEN_SRC_INPUT"];
    }
    nd_halcogen -> nd_input         [lhead=cluster_cmd];
    nd_hcg      -> nd_input         [lhead=cluster_cmd];
    nd_dil      -> nd_input         [lhead=cluster_cmd];
    nd_input    -> nd_gen_sources   [ltail=cluster_cmd];
    nd_input    -> nd_gen_headers   [ltail=cluster_cmd];
    nd_input    -> nd_cpu_freq      [ltail=cluster_cmd];
    nd_input    -> nd_log           [ltail=cluster_cmd];
}

Fig. 3.4 Input-output relation of hcg and dil file and corresponding output files

A copy of the FreeRTOS sources is provided in the repository. Therefore the generated FreeRTOS sources are not needed and these files must be removed as otherwise the wrong files may be included.

The only information needed from the generated sources is the configCPU_CLOCK_HZ. This information is extracted from the sources (see hcg_compiler.run() for details) and written into a configuration header. This configuration header is config_cpu_clock_hz.h.

Raises

ConfigurationError – Raises an error that stops the build if no corresponding .dil file is found.