[AutoSar]BSW_Diagnostic_007 BootLoader 跳转及APP OR boot response 实现

目录

  • 关键词
  • 平台说明
  • 背景
  • [一、Process Jump to Bootloader](#一、Process Jump to Bootloader)
  • 二、相关函数和配置
    • [2.1 Dcm_GetProgConditions()](#2.1 Dcm_GetProgConditions())
    • [2.2 Dcm_SetProgConditions()](#2.2 Dcm_SetProgConditions())
  • [三、如何实现在APP 还是BOOT 中对10 02服务响应](#三、如何实现在APP 还是BOOT 中对10 02服务响应)
    • [3.1 配置](#3.1 配置)
    • [3.2 code](#3.2 code)
  • 四、报文
  • 五、小结

  

关键词

嵌入式、C语言、autosar、OS、BSW、UDS、diagnostic

平台说明

项目 Value
OS autosar OS
autosar厂商 vector
芯片厂商 TI
编程语言 C,C++
编译器 HighTec (GCC)
autosar版本 4.3.1
参考文档 TechnicalReference_Dcm.pdf AUTOSAR_SRS_DiagnosticLogAndTrace.pdf AUTOSAR_SWS_DiagnosticCommunicationManager.pdf AUTOSAR_SWS_DiagnosticEventManager.pdf AUTOSAR_SWS_FunctionInhibitionManager.pdf- 【14229-1.2.3】,【15765-1.2.3.4】. 【11898】 《MICROSAR Classic DCM》

  

  
>>>>>>>>>>>>>>>>>>>>>>>>>回到总目录<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

  

  

缩写 描述
DEM Diagnostic Event Manager
DET Development Error Tracer
DDM Diagnostic Data Modifier
DCM Diagnostic Communication Manager
LSB least significant byte
MSB most significant byte
DID Data dentifier
DSD Diagostic Service Dispatcher (submodule of the DCM module)
DSL Diagostic Session Layer (submodule of the DCM module)
DSP Diagostic Service Processing (submodule of the DCM module)
ResData response Data
ReqData request Data
HIS Hersteller Initiative Software
RCR-RP response pending

背景

   1.基于vector 工具 的boot 跳转的通用流程及其实现。2.如何实现在在APP还是boot 中对 10 02 的response。

一、Process Jump to Bootloader

  在autosar 标准文档中我们可以看到跳转到boot的流程图如下:

  一般情况下需要先进入external session(10 03),并且在external session 下进行 解锁(27 01 and 27 02),再通过 10 02 进入 program session 触发上图流程。

二、相关函数和配置

2.1 Dcm_GetProgConditions()

  该函数用于在ECU启动的时候获取配置信息(例如被置位的 bootloader_flag),并根据冷启动或热启动判定结果判定是否对10 服务进行响应。

  使用此函数需要配置DcmFinalResponseToFblEnabled = true.

2.2 Dcm_SetProgConditions()

  此函数在触发10 02 后被调用,主要实现在跳转到boot 前的信息的存储(如置位 bootloader_flag),硬件配置(如关闭watchdog 检测)等,最后调用软复位 函数对ECU进行复位。

三、如何实现在APP 还是BOOT 中对10 02服务响应

  两种情况:1.在请求 10 02 后 ,先在APP 中 对 10 02 进行 positive response,然后进行ecu复位,复位后进入boot。2.在请求 10 02 后 ,先在APP 中进行ecu复位,诊断响应0x78 pending,复位后进入boot,再在boot中 对 10 02 进行 positive response。

3.1 配置

  要实现此功能需要进行两处配置

1.DcmResetToFblAfterSessionFinalResponseEnabled

该配置决定了是否在APP 中响应10 服务。如果设置为false,则为在BOOT 中响应。

2.DcmSendRespPendOnRestart

  该配置决定了是否在ECU复位前发送0x78 即RCR-RP 。同时需要合理设置P2 和P2* 时间。

3.2 code

1.Dcm_SetProgConditions()

c 复制代码
Std_ReturnType Dcm_SetProgConditions(Dcm_ProgConditionsPtrType progConditions)
{
  Std_ReturnType retVal = DCM_E_NOT_OK;
  Psc_t_Status s_RetVal_Psc = PSC_NOT_OK;
    if(NULL_PTR != progConditions)
    {
        if( (progConditions->ReprogrammingRequest == TRUE) &&
            (progConditions->Sid == 0x10) &&
            (progConditions->ResponseRequired == FALSE) &&
            (progConditions->SubFuncId == 0x02) )
        {
            bootloader_flag = TRUE;/*设置标志位用于在复位后判定是该进入app还是boot*/

            close_watchdog() /*关闭喂狗*/
            Mcu_PerformReset()/*复位,4.0.3之前调用这个函数,新版本会在10 或者 11复位 触发Rte_Switch_DcmEcuReset_DcmEcuReset进行复位*/
            retVal = DCM_E_OK;
        }
        if (progConditions->ReprogrammingRequest == FALSE)
        {
            retVal = DCM_E_OK;
        }
    }
    else
    {
        /* NOK returned */
    }
  return retVal;
}

2.Dcm_GetProgConditions()

c 复制代码
Dcm_EcuStartModeType Dcm_GetProgConditions(Dcm_ProgConditionsPtrType progConditions)
{
  Dcm_EcuStartModeType retVal = DCM_COLD_START;

  if(NULL_PTR != progConditions)
  {
    /* Check if there was a programming request */
    if(bootloader_flag == TRUE) /*热启动,从APP跳转而来*/
    {
      progConditions->TesterSourceAddr = DIAG_ID;/*DcmDslProtocolRxTesterSourceAddr 配置的值*/
      progConditions->Sid = 0x10;
      progConditions->SubFuncId = 0x02;
      progConditions->ResponseRequired = TRUE;/*TRUE 才能响应*/
      progConditions->ApplUpdated = FALSE;
      bootloader_flag == FALSE;/*清除标志位*/
      retVal = DCM_WARM_START;
    }
  }
  if(retVal == DCM_COLD_START)
  {
    /* The ECU starts normally */
    progConditions->TesterSourceAddr = DIAG_ID;/*DcmDslProtocolRxTesterSourceAddr*/
    progConditions->ProtocolId = 0;
    progConditions->Sid = 0x10;
    progConditions->SubFuncId = 0x02;
    progConditions->ReprogrammingRequest = FALSE;
    progConditions->ResponseRequired = FALSE;
    progConditions->ApplUpdated = FALSE;
  }

  return retVal;
}

四、报文

  

  

五、小结

  

  

  
>>>>>>>>>>>>>>>>>>>>>>>>>回到总目录<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

  

  

相关推荐
叶修_A4 天前
【IF-SAFE-05】MTU内存测试 - ASIL-B安全机制
autosar
飞斯柯罗7 天前
[飞斯柯罗] 为满足网络安全要求,是否必须使用AUTOSAR?
autosar·crypto·mcal·软件复用·汽车网络安全·iso21434·控制器开发
叶修_A8 天前
【CP-11】复杂驱动设计 - AUTOSAR CP驱动架构与实现
架构·嵌入式·autosar·cp·驱动设计
青草地溪水旁8 天前
UDS 0x27服务:安全级别与算法类型的“灵活婚约”
uds·autosar cp·27服务
青草地溪水旁8 天前
UDS 0x27服务完全解读:从诊断协议到AUTOSAR实现的安全解锁之道
uds·autosar cp·27服务
赞哥哥s10 天前
诊断请求1101到MCU复位的完整流程
autosar·dcm·1101
w59875346811 天前
小米平板 7 Pro 解锁BL降压超频
小米·bootloader·bl·降压超频·konabess
无畏jh13 天前
CCFC3008PCSN与Vector适配经验分享
autosar·国产化·汽车嵌入式·ccfc3008pcsn
Electron-er14 天前
什么是 UDS?汽车 ECU 诊断协议入门详解(工程师视角)
汽车·诊断·uds·bootloader·诊断测试
车软派开发学长19 天前
零基础学习车软嵌入式AUTOSAR,以一帧CAN报文实战讲解AUTOSAR的学习
网络·stm32·车载系统·autosar·嵌入式实时数据库