# Secure Bootloader Sample Reference Macro Definition Documentation

## VT_OFFSET_STACK_POINTER

#define VT_OFFSET_STACK_POINTER 0

Vector table offset for the stack pointer.

Location: bl_check.h:80

## VT_OFFSET_RESET_VECTOR

#define VT_OFFSET_RESET_VECTOR 1

Vector table offset for the reset vector.

Location: bl_check.h:83

## VT_OFFSET_VERSION_INFO

#define VT_OFFSET_VERSION_INFO 8

Vector table offset for the version information pointer.

Location: bl_check.h:86

## VT_OFFSET_IMAGE_SIZE

#define VT_OFFSET_IMAGE_SIZE 9

Vector table offset for the used image size pointer.

Location: bl_check.h:89

## VT_OFFSET_CERT_SIZE

#define VT_OFFSET_CERT_SIZE 10

Vector table offset for the certificate size.

Location: bl_check.h:92

## BL_CONFIGURATION_BASE

#define BL_CONFIGURATION_BASE ((BL_AppConfiguration_t *) FLASH0_DATA_BASE)

Base address of the boot configuration in flash.

Location: bl_configuration.h:81

## BL_CONFIGURATION_WORDS

#define BL_CONFIGURATION_WORDS (sizeof(BL_AppConfiguration_t) >> 2)

Define the size of the configuration area in words.

Location: bl_configuration.h:84

## BL_CRYPTO_BOOT_SEED_LENGTH

#define BL_CRYPTO_BOOT_SEED_LENGTH 32

Define the length in bytes of the boot seed value, random number.

Location: bl_crypto.h:86

## BL_CRYPTO_SHA256_DIGEST_LENGTH

#define BL_CRYPTO_SHA256_DIGEST_LENGTH 32

Define the digest length in bytes for SHA256.

Location: bl_crypto.h:89

## BL_ENCRYPT_KEY_SIZE_BITS

#define BL_ENCRYPT_KEY_SIZE_BITS 128

Define the AES key size in bits when performing AES encryption.

Location: bl_file_encryption.h:84

## BL_ENCRYPT_KEY_SIZE_BYTES

#define BL_ENCRYPT_KEY_SIZE_BYTES (BL_ENCRYPT_KEY_SIZE_BITS >> 3)

Define the AES key size in bytes when performing AES encryption.

Location: bl_file_encryption.h:87

## BL_ENCRYPT_BLOCK_SIZE_BITS

#define BL_ENCRYPT_BLOCK_SIZE_BITS 128

Define the block size in bits when performing AES encryption.

Location: bl_file_encryption.h:90

## BL_ENCRYPT_BLOCK_SIZE_BYTES

#define BL_ENCRYPT_BLOCK_SIZE_BYTES (BL_ENCRYPT_BLOCK_SIZE_BITS >> 3)

Define the block size in bytes when performing AES encryption.

Location: bl_file_encryption.h:93

## FLASH_BOND_INFO_SIZE

#define FLASH_BOND_INFO_SIZE 0x800

Location: bl_memory.h:78

## BL_CODE_SECTOR_SIZE

#define BL_CODE_SECTOR_SIZE 2048

The image block size when loading data.

(Size of a code sector.)

Location: bl_memory.h:81

## BL_DATA_SECTOR_SIZE

#define BL_DATA_SECTOR_SIZE 256

The image block size when loading data.

(Size of a code sector.)

Location: bl_memory.h:84

## BL_FLASH_RESERVED_SIZE

#define BL_FLASH_RESERVED_SIZE (FLASH_DEU_RESERVED_SIZE + FLASH_BOND_INFO_SIZE)

The size of the area reserved for use by the ROM and stack.

Location: bl_memory.h:87

## BL_SECURE_STORAGE_BASE

#define BL_SECURE_STORAGE_BASE (FLASH0_DATA_BASE + BL_FLASH_RESERVED_SIZE)

Define the base address of the secure storage area.

Location: bl_memory.h:91

## BL_SECURE_STORAGE_SIZE

