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

四、报文

五、小结

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

相关推荐
原野风霜3246 天前
AutoSar RTE介绍
autosar·rte
青草地溪水旁10 天前
SOME/IP-SD报文场景示例讲解
autosar·some/ip·服务发现报文
烟花的学习笔记16 天前
【科普向-第三篇】汽车电子MCU操作系统详解:CP AUTOSAR与FreeRTOS
操作系统·freertos·autosar·嵌入式开发·汽车电子·cp autosar
原野风霜32421 天前
AUTOSAR ARXML介绍
autosar·arxml
赞哥哥s21 天前
Python脚本开发-统计Rte中未连接的Port
python·autosar·rte
原野风霜32421 天前
AutoSar BSW介绍
autosar·bsw
robur1 个月前
Cisco 3750X交换机更新到IOS 15.2后无法启动 提示:Boot process failed...
ios·交换机·cisco·bootloader
KaiGer6662 个月前
AUTOSAR进阶图解==>AUTOSAR_SWS_V2XFacilities
单片机·汽车·嵌入式·autosar
Stephen深瞳3 个月前
工具:Autosar:DBC转ARXML
汽车·autosar·uds
天天爱吃肉82183 个月前
新能源汽车电子架构革命:深度解析AUTOSAR标准与实践
架构·汽车·autosar