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

四、报文

五、小结

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

相关推荐
小丑小丑小丑4 天前
【AP AUTOSAR】AUTOSAR_PRS_SOMEIPProtocol解读
autosar·车载以太网·some/ip·autosar ap
AUTOSAR组织5 天前
深入解析AUTOSAR框架下的TCP/IP协议栈
网络协议·tcp/ip·汽车·autosar·软件架构·软件·培训
赞哥哥s5 天前
Autosar Com信号收不到排查-基于ETAS软件
can·autosar·com
STCNXPARM6 天前
Linux-ARM-Bootloader概述
linux·运维·arm开发·uboot·bootloader
wechat_Neal9 天前
AUTOSAR标准体系与域控制器开发流程简述
车载系统·autosar
linweidong9 天前
AUTOSAR中的软件更新(OTA)机制如何实现容错恢复?
autosar·ota
wechat_Neal9 天前
Autosar多核部署全面解析:从架构原则到部署策略
车载系统·autosar
linweidong10 天前
多个供应商模块如何集成到统一的AUTOSAR架构中?
架构·autosar
小丑小丑小丑10 天前
【AP AUTOSAR】COM通信模块api详解
中间件·汽车·autosar·autosar ap
wechat_Neal10 天前
SOA汽车架构进阶:复杂服务接口设计与实时性、安全性保障万字解析
车载系统·autosar