2.4 Bootloader Operation
At the start of the example bootloader, the state of a GPIO pin is polled. If this boot pin is high, BOOTLOCK is enabled and execution jumps to APPCODE. If the pin is low, the bootloader starts receiving data over USART, and writes this data to the page buffer. When the page buffer is full, the page is written to Flash. After enough data is received to fill the entire Flash, a software Reset is issued, resetting all peripherals. The new application can then be started.
When first programming the bootloader to the device, APPCODE and APPDATA are
empty. In this situation, if the boot pin is high on start-up, code execution will jump
to a Flash section with all bytes equal 0xff
. This will be executed as
a NOP
. When execution reaches the end of Flash, it will wrap around to
the start of BOOT, and again execute the bootloader. This will create a loop, until the
boot pin goes low.
The following illustration shows a flow diagram of the bootloader operation.
Before jumping to the application code, BOOTLOCK is enabled to prevent access to boot from the application.