GBL Parser#
GBL parser implementation.
Image parser for GBL files. Parses GBL files based on the GBL file format specification. Callbacks are used to present data and metadata contents of the GBL file to the bootloader.
Modules#
Enumerations#
State in the GBL parser state machine.
Functions#
Function for looking up and retrieving the parsing information struct associated with a particular GBL tag type / tag ID.
Initialize the parser's context.
Parse an image file to extract the binary and some metadata.
Verify the GBL certificate.
Write application data.
Macros#
GBL file is encrypted.
Parse custom tags rather than silently traversing them.
Some flags are public, some are internal to the parser.
GBL parser buffer size.
Bootloader/parser configurations.
Parser requires upgrade images to be encrypted, providing confidentiality, if true.
Parser requires upgrade images to be authenticated by the bootloader certificate, if true.
Parser requires rollback protection of applications, if true.
Defines the minimum application version that can be accepted.
Upgrade image contains application upgrade.
Upgrade image contains bootloader upgrade.
Upgrade image contains SE upgrade.
Upgrade image contains Delta upgrade.
Application upgrade should be applied from upgrade image.
Bootloader upgrade should be applied from upgrade image.
SE upgrade should be applied from upgrade image.
Enumeration Documentation#
GblParserState_t#
GblParserState_t
State in the GBL parser state machine.
| Enumerator | |
|---|---|
| GblParserStateInit | Initial state. |
| GblParserStateIdle | Idle state. |
| GblParserStateHeader | Parsing header tag. |
| GblParserStateBootloader | Parsing bootloader tag. |
| GblParserStateBootloaderData | Parsing bootloader tag data. |
| GblParserStateApplication | Parsing application tag. |
| GblParserStateMetadata | Parsing metadata tag. |
| GblParserStateMetadataData | Parsing metadata tag data. |
| GblParserStateProg | Parsing flash program tag. |
| GblParserStateProgData | Parsing flash program tag data. |
| GblParserStateEraseProg | Parsing flash erase&program tag. |
| GblParserStateFinalize | Finalizing file. |
| GblParserStateDone | Parsing complete. |
| GblParserStateEncryptionInit | Parsing encryption init tag. |
| GblParserStateEncryptionContainer | Parsing encryption data tag. |
| GblParserStateSignature | Parsing signature tag. |
| GblParserStateError | Error state. |
Function Documentation#
gbl_getTagParsingInfoFromTagId#
const GblTagParsingInfo_t * gbl_getTagParsingInfoFromTagId (uint32_t tagId)
Function for looking up and retrieving the parsing information struct associated with a particular GBL tag type / tag ID.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| uint32_t | [in] | tagId | The tag ID to be looked up. |
Returns
A pointer to the GblTagParsingInfo_t struct associated with tagId, or a NULL pointer if the provided tagId cannot be found.
parser_init#
int32_t parser_init (void * context, void * decryptContext, void * authContext, uint8_t flags)
Initialize the parser's context.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| void * | N/A | context | Pointer to context for the parser implementation |
| void * | N/A | decryptContext | Pointer to context for decryption of parsed file |
| void * | N/A | authContext | Pointer to context for authentication of parsed file |
| uint8_t | N/A | flags | Flags for parser support |
Returns
BOOTLOADER_OK if OK, error code otherwise.
parser_parse#
int32_t parser_parse (void * context, ImageProperties_t * imageProperties, uint8_t buffer, size_t length, const BootloaderParserCallbacks_t * callbacks)
Parse an image file to extract the binary and some metadata.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| void * | N/A | context | Pointer to the specific parser's context variable |
| ImageProperties_t * | N/A | imageProperties | Pointer to the image file state variable |
| uint8_t | N/A | buffer | Pointer to byte array containing data to parse |
| size_t | N/A | length | Size in bytes of the data in buffer |
| const BootloaderParserCallbacks_t * | N/A | callbacks | Struct containing function pointers to be called by the parser to pass the extracted binary data back to BTL. |
Pushes data into the image file parser to be parsed.
Returns
BOOTLOADER_OK if OK, error code otherwise.
parser_verifyCertificate#
int32_t parser_verifyCertificate (void * context, void * input, void * blProperties, void * shaState)
Verify the GBL certificate.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| void * | [inout] | context | GBL parser context |
| void * | [in] | input | Input data |
| void * | [in] | blProperties | Pointer to ApplicationProperties_t of bootloader |
| void * | [inout] | shaState | Pointer to Sha256Context_t used to store SHA256 of GBL certificate |
Note
The behavior of this function depends on the context state.
Returns
BOOTLOADER_ERROR_PARSER_PARSED if done parsing the current input buffer. BOOTLOADER_OK if input data is stored in the internal buffer. BOOTLOADER_OK if the certificate in GBL is accepted. BOOTLOADER_ERROR_PARSER_SIGNATURE if the certificate in GBL is rejected.
gbl_writeProgData#
int32_t gbl_writeProgData (ParserContext_t * context, uint8_t buffer, size_t length, const BootloaderParserCallbacks_t * callbacks)
Write application data.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| ParserContext_t * | N/A | context | GBL parser context |
| uint8_t | N/A | buffer | Input buffer containing data to be written |
| size_t | N/A | length | Size of input buffer |
| const BootloaderParserCallbacks_t * | N/A | callbacks | GBL Parser callbacks for writing data |
This function is called when parsing any tag with GblProg_t structured content.
Returns
Error code
Macro Definition Documentation#
PARSER_FLAG_PARSE_CUSTOM_TAGS
#define PARSER_FLAG_PARSE_CUSTOM_TAGSValue:
(1U << 5U)
Parse custom tags rather than silently traversing them.
PARSER_FLAGS_PUBLIC_MASK#
#define PARSER_FLAGS_PUBLIC_MASKValue:
PARSER_FLAG_PARSE_CUSTOM_TAGS
Some flags are public, some are internal to the parser.
PARSER_REQUIRE_AUTHENTICITY#
#define PARSER_REQUIRE_AUTHENTICITYValue:
(false)
Bootloader/parser configurations.
Parser requires upgrade images to be signed, providing authenticity, if true.
PARSER_REQUIRE_CONFIDENTIALITY#
#define PARSER_REQUIRE_CONFIDENTIALITYValue:
(false)
Parser requires upgrade images to be encrypted, providing confidentiality, if true.
PARSER_REQUIRE_CERTIFICATE_AUTHENTICITY#
#define PARSER_REQUIRE_CERTIFICATE_AUTHENTICITYValue:
(false)
Parser requires upgrade images to be authenticated by the bootloader certificate, if true.
PARSER_REQUIRE_ANTI_ROLLBACK_PROTECTION#
#define PARSER_REQUIRE_ANTI_ROLLBACK_PROTECTIONValue:
(false)
Parser requires rollback protection of applications, if true.
PARSER_APPLICATION_MINIMUM_VERSION_VALID#
#define PARSER_APPLICATION_MINIMUM_VERSION_VALIDValue:
(0UL)
Defines the minimum application version that can be accepted.
BTL_IMAGE_CONTENT_APPLICATION#
#define BTL_IMAGE_CONTENT_APPLICATIONValue:
0x01U
Upgrade image contains application upgrade.
BTL_IMAGE_CONTENT_BOOTLOADER#
#define BTL_IMAGE_CONTENT_BOOTLOADERValue:
0x02U
Upgrade image contains bootloader upgrade.
BTL_IMAGE_CONTENT_DELTA#
#define BTL_IMAGE_CONTENT_DELTAValue:
0x08U
Upgrade image contains Delta upgrade.
BTL_IMAGE_INSTRUCTION_APPLICATION#
#define BTL_IMAGE_INSTRUCTION_APPLICATIONValue:
0x01U
Application upgrade should be applied from upgrade image.
BTL_IMAGE_INSTRUCTION_BOOTLOADER#
#define BTL_IMAGE_INSTRUCTION_BOOTLOADERValue:
0x02U
Bootloader upgrade should be applied from upgrade image.
BTL_IMAGE_INSTRUCTION_SE#
#define BTL_IMAGE_INSTRUCTION_SEValue:
0x04U
SE upgrade should be applied from upgrade image.