P2 batch translation: 49 PDFs (Memory + Safety + Crypto + ModeManagement + IO)

This commit is contained in:
opencode-translator
2026-06-13 10:04:28 +08:00
parent 6f293acbf7
commit 784f11ab73
50 changed files with 36262 additions and 57 deletions
+658
View File
@@ -0,0 +1,658 @@
# Flash 测试规范
> **文档标题**: Specification of Flash Test
> **AUTOSAR CP Release**: 4.4.0
> **文档编号**: 261
> **文档类型**: SWS (Software Specification)
---
## 文档标识
| 项目 | 内容 |
|------|------|
| Document Title | Specification of Flash Test |
| Document Owner | AUTOSAR |
| Document Responsibility | AUTOSAR |
| Document Identification No | 261 |
| Document Status | Final |
| Part of AUTOSAR Standard | Classic Platform |
| Part of Standard Release | 4.4.0 |
---
## 文档变更历史
| 日期 | 版本 | 变更者 | 变更描述 |
|------|------|--------|----------|
| 2018-10-31 | 4.4.0 | AUTOSAR Release Management | 移除 FlsTstBlockBgndConfigSet 和 FlsTstBlockFgndConfigSet;新增 FlsTstEcucPartitionRef 配置参数 |
| 2017-12-08 | 4.3.1 | AUTOSAR Release Management | 数值定义;小幅更正/澄清/编辑性修订 |
| 2016-11-30 | 4.3.0 | AUTOSAR Release Management | 新增 ECUC_FlsTst_00172: FlsTstMainFunctionPeriod;移除 SWS_FlsTst_00081 |
| 2015-07-31 | 4.2.2 | AUTOSAR Release Management | 调试支持标记为过时;扩展生产错误表带通过/失败标准;Default Error Tracer 重命名 |
| 2014-10-31 | 4.2.1 | AUTOSAR Release Management | 多项 SWS_FlsTst 文本修改;ECUC_FlsTst_00086 新增 FlsTstConfigurationOfOptApiServices |
| 2013-10-31 | 4.1.2 | AUTOSAR Release Management | 编辑性修订 |
| 2013-03-15 | 4.1.1 | AUTOSAR Administration | 按新 SWS_BSWGeneral 文档重做;MemMap.h 重命名为 FlsTst_MemMap.h;移除生产错误;新增生产错误和扩展生产错误章节 |
| 2011-12-22 | 4.0.3 | AUTOSAR Administration | SWS_FlsTst_00026 文本变更;SWS_FlsTst_00052 参数范围修改 |
| 2010-09-30 | 3.1.5 | AUTOSAR Administration | FlsTst_BlockIdFgndType 类型变为 uint8-32;参数范围限制为最大值 0xFFFFFFFF |
| 2010-02-02 | 3.1.4 | AUTOSAR Administration | 初始版本发布 |
---
## 目录
1. [介绍与功能概述](#1-介绍与功能概述)
2. [缩略语](#2-缩略语)
3. [相关文档](#3-相关文档)
4. [约束与假设](#4-约束与假设)
5. [模块依赖](#5-模块依赖)
6. [需求追溯](#6-需求追溯)
7. [功能规范](#7-功能规范)
8. [API 规范](#8-api-规范)
9. [时序图](#9-时序图)
10. [配置规范](#10-配置规范)
11. [不适用需求](#11-不适用需求)
---
## 1 介绍与功能概述
本规范规定 AUTOSAR 基础软件模块 Flash Test Driver 的功能、API 和配置。
Flash Test 模块提供测试不变内存(invariable memory)的算法。不变内存可以是数据/程序 Flash、程序 SRAM、锁定缓存,可嵌入微控制器或通过内存映射连接。
主要特性:
- **后台测试**(Background Test):周期性调用,可中断,在多个调度任务上分散执行
- **前台测试**(Foreground Test):由用户调用,同步,不可中断
- 支持多种算法:ECC 检查、CRC 签名(8/16/32 位)、校验和、重复块比较
- 测试间隔标识符
---
## 2 缩略语
| 缩略语 | 描述 |
|--------|------|
| FlsTst | Flash Test 模块名 |
| ECU | Electric Control Unit |
| EOL | End Of Line |
| CRC | Cyclic Redundancy Check |
| MCAL | Microcontroller Abstraction Layer |
| MCU | Microcontroller Unit |
| DEM | Diagnostic Event Manager |
| DET | Default Error Tracer |
| ECC | Error Correction Code |
| Invariable memory | 不变内存(程序 Flash、程序 SRAM、锁定缓存、ROM) |
| Background test | 由调度程序周期调用、可中断 |
| Foreground test | 由用户调用,同步 |
| Test interval | 后台模式下完整 Flash 测试的间隔 |
| Signature | 内存块内容的唯一计算结果 |
| Memory scrubbing | 自动顺序数据读取触发检测/验证机制 |
---
## 3 相关文档
### 3.1 输入文档
- List of Basic Software Modules
- Layered Software Architecture
- General Requirements on Basic Software Modules
- Requirements on Flash Test — AUTOSAR_SRS_FlashTest.pdf
- Specification of Default Error Tracer
- Specification of Diagnostic Event Manager
- Specification of ECU State Manager
- General Specification of Basic Software Modules
### 3.2 相关规范
AUTOSAR 提供基础软件模块通用规范(SWS BSW General),也适用于 Flash Test。
---
## 4 约束与假设
### 4.1 限制
Flash Test 模块旨在集成于整体安全概念中,本身不会提供所需的诊断覆盖率。
### 4.2 适用车型领域
无限制。
---
## 5 模块依赖
### 5.1 文件结构
#### 5.1.1 代码文件结构
[SWS_FlsTst_00003] ⌈Flash Test 模块的内存映射应通过 FlsTst_MemMap.h 实现。⌋
---
## 6 需求追溯
(主要追溯关系,完整表见原文 PDF)
| 需求 | 描述 | 满足者 |
|------|------|--------|
| SRS_BSW_00337 | 开发错误分类 | SWS_FlsTst_00007 |
| SRS_BSW_00377 | 模块特定类型 | SWS_FlsTst_00048 |
| SRS_BSW_00385 | 错误通知列表 | SWS_FlsTst_00007 |
| SRS_BSW_00405 | 配置结构 | SWS_FlsTst_00018, 00019 |
| SRS_BSW_00406 | 模块初始化 | SWS_FlsTst_00011 |
| SRS_FlsTst_14200 (Flash 测试服务配置) | SWS_FlsTst_00018, 00019 |
| SRS_FlsTst_14202 (ECC) | SWS_FlsTst_00161 |
| SRS_FlsTst_14203 (校验和) | SWS_FlsTst_00161 |
| SRS_FlsTst_14204/14205/14206 (8/16/32 位 CRC) | SWS_FlsTst_00161 |
| SRS_FlsTst_14207 (重复块比较) | SWS_FlsTst_00161 |
| SRS_FlsTst_14208 (后台 Flash 可中断) | SWS_FlsTst_00139, 00140 |
| SRS_FlsTst_14209 (内存分散) | SWS_FlsTst_00139 |
| SRS_FlsTst_14211 (测试执行状态) | SWS_FlsTst_00043 |
| SRS_FlsTst_14212 (通知机制) | SWS_FlsTst_00040, 00042 |
| SRS_FlsTst_14213 (签名/校验和) | SWS_FlsTst_00046, 00079 |
| SRS_FlsTst_14215 (暂停) | SWS_FlsTst_00071 |
| SRS_FlsTst_14216 (恢复) | SWS_FlsTst_00067 |
| SRS_FlsTst_14217 (停止) | SWS_FlsTst_00115, 00116, 00117 |
| SRS_FlsTst_14219 (前台测试) | SWS_FlsTst_00137, 00143 |
| SRS_FlsTst_14223 (错误细节) | SWS_FlsTst_00132 |
| SRS_FlsTst_14224 (ECC 电路测试) | SWS_FlsTst_00164 |
| SRS_FlsTst_14225 (测试间隔标识符) | SWS_FlsTst_00153, 00154, 00155, 00156 |
| SRS_SPAL_12057 (初始化) | SWS_FlsTst_00017, 00020 |
| SRS_SPAL_12163 (反初始化) | SWS_FlsTst_00027, 00028 |
| SRS_SPAL_12448 (开发错误检测后行为) | SWS_FlsTst_00025, 00033, 00039 |
完整追溯表见原文 PDF。
---
## 7 功能规范
### 7.1 总体行为
[SWS_FlsTst_00137] ⌈Flash 测试模块提供后台和前台模式的测试执行服务。⌋
[SWS_FlsTst_00138] ⌈待测内存块应可分别为后台和前台模式配置。⌋
#### 后台模式
[SWS_FlsTst_00139] ⌈后台模式下,测试块应按配置结构中的顺序进行测试。当所有块测试完毕,完成一个测试间隔。后台测试中,部分测试通过 `FlsTst_MainFunction` 触发。⌋
[SWS_FlsTst_00140] ⌈部分测试长度由一个调度任务中被测试的单元数定义(`ECUC_FlsTst_00161`)。不中断的部分测试所需时间定义为"测试时间"。⌋
[SWS_FlsTst_00142] ⌈后台测试应可通过 `FlsTst_Abort()``FlsTst_Suspend()` API 服务中止或暂停。API 调用请求处理的最大延迟时间应可配置。⌋
[SWS_FlsTst_00156] ⌈每个 Flash 测试间隔应有一个标识符,在后台模式下每次新测试间隔启动时递增。⌋
#### 7.1.1 状态图
后台模式下 Flash 测试驱动状态:
```
FlsTst_Init()
[Reset] → FLSTST_UNINIT ─────────→ FLSTST_INIT
↑ │ autostart
│ ↓
FlsTst_DeInit() FLSTST_RUNNING
↑ ↑ ↓
│ FlsTst_Resume│ │ Test completed
│ │ │ FlsTst_Suspend()
│ │ │
↑ FLSTST_SUSPENDED↓
FLSTST_ABORTED ←─── FlsTst_Abort() ──┘
↑ ↑
└────FlsTst_Abort()────┘
```
[SWS_FlsTst_00143] ⌈前台测试定义为同步、不可中断的测试。前台测试执行可配置,可在模块初始化后随时调用。⌋
### 7.2 错误分类
[SWS_FlsTst_00007] ⌈
| 错误类型 | 错误类别 | 相关错误代码 | 值[hex] |
|----------|----------|--------------|---------|
| Flash 测试执行状态故障 | Development | FLSTST_E_STATE_FAILURE | 0x01 |
| API 参数超出规定范围 | Development | FLSTST_E_PARAM_INVALID | 0x02 |
| 模块未初始化即调用 API 服务 | Development | FLSTST_E_UNINIT | 0x03 |
| Flash 测试模块已初始化 | Development | FLSTST_E_ALREADY_INITIALIZED | 0x04 |
| 配置指针错误(PB:为 NULL;PC:不为 NULL) | Development | FLSTST_E_INIT_FAILED | 0x05 |
| NULL 指针 | Development | FLSTST_E_PARAM_POINTER | 0x06 |
### 7.3 生产错误
Flash Test 模块未规定生产错误。
### 7.4 扩展生产错误
[SWS_FlsTst_00168] ⌈
| 项 | 内容 |
|-----|------|
| Error Name | FLSTST_E_FLSTST_FAILURE |
| Short Description | 后台模式中的失败检测 |
| Long Description | 在测试间隔内后台模式检测到故障时发出此扩展生产错误。 |
| Detection Criteria | Fail: 后台模式测试间隔内至少一个块为 NOT OK;Pass: 所有块以 OK 结果测试 |
| Monitor Frequency | continuous |
### 7.5 运行时错误
Flash Test 模块未规定运行时错误。
### 7.6 瞬态故障
Flash Test 模块未规定瞬态故障。
### 7.7 错误检测
[SWS_FlsTst_00011] ⌈在调用任何其他 Flash Test 函数(除 `FlsTst_GetCurrentState`)之前必须先调用 `FlsTst_Init`。如不遵守此顺序,应向 Default Error Tracer 报告错误代码 `FLSTST_E_UNINIT`(如启用开发错误检测)。⌋
### 7.8 错误通知
参考 SWS_BSWGeneral 文档。
### 7.9 版本检查
参考 SWS_BSWGeneral 文档。
### 7.10 调试支持
无需求定义。
---
## 8 API 规范
### 8.1 导入的类型
[SWS_FlsTst_00016] ⌈
| 模块 | 头文件 | 导入类型 |
|------|--------|----------|
| Dem | Rte_Dem_Type.h | Dem_EventIdType, Dem_EventStatusType |
| Std_Types | StandardTypes.h | Std_ReturnType, Std_VersionInfoType |
### 8.2 类型定义
#### 8.2.1 FlsTst_ConfigType
| 项 | 内容 |
|-----|------|
| Name | FlsTst_ConfigType |
| Type | Structure |
| Range | 实现特定 |
| Description | 包含 Flash 测试初始化数据的外部数据结构类型。 |
强制配置参数:
- 前台模式测试内存块定义
- 后台模式测试内存块定义
- 后台模式测试序列指示
- 硬件特定配置
#### 8.2.2 FlsTst_StateType
| 项 | 内容 |
|-----|------|
| Name | FlsTst_StateType |
| Type | Enumeration |
| Range | FLSTST_UNINIT (0x00) — 未初始化或不可用;FLSTST_INIT (0x01) — 已初始化,准备启动;FLSTST_RUNNING (0x02) — 当前正在运行;FLSTST_ABORTED (0x03) — 已中止;FLSTST_SUSPENDED (0x04) — 等待恢复或等待启动前台模式测试 |
| Description | 由 `FlsTst_GetCurrentState()` API 服务返回的状态值。 |
#### 8.2.3 FlsTst_TestResultFgndType
| 项 | 内容 |
|-----|------|
| Range | FLSTST_NOT_TESTED (0x00); FLSTST_OK (0x01); FLSTST_NOT_OK (0x02) |
| Description | `FlsTst_GetResultFgnd()` API 服务的返回类型。 |
#### 8.2.4 FlsTst_TestResultBgndType
| 项 | 内容 |
|-----|------|
| Type | Structure |
| Elements | 当前 FlsTstTestIntervalId 值;FlsTst_TestResultType 结果 |
| Description | `FlsTst_GetTestResultBgnd()` 的返回类型。 |
#### 8.2.5 FlsTst_BlockIdFgndType
uint8/uint16/uint32 — 前台模式 Flash 块的 ID。
#### 8.2.6 FlsTst_ErrorDetailsType
| 项 | 内容 |
|-----|------|
| Type | Structure (实现特定) |
| Description | 实现特定的错误信息。 |
#### 8.2.7 FlsTst_TestSignatureFgndType
| 项 | 内容 |
|-----|------|
| Type | Structure (实现特定) |
| Description | 前台模式测试签名。 |
#### 8.2.8 FlsTst_TestSignatureBgndType
| 项 | 内容 |
|-----|------|
| Type | Structure |
| Elements | 当前 FlsTstTestIntervalId 值;签名值 |
| Description | 后台模式测试签名。 |
#### 8.2.9 FlsTst_TestResultType
| 项 | 内容 |
|-----|------|
| Range | FLSTST_RESULT_NOT_TESTED (0x00); FLSTST_RESULT_OK (0x01); FLSTST_RESULT_NOT_OK (0x02) |
### 8.3 函数定义
#### 8.3.1 FlsTst_Init
```c
void FlsTst_Init(const FlsTst_ConfigType* ConfigPtr)
```
| 项 | 内容 |
|-----|------|
| Service ID[hex] | 0x00 |
| Sync/Async | Synchronous |
| Description | 初始化 Flash Test 模块。 |
#### 8.3.2 FlsTst_DeInit
```c
void FlsTst_DeInit(void)
```
| 项 | 内容 |
|-----|------|
| Service ID[hex] | 0x01 |
| Description | 反初始化 Flash Test 模块。 |
#### 8.3.3 FlsTst_StartFgnd
```c
Std_ReturnType FlsTst_StartFgnd(FlsTst_BlockIdFgndType BlockId)
```
| 项 | 内容 |
|-----|------|
| Service ID[hex] | 0x02 |
| Sync/Async | Synchronous |
| Description | 启动前台模式 Flash 测试。 |
#### 8.3.4 FlsTst_Abort
```c
Std_ReturnType FlsTst_Abort(void)
```
| 项 | 内容 |
|-----|------|
| Service ID[hex] | 0x03 |
| Description | 中止后台 Flash 测试。 |
#### 8.3.5 FlsTst_Suspend
```c
Std_ReturnType FlsTst_Suspend(void)
```
| 项 | 内容 |
|-----|------|
| Service ID[hex] | 0x04 |
| Description | 暂停后台 Flash 测试。 |
#### 8.3.6 FlsTst_Resume
```c
Std_ReturnType FlsTst_Resume(void)
```
| 项 | 内容 |
|-----|------|
| Service ID[hex] | 0x05 |
| Description | 恢复后台 Flash 测试。 |
#### 8.3.7 FlsTst_GetCurrentState
```c
FlsTst_StateType FlsTst_GetCurrentState(void)
```
| 项 | 内容 |
|-----|------|
| Service ID[hex] | 0x06 |
| Description | 返回当前 Flash 测试状态。 |
#### 8.3.8 FlsTst_GetTestResultBgnd
```c
Std_ReturnType FlsTst_GetTestResultBgnd(FlsTst_TestResultBgndType* TestResultBgndPtr)
```
| 项 | 内容 |
|-----|------|
| Service ID[hex] | 0x07 |
| Description | 返回后台测试结果。 |
#### 8.3.9 FlsTst_GetTestResultFgnd
```c
FlsTst_TestResultFgndType FlsTst_GetTestResultFgnd(void)
```
| 项 | 内容 |
|-----|------|
| Service ID[hex] | 0x08 |
| Description | 返回前台测试结果。 |
#### 8.3.10 FlsTst_GetVersionInfo
```c
void FlsTst_GetVersionInfo(Std_VersionInfoType* VersionInfoPtr)
```
| 项 | 内容 |
|-----|------|
| Service ID[hex] | 0x09 |
#### 8.3.11 FlsTst_GetTestSignatureBgnd
```c
Std_ReturnType FlsTst_GetTestSignatureBgnd(FlsTst_TestSignatureBgndType* TestSignaturePtr)
```
| 项 | 内容 |
|-----|------|
| Service ID[hex] | 0x0a |
| Description | 返回后台测试签名。 |
#### 8.3.12 FlsTst_GetTestSignatureFgnd
```c
Std_ReturnType FlsTst_GetTestSignatureFgnd(FlsTst_TestSignatureFgndType* TestSignaturePtr)
```
| 项 | 内容 |
|-----|------|
| Service ID[hex] | 0x0b |
| Description | 返回前台测试签名。 |
#### 8.3.13 FlsTst_GetErrorDetails
```c
Std_ReturnType FlsTst_GetErrorDetails(FlsTst_ErrorDetailsType* ErrorDetailsPtr)
```
| 项 | 内容 |
|-----|------|
| Service ID[hex] | 0x0c |
| Description | 返回错误细节。 |
#### 8.3.14 FlsTst_TestEcc
```c
Std_ReturnType FlsTst_TestEcc(void)
```
| 项 | 内容 |
|-----|------|
| Service ID[hex] | 0x0d |
| Description | 测试 ECC 电路。 |
### 8.4 回调通知
无。
### 8.5 调度函数
#### FlsTst_MainFunction
```c
void FlsTst_MainFunction(void)
```
| 项 | 内容 |
|-----|------|
| Service ID[hex] | 0x0e |
| Description | 执行后台 Flash 测试的服务。 |
| Available via | SchM_FlsTst.h |
### 8.6 期望接口
#### 强制接口
| API 函数 | 头文件 | 描述 |
|----------|--------|------|
| Dem_SetEventStatus | Dem.h | 报告监视状态信息到 Dem |
#### 可选接口
| API 函数 | 头文件 | 描述 |
|----------|--------|------|
| Det_ReportError | Det.h | 报告开发错误 |
#### 可配置接口
##### FlsTst_TestCompleted 通知
测试完成时调用的可配置回调函数。
---
## 9 时序图
### 9.1 初始化
EcuM → FlsTst:`FlsTst_Init`
### 9.2 反初始化
EcuM → FlsTst:`FlsTst_DeInit`
### 9.3 后台测试
调度程序周期调用 `FlsTst_MainFunction`,执行部分测试。可选地:
- 在驱动内部计算测试结果
- 将测试签名提供给调用者
### 9.4 暂停和恢复后台测试
用户 → FlsTst:`FlsTst_Suspend``FlsTst_Resume`
### 9.5 前台任务中断后台任务
后台测试运行时,通过 `FlsTst_StartFgnd` 启动前台测试。
---
## 10 配置规范
### 10.1 容器与配置参数
#### 10.1.1 FlsTst
| 项 | 内容 |
|-----|------|
| SWS Item | ECUC_FlsTst_00150 |
| Module Name | FlsTst |
| Module Description | Flash Test 模块配置 |
| Post-Build Variant Support | true |
| Supported Config Variants | VARIANT-POST-BUILD, VARIANT-PRE-COMPILE |
#### 10.1.2 FlsTstGeneral
| 参数 | 描述 |
|------|------|
| FlsTstDevErrorDetect | 开发错误检测开关 |
| FlsTstVersionInfoApi | 版本信息 API 启用 |
| FlsTstNumberOfTestedCells | 一周期测试的单元数 |
| FlsTstNumberOfTestedCellsAtomic | 部分测试中可中断的最小单元数 |
| FlsTstTestIntervalIdEndValue | 测试间隔标识符结束值 |
| FlsTstMainFunctionPeriod | 主函数周期(秒) |
| FlsTstEcucPartitionRef | ECUC 分区引用 |
#### 10.1.3 FlsTstConfigurationOfOptApiServices
可选 API 服务配置:启用/禁用以下 API:
- FlsTst_StartFgnd
- FlsTst_GetTestResultBgnd
- FlsTst_GetTestResultFgnd
- FlsTst_GetTestSignatureBgnd
- FlsTst_GetTestSignatureFgnd
- FlsTst_GetErrorDetails
- FlsTst_TestEcc
#### 10.1.4 FlsTstDemEventParameterRefs
引用 DEM 事件参数:
- FLSTST_E_FLSTST_FAILURE
#### 10.1.5 FlsTstBlockBgnd
每个后台测试块:
| 参数 | 描述 |
|------|------|
| FlsTstBlockNumberBgnd | 后台块编号 |
| FlsTstBlockIndex | 块索引 |
| FlsTstBlockSize | 块大小 |
| FlsTstBlockType | 块类型(算法选择) |
| FlsTstBlockStartAddress | 块起始地址 |
#### 10.1.6 FlsTstBlockFgnd
每个前台测试块:
| 参数 | 描述 |
|------|------|
| FlsTstBlockNumberFgnd | 前台块编号 |
| FlsTstBlockIndex | 块索引 |
| FlsTstBlockSize | 块大小 |
| FlsTstBlockType | 块类型(算法选择) |
| FlsTstBlockStartAddress | 块起始地址 |
### 10.2 已发布信息
发布的参数包括版本信息等。
---
## 11 不适用需求
[SWS_FlsTst_00166] ⌈这些需求不适用于本规范。⌋ 涉及多个 SRS_BSW_* 和 SRS_SPAL_* 需求,详见原文 PDF。
---
## 翻译说明
- 本文档完整翻译自 AUTOSAR_SWS_FlashTest v4.4.0(Document ID 261,56 页)。
- 保留所有需求 ID(SWS_FlsTst_xxxxx、SRS_FlsTst_xxxxx、ECUC_FlsTst_xxxxx)。
- 保留 AUTOSAR 方框符 ⌈⌋。
- 模块缩写(FlsTst、Fls、ECC、CRC、DEM、DET 等)和 API 函数名保持英文。
- 详细配置参数和示例请参考原文 PDF 第 10 章。