Skip to main content

Commands description

This section contains descriptions for the following commands:

Shift

Shift segment to a specific address.

Inputs

NameTypeOptional/RequiredDescription
filestringrequiredInput hex file containing the segment to shift.
addressstringoptionalAddress of the segment that has to be shifted.
descriptionstringoptionalDescription for this field.

Outputs

NameTypeOptional/RequiredDescription
filestringrequiredPath to the output file.
addressstringoptionalThe new address of the segment.
descriptionstringoptionalDescription for this field.

Example

{    
"schema-version": 1.0,
"content": [
{
"name": "Shift command example",
"description": "Shifts a hex segment to a secondary address",
"enabled": true,
"commands": [
{
"command": "shift",
"inputs": [
{
"description": "CM33 Secure + CM33 Non-Secure application",
"file": "rram_3.hex",
"address" : "0x32030000"
}
],
"outputs": [
{
"description": "CM33 Secure + CM33 Non-Secure application shifted to secure region",
"address": "0x3202A000",
"file": "shifted_rram_3.hex"
}
]
}
]
}
]
}

Hex relocate

Relocates regions in the hex file to new address spaces. Relocates regions in the hex file to new address spaces. All segments within the specified region (from start to start + size) will be relocated to the new address (dest).

Inputs:

NameTypeOptional/RequiredDescription
filestringrequiredInput hex file containing the segment(s) to relocate.
regionsarrayrequiredRegions to relocate. An array of objects, each containing start, size, and dest fields.
descriptionstringoptionalDescription for this field.

Outputs:

NameTypeOptional/RequiredDescription
filestringrequiredPath to the output hex file.
descriptionstringoptionalDescription for this field.

Example:

{
"schema-version": 1.0,
"content": [
{
"name": "hex-relocate command example",
"description": "Relocates regions in hex file to new address spaces",
"enabled": true,
"commands": [
{
"command": "hex-relocate",
"inputs": [
{
"file": "input.hex",
"regions": [
{
"start": "0x08000000",
"size": "0x04000000",
"dest": "0x60000000"
}
]
}
],
"outputs": [
{
"file": "output.hex"
}
]
}
]
}
]
}

Hex segment

Extracts a segment from the hex file.

Inputs

NameTypeOptional/RequiredDescription
filestringrequiredPath to the input hex file.
addressstringrequiredAddress of the segment.
descriptionstringoptionalDescription for this field.

Outputs

NameTypeOptional/RequiredDescription
filestringrequiredPath to the file where to save the extracted segment.
descriptionstringoptionalDescription for this field.

Example

{
"schema-version": 1.0,
"content": [
{
"name": "Shift command example",
"description": "Shifts a hex segment to a secondary address",
"enabled": true,
"commands": [
{
"command": "shift",
"inputs": [
{
"description": "CM33 Secure + CM33 Non-Secure application",
"file": "rram_3.hex",
"address" : "0x32030000"
}
],
"outputs": [
{
"description": "CM33 Secure + CM33 Non-Secure application shifted to secure region",
"address": "0x3202A000",
"file": "shifted_rram_3.hex"
}
]
}
]
}
]
}

Merge

Inputs

This command requires two or more inputs of the same format.

NameTypeOptional/RequiredDescription
filestringrequiredPath to the file to merge.
descriptionstringoptionalDescription for this field.

Outputs

NameTypeOptional/RequiredDescription
filestringrequiredPath to the merged file.
formatstringoptionalFormat of the output file. Available values: ihex or bin.
addressstringoptionalStart address of the output hex file.
descriptionstringoptionalDescription for this field.

Example

{    
"schema-version": 1.0,
"content": [
{
"name": "Merge command example",
"description": "Merges two or more hex/bin files into a single file",
"enabled": true,
"commands": [
{
"command": "merge",
"inputs": [
{
"description": "CM33 Secure application",
"file": "./rram_1.hex"
},
{
"description": "CM33 Non-Secure application",
"file": "./rram_2.hex"
},
{
"description": "CM33 Secure + CM33 Non-Secure application",
"file": "./rram_3.hex"
}
],
"outputs": [
{
"description": "CM33 Secure + CM33 Non-Secure application merged to one file",
"format": "ihex",
"file": "./cmd_merge_3_files.hex"
}
]
}
]
}
]
}

Sign image

Signs the user application and converts it into MCUboot format. If the signing key is not provided, the result is the MCUboot formatted unsigned image. All the numeric values can be provided in a decimal (for example, fill-value: 255) or hexadecimal format (for example, fill-value: "0xFF").

