Appendix A: Tool Configuration Reference

This appendix provides complete configuration examples for all tools referenced throughout this book. Use these as starting points for your own projects, and adapt them to your specific toolchain and requirements.


Static Analysis Tools

1. PC-lint Plus (MISRA C:2012)

Configuration File: project.lnt

Version Compatibility: PC-lint Plus 2.0+ (tested with 2.1). For PC-lint 9.x, use au-misra2.lnt and adjust option syntax.

// PC-lint Plus Configuration for MISRA C:2012
// Embedded automotive project (ASPICE CL2, ISO 26262 ASIL-B)

// Include MISRA C:2012 rule set
au-misra3.lnt

// Compiler selection (GCC for ARM Cortex-M)
co-gcc.lnt
// For TriCore: co-tricore.lnt (Infineon AURIX)
// For IAR ARM: co-iar-arm.lnt

// Size options (32-bit ARM Cortex-M)
-si4    // sizeof(int) = 4
-sp4    // sizeof(pointer) = 4
-sl4    // sizeof(long) = 4
// For TriCore TC39x: -si4 -sp4 -sl4 (same as ARM)
// For 16-bit targets: -si2 -sp2 -sl4

// Project-specific directories
-i"./src"
-i"./include"
-i"./AUTOSAR/include"

// Suppress specific warnings (with justification)
// IMPORTANT: Each suppression requires a Deviation Record per MISRA compliance
-e537   // Repeated include files (AUTOSAR BSW has intentional repeats)
        // Deviation: DEV-MISRA-001 - AUTOSAR Specification requires repeated includes
-e451   // Header guard not recognized (some AUTOSAR headers use #pragma once)
        // Deviation: DEV-MISRA-002 - Vendor-supplied AUTOSAR BSW headers

// Enable all MISRA Required rules (no exceptions)
+elib(*)

// Severity escalation
-strong(AJX)  // All MISRA violations are errors

// Output format
-format="MISRA C:2012 %t %f(%l): %n %m"
-width(120)

// Work products
-os(lint_output.txt)

2. cppcheck (Static Analysis)

Configuration File: .cppcheck

<?xml version="1.0"?>
<project>
    <root name="."/>
    <builddir>build/cppcheck</builddir>

    <!-- Include paths -->
    <includedir>src/</includedir>
    <includedir>include/</includedir>

    <!-- Suppress false positives -->
    <suppress>
        <id>missingIncludeSystem</id>
    </suppress>

    <!-- Enable all checks -->
    <check-config/>
    <check-library/>

    <!-- MISRA addon -->
    <addon>misra</addon>

    <!-- Platform -->
    <platform>unix32</platform>
</project>

Command Line:

cppcheck --project=.cppcheck \
         --enable=all \
         --inconclusive \
         --std=c11 \
         --addon=misra \
         --xml \
         --xml-version=2 \
         2> cppcheck-report.xml

CI/CD Configurations

3. GitLab CI (.gitlab-ci.yml)

Complete Pipeline (from 34.04 Continuous Integration Mastery):

stages:
  - format-check
  - build
  - test
  - static-analysis
  - coverage
  - traceability
  - artifacts

variables:
  MISRA_COMPLIANCE_THRESHOLD: "0"
  COVERAGE_THRESHOLD: "90"
  GCC_ARM: "arm-none-eabi-gcc"