#define BL_SECURE_STORAGE_SIZE (FLASH0_DATA_RSL15_284_TOP - BL_SECURE_STORAGE_BASE + 1)

Define a size for the secure storage area.

Location: bl_memory.h:94

## BL_SECURE_STORAGE_TOP

#define BL_SECURE_STORAGE_TOP (BL_SECURE_STORAGE_BASE + BL_SECURE_STORAGE_SIZE - 1)

Define the top of the secure storage area.

Location: bl_memory.h:98

## BL_BOOTLOADER_BASE

#define BL_BOOTLOADER_BASE FLASH0_CODE_BASE

The base address of the bootloader flash.

Location: bl_memory.h:102

## BL_BOOTLOADER_SIZE

#define BL_BOOTLOADER_SIZE BL_BOOTLOADER_KB

Define the size of the bootloader in kB.

The size of the area reserved for use by the bootloader.

Location: bl_memory.h:135

## BL_FLASH_CODE_BASE

#define BL_FLASH_CODE_BASE (BL_BOOTLOADER_BASE + BL_BOOTLOADER_SIZE)

The base of the code flash.

Location: bl_memory.h:138

## BL_FLASH_DATA_BASE

#define BL_FLASH_DATA_BASE (BL_SECURE_STORAGE_TOP + 1)

The base of the data flash, offset by the reserved areas.

Location: bl_memory.h:141

## BL_FLASH_CODE_TOP

#define BL_FLASH_CODE_TOP FLASH0_CODE_TOP

Define the top of code flash in 512K device.

Location: bl_memory.h:154

## BL_FLASH_DATA_TOP

#define BL_FLASH_DATA_TOP FLASH0_DATA_TOP

Define the top of data flash in 512K device.

Location: bl_memory.h:157

## BL_FLASH_CODE_SIZE

#define BL_FLASH_CODE_SIZE (BL_FLASH_CODE_TOP - BL_FLASH_CODE_BASE + 1)

Code size is derived from the base and top addresses.

Location: bl_memory.h:162

## BL_FLASH_DATA_SIZE

#define BL_FLASH_DATA_SIZE (BL_FLASH_DATA_TOP - BL_FLASH_DATA_BASE + 1)

Data size is derived from the base and top addresses.

Location: bl_memory.h:165

## BL_APPLICATION_BASE

#define BL_APPLICATION_BASE BL_FLASH_CODE_BASE

Define the base address of the application.

Location: bl_memory.h:168

## BL_AVAILABLE_SIZE

#define BL_AVAILABLE_SIZE (BL_FLASH_CODE_SIZE + BL_FLASH_DATA_SIZE)

Define the total available flash for application and download.

Location: bl_memory.h:171

## BL_APPLICATION_SIZE

#define BL_APPLICATION_SIZE ((BL_AVAILABLE_SIZE >> 1) & 0xFFFFF800)

Define the maximum size of an application.

(must be 2K aligned)

Location: bl_memory.h:174

## BL_DOWNLOAD_BASE

#define BL_DOWNLOAD_BASE (BL_APPLICATION_BASE + BL_APPLICATION_SIZE)

Define the base address of the download area.

Location: bl_memory.h:177

## BL_DOWNLOAD_SIZE

#define BL_DOWNLOAD_SIZE BL_APPLICATION_SIZE

Define the maximum size of the download area.

Location: bl_memory.h:180

## BL_OPT_FEATURE_ENABLED

#define BL_OPT_FEATURE_ENABLED 1

Indicator that a given feature should be enabled.

Location: bl_options.h:80

## BL_OPT_FEATURE_DISABLED

#define BL_OPT_FEATURE_DISABLED 0

Indicator that a given features should be disabled.

Location: bl_options.h:83

## BL_OPT_FEATURE_BOOTLOADER

#define BL_OPT_FEATURE_BOOTLOADER BL_OPT_FEATURE_ENABLED

Marker indicating that the bootloader feature is enabled.

Location: bl_options.h:89

## BL_OPT_FEATURE_BOOTLOADER