Inputs

NameTypeOptional/RequiredDescription
filestringrequiredPath to the file to be signed or converted into MCUboot format.
descriptionstringoptionalDescription for this field.
signing-keystringoptionalECDSA or RSA private key used to sign the image.
header-sizestring, integerrequiredMCUboot header size.
slot-sizestring, integerrequiredMaximum slot size.
fill-valuestring, integeroptionalValue read back from erased flash. Default: 0. Available values: 0, 0xFF.
min-erase-sizestring, integeroptionalMinimum erase size. Default: 0x8000.
image-versionstringoptionalImage version in the image header. Default: 0.0.0.
security-counterstring, integeroptionalValue of security counter. Use the auto keyword to automatically generate it from the image version. Default: auto.
alignstring, integeroptionalFlash alignment. Default: 8. Available values: 1, 2, 4, 8.
pubkey-formatstringoptionalPublic key format in the image TLV: full key or hash of the key. Available values: hash or full. Default: hash.
pubkey-encodingstringoptionalPublic key encoding in the image TLV. Applicable values: der, or raw. Default: der.
signature-encodingstringoptionalImage signature encoding. Applicable values: asn1, or raw. Default: asn1.
padbooleanoptionalAdds padding to the image trailer. Pads the image from the end of the TLV area up to the slot size. boot_magic is always at the very end after the padding.
confirmbooleanoptionalAdds image OK status to the trailer. Pads the image from the end of the TLV area up to the slot size and sets the image OK byte to 0x01 (the eighth byte from the end). The padding is required for this feature and is always applied. boot_magic is always at the very end after the padding.
overwrite-onlybooleanoptionalUse overwrite mode instead of swap.
boot-recordstringoptionalCreate CBOR encoded boot record TLV. Represents the role of the software component (for example, CoFM for coprocessor firmware). Maximum 12 characters.
hex-addressstring, integeroptionalAdjust the address in the hex output file.
load-addressstring, integeroptionalLoad address for image when it should run from RAM.
rom-fixedstring, integeroptionalSet flash address the image is built for.
max-sectorsstring, integeroptionalWhen padding allow for this amount of sectors. Default: 128.
save-enctlvbooleanoptionalWhen upgrading, save encrypted key TLVs instead of plain keys. Enable when BOOT_SWAP_SAVE_ENCTLV config option was set.
dependenciesstringoptionalAdd dependency on another image. Format: ([image_ID],[image_version]), ... .
encryption-public-keystringoptionalECDSA public key used to generate the symmetric key for image encryption (ECIES schema). It must be the receiver's public key.
encryption-secret-keystringoptionalAn encryption key.
encryption-key-rolestringoptionalAn encryption key role. Specifies what the key is used for: - Image Encryption: Encrypts images for decryption in the XIP mode
- Key Wrapping: Acts as a Key Encryption Key (KEK) for AES Key Wrapping (AES-KW), ensuring secure key management.
Available values: XIP, AES-KW. Default: XIP.
encryption-addressstringoptionalStarting address for data encryption.
protected-tlvlistoptionalThe custom TLV to be placed into a protected area (the signed part). Add the 0x prefix for the value to be interpreted as an integer, otherwise it will be interpreted as a string.
tlvlistoptionalThe custom TLV to be placed into a non-protected area. Add the 0x prefix for the value to be interpreted as an integer, otherwise it will be interpreted as a string.
kdfstringoptionalKey derivation function name. Default: HKDF. Available values: HKDF, KBKDFCMAC.
remove-tlvlistoptionalRemoves TLV with the specified ID.

Outputs

NameTypeOptional/RequiredDescription
descriptionstringoptionalDescription for this field.
filestringrequiredPath to the signed and/or converted to the MCUboot format image.
formatstringrequiredFormat of the output file. Available values: ihex or bin.
unencryptedstringoptionalThe path where to save unencrypted image payload (bin). Specify this option if the image is encrypted and provide the unencrypted image to HSM because the signature is calculated on the unencrypted data.
nonce-outputstringoptionalThe path to a file where to save the nonce.

Example