# Format check
format-check:
  stage: format-check
  image: ubuntu:22.04
  before_script:
    - apt-get update && apt-get install -y clang-format
  script:
    - clang-format --dry-run --Werror src/*.c src/*.h
  allow_failure: false

# Build
build:
  stage: build
  image: gcc:11
  script:
    - mkdir -p build && cd build
    - cmake .. -DCMAKE_BUILD_TYPE=Release
    - make -j$(nproc)
  artifacts:
    paths:
      - build/acc_ecu.elf
      - build/compile_commands.json
    expire_in: 1 week

# Unit tests
test:
  stage: test
  image: gcc:11
  dependencies:
    - build
  script:
    - cd build
    - cmake .. -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON
    - make -j$(nproc)
    - ./tests/acc_tests --gtest_output=xml:test_results.xml
  artifacts:
    reports:
      junit: build/test_results.xml
    paths:
      - build/test_results.xml

# Static analysis
static-analysis:
  stage: static-analysis
  image: ubuntu:22.04
  before_script:
    - apt-get update && apt-get install -y cppcheck python3-pip
    # cppcheck's MISRA addon is built-in; no separate pip package required
  script:
    - cppcheck --enable=all --addon=misra --xml --xml-version=2 src/ 2> cppcheck.xml
    - python3 scripts/check_misra.py cppcheck.xml
  artifacts:
    paths:
      - cppcheck.xml
  allow_failure: false

# Coverage
coverage:
  stage: coverage
  image: gcc:11
  dependencies:
    - test
  script:
    - cd build
    - gcovr -r .. --xml --output coverage.xml
    - COVERAGE=$(gcovr -r .. | grep TOTAL | awk '{print $4}' | sed 's/%//')
    - echo "Coverage: $COVERAGE%"
    - |
      if (( $(echo "$COVERAGE < $COVERAGE_THRESHOLD" | bc -l) )); then
        echo "Coverage $COVERAGE% is below threshold $COVERAGE_THRESHOLD%"
        exit 1
      fi
  coverage: '/TOTAL.*\s+(\d+%)/'
  artifacts:
    reports:
      coverage_report:
        coverage_format: cobertura
        path: build/coverage.xml

# Traceability check
traceability:
  stage: traceability
  image: python:3.11
  script:
    - python3 scripts/check_traceability.py src/ tests/
  allow_failure: false

# Create release artifacts
artifacts:
  stage: artifacts
  image: ubuntu:22.04
  dependencies:
    - build
    - coverage
  script:
    - mkdir release
    - cp build/acc_ecu.elf release/
    - cp build/coverage.xml release/
    - tar -czf release.tar.gz release/
  artifacts:
    paths:
      - release.tar.gz
    expire_in: 30 days
  only:
    - tags

4. GitHub Actions (.github/workflows/ci.yml)

name: ASPICE CI/CD Pipeline

on:
  push:
    branches: [ main, develop ]
  pull_request:
    branches: [ main ]

jobs:
  build-and-test:
    runs-on: ubuntu-22.04

    steps:
    - uses: actions/checkout@v4

    - name: Setup GCC ARM
      run: |
        sudo apt-get update
        sudo apt-get install -y gcc-arm-none-eabi

    - name: Build
      run: |
        mkdir build && cd build
        cmake .. -DCMAKE_BUILD_TYPE=Release
        make -j$(nproc)

    - name: Run Tests
      run: |
        cd build
        ctest --output-on-failure

    - name: Upload artifacts
      uses: actions/upload-artifact@v4
      with:
        name: firmware
        path: build/*.elf

  static-analysis:
    runs-on: ubuntu-22.04

    steps:
    - uses: actions/checkout@v4

    - name: Run cppcheck
      run: |
        sudo apt-get install -y cppcheck
        cppcheck --enable=all --error-exitcode=1 src/

    - name: MISRA Check
      run: |
        # cppcheck's --addon=misra provides built-in MISRA checking
        cppcheck --enable=all --addon=misra --error-exitcode=1 src/

AI Tool Configurations

5. GitHub Copilot (.github/copilot-instructions.md)

# GitHub Copilot Instructions for ASPICE Project

## Coding Standards
- **Language**: C11 (embedded systems)
- **Standard**: MISRA C:2012 (all Required rules, most Advisory)
- **Documentation**: Doxygen format
- **Naming**: Hungarian notation for embedded (g_global, p_pointer, u8_uint8)

## Code Generation Rules
1. All functions must have Doxygen headers
2. Include @implements tag with requirement ID
3. Defensive programming: check all pointers
4. Use const wherever possible
5. No dynamic memory allocation (malloc/free forbidden)
6. All switch statements must have default case

## Example Function Template
```c
/**
 * @brief Calculate obstacle distance from radar
 * @implements [SWE-045-1]
 * @param[out] distance_m Distance in meters
 * @return 0=success, -1=error
 * @safety_class ASIL-B
 */
int ACC_GetObstacleDistance(float* distance_m);

Test Generation

  • Framework: Google Test (C++)
  • Coverage target: 100% for ASIL-B
  • Include typical, boundary, and error cases

---

### 6. .clang-format (Code Formatting)

