# Bootloader Firmware

The bootloader firmware application must be initially loaded onto an RSL15 device. It can be loaded via SWD/JTAG.

The bootloader divides the main flash memory into two areas: the app download area and the app execution area. This subdivision provides a starting point for users who want to use the bootloader for firmware update purposes. The bootloader application is the first entry point after reset. It is located at the base address of the main flash (0x00100000) and uses the first 32 KB of memory. To be compatible with the bootloader, the linker memory map of a user application needs to be updated to add a new BOOTLOADER area and shift the application origin by 32 KB (address 0x00108000).

## Vector Table Positions

In addition, the boot image vector table contains two special items on positions 8 and 9, respectively: the application version descriptor and the image size. This means that modifications on the linker script (sections.ld) and the startup code (startup.S) are required to make a typical sample application (for example, blinky) compatible with the bootloader. See the "Vector Table Positions" figure

NOTE: The modified linker script (sections.ld) and startup code (startup.S) files are available in the utility folder of the bootloader sample application.

## Layout in Flash

The bootloader application assumes a specific layout in the main flash memory, as shown in the "Bootloader Application Layout in Flash" table:

Table: Bootloader Application Layout in Flash
Area | Size | Flash Start Address
--- | --- | ---
bootloader | 32 KB | 0x00100000
app execution | 236 KB | 0x00108000
app download | 236 KB | 0x00143000

## Power-on-Reset

Upon a power-on-reset, the bootloader checks if there is a valid boot image in the app download area (second half of flash). If there is one, it copies/overwrites this image into the app execution area, invalidates the data in the download area and boots this new image. If no valid boot image is found in the download area, the bootloader verifies and boots from the app execution area. If no valid image is found in either area, the bootloader keeps the device trapped and prints an error message.

## Activating the Updater

The bootloader updater is activated on one of these two occasions:

- The bootloader detects an invalid user application in the flash memory.
- The UPDATE_GPIO pin is held low while resetting the device (configurable in drv.targ.h)

## Downloading the .bin Image

Using a PC and the RSL15 EVB, the download of the .bin image file can be performed by the provided updater.py PC tool, as illustrated in the "Updater Tool Downloads .bin Image File" figure, below:

Figure: Updater Tool Downloads .bin Image File

## Image Format

The application firmware image to be updated via the bootloader must be created out of the .elf file by calling objcopy for the GCC toolchain and the _FROMELF.EXE_ tool for the Keil Arm toolchain, as explained in the Tutorial 2 section of the bootloader sample readme.

## Load Image

The bin image file can be loaded onto the RSL15 EVB using SEGGER® J-Link Commander or the UART updater.py PC tool, as explained in the Tutorial 3 and Tutorial 4 sections of the bootloader sample readme.