Understanding of watchdog under AUTOSAR architecture

Song Baohua 2021-09-15 09:48:48

This paper mainly introduces AUTOSAR Under the framework of WdgDriver WdgIf WdgM modular , Analyze the dependencies between modules and how they work to help you quickly understand . This article takes MPC5746R Master chip , With FS6500 by SBC,DaVinci Configurator by AUTOSAR Tool chain .

01

Module architecture and dependencies

1、 Module introduction

AUTOSAR In the architecture WDG It's divided into three parts ,Wdg Driver Wdg Interface Wdg Manager. among Wdg Driver It is divided into External watchdog driver And Internal watch driver. The external drive is driven by SBC Provide function , Internal drive by SWT The module provides functions .MPC5746R There are three SWT(Soft Watchdog Timer),SWT0 be responsible for CPU0,SWT1 be responsible for CPU1,SWT2 Can be CPU0 And CPU1 visit .

Wdg Driver Provide driver functions for bottom dog feeding and setting watchdog mode , from WdgIf Abstract into Wdg Device.WdgM obtain WdgIf Get the underlying configuration data and driver interface function from the abstract data .

WdgM A total of three types of watchdog inspection are supported .1.AliveSpuervision 2.DeadlineSupervision 3. LogicalSupervision.

AliveSpuervision Provide general dog feeding service , That is, monitor whether the periodic program can be executed normally , Ensure that the program is in Alive state .

DeadlineSupervision Provide the transition time of the monitoring software between two states .

LogicalSupervision Provide supervision on the correctness of software execution sequence .

According to different inspection methods ,WdgM You can abstract out different CheckPoint,Rte Layers can be represented by functions

WdgM_CheckpointReached() To inform WdgM The program is running correctly .

2、 Module interaction and dependency

The watchdog module consists of WdgM After unified management , It only revolves around WdgM Module analysis and other module dependencies .

WdgIf modular ,WdgM adopt WdgIf Interface changes WdgDriver The driving mode of , At the same time, notify the watchdog of the trigger condition

EcuM modular , management WdgM Of Initializing and DeInitializing state , stay Sleep Starting hardware watchdog in mode

Mcu modular , stay WdgM After the monitor fails , Can pass Mcu The interface of Mcu_PerformReset Restart immediately ECU unit

Det modular , Diagnose errors in development

Dem modular ,WdgM After detecting the error , Can pass Dem Module trigger Event

SchM modular ,WdgM call SchM Module interface WdgM_GlobalSuspendInterrupts Enter the critical area ,WdgM_GlobalRestoreInterrupts Exit critical region

Rte modular ,Rte adopt WdgM_CheckpointReached() Interface , monitor SWC Whether it operates according to the design

BswM modular ,WdgM In the monitoring Spuervised Entity After failure , Can pass BswM The module restarts the monitored program

OS modular , Periodic scheduling Task adopt WdgM_MainFunction() call WdgM_UpdateTickCount() Interface for WdgM Provide a timestamp

The specific block diagram is as follows :

02

The module configuration

1、Wdg

 Wdg Driver Provide three dog feeding modes for WdgM management ,WdgM Can pass Wdg_SetMode Interface setting watchdog operation mode

WdgSettingFast Feed the dog quickly

WdgSettingOff Turn off the watchdog

WdgSettingSlow Feed the dog slowly

Wdg External Trigger Counter : External timer , Timed call Cbk function , Test the dog feeding conditions and feed the dog

2、Wdg_Sbc

WdgGptChannelParameterRef : relation Gpt modular , utilize Cbk The function feed dog performs the feed dog operation .

Q : Why feed dogs with timed interruptions ?

A : General understanding , Not feeding the dog in the timed interrupt function is to avoid the exception of the main function , The interrupt service function can execute normally , So feeding the dog doesn't really work . stay AUTOSAR Why in SBC The external watchdog uses this method , because Wdg_30_Sbc_SetTriggerCondition The function is only responsible for adjusting the timing of watchdog feeding according to the configuration , then Gpt Of Cbk The function will feed the dog when this time arrives . If ,MainFunction The watchdog trigger condition is not set in time ,Cbk The watchdog will make mistakes because of feeding the dog in advance .