```yaml
---
Language: Cpp
BasedOnStyle: LLVM
IndentWidth: 4
ColumnLimit: 100
UseTab: Never
BreakBeforeBraces: Linux
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
IndentCaseLabels: true
PointerAlignment: Right
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
IncludeBlocks: Regroup
IncludeCategories:
  - Regex:           '^".*\.h"'
    Priority:        1
  - Regex:           '^<.*\.h>'
    Priority:        2
  - Regex:           '.*'
    Priority:        3

Requirements Management Tools

7. DOORS Next (DXL Script Example)

// Export requirements to CSV for AI processing
// File: export_requirements.dxl

Module m = current
string csvPath = "requirements_export.csv"

Stream output = write(csvPath)

// Write header
output << "ID,Title,Description,Priority,Status,Verification\n"

// Iterate all objects
for obj in m do {
    if (obj."Object Type" == "Requirement") {
        string id = obj."Absolute Number"
        string title = obj."Object Heading"
        string desc = obj."Object Text"
        string priority = obj."Priority"
        string status = obj."Status"
        string verification = obj."Verification Method"

        output << id << ","
                << title << ","
                << desc << ","
                << priority << ","
                << status << ","
                << verification << "\n"
    }
}

close(output)
print "Exported to " csvPath

Testing Frameworks

8. Google Test (CMakeLists.txt)

cmake_minimum_required(VERSION 3.14)
project(ACC_Tests)

# GoogleTest
include(FetchContent)
FetchContent_Declare(
  googletest
  URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)

enable_testing()

# Test executable
add_executable(
  acc_tests
  tests/test_acc_controller.cpp
  tests/test_sensor_fusion.cpp
  src/acc_controller.c
  src/sensor_fusion.c
)

target_link_libraries(
  acc_tests
  GTest::gtest_main
  GTest::gmock
)

target_include_directories(acc_tests PRIVATE include/)

# Coverage flags
if(ENABLE_COVERAGE)
  target_compile_options(acc_tests PRIVATE --coverage)
  target_link_options(acc_tests PRIVATE --coverage)
endif()

include(GoogleTest)
gtest_discover_tests(acc_tests)

Traceability Tools

9. Python Traceability Script

File: scripts/check_traceability.py

#!/usr/bin/env python3
"""
Traceability verification script
Checks @implements and @verifies tags in code
"""

import re
import sys
from pathlib import Path

def extract_requirements(source_dir):
    """Extract @implements tags from source code"""
    implements = set()

    for c_file in Path(source_dir).rglob("*.c"):
        content = c_file.read_text()
        matches = re.findall(r'@implements\s+\[([^\]]+)\]', content)
        implements.update(matches)

    return implements

def extract_tests(test_dir):
    """Extract @verifies tags from test code"""
    verifies = set()

    for test_file in Path(test_dir).rglob("test_*.cpp"):
        content = test_file.read_text()
        matches = re.findall(r'@verifies\s+\[([^\]]+)\]', content)
        verifies.update(matches)

    return verifies

def main():
    if len(sys.argv) != 3:
        print("Usage: check_traceability.py <source_dir> <test_dir>")
        sys.exit(1)

    source_dir = sys.argv[1]
    test_dir = sys.argv[2]

    implemented = extract_requirements(source_dir)
    verified = extract_tests(test_dir)

    print(f"[OK] Requirements implemented: {len(implemented)}")
    print(f"[OK] Requirements verified: {len(verified)}")

    # Check coverage
    not_verified = implemented - verified
    if not_verified:
        print(f"\n⚠ WARNING: {len(not_verified)} requirements not verified:")
        for req in sorted(not_verified):
            print(f"  - {req}")
        sys.exit(1)

    print("\n[PASS] All implemented requirements have test coverage")
    sys.exit(0)

if __name__ == "__main__":
    main()

Automated Documentation

10. Doxygen (Doxyfile.cfg)

PROJECT_NAME           = "ACC ECU Software"
PROJECT_BRIEF          = "ASPICE CL2 + ISO 26262 ASIL-B"
OUTPUT_DIRECTORY       = docs/
INPUT                  = src/ include/
RECURSIVE              = YES
EXTRACT_ALL            = YES
EXTRACT_PRIVATE        = YES
EXTRACT_STATIC         = YES

# Traceability support
ALIASES += implements{1}="Implements requirement: \1"
ALIASES += verifies{1}="Verifies requirement: \1"
ALIASES += safety_class{1}="Safety Class: \1"

# Generate diagrams
HAVE_DOT               = YES
CALL_GRAPH             = YES
CALLER_GRAPH           = YES
CLASS_DIAGRAMS         = YES

# Output formats
GENERATE_HTML          = YES
GENERATE_LATEX         = NO
GENERATE_XML           = YES

# Warnings
WARN_IF_UNDOCUMENTED   = YES
WARN_NO_PARAMDOC       = YES