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

四、报文

五、小结

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

相关推荐
龙智DevSecOps解决方案5 天前
TESSY AUTOSAR插件详解:从ARXML模型到自动化测试的完整工作流
autosar·tessy
说不得明天6 天前
网络管理:AutoarNM部分
c语言·网络·mcu·汽车·autosar
小凡子空白在线学习7 天前
汽车点火各状态
汽车·uds
内容为空11 天前
comm网络开启流程
autosar
内容为空11 天前
comm网络关闭流程
autosar
想成为优秀工程师的爸爸13 天前
车载以太网之要火系列 - 第35篇:郭大侠学UDS(34/36/37服务)- 环环相扣展神奇,丝滑更新不迷离
网络协议·uds·车载以太网
内容为空14 天前
AUTOSAR COM 发送流程笔记:Com_SendSignal 与 Com_MainFunctionTx
autosar
嵌软小白呗17 天前
Autosar-SecOC功能详解(一)
e2e·can·autosar·crc·secoc
嵌入式×边缘AI:打怪升级日志18 天前
100ASK-T113 Pro 开发板 Bootloader 完全开发指南
linux·ubuntu·bootloader
内容为空22 天前
TC397 CAN 模块硬件资源与配置详解笔记
autosar