本规约规定 AUTOSAR 基础软件模块 Core Test(核心测试,CorTst)的功能、API 与配置。CorTst 位于微控制器抽象层(MCAL),用于测试 MCU 核心硬件(如寄存器、ALU、地址生成器、内存接口、缓存、中断/异常处理、MMU/MPU 等)。
CorTst 提供后台(Background)与前台(Foreground)两种测试模式:
测试通过比较校验和/签名与黄金参考值(Golden Reference Value)判断 pass/fail 状态。
| 缩略语 | 描述 |
|---|---|
| CorTst | Core Test(核心测试) |
| CPU | Central Processing Unit(中央处理器) |
| MPU | Memory Protection Unit(内存保护单元) |
| MMU | Memory Management Unit(内存管理单元) |
| DEM | Diagnostic Event Manager(诊断事件管理器) |
| DET | Default Error Tracer(默认错误追踪器) |
| EcuM | ECU State Manager(ECU 状态管理器) |
| ISR | Interrupt Service Routine(中断服务例程) |
| BIST | Built in Self Test(内建自测试) |
| IRQ | Interrupt Request(中断请求) |
| Core | A CPU plus closely located functional resources(CPU 及其紧密相关的功能资源) |
| Atomic Sequence | Sequence of software code execution which must not be interrupted at any time(任何时候都不得被中断的软件代码执行序列) |
| Checksum / Signature | Numerical representation of the result of a test execution(测试执行结果的数值表示) |
| Golden (Ref.) Value | Reference value used for comparison(用于比较的参考值) |
AUTOSAR_EXP_LayeredSoftwareArchitecture — 分层软件架构AUTOSAR_SRS_BSWGeneral — 基础软件通用需求AUTOSAR_SWS_BSWGeneral — 基础软件通用规范AUTOSAR_SRS_CoreTest — 核心测试需求AUTOSAR_SRS_SPALGeneral — SPAL 通用需求CorTst 实现可能仅限于 power-up/start-up 阶段执行(此时核资源不在线程或实体之间共享,例如 IRQ 控制器、DMA),或仅限于测试运行时未共享的资源(如 CPU 本身)。多微控制器系统不在 CorTst 范围内。
CorTst.c # 主源文件
CorTst_Lcfg.c # Link-time 配置
CorTst_PBcfg.c # PostBuild 配置
CorTst 依赖 EcuM(资源管理)、DEM(错误报告)、DET(开发错误追踪)、OS(中断管理)。
CorTst 满足 SRS_CoreTst_NNNNN 中的 25+ 条需求(参见 SRS 翻译)以及 RS_BRF_NNNNN 顶层需求。CorTst 自身的 SWS_CorTst_NNNNN 规范项 ID 约 100+ 条(详细列表见原文第 6/7/8/10 章;编号范围 00001-01004)。
完整测试由 2 步组成:
CorTst 计算两个步骤并返回 pass/fail 状态,或仅计算校验和并提供完成通知给调用实体。
应(shall)可对硅设备内每个相等的核实例执行 CorTst。CorTst 本身与 API 由于其作为位于较低 AUTOSAR 层的驱动程序的特性,无需了解系统架构本身。
| 错误码 | 值 | 含义 |
|---|---|---|
CORTST_E_UNINIT | 0x01 | CorTst 未初始化 |
CORTST_E_ALREADY_INITIALIZED | 0x02 | CorTst 已初始化 |
CORTST_E_PARAM_POINTER | 0x03 | 无效的指针 |
CORTST_E_PARAM_VALUE | 0x04 | 无效的参数值 |
CORTST_E_BUSY | 0x05 | 测试忙 |
CORTST_E_NOT_VALID | 0x06 | 签名/校验和无效 |
| 错误码 | 值 | 含义 |
|---|---|---|
| 无。 | ||
无。
无(CorTst 不直接产生生产错误;由 DEM 报告)。
| 错误码 | 含义 |
|---|---|
CORTST_E_CORE_FAILURE | 核心测试失败(Core 故障) |
Std_ReturnType、Std_VersionInfoType、Std_ConfigType| 类型 | 描述 |
|---|---|
CorTst_ConfigType | CorTst 抽象配置类型 |
CorTst_ResultType | CorTst 测试结果类型(PASS / FAIL / NOT_TESTED / UNDEFINED) |
| API | 签名 | 功能 |
|---|---|---|
CorTst_Init | void CorTst_Init(const CorTst_ConfigType* ConfigPtr) | 初始化 CorTst |
CorTst_DeInit | void CorTst_DeInit(void) | 反初始化 CorTst |
| API | 签名 | 功能 |
|---|---|---|
CorTst_Abort | void CorTst_Abort(void) | 中止正在运行的测试 |
CorTst_Start | Std_ReturnType CorTst_Start(CorTst_TestIdType TestId, uint8 ChannelId) | 启动指定测试 |
CorTst_GetVersionInfo | void CorTst_GetVersionInfo(Std_VersionInfoType* VersionInfoPtr) | 获取版本信息 |
| API | 签名 | 功能 |
|---|---|---|
CorTst_GetState | CorTst_StateType CorTst_GetState(void) | 获取当前测试状态(IDLE/RUNNING/COMPLETED/ABORTED) |
CorTst_GetCurrentStatus | CorTst_ResultType CorTst_GetCurrentStatus(CorTst_TestIdType TestId) | 获取指定测试的当前结果 |
| API | 签名 | 功能 |
|---|---|---|
CorTst_GetSignature | Std_ReturnType CorTst_GetSignature(CorTst_SignatureType* SignaturePtr, CorTst_LengthType* LengthPtr) | 获取后台测试签名/校验和 |
CorTst_GetFgndSignature | Std_ReturnType CorTst_GetFgndSignature(CorTst_SignatureType* SignaturePtr, CorTst_LengthType* LengthPtr) | 获取前台测试签名/校验和 |
见 8.3.2 CorTst_Start。
| API | 签名 | 功能 |
|---|---|---|
CorTst_MainFunction | void CorTst_MainFunction(void) | 主函数(处理后台测试调度) |
| API | 签名 | 功能 |
|---|---|---|
CorTst_TestCompletedNotification | void CorTst_TestCompletedNotification(CorTst_TestIdType TestId, CorTst_ResultType Result) | 测试完成通知回调(应用实现) |
CorTst API 完整清单:11 个 API 函数(Init/DeInit/Start/Abort/GetState/GetCurrentStatus/GetSignature/GetFgndSignature/GetVersionInfo/MainFunction/TestCompletedNotification)。
CorTst_Start() → CorTst 入队 → CorTst_MainFunction() 处理 → 原子序列执行 → CorTst_GetSignature() 读取签名 → CorTst_TestCompletedNotification() 通知应用;CorTst_Start() → 立即执行 → CorTst_GetCurrentStatus() 读取结果;CorTst_Abort() → CorTst 取消运行测试 → 状态置为 ABORTED;| 参数 | 描述 |
|---|---|
| CorTstDevErrorDetect | 开发错误检测开关 |
| CorTstVersionInfoApi | CorTst_GetVersionInfo() API 开关 |
| CorTstMainFunctionPeriod | 主函数调度周期(秒) |
| CorTstEcucPartitionRef | ECU 分区引用 |
| 参数 | 描述 |
|---|---|
| CorTstNumberOfTests | 测试数量 |
| CorTstMulticoreSupport | 多核支持开关 |
| 参数 | 描述 |
|---|---|
| CorTstTestId | 测试 ID |
| CorTstTestPartitionRef | 测试分区引用 |
| CorTstTestAtomicSequenceRef | 原子序列引用 |
发布信息包括 CorTst 模块版本、配置变体、测试数量、多核支持等。
校对轮次:L1 自动校对(2026-06-13)
CORTST_E_UNINIT=0x01/ALREADY_INITIALIZED=0x02/PARAM_POINTER=0x03/PARAM_VALUE=0x04/BUSY=0x05/NOT_VALID=0x06) + 1 个扩展生产错误 CORTST_E_CORE_FAILURE 完整翻译。