Intercept Gpt The callback function is as follows :

3、WdgIf

relation Wdg Driver Driving functions , And WdgM Directly through the function interface , therefore WdgIf No, Lcfg file . The associated key functions are as follows

4、WdgM

WdgMDemEventParameterRefs : relation Dem modular , stay WdgM When the module fails, you can Event The way of recording .

WdgMMode :

1)WdgMAliveSupervision : Activate monitoring mode

2 ) WdgMDeadlineSupervision : Cut off monitoring mode

3)WdgMLocalStatusParams : Logic monitoring mode

4)WdgMSupervisedEntity : Monitoring entities

WdgMWatchdog :: Managed Wdg Device, Need Association WdgIf Of Device, configured WdgM_ConfigSet Connect different Device, Can achieve different Wdg Device Connect different Core.

1.、 relation WdgIf Device

2、 relation Trigger Of Device

3、 relation Core

3

Source code analysis

WdgIf There are two external interfaces :Std_ReturnType WdgIf_SetMode(uint8 DeviceIndex, WdgIf_ModeType WdgMode )

                             void WdgIf_SetTriggerCondition( uint8 DeviceIndex, uint16 Timeout )

It's all through DeviceIndex To determine the driver list ,WdgM The module will pass through the managed Device Number to poll the calling interface

Cut off a paragraph WdgM_Init Code description of :

1、 The difference between an internal dog and an external dog

WdgM External dogs are managed in the same way as internal dogs , It's all through SetTriggerCondition How to set , Through the associated Gpt Modular Ckb Function to feed the dog . However, the internal implementation of the two is inconsistent .

The internal dog counts through the timer , Every time an interrupt is triggered, the timer is turned off , need SetMode Turn it on again and continue counting , Last in Cbk Finish feeding the dog .

Set operation mode , Turn on timer

Set trigger conditions , Write count value

Gpt The callback function detects the dog feeding condition , And feed the dog

2、Checkpoint

WdgM There are three ways to SupervisedEntity The way

1. Alive

 2. Deadline

 3. ProgrameFlow

WdgM Through the interface function WdgM_CheckpointReached   To express SpuervisedEntityes Of Checkpoint arrive , The function interface is described in detail as follows .

Std_ReturnType WdgM_CheckpointReached( WdgM_SupervisedEntityIdType SEID, WdgM_CheckpointIdType CheckpointID );

 

04

Multicore WdgM management

WdgM Support multi-core , Each kernel does not interfere with each other , Every Core The following are associated with individual SupervisedEntityes, Every Core All need to be called separately WdgM_MainFunction.

1. obtain CoreId, according to CoreId Get configuration pointer

2. to update WdgM Number of beats

   WdgM There are three ways to update the number of beats

   1. WDGM_INTERNAL_SOFTWARE_TICK , adopt MainFunction Scheduling and new beats

   2. WDGM_OS_COUNTER , according to OS The beat number is new WdgM Rhythm

   3. WDGM_EXTERNAL_TICK , According to the interface WdgM_UpdateTickCounter Update beat

3. to update SpuervisedEntityes The state of

4. according to Global Spuervised Entityes Feed the dog


Copyright notice : This paper is about CSDN Blogger 「ZhouArchie」 The original article of , follow CC 4.0 BY-SA Copyright agreement , For reprint, please attach the original source link and this statement , The author has obtained permission to reprint .

Recommended reading

How to write technical documents ?

2018 edition IS026262 And 2011 What are the differences between the two versions ?

Adaptive AUTOSAR Learning notes - AP background 、 Technology and features

AURIX TC3XX Series of SOTA Detailed explanation of mechanism

An article explains Audi in detail e-tron Internal system | Attached Download

ID.3 And Volkswagen's electrification platform | Attached Download

A detailed explanation CAN Bus error frame | Attached Download

DoIP Protocol is introduced , Data sharing !

Explain the vehicle network in detail OTA System development | Download is attached at the end of the article

An article on understanding automotive embedded systems AUTOSAR framework | Attached Download

tesla Autopilot System security research | attach dbc download

It's not easy to share , Please order 【 Look again 】

Please bring the original link to reprint ,thank
Similar articles

2021-09-15

2021-09-15