{    
"schema-version": 1.0,
"content": [
{
"name" : "sign command example",
"description": "Signs the input file and converts it to the MCUboot format",
"enabled": true,
"commands": [
{
"command": "sign",
"inputs": [
{
"description": "Secure application",
"file": "./rram_1.hex",
"signing-key": "./some-key-ec-p256.pem",
"overwrite-only": true,
"header-size": "0x400",
"slot-size": "0x1000",
"fill-value": "0x00",
"min-erase-size": "0x200",
"pad": true,
"hex-address": "0x32005000",
"protected-tlv": [
{
"tag": "0x22",
"value": "0x12345678"
}
]
}
],
"outputs" : [
{
"description": "Signed secured application",
"format" : "ihex",
"file": "./rram_1_signed.hex"
}
]
}
]
}
]
}

Extract payload

The MCUboot formatted image consists of a header, a payload, a protected TLV area, and a non-protected TLV area. A header, a payload, and a protected TLV are the data that must be signed. A non-protected TLV area must not be included in a signature. This command extracts a part of an image to be signed.

Inputs

NameTypeOptional/RequiredDescription
filestringrequiredImage with MCUboot metadata.
descriptionstringoptionalDescription for this field.

Outputs

NameTypeOptional/RequiredDescription
filestringrequiredPath where to save the image to be signed (bin).
descriptionstringoptionalDescription for this field.

Example

{    
"schema-version": 1.0,
"content": [
{
"name": "Extract-payload command example",
"description": "Adds a signature to the MCUboot formatted image",
"enabled": true,
"commands": [
{
"command": "extract-payload",
"inputs": [
{
"description": "Path to the input hex file",
"file": "./hexs/rram_1_meta.hex"
}
],
"outputs": [
{
"description": "Name of output file",
"file": "./hexs/extracted.bin"
}
]
}
]
}
]
}

Add signature

Adds signature to the existing MCUboot format image.

Command name

add-signature

Inputs

This command requires two input files, where one is the MCUboot formatted image and the second is the signature.

NameTypeOptional/RequiredDescription
filestringrequiredPath to the image with MCUboot metadata
descriptionstringoptionalDescription for this field.
NameTypeOptional/RequiredDescription
filestringrequiredBinary file containing signature.
algorithmstringrequiredSignature algorithm. Available values: ECDSA-P256, RSA2048, RSA4096.
descriptionstringoptionalDescription for this field.

Outputs

NameTypeOptional/RequiredDescription
filestringrequiredPath to the output file.
formatstringrequiredFormat of the output file. Available values: ihex, bin.
descriptionstringoptionalDescription for this field.

Example


{
"schema-version": 1.0,
"content": [
{
"name": "Add-signature command example",
"description": "Adds a signature to the MCUboot formatted image",
"enabled": true,
"commands": [
{
"command": "add-signature",
"inputs": [
{
"description": "Unsigned bootloader in MCUboot format",
"file": "./hexs/bootloader_meta.hex"
},
{
"description": "Signature returned by HSM",
"file": "./hexs/signature.bin",
"algorithm": "ECDSA-P256"
}
],
"outputs": [
{
"description": "Final image signed with HSM",
"format": "ihex",
"file": "./hexs/bootloader_signed.hex"
}
]
}
]
}
]
}

Custom script

Executes system commands or other programs.

Command name

custom-script

Inputs

NameTypeOptional/RequiredDescription
command-linestringrequiredThe command line to be executed.
shellbooleanoptionalSpecifies whether the command will be executed through the shell. On POSIX with shell=True, the shell defaults to /bin/sh. Invoking via the shell does allow you to expand environment variables and file globs according to the shell's usual mechanism. On Windows with shell=True, the COMSPEC environment variable specifies the default shell. The only time you need to specify shell=True on Windows is when the command you wish to execute is built into the shell (for example, dir or copy). You do not need shell=True to run a batch file or console-based executable.
descriptionstringoptionalThe command description.

Outputs

None

Example

{    
"schema-version": 1.0,
"content": [
{
"name": "Custom-script command example",
"description": "Test template for the custom-script command",
"enabled": true,
"commands": [
{
"command": "custom-script",
"inputs": [
{
"description": "List detailed information about files and directories in the current directory",
"command-line": "ls -la",
"shell": false
}
]
}
]
}
]
}

Bin dump

Creates binary file from the hex string or random bytes.

Command name: bin-dump

Inputs:

NameTypeOptional/RequiredDescription
datastringoptionalThe hex string. Either data or random property must be specified.
randomstring, integeroptionalGenerate random binary of the specified length.
descriptionstringoptionalDescription for this field.

Outputs:

NameTypeOptional/RequiredDescription
filestringrequiredPath to the output bin file.
descriptionstringoptionalDescription for this field.

