3.1.26. waf_tools.hexgen

Generation of Intel HEX files from linked ELF outputs.

This waf tool converts a linked ELF executable into an Intel HEX file using the TI armhex utility (ARMHEX). The HEX generation task is automatically appended after the link step for task generators with the cprogram feature when the TI ARM CGT toolchain is active and a hex linker script (linker_script_hex) is provided.

Before creating the task, the tool validates the integrity of the ELF linker script by comparing its MD5 hash against a known hash embedded in the first line of the hex linker script. This ensures that changes to the ELF linker script are intentionally reflected in the hex linker script.

3.1.26.1. Usage

  1. The tool is loaded and configured by waf_tools.ti_arm_cgt.find_hexgen():

    # in ti_arm_cgt.py
    @conf
    def find_hexgen(ctx):
        ctx.load("hexgen", tooldir=TOOL_DIR)
    
  2. In a build script, declare a task generator with a hex linker script:

    def build(bld):
        bld(
            features="c cprogram",
            source="main.c",
            target="main",
            linker_script=bld.path.find_node("app.cmd"),
            linker_script_hex=bld.path.find_node("app_hex.cmd"),
        )
    

    The linker_script_hex attribute points to the hex file linker script that controls how sections are mapped into the HEX output. The first line of this file must contain a comment with the MD5 hash of the ELF linker script content.

3.1.26.2. Dependencies

  • TI armhex utility (HEX environment variable)

  • TI ARM CGT toolchain (CC_NAME == "armcl")

Functions

add_hexgen_task(self)

Append a HEX-file generation task after the link step.

check_linker_script_hash(bld, linker_script, ...)

Verify that the ELF linker script content matches the expected hash.

configure(ctx)

Configure the Intel HEX generation tool.

Classes

hexgen(*k, **kw)

Task that converts a linked ELF file into an Intel HEX file.