#define BL_OPT_FEATURE_BOOTLOADER BL_OPT_FEATURE_ENABLED

Marker indicating that the bootloader feature is enabled.

Location: bl_options.h:131

## BL_OPT_FEATURE_SECURE_BOOTLOADER

#define BL_OPT_FEATURE_SECURE_BOOTLOADER BL_OPT_FEATURE_DISABLED

Marker indicating that the bootloader supports authenticated update of images.

Location: bl_options.h:95

## BL_OPT_FEATURE_SECURE_BOOTLOADER

#define BL_OPT_FEATURE_SECURE_BOOTLOADER BL_OPT_FEATURE_ENABLED

Marker indicating that the bootloader supports authenticated update of images.

Location: bl_options.h:124

## BL_OPT_FEATURE_SECURE_STORAGE

#define BL_OPT_FEATURE_SECURE_STORAGE BL_OPT_FEATURE_DISABLED

Marker indicating if the secure storage feature is provided.

Location: bl_options.h:100

## BL_OPT_FEATURE_SECURE_STORAGE

#define BL_OPT_FEATURE_SECURE_STORAGE BL_OPT_FEATURE_ENABLED

Marker indicating if the secure storage feature is provided.

Location: bl_options.h:117

## BL_OPT_FEATURE_ATTESTATION

#define BL_OPT_FEATURE_ATTESTATION BL_OPT_FEATURE_DISABLED

Marker indicating if the bootloader supports attestation protocols.

Location: bl_options.h:105

## BL_OPT_ATTEST_KEY_AES

#define BL_OPT_ATTEST_KEY_AES BL_OPT_FEATURE_DISABLED

Marker indicating that the attestation feature supports AES keys.

Location: bl_options.h:143

## BL_OPT_ATTEST_KEY_RSA

#define BL_OPT_ATTEST_KEY_RSA BL_OPT_FEATURE_DISABLED

Marker indicating that the attestation feature supports RSA keys.

Location: bl_options.h:149

## BL_OPT_ATTEST_KEY_ECC

#define BL_OPT_ATTEST_KEY_ECC BL_OPT_FEATURE_DISABLED

Marker indicating that the attestation feature supports ECC keys.

Location: bl_options.h:155

## BL_OPT_SECURE_FILE_SYSTEM_RESET

#define BL_OPT_SECURE_FILE_SYSTEM_RESET BL_OPT_FEATURE_DISABLED

Marker indicating that the attestation feature supports AES keys.

Location: bl_options.h:200

## DEBUG_CATCH_GPIO

#define DEBUG_CATCH_GPIO 0

Location: bl_recovery.h:78

## BL_SEC_IGNORE_KEY

#define BL_SEC_IGNORE_KEY 0

Define a marker value that indicates a key may be ignored.

Location: bl_secure_boot.h:100

## BL_SEC_DEFER_KEY

#define BL_SEC_DEFER_KEY 0xFFFFFFFF

Define a marker value that indicates a key should be deferred.

Location: bl_secure_boot.h:103

## BL_FS_MAX_FILE_SIZE

#define BL_FS_MAX_FILE_SIZE BL_CODE_SECTOR_SIZE

Define the maximum supported file size.

Location: bl_simple_filer.h:86

## UART_CLK

#define UART_CLK 8000000

Set UART peripheral clock.

Location: bl_target.h:77

## SENSOR_CLK

#define SENSOR_CLK 32768

Set sensor clock.

Location: bl_target.h:80

## USER_CLK

#define USER_CLK 1000000

Set user clock.

Location: bl_target.h:83

## VCC_BUCK_ENABLE

#define VCC_BUCK_ENABLE (1)

Enable or disable the buck converter.

The system allows for two methods of reducing the battery power supply from a higher voltage (1.2V-3.6V) to usable supply voltage (1.0V-1.31V). If the VBAT supply voltage is less than 1.4V, this should be disabled so that the device uses the low drop out (LDO) regulator. Otherwise, the buck (DC-DC) converter may be enabled. Set this to: => 0 to disable buck converter mode and enable linear mode => 1 to enable buck converter mode and disable linear mode

