sign_gsc_firmware: add functions to determine ihex module base address

With the advent of D2 memory layout scheme it became impossible to
hardcode the base address of various components of the D2 firmware
image. Luckily, the components are represented as binary blobs in
Intel ihex format, which allows to retrieve the base address of the
component from the ihex records.

The address is composed of two elements: the segment base supplied in
the record type 02 or 04, and the record offset into the segment,
supplied in the data record of type 0.

The segment address is expressed as a 16 bit value, the actual value
shifted right either 4 bits (in case of record type 02) or 16 bits (in
case of record type 04). The data record offset is also a 16 bit

The base address of the blob is calculated as

<segment address> + <first data record offset>

and is available from the first two records in the ihex module.

Detailed information of ihex file format can be found in .

TEST=with the next patch in the stack applied was able to successfully
     build a multicomponent ti50 image.

Change-Id: I135c2f9960f1f218532c82bafd7acbe362414fc9
Signed-off-by: Vadim Bendebury <>
Tested-by: Vadim Bendebury <>
Reviewed-by: George Engelbrecht <>
Commit-Queue: Vadim Bendebury <>
1 file changed