[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;
}

四、报文

  

  

五、小结

  

  

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

  

  

相关推荐
叶修_A2 天前
FS-17 功能安全ISO26262之敏捷开发融合深度解析
敏捷开发·autosar·汽车电子·功能安全·iso26262
李boyang6 天前
STM32H5_Bootloader与IAP升级机制深度解析
stm32·iap·bootloader
叶修_A16 天前
FS-11 功能安全ISO26262之生产运维与报废阶段安全保障深度解析
autosar·汽车电子·功能安全·iso26262
原野风霜32420 天前
认识UDS故障诊断中DTC的形成过程
故障诊断·uds·dtc
齊家治國平天下21 天前
Google AAOS 中 SOME/IP 框架深度解析:从架构到实践
android·autosar·aaos·车载以太网·some/ip·sdv·vsomeip
叶修_A1 个月前
AP-03 SOME/IP协议实战 - AUTOSAR自适应平台通信中间件深度解析
autosar·汽车电子·some/ip·ap·通信中间件
赞哥哥s1 个月前
Autosar网络管理笔记-被动唤醒和主动请求时Nm报文发送的差异
autosar·网络管理·nm
硅农深芯1 个月前
解读AUTOSAR:定义现代汽车电子的标准化架构
架构·汽车·autosar
叶修_A2 个月前
【IF-SAFE-05】MTU内存测试 - ASIL-B安全机制
autosar
飞斯柯罗2 个月前
[飞斯柯罗] 为满足网络安全要求,是否必须使用AUTOSAR?
autosar·crypto·mcal·软件复用·汽车网络安全·iso21434·控制器开发