Location: bl_target.h:97

## BL_TICKER_TIME_MS

#define BL_TICKER_TIME_MS 10

Define the time in ms for each interrupt.

Location: bl_ticker.h:79

## BL_DEBUG

#define BL_DEBUG swmLogVerbose

Define the standard verbose/debug tracing routine.

Location: bl_trace.h:78

## BL_TRACE

#define BL_TRACE swmLogInfo

Define the standard tracing routine.

Location: bl_trace.h:81

## BL_WARNING

#define BL_WARNING swmLogWarn

Define the standard warning message routine.

Location: bl_trace.h:84

## BL_ERROR

#define BL_ERROR swmLogError

Define the standard error message routine.

Location: bl_trace.h:87

## BL_UART_RX_TIMEOUT_MS

#define BL_UART_RX_TIMEOUT_MS (3000)

Define the receive timeout in milliseconds.

Location: bl_uart.h:88

## BL_WATCHDOG_FEED_ME_MS

#define BL_WATCHDOG_FEED_ME_MS (2000)

While waiting for UART input, ensure watch dog is fed.

Location: bl_uart.h:91

## BL_UART_TX_TIMEOUT_MS

#define BL_UART_TX_TIMEOUT_MS (3000)

Define the send timeout in milliseconds.

Location: bl_uart.h:94

## BL_UART_MAX_RX_LENGTH

#define BL_UART_MAX_RX_LENGTH (2048)

Define the maximum length of a single receive operation.

Location: bl_uart.h:97

## BL_UART_MAX_TX_LENGTH

#define BL_UART_MAX_TX_LENGTH (2048)

Define the maximum length of a single send operation.

Location: bl_uart.h:100

## BL_BAUD_RATE

#define BL_BAUD_RATE 115200

Define a baud rate for loading.

Location: bl_uart.h:103

## BL_UART_DELAY_CYCLES

#define BL_UART_DELAY_CYCLES ((20 * SystemCoreClock) / BL_BAUD_RATE)

Define a delay time to allow the hardware buffers to clear.

Location: bl_uart.h:106

## UPDATE_GPIO

#define UPDATE_GPIO 14

Define the GPIO pin to be used to indicate an update is required.

Location: bl_update.h:81

## MIN

#define MIN ((a) < (b) ? (a) : (b))

Define a shorthand to get the minimum of two values.

Location: bl_util.h:79

## MAX

#define MAX ((a) > (b) ? (a) : (b))

Define a shorthand to get the maximum of two values.

Location: bl_util.h:82

## BITS2BYTES

#define BITS2BYTES ((x + 7) >> 3)

Calculate the number of bytes needed to hold x bits.

Location: bl_util.h:85

## BITS2HALFWORDS

#define BITS2HALFWORDS ((x + 15) >> 4)

Calculate the number of 16 bit words needed to hold x bits.

Location: bl_util.h:88

## BL_VERSION_ENCODE

#define BL_VERSION_ENCODE (((m) << 12) | ((n) << 8) | (r))

Define a mechanism to encode a version number as a uint16_t.

Location: bl_versions.h:88

## BL_VERSION_DECODE

#define BL_VERSION_DECODE ((num >> 12) & 0xF), ((num >> 8) & 0xF), (num & 0xFF)

Define a mechanism to decode a version number from a uint16_t.

Location: bl_versions.h:91

## BL_BOOT_VERSION

#define BL_BOOT_VERSION __attribute__ ((section(".rodata.boot.version"))) \ const BL_BootAppVersion_t blBootAppVersion = \ { \ id, BL_VERSION_ENCODE(major, minor, revision) \ };

Define the boot version including name and ensure it is stored in an easily accessible location.

Location: bl_versions.h:96

## BL_WATCHDOG_MAX_HOLD_OFF_SECONDS

#define BL_WATCHDOG_MAX_HOLD_OFF_SECONDS 600

Define the maximum time that can elapse before the watchdog must be refreshed.

Location: bl_watchdog.h:83