1.7.5.2 bootloader_Trigger Function
bool bootloader_Trigger(void);
Summary
Checks if Bootloader has to be executed at startup.
Description
This function can be used to check for a External HW trigger or Internal firmware trigger to execute bootloader at startup.
This function has to be implemented by the bootloader application to override the WEAK implementation in bootloader.c
The checks in trigger function should happen before any system resources are initialized apart for PORT, As the same system resource can be Re-initialized by the application if bootloader jumps to it and may cause issues.
External Trigger:
Can be achieved by triggering a GPIO_PIN at startup.
Firmware Trigger:
Application firmware which wants to execute bootloader at startup needs to fill first n bytes of ram location with a request pattern. The Number of bytes to be reserved for storing the pattern has to be configured in bootloader component configuration in MCC.
uint32_t *sram = (uint32_t *)BTL_TRIGGER_RAM_START; sram[0] = 0x5048434D; sram[1] = 0x5048434D; sram[2] = 0x5048434D; sram[3] = 0x5048434D;
Precondition
PORT/PIO Initialize must have been called.
Parameters
None
Returns
True : If any of trigger is detected.
False : If no trigger is detected..
Example
#define BTL_TRIGGER_PATTERN 0x5048434D static uint32_t *ramStart = (uint32_t *)BTL_TRIGGER_RAM_START; bool bootloader_Trigger(void) { // Check for Bootloader Trigger Pattern in first 16 Bytes of RAM to enter Bootloader. if (BTL_TRIGGER_PATTERN == ramStart[0] && BTL_TRIGGER_PATTERN == ramStart[1] && BTL_TRIGGER_PATTERN == ramStart[2] && BTL_TRIGGER_PATTERN == ramStart[3]) { ramStart[0] = 0; return true; } // Check for Switch press to enter Bootloader if (SWITCH_Get() == 0) { return true; } return false; } void SYS_Initialize() { NVMCTRL_Initialize(); PORT_Initialize(); if (bootloader_Trigger() == false) { run_Application(); } CLOCK_Initialize(); }