Initialization Sequence of an AUTOSAR ECU#1

ECU initialization in AUTOSAR application is handled by the EcuM module of BSW. After the initialization sequence in boot-loader and C Init Code has been completed, the first API to be called from the “main()” is EcuM_Init().

The startup is divided in to two parts, first part being StartPreOs Sequence and the second part being StartPostOs Sequence, as represented in the image below

The two step Init Process

In the first part of initialization [handled by EcuM_Init()] the following activities take place

  • Initialization of interrupts [EcuM_AL_SetProgrammableInterrupts()]
  • Initialization of BlockZero drivers [EcuM_AL_DriverInitZero()]
  • Loading of Post Build Configuration Data
  • Validation of the loaded data
  • Initialization of BlockOne drivers [EcuM_AL_DriverInitOne()]
  • Translation of Reset Reason
  • Selection of default Shutdown Target
  • Starting the OS

In case of a multi-core ECU, the master core is initialized first, followed by the initialization of BlockZero and BlockOne drivers of the slave core, and then, the OS is started. The last step of the StartPreOs Sequence is always to start the OS. At this point EcuM gives up the control for a moment, only to gain it back once the OS has started.

Step 1 : StartPreOs Sequence

After the OS has started, EcuM_StartupTwo() is called from an Init_OsTask and it hands over the control back to the EcuM module. Then the StartPostOs Sequence starts and following steps are handled by EcuM_StartupTwo().

  • SchM_Init — BSW scheduler is initialized
  • BswM_Init — BSW Mode Manager is initialized
  • BSW is notified about the wake-up events raised received during the startup.

In case of multi-core ECU, SchM_Init and BswM_Init on the master core is called first followed by the same steps in the slave core. After the BswM has been initialized, RTE is started and then the rest of the initialization continues.

Step Two : StartPostOs Sequence

Initializations done in BlockZero and BlockOne drivers are low level initializations that are not dependent on the OS.

AUTOSAR provides callouts for the initialization of interrupts, BlockZero and BlockOne drivers. These callouts are part of the initialization sequence by default, but the actual implementation inside these callouts are target dependent. AUTOSAR and the tool chain vendors provide recommendations only. What exactly is done in these callouts, is upto the system designers discretion.

Recommended Initialization Activities in StartPreOs Sequence

The following modules will usually be initialized in the BlockZero drivers callout, Det_Init(), Det_Start(), Dem_MasterPreInit().

The following modules will usually be initialized in the BlockOne drivers callout, Mcu_Init(), Gpt_Init(), Wdg_Init(), WdgM_Init(), Adc_Init(), Icu_Init(), Pwm_Init()

EcuM provides the possibility to select the shutdown target that is used for the next shutdown. This target is used by EcuM when the ECU is undergoing shutdown sequence. The possible shutdown targets are SLEEP, RESET & OFF.

About the EcuM module,

EcuM module initializes and de-initializes the OS, Scheduler, Bsw Mode Manager and several other BSW driver modules. It also manages the sleep, wake-up and shutdown of the ECU.
There are two variants of the EcuM module, flex and fixed. Flex is the more advanced of the two. It supports multi-core ECUs along with partial or fast wake-up, interleaved wake-ups of BSW, RTE, APPL and even multiple running states. All the discussion above has been with respect to Flex EcuM.

I stare at screens for a living.