RSL10 Bootloader Guide
RSL10 Bootloader Guide
IMPORTANT: onsemi acknowledges that this document might contain the inappropriate terms “white list",
"master" and "slave”. We have a plan to work with other companies to identify an industry wide solution that
can eradicate non-inclusive terminology but maintains the technical relationship of the original wording. Once
new terminologies are agreed upon, future products will contain new terminology.
The RSL10 bootloader provides means of performing firmware updates using the UART interface, and is a
required component for Firmware Over the Air (FOTA). The bootloader enables firmware updates without the use of
the JTAG interface. Firmware can be loaded from a host microcontroller over UART or over the air from another
wireless device using FOTA. The bootloader copies the firmware image to the designated location in flash memory.
The bootloader source code is provided as a sample application in the RSL10 Software Development Kit (SDK),
and comes pre-loaded on the RSL10 USB dongle. This dongle can be used for bootloader development but is not
strictly required.
This document describes the bootloader firmware application and development tools. You will learn:
PC Personal Computer
3. BOOTLOADER FIRMWARE
The bootloader firmware application must be initially loaded on to an RSL10 device. It can be loaded via JTAG.
The RSL10 USB dongles come pre-loaded with the bootloader firmware.
Upon a power-on-reset, the bootloader determines whether to boot up the user application (default behavior) or
activate the updater. The bootloader updater is activated on one of these three occasions:
1. A call to the Sys_Boot_StartUpdater() function from sys_boot.h is explicitly made from the user
application.
2. The CFG_nUPDATE_DIO pin is held low while resetting the device (configurable in config.h).
www.onsemi.com
1
onsemi
RSL10 Bootloader Guide
a. On the RSL10 Evaluation Board this can be accomplished by pressing both the reset and the user push
buttons (DIO5) simultaneously, and then releasing the reset push button first. Upon releasing both push
buttons, the LED (DIO6) on the RSL10 EVB is set constant high, indicating that the updater is active.
b. On the RSL10 USB Dongle, this is performed by the updater.py PC tool. The red LED on the RSL10 USB
Dongle stays on to indicate the updater is activated.
In updater mode, the RSL10 UART is used to receive a .bin image file. If the image conforms to the expected
format, the bootloader overwrites the user application area and reports a successful status. In case of error, no write
operation is performed and an error status is returned over UART. Using a PC and the RSL10 EVB, the download of the
.bin image file can be performed by the provided updater.py PC tool, as illustrated in Figure 1, below:
CAUTION: The updater function of the bootloader runs from the PRAM. It is therefore theoretically possible to update
the bootloader itself. However, we do not recommend this procedure, as your device can be irreversibly damaged if the
power is lost during such an update.
The config.h header in the bootloader source code provides some configurable definitions, as shown below. It has
pre-defined DIO and UART settings for both the RSL10 Dongle and the RSL10 EVB. You can choose between the
EVB and the Dongle through the RSL10_DEV_OR_DONGLE definition.
www.onsemi.com
2
onsemi
RSL10 Bootloader Guide
When the updater is activated, it expects to receive commands through the UART from the PC. If no command is
received within a few seconds, the bootloader firmware watchdog times out and the device is rebooted.
The bootloader is placed at the base of the main flash region (address 0x00100000) and uses the first 8KB of
memory. In order 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 8KB (address 0x00102000). For example,
the following memory map is the updated version of the one from the blinky sample application located in the
sections.ld file:
MEMORY
{
ROM (r) : ORIGIN = 0x00000000, LENGTH = 4K
BOOT (xrw) : ORIGIN = 0x00100000, LENGTH = 8K
FLASH (xrw) : ORIGIN = 0x00102000, LENGTH = 372K
PRAM (xrw) : ORIGIN = 0x00200000, LENGTH = 32K
DRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 24K
DRAM_DSP (xrw) : ORIGIN = 0x20006000, LENGTH = 48K
DRAM_BB (xrw) : ORIGIN = 0x20012000, LENGTH = 16K
}
All firmware designed to be updatable by the bootloader must define a constant named Sys_Boot_app_version
of type Sys_Boot_app_version_t. It is an 8-byte structure composed of a 6-ASCII-character-long application ID
and a 16-bit version number:
The macro SYS_BOOT_VERSION(id, major, minor, rev), available in sys_boot.h, provides a convenient
way to define this constant. This version constant is referenced in the Arm® Cortex®-M3 core interrupt vector table at
position 7 (normally unused). As the interrupt vector table is always at the beginning of the firmware, it is possible to
find the version information without knowing the symbol table of the particular firmware. This second listing is an
excerpt from startup.S:
ISR_Vector_Table:
.long __stack /* 0 Initial Stack Pointer */
.long Reset_Handler /* 1 Reset Handler */
.long NMI_Handler /* 2 Non-Maskable Interrupt Handler */
.long HardFault_Handler /* 3 Hard Fault Handler */
.long MemManage_Handler /* 4 Mem Manage Fault Handler */
.long BusFault_Handler /* 5 Bus Fault Handler */
.long UsageFault_Handler /* 6 Usage Fault Handler */
.long Sys_Boot_app_version /* 7 Pointer to app version */
www.onsemi.com
3
onsemi
RSL10 Bootloader Guide
The user application can define any string ID. For the RSL10 USB Dongle, the IDs shown below in Table 1 are
currently used as application IDs.
The application firmware image to be updated via the bootloader must be created out of the .elf file by calling
objcopy:
For convenience, this can be added as a post-build command in your project settings. In Section 5.2, “Loading
blinky.bin into RSL10 Using the PC Updater Tool (updater.py)” on page 6, we show how to add this project setting in
Eclipse.
• The image has to be linked at the start of either the BOOT or the FLASH area.
CAUTION: If the image starts at the BOOT area, it replaces the bootloader, which can irreversibly damage the device.
The bootloader update protocol on the PC side is implemented by the Python script updater.py. This tool is
available in the scripts subfolder of the bootloader sample application, and needs the following prerequisites:
www.onsemi.com
4
onsemi
RSL10 Bootloader Guide
This usage updates RSL10 with a firmware image file over UART.
Arguments that can be used with the updater.py command are shown in Table 2, below.
The following command is an example of using the updater.py tool with the PORT positional argument to update
the RSL10 Dongle firmware:
The command also programs the new firmware into the RSL10 USB Dongle. It shows the version information of
the image file, the currently installed application, and the installed bootloader. For every transmitted flash sector of
image data, an asterisk (*) is printed. More details about the bootloader protocol and the messages exchanged between
the PC tool and the firmware are provided in Section 6., “The Bootloader Protocol” on page 8.
This section describes the process of preparing and loading the blinky sample application using the updater PC
application (updater.py). This step-by-step tutorial assumes that you are using an RSL10 Evaluation and Development
Board and have installed the pre-requisites described in Section 4., “Updater PC Application (updater.py)” on page 4.
In order to generate a bootloader-compatible firmware image, you first need to modify the linker settings of the
blinky application. Then, a post-build step is added to generate the bootloader binary image.
Step-by-step guide:
www.onsemi.com
5
onsemi
RSL10 Bootloader Guide
b. If you are using the standalone RSL10 SDK, this application uses the default sections.ld file, located in the
configuration folder in your SDK installation. Copy this file into your blinky sample application folder
before modifying it.
3. Make sure your project uses the modified linker script. Go to the project settings and navigate to C/C++ Build
> Settings > Cross ARM C Linker > General Script files (-T). It points to the local sections.ld file
${workspace_loc:/${ProjName}/sections.ld}.
4. Add a post-build step to generate the binary (.bin) file required by the bootloader, as shown in Section 3.3,
“Image Format” on page 4. In the project settings, navigate to C/C++ Build > Settings > Build Steps >
Post-build steps > Command as shown below in Figure 2, and add the following command to generate the
binary image:
${cross_prefix}${cross_objcopy}${cross_suffix} -O binary "${BuildArtifactFileName}"
"${BuildArtifactFileBaseName}.bin"
5. Set the ID and version number of your application by adding the following lines of code in the app.c file:
#include <sys_boot.h>
SYS_BOOT_VERSION("BLINKY",2,0,0);
6. Build the blinky application. If everything is correct, a blinky.bin file is generated in the output folder. This is
the binary image file required by bootloader.
5.2 Loading blinky.bin into RSL10 Using the PC Updater Tool (updater.py)
www.onsemi.com
6
onsemi
RSL10 Bootloader Guide
5. Copy the blinky.bin file generated in the previous section into the bootloader/scripts folder for ease of use.
6. Using the command prompt, navigate to the bootloader/scripts folder and use the updater.py tool to load the
blinky.bin image into RSL10. You can expect an output similar to this one:
The "**" means that 2 flash sectors have been programmed and the image has been successfully loaded. The
bootloader application reboots the board and the blinky application starts running (you can confirm it by
observing the LED flashing).
If the output includes question marks after the word Image, as shown in the above example, it means that
updater.py could not find the version information in the binary image. This could happen if the
ISR_Vector_Table in startup_rsl10.S is not updated to include Sys_Boot_app_version in position 7, as
shown in Section 3.2, “Application Version and ID” on page 3.
it is likely that updater.py could not communicate with the board because the bootloader updater has not been
activated. As bootloader now finds a valid application in flash, it boots it up, instead of activating the updater.
In order to force the activation of the bootloader updater mode, make sure to reset the RSL10 EVB by holding
down the reset button and the DIO5 push button, and releasing the reset button first. After that, the LED on the
board (DIO6) stays ON, indicating that the bootloader updater mode is active (it stays in this mode for a few
seconds before timing out and rebooting the board if no serial commands are received).
www.onsemi.com
7
onsemi
RSL10 Bootloader Guide
The bootloader protocol on the PC side is implemented in the updater.py tool. After activating the updater mode,
the PC side has to query the bootloader version, the currently installed application version, and the flash memory sector
size, with the HELLO command. Then the image is transferred and programmed using the PROG command. Once the
programming is complete, the device is set to application mode.
A command can consist of several messages, but every message from the PC side must be confirmed by the RSL10
bootloader firmware before the PC side can send the next message. Except for the standard RESP message, every
message is appended with a CCITT-CRC.
6.1 RESP
The standard response is a two-byte message. In the first byte is the type encoded: 0x55 stands for NEXT and 0xAA
stands for END. The second byte for type = NEXT is always 0; for type = END, the second byte contains an error code:
• 0 = NO_ERROR
• 1 = BAD_MSG
• 2 = UNKNOWN_CMD
• 3 = INVALID_CMD$
• 4 = GENERAL_FLASH_FAILURE
• 5 = WRITE_FLASH_NOT_ENABLED
• 6 = BAD_FLASH_ADDRESS
• 7 = ERASE_FLASH_FAILED
• 8 = BAD_FLASH_LENGTH
• 9 = INACCESSIBLE_FLASH
• 10 = FLASH_COPIER_BUSY
• 11 = PROG_FLASH_FAILED
• 12 = VERIFY_FLASH_FAILED
• 13 = VERIFY_IMAGE_FAILED
A message from the PC side with a bad CRC is always confirmed with RESP(END, BAD_MSG) by the device
running the bootloader firmware. A command message with an unknown command code is confirmed with RESP(END,
UNKNOWN_CMD). A message with invalid parameters is confirmed with RESP(END, INVALID_CMD). The standard
response is the only message without an appended CCITT-CRC.
6.2 HELLO
The HELLO command message has no parameters, but because every command must be of the same length, the
HELLO command message is padded with null bytes. The HELLO response message has three parameters:
6.3 PROG
www.onsemi.com
8
onsemi
RSL10 Bootloader Guide
If the start address and length are valid, the command is confirmed with RESP(NEXT); otherwise, RESP(END,
INVALID_CMD) is sent. After a positive confirmation, the PC side sends data messages containing the image data in
sector-sized blocks of bytes, until it has sent the last data message containing the last part of the image. Every data
message is confirmed with RESP(NEXT) until the last data message, which is confirmed with RESP(END, NO_ERROR).
If an error occurs during image transmission or programming, the next confirmation is a RESP(END, <error code>).
In this case, the PC side must start the whole sequence over again.
6.4 Restart
Similar to the HELLO command, the RESTART command message has no parameters, and the command message is
padded with null bytes. If there is a valid bootloader, this command is confirmed with RESP(END, NO_ERROR) and the
device is rebooted. Otherwise, it is confirmed with RESP(END, NO_VALID_BOOTLOADER) and no operation is
performed. This command is usually executed after a successful firmware update, i.e., a sequence of PROG command
messages.
6.5 Read
The READ command is disabled by default. The support for this command can be added by compiling the
bootloader firmware with the configuration CFG_READ_SUPPORT = 1 in config.h. This command has two parameters:
This command is confirmed with RESP(END, UNKNOWN_CMD) if the debug lock is not set, or RESP(END,
INVALID_CMD) if the length is invalid, i.e., length is zero or greater than FLASH_SECTOR_SIZE. Otherwise, the
command returns the length in bytes read from the start address passed as argument, followed by a CRC.
Figure 4 on page 10 illustrates a typical message exchange between the bootloader firmware (running on RSL10)
and the PC tool:
www.onsemi.com
9
onsemi
RSL10 Bootloader Guide
> 10 μs
nRST=1
> 10 ms
nUPD=1
HELLO_CMD()
RESP(NEXT)
RESP(NEXT)
RESP(END, NO_ERROR)
nRST=0
> 10 μs
nRST=1
www.onsemi.com
10
onsemi
RSL10 Bootloader Guide
onsemi and the onsemi logo are registered trademarks of Semiconductor Components Industries, LLC (onsemi).Windows is a registered trademark of Microsoft Corporation.
Arm and Cortex are registered trademarks of Arm Limited.All other brands, product names and company names mentioned herein may be trademarks or registered trademarks of
their respective holders.
onsemi and the onsemi logo are trademarks of Semiconductor Components Industries, LLC dba onsemi or its subsidiaries in the United States and/or other countries. onsemi
owns the rights to a number of patents, trademarks, copyrights, trade secrets, and other intellectual property. A listing of onsemi’s product/patent coverage may be accessed at
www.onsemi.com/site/pdf/Patent-Marking.pdf. onsemi reserves the right to make changes without further notice to any products herein. onsemi makes no warranty,
representation or guarantee regarding the suitability of its products for any particular purpose, nor does onsemi assume any liability arising out of the application or use of any
product or circuit, and specifically disclaims any and all liability, including without limitation special, consequential or incidental damages. Buyer is responsible for its products and
applications using onsemi products, including compliance with all laws, regulations and safety requirements or standards, regardless of any support or applications information
provided by onsemi. “Typical” parameters which may be provided in onsemi data sheets and/or specifications can and do vary in different applications and actual performance
may vary over time. All operating parameters, including “Typicals” must be validated for each customer application by customer’s technical experts. onsemi does not convey any
license under its patent rights nor the rights of others. onsemi products are not designed, intended, or authorized for use as a critical component in life support systems or any
FDA Class 3 medical devices or medical devices with a same or similar classification in a foreign jurisdiction or any devices intended for implantation in the human body. Should
Buyer purchase or use onsemi products for any such unintended or unauthorized application, Buyer shall indemnify and hold onsemi and its officers, employees, subsidiaries,
affiliates, and distributors harmless against all claims, costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal
injury or death associated with such unintended or unauthorized use, even if such claim alleges that onsemi was negligent regarding the design or manufacture of the part.
onsemi is an Equal Opportunity/Affirmative Action Employer. This literature is subject to all applicable copyright laws and is not for resale in any manner.
M-20851-005