Example:

{
"schema-version": 1.0,
"content": [
{
"name": "bin-dump command example",
"description": "Creates binary file",
"enabled": true,
"commands": [
{
"command": "bin-dump",
"inputs": [
{
"description": "Hex string or random value",
"data": "0011223344556677889900AABBCCDDEEFF",
"random": null
}
],
"outputs": [
{
"description": "Output file",
"file": "output.bin"
}
]
}
]
}
]
}

Hex dump

Extracts data from the hex file and saves it to a binary file.

Command name: hex-dump

Inputs:

NameTypeOptional/RequiredDescription
filestringrequiredThe path to the hex file.
addressstring, integerrequiredAddress of the data in the hex file.
sizestring, integerrequiredSize of the data.
descriptionstringoptionalDescription for this field.

Outputs:

NameTypeOptional/RequiredDescription
filestringrequiredPath to the output bin file.
fill-valuestring, integeroptionalValue to fill the spaces between the segments. Available values: 0x00-0xFF. Default: 0.
descriptionstringoptionalDescription for this field.

Example:

{
"schema-version": 1.0,
"content": [
{
"name": "hex-dump command example",
"description": "Extracts data from the hex file",
"enabled": true,
"commands": [
{
"command": "hex-dump",
"inputs": [
{
"description": "Input hex file",
"file": "input.hex",
"address": "0x00",
"size": "0xFF"
}
],
"outputs": [
{
"description": "Output bin file",
"file": "output.bin",
"fill-value": 0
}
]
}
]
}
]
}

Bin to hex

Converts binary file to hex.

Command name: bin2hex

Inputs:

NameTypeOptional/RequiredDescription
filestringrequiredThe path to the bin file.
offsetstring, integeroptionalStarting address offset for loading bin.
descriptionstringoptionalDescription for this field.

Outputs:

NameTypeOptional/RequiredDescription
filestringrequiredPath to the output hex file.
descriptionstringoptionalDescription for this field.

Example:

{    
"schema-version": 1.0,
"content": [
{
"name": "bin2hex command example",
"description": "Converts binary image to hex",
"enabled": true,
"commands": [
{
"command": "bin2hex",
"inputs": [
{
"description": "Input bin file",
"file": "input.bin",
"offset": 0
}
],
"outputs": [
{
"description": "Output hex file",
"file": "output.hex"
}
]
}
]
}
]
}

Hex to bin

Converts hex file to binary.

Command name: hex2bin

Inputs:

NameTypeOptional/RequiredDescription
filestringrequiredThe path to the input hex file.
startstring, integeroptionalStart of address range.
endstring, integeroptionalEnd of address range.
descriptionstringoptionalDescription for this field.

Outputs:

NameTypeOptional/RequiredDescription
filestringrequiredThe path to the output bin file.
sizestring, integeroptionalSize of the resulting file in bytes.
fill-valuestring, integeroptionalValue to fill the spaces between the segments. Available values: 0x00-0xFF. Default: 0xFF.
descriptionstringoptionalDescription for this field.

Example:

{
"schema-version": 1.0,
"content": [
{
"name": "hex2bin command example",
"description": "Converts hex file to binary",
"enabled": true,
"commands": [
{
"command": "hex2bin",
"inputs": [
{
"description": "Input hex file",
"file": "input.hex",
"start": "0x32000000",
"end": "0x32000200"
}
],
"outputs": [
{
"description": "Output bin file",
"file": "output.bin",
"size": "0x400",
"fill-value": 0
}
]
}
]
}
]
}

Hash

Calculates hash of a file.

Command name: hash

Inputs:

NameTypeOptional/RequiredDescription
filestringrequiredThe path to the input file.
algorithmstringrequiredHash algorithm.
descriptionstringoptionalDescription for this field.

Outputs:

NameTypeOptional/RequiredDescription
filestringrequiredOutput binary or text file.
formatstringrequiredFormat of the output file. Available values: bin, txt. Default: bin.
descriptionstringoptionalDescription for this field.

Example:

{
"schema-version": 1.0,
"content": [
{
"name": "hash command example",
"description": "Calculates hash of a file",
"enabled": true,
"commands": [
{
"command": "hash",
"inputs": [
{
"description": "Calculate hash of binary file",
"file": "output.bin",
"algorithm": "SHA256"
}
],
"outputs": [
{
"description": "Output binary or text file",
"file": "hash.txt",
"format": "txt"
}
]
}
]
}
]
}