SN-IES-1-016 Interface Application Bootloader
SN-IES-1-016 Interface Application Bootloader
Version 1.1.1
2022-10-20
Support Note SN-IES-1-016
Table of Contents
1 Introduction ...................................................................................................................................2
2 ECU Boot Sequence......................................................................................................................2
2.1 Boot Sequence without Boot Manager ................................................................................2
2.2 Boot Sequence with Boot Manager .....................................................................................3
3 The Application .............................................................................................................................4
3.1 Jump From Application to Bootloader ..................................................................................4
3.2 Jump From Bootloader to the Application ............................................................................6
4 Bootloader .....................................................................................................................................7
4.1 Jump From Application to Bootloader ..................................................................................7
4.2 Jump From Bootloader to the Application ............................................................................8
4.3 Tester Source Address ........................................................................................................8
4.4 Data exchange .....................................................................................................................8
5 Data Exchange Between Application and Bootloader ..............................................................8
5.1 Data Exchange.....................................................................................................................8
5.2 Data Format and Usage (Application) .................................................................................9
5.2.1 Tester Source Address ........................................................................................................9
5.2.2 Protocol ID ...........................................................................................................................9
5.2.3 Service ID .............................................................................................................................9
5.2.4 Subfunction ID......................................................................................................................9
5.2.5 Reprogramming Request Flag .............................................................................................9
5.2.6 Application Updated Flag .....................................................................................................9
5.2.7 Response Required Flag ...................................................................................................10
5.3 Data Format and Usage (Bootloader) ................................................................................10
5.3.1 Tester Source Address ......................................................................................................10
5.3.2 Reset Response Handling .................................................................................................10
5.3.3 Reprogramming Request Flag ...........................................................................................10
5.3.4 Application Update Flag .....................................................................................................10
5.4 Sharing non-volatile data between Application and Bootloader using FEE Blocks ...........11
5.4.1 Preconditions on the FEE Layout ......................................................................................11
5.4.2 FEE Configuration with the DaVinci Configurator Pro .......................................................14
5.4.3 Usage of Fee Configuration in Flash Bootloader ...............................................................22
6 Additional Resources .................................................................................................................26
7 Contacts .......................................................................................................................................26
Interface Application Bootloader
1 Introduction
Automotive ECUs typically contain at least two separate software parts, the Application and the Flash
Bootloader (Bootloader or also abbreviated via FBL). The Application implements the specific
functionality of the ECU, e.g. controlling the engine or the airbags. The Bootloader allows to update
the Application once the vehicle has been put on the market.
Although Application and Bootloader are separate software parts, they require to exchange a
minimum of information, for example whether the ECU shall enter and stay in FBL to wait for an
update of the Application. For this reason, an Application-Bootloader-Interface must be implemented.
This document gives an overview of the Application-Bootloader-Interface on both sides, the
Application side and the Bootloader side and which information must be exchanged.
The focus of the description of the Application software is on AUTOSAR standard (R4.x) which is
widely used for automotive ECUs nowadays. Concerning the Bootloader software, this document
shows the Vector proprietary and the Vector AUTOSAR Bootloader.
The first is a reprogramming request that is provoked by a diagnostic tester. The second is
the check whether the Application is valid or not.
The Application is started, if there is no reprogramming request and the Application is valid.
The Bootloader is started, if there is a reprogramming request or the Application is not valid.
Therefore, the reprograming request flag is one part of the information that has to be
exchanged between the Application and the FBL.
Usually, the Boot Manager is the first instance which is started after the ECU powers up.
There are still systems without Boot Manager. Then the Bootloader is started first and
performs the checks for valid Application.
When there is no reprogramming request the FBL will check whether the application validity
is set or not. Depending on the check’s result the FBL will finish its initialization, stays in the
FBL, and waits for requests from the Tester or jumps to the entry point of the application.
In case there is no valid application the FBL will stay in the FBL.
With valid FBL the BM checks for a reprogramming flag. When the flag is set the FBL is
started. If the flag is not set the BM will search for a valid executable target. In case a valid
target is found the BM will start it otherwise the FBL will be started to make sure the ECU is
able to be (re)programmed.
3 The Application
If there is no reprogramming request and the Application is valid, the ECU follows the above shown
boot sequence and will stay in the Application.
In order to store the information required by the Bootloader, the Dcm will execute the application
callout Dcm_SetProgConditions (refer to [1] for detailed API description). This callout must be
implemented by the user. The goal is to hand over the information in the parameter ProgConditions of
the type Dcm_ProgConditionsType (see figure below) provided by Dcm and store it in a place and
format, the Bootloader can access and understand.
Caution
Before storing the information for the Bootloader, the Dcm will notify the BswM via
ModeDeclarationGroupPrototype DcmEcuReset by respectively sending mode
JUMPTOBootloader or JUMPTOSYSSUPPLIERBootloader, so any activities for
preparing the jump can be executed. These activities are optional.
If an asynchronous processing is required to store the information, for instance by using an AUTOSAR
memory stack, the callout Dcm_SetProgConditions allows the return value DCM_E_PENDING
which results in the Dcm_MainFunction calling Dcm_SetProgConditions in each subsequent
cycle until it returns E_OK, before the Dcm continues with the jump to Bootloader.
Caution
After storing the information for the Bootloader, the Dcm will notify the BswM via
ModeDeclarationGroupPrototype DcmEcuReset by sending mode EXECUTE, so
the project-specific implementation for jumping to bootloader, e.g. causing watchdog
reset, is triggered. Implementing an appropriate reaction on mode EXECUTE is mandatory
for jumping to the Bootloader.
The option Send Resp Pend On Trans To Boot has to be activated in the DaVinci configurator
(see Figure 3-3) to allow the application software to send a RCR-RP message (regardless of the
posRspMsg-Indication-Bit) prior jumping to the Bootloader on the programming session request 0x10
0x02. The response pending message is needed to avoid a tester session timeout during the transition
to Bootloader. After the reset, the Bootloader will send the positive response to the programming
session request.
In order to avoid that the Dcm sends a positive response to the services which cause the
ECU reset (e.g. 0x10 and 0x11), the parameter Reset to Fbl After Session Final
Response Enabled must be deactivated. When the parameter is deactivated, the Dcm
sends only a response pending before issuing the reset and the Bootloader is the
responsible to send the final positive response.
Figure 3-4 - Deactivate Reset To Fbl After Session Final Response Enabled
For more information see [4] (chapter 5.2 Transition from Application to Bootloader).
Caution
The user has to make sure that the information required from Bootloader is already
available when Dcm_Init is called during start-up of the Application, for instance by
restoring the data from non-volatile memory before.
During start-up (in scope of processing Dcm_Init) the Dcm will execute the application callout
Dcm_GetProgConditions (refer to [1] for detailed API description). This callout must be
implemented by the user. The goal is to detect if there was a normal start-up or a jump from the
bootloader. This must be indicated to Dcm by using either the return value DCM_COLD_START or
DCM_WARM_START of the type Dcm_EcuStartModeType (see figure below). In case of
DCM_COLD_START, no further handling is required, because the Dcm will skip the respective
evaluation of information and continue.
In case of DCM_WARM_START the information stored by Bootloader must be read, translated to type
Dcm_ProgConditionsType (see Figure 3-2) and provided to Dcm via parameter
ProgConditions.
For more information see [4] (chapter 5.3 Transition from Bootloader to Application).
4 Bootloader
If a reprogramming request is present (set by application) or the application is not valid, then the
Bootloader is started.
FblStart: FblStart uses a RAM pattern called Magic Flag. Once the reprogramming request from
the tester is received by the application the FblStart function is invoked by the application. This
function simply writes a Magic Flag to RAM and performs a reset. After the reset the BM/FBL will
not initialize the area where the Magic Flag has been written before. This enables the BM/FBL to
check whether the Magic Flag has been written prior to the issued reset. Depending on the
architecture (with or without BM) if it is written the BM would jump to the FBL or the FBL would
stay in the FBL and will wait for further Tester requests.
Hint: The application does not have to consider the location of the Magic Flag because when the
FblStart function is invoked the context is switched back to the BM/FBL. The Magic Flag is written
to the RAM area which is linked in the BM/FBL and after the reset the BM/FBL will read from the
RAM area which is linked in the BM/FBL.
In both variants the Boot Manager / Bootloader reads the flag (e.g.
ApplFblExtProgRequest()) and clears it.
Caution
CallFblStart() does not return to the Application. Please make sure that all tasks
have been finished, e.g. shutting down the Os, before executing CallFblStart().
Caution
Consider the usage of RAM pattern carefully. It can cause issues, e.g. as follows:
1. The bootloader cannot be started, because the RAM contents get lost after reset (e.g.
by a short loss of power on the micro or initialization through the start-up code).
2. The bootloader is accidentally started after power-up because the RAM location
randomly contains the specified pattern named above.
3. The RAM pattern will be allocated by the Bootloader anywhere in RAM. This may
overlap with data inside the Application. If you perform the call of CallFblStart(),
you potentially overwrite the data. The ECU should be shutdown then immediately.
This could otherwise cause unpredictable behavior of the ECU.
Data
Reprogramming
Subfunction ID
Required Flag
Tester Source
Updated Flag
Request Flag
Protocol ID
Application
Service ID
Response
Address
Software Part
* Application Updated Flag will only be evaluated by Dcm, if the respective feature is used
**Bootloader does not handle Application Updated Flag. If Application is using this feature, the user
has to handle this flag on bootloader side as described in 5.3.4.
5.2.2 Protocol ID
The Protocol ID is not used by Dcm.
5.2.3 Service ID
The Service ID is important for assembling the response to the tester. The Dcm uses the hexadecimal
values as specified in the ISO14229-1.
5.2.4 Subfunction ID
The Subfunction ID is important for assembling the response to the tester. The Dcm uses the
hexadecimal values as specified in the ISO14229-1.
The actual location of this flag needs to be checked within the Bootloader.
The actual location of this flag needs to be checked within the Bootloader.
5.4 Sharing non-volatile data between Application and Bootloader using FEE Blocks
This below sub chapters addresses the case that nonvolatile data should be shared between application
and bootloader and how this can be achieved by using the AR memory stack within the bootloader
Chapter 5.4.2 explains how the FEE works in the given use case and which are the necessary
reconditions on the FEE layout.
Chapter 5.4.3 describes the necessary actions in the DaVinci Configurator Pro 5 step by step.
Note
Details on NvM and FEE configuration are not covered by this document.
1. AR MemIF
2. AR FEE
3. AR FLS
4. Stub for AR NVM or AR NVM (compare 5.4.1.2.1, 5.4.2.4)
In case the flash bootloader does not include ASR components the following is needed additionally
Real ASR Nvm module usage is not detailed within this document.
In any case, you must configure the NvMDataSelectionBits parameter in order to allow the FEE
calculates valid block numbers. Currently it is therefore mandatory create an NvM stub in case no real
NVM is present.
Set the parameter Fee Block Id Fixed to enabled for at least all blocks which shall be accessed
by the bootloader only and all blocks which can be accessed by bootloader and application. But it is
also advisable to enable this parameter for application blocks to assure that a non-voluntary change of
Fee Block Id is not possible.
Figure 2‑1 Parameter Block Id Fixed in DaVinci Configurator Pro Comfort Editor Memory Blocks
Figure 2‑2 Parameter Fee Block Id Fixed in the DaVinci Configurator Pro Basic Editor
In this mode the FEE is able to detect and handle blocks which are not part of the bootloader
configuration, but which need to be handled in case of a sector switch.
This chapter gives a short description about the issues non-Vector solutions may cause and how the
Vector solution addresses this problem.
Note
Please note that the background sector switch (BSS) is disabled in this mode. The FEE
works according to a single sector principle.
Note
Details on NvM and FEE configuration are not covered by this document.
Further information how to configure NvM and FEE can be found in the technical reference of these
modules.
Once this is done, you can import the configuration into your bootloader project.
Note
If your Fbl does not use DaVinci Configurator, but another tool (e.g. GENy), you have to
create an empty configuration within the DaVinci Configurator first and import the
configuration here in order to generate your Fee configuration (chapter Fehler!
Verweisquelle konnte nicht gefunden werden. describes some more aspects for this
situation).
The DaVinci Configurator automatically adds the new modules to your configuration.
Note
It is possible to use FEE within bootloader context without using the bootloader mode.
In that case, the bootloader blocks must be in their own partition. That has the advantage
that all services can be used without restrictions and the disadvantage that
potentially a lot of flash memory is needed
Now we can delete the blocks which are not needed in the bootloader. This can be easily done by the
multi select feature of the DaVinci Configurator Pro. Mark the blocks you want to delete and hit the
delete button.
Last step: Disable features which are enabled for the application configuration but not used in the
bootloader. The development and production error detection for example. You can use the validation
messages of DaVinci Configurator Pro. It will execute the necessary actions automatically.
To do so, add the NvM standard definition using the project settings editor of the DaVinci Configurator
Pro.
Now configure the parameter NvMDataSelectionBits to the same value as in the application
configuration. All the other parameter errors and warnings can be ignored as we do not want to use nor
generate the NvM module.
Figure 3‑11 Nvm Stub Configuration to Allow Calculation of Valid Block Numbers
The SmallSector FEE does not distinguish between Flash Bootloader and Application blocks in the
configuration.
In this case there is no need to switch the FEE into the bootloader mode described in chapter 5.4.2.3.
Please note that the parameters Fee Block Id Fixed and Flash Bootloader
Configuration are not present in this configuration.
It is reasonable to use different FEE partitions to logically separate Flash Bootloader blocks from user
data blocks. The Flash Bootloader partition should be the first partition in dataflash. Make sure the
shared blocks have smallest block ID and same config between application and Flash Bootloader.
In this mode the FEE provides services to read and write the configured blocks as usual but also has a
few restrictions regarding other services.
Restrictions:
> The lookup table is not persisted in bootloader mode and hence the service to
> The size of the lookup table that is usually determined automatically must be
The parameter specifies the size of the lookup table which is used to reduce search effort for the latest
valid instance of a block. If bootloader mode is enabled the lookup table size must be preconfigured by
the user. The size should be at least the number of blocks configured for this partition plus one,
because one index is reserved for the lookup table block.
ATTENTION: The size must be large enough to reserve space for future application updates without
needing to update the bootloader.
It is possible to use the FEE within bootloader context without using the bootloader mode. In that case,
the bootloader blocks must be in their own partition. That has the advantage that all services can be
used without restrictions and the disadvantage that potentially more flash memory is needed.
If bootloader mode is disabled, the lookup table size is determined automatically from the number of
blocks and cannot be configured by the user.
Please note that the parameters Fee Block Id Fixed is not present in this configuration.
It is reasonable to use different FEE partitions to logically separate Flash Bootloader blocks from user
data blocks. The Flash Bootloader partition should be the first partition in dataflash.
Figure 3‑12 Add Stubs for Det, EcuC, MemIf from Application Software Integration Package
After adding stubs for Det, EcuC and MemIf, some error may occur. Follow DaVinci Configurator Pro
propositions to resolve these problems (e.g. add Fee reference to MemIf, resolve EcuC related errors
(HW-dependent)).
In case the configuration was created for Fbl Fee configuration only, only the minimum configuration
Fee and Fls need to be generated
Modules Content
Modules Content
SchM SchM_Fee.h :
#define SchM_Enter_Fee_FEE_EXCLUSIVE_AREA_0()
#define SchM_Exit_Fee_FEE_EXCLUSIVE_AREA_0()
SchM_Fls.h:
Modules Content
Fee_Cfg.h
Fee Fee_Lcfg.c
Fee_PrivateCfg.h
Fls Fls_Cfg.h
Example
Call Fxx_Init()
while MEMIF_IDLE != Fxx_GetStatus() call Fxx_MainFunction()
Fee specific:
Example
Depending on configuration call Fee_EnableFss()
#if (FEE_FSS_CONTROL_API == STD_ON)
Fee_EnableFss();
#endif
The location where the initialization needs to be done depends on the elements that need to be
accessed via Fee. If elements need to be accessed before decision to jump to application (e.g. valid
flag(s)), do the initialization within ApplFblInit(), otherwise within ApplFblStartup(),
initposition == kStartupPostInit. If you need to do the initialization within ApplFblInit(),
be sure to initialize watchdog and timer early in your configuration (set FBL_ENABLE_PRE_WDINIT /
FBL_ENABLE_PRE_TIMERINIT)
Example
Required implementation:
If Fee_Read(blockNumber, blockOffset, pBuffer, length ) == E_OK
{
While MEMIF_IDLE != Fee_GetStatus()
{
Call Fls_MainFunction()
Call Fee_MainFunction()
}
//Check Fee_GetJobResult() == MEMIF_JOB_OK /
MEMIF_BLOCK_INCONSISTENT / MEMIF_BLOCK_INVALID
If Fee_GetJobResult() == MEMIF_JOB_OK
return OK
Else If Fee_GetJobResult() == MEMIF_BLOCK_INCONSISTENT OR
MEMIF_BLOCK_INVALID
fill read buffer with FBL_FLASH_DELETED
return OK
Else
return failed
}
Else return failed
Example
Required implementation:
If Fee_Write(blockNumber, pBuffer) == E_OK
{
While MEMIF_IDLE != Fee_GetStatus()
{
Call Fls_MainFunction()
Call Fee_MainFunction()
}
If Fee_GetJobResult() == MEMIF_JOB_OK
return Ok
Else
return failed
}
Else return failed
The length information required for read information has to be defined somewhere in the flash bootloader
Example
#define FBL_NV_APPNBID_FEE_LENGTH 2u
#define FBL_NV_KEYNBID_FEE_LENGTH 2u
#define FBL_NV_SBAT_FEE_LENGTH 822u
An example call that can be mapped to the corresponding fbl_apnv.c/.h function for reading the above
mentioned element Fbl_SBATicket e.g. would be then:
ApplFblNvRead(FeeConf_FeeBlockConfiguration_FeeFbl_SBATicket, 0u,
(buffer),FBL_NV_SBAT_FEE_LENGTH)
6 Additional Resources
No. Source Title Version
[1] Vector TechnicalReference_Dcm.pdf 14.1.0
[2] AUTOSAR AUTOSAR_SWS_DiagnosticCommunicationManager.pdf 4.2.2
[3] Vector TechnicalReference_FBL-<OEM>.pdf
[4] Vector TechnicalReference_FblCw.pdf 3.03.01
[5] Vector TechincalReference_Fee_FlexNor.pdf 1.02.00
7 Contacts
For a full list with all Vector locations and addresses worldwide, please visit http://vector.com/contact/.