Add full automotive RTOS project

Add kernel (Cortex-M0/M3/M4, Tricore, S32K, RISC-V ports), drivers,
middleware (CAN stack, diagnostics, safety), applications, board
support, build/test tooling, and documentation.
This commit is contained in:
root
2026-08-23 03:35:29 -04:00
parent f113bf0a05
commit ca13734bf0
151 changed files with 23945 additions and 0 deletions
+261
View File
@@ -0,0 +1,261 @@
/**
* @file build.yml
* @brief Gitea workflow for building Automotive RTOS
*/
name: Build
on:
push:
branches: [main, develop]
tags:
- 'v*'
pull_request:
branches: [main, develop]
workflow_dispatch:
env:
PROJECT_NAME: automotive-rtos
BUILD_DIR: build
jobs:
# Build for STM32F407 Discovery
build-stm32f407:
name: Build STM32F407 Discovery
runs-on: ubuntu-latest
container:
image: ghcr.io/automotive-rtos/build-env:latest
options: --privileged
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Cache build artifacts
uses: actions/cache@v3
with:
path: |
${{ env.BUILD_DIR }}/stm32f407_discovery
~/.cache
key: stm32f407-${{ runner.os }}-${{ hashFiles('**/*.c', '**/*.h', '**/Makefile', '**/CMakeLists.txt') }}
restore-keys: |
stm32f407-${{ runner.os }}-
- name: Setup build environment
run: |
echo "Setting up build environment..."
export PATH="/opt/arm-gcc/bin:$PATH"
arm-none-eabi-gcc --version
cmake --version
make --version
- name: Configure debug build
run: |
mkdir -p ${{ env.BUILD_DIR }}/stm32f407_discovery/debug
cd ${{ env.BUILD_DIR }}/stm32f407_discovery/debug
cmake ../../.. \
-DTARGET_BOARD=stm32f407_discovery \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_TOOLCHAIN_FILE=../../../cmake/toolchain-stm32f407_discovery.cmake \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
- name: Build debug
run: |
cd ${{ env.BUILD_DIR }}/stm32f407_discovery/debug
make -j$(nproc)
arm-none-eabi-size automotive_rtos.elf
- name: Configure release build
run: |
mkdir -p ${{ env.BUILD_DIR }}/stm32f407_discovery/release
cd ${{ env.BUILD_DIR }}/stm32f407_discovery/release
cmake ../../.. \
-DTARGET_BOARD=stm32f407_discovery \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=../../../cmake/toolchain-stm32f407_discovery.cmake \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
- name: Build release
run: |
cd ${{ env.BUILD_DIR }}/stm32f407_discovery/release
make -j$(nproc)
arm-none-eabi-size automotive_rtos.elf
- name: Generate artifacts
run: |
cd ${{ env.BUILD_DIR }}/stm32f407_discovery/release
arm-none-eabi-objcopy -O ihex automotive_rtos.elf automotive_rtos.hex
arm-none-eabi-objcopy -O binary automotive_rtos.elf automotive_rtos.bin
arm-none-eabi-nm -n automotive_rtos.elf > automotive_rtos.map
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: stm32f407-firmware
path: |
${{ env.BUILD_DIR }}/stm32f407_discovery/release/automotive_rtos.elf
${{ env.BUILD_DIR }}/stm32f407_discovery/release/automotive_rtos.hex
${{ env.BUILD_DIR }}/stm32f407_discovery/release/automotive_rtos.bin
${{ env.BUILD_DIR }}/stm32f407_discovery/release/automotive_rtos.map
- name: Upload build logs
if: always()
uses: actions/upload-artifact@v3
with:
name: stm32f407-build-logs
path: |
${{ env.BUILD_DIR }}/stm32f407_discovery/**/*.log
${{ env.BUILD_DIR }}/stm32f407_discovery/**/compile_commands.json
# Build for NXP S32K144 EVB
build-s32k144:
name: Build NXP S32K144 EVB
runs-on: ubuntu-latest
container:
image: ghcr.io/automotive-rtos/build-env:latest
options: --privileged
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive
- name: Cache build artifacts
uses: actions/cache@v3
with:
path: ${{ env.BUILD_DIR }}/nxp_s32k144_evb
key: s32k144-${{ runner.os }}-${{ hashFiles('**/*.c', '**/*.h') }}
- name: Setup build environment
run: |
export PATH="/opt/arm-gcc/bin:$PATH"
arm-none-eabi-gcc --version
- name: Configure build
run: |
mkdir -p ${{ env.BUILD_DIR }}/nxp_s32k144_evb/debug
cd ${{ env.BUILD_DIR }}/nxp_s32k144_evb/debug
cmake ../../.. \
-DTARGET_BOARD=nxp_s32k144_evb \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_TOOLCHAIN_FILE=../../../cmake/toolchain-nxp_s32k144_evb.cmake
- name: Build
run: |
cd ${{ env.BUILD_DIR }}/nxp_s32k144_evb/debug
make -j$(nproc)
arm-none-eabi-size automotive_rtos.elf
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: s32k144-firmware
path: |
${{ env.BUILD_DIR }}/nxp_s32k144_evb/debug/automotive_rtos.elf
${{ env.BUILD_DIR }}/nxp_s32k144_evb/debug/automotive_rtos.hex
${{ env.BUILD_DIR }}/nxp_s32k144_evb/debug/automotive_rtos.bin
# Build for Custom ECU
build-custom-ecu:
name: Build Custom ECU
runs-on: ubuntu-latest
container:
image: ghcr.io/automotive-rtos/build-env:latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup build environment
run: |
export PATH="/opt/arm-gcc/bin:$PATH"
arm-none-eabi-gcc --version
- name: Configure build
run: |
mkdir -p ${{ env.BUILD_DIR }}/custom_ecu/release
cd ${{ env.BUILD_DIR }}/custom_ecu/release
cmake ../../.. \
-DTARGET_BOARD=custom_ecu \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=../../../cmake/toolchain-custom_ecu.cmake
- name: Build
run: |
cd ${{ env.BUILD_DIR }}/custom_ecu/release
make -j$(nproc)
arm-none-eabi-size automotive_rtos.elf
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: custom-ecu-firmware
path: |
${{ env.BUILD_DIR }}/custom_ecu/release/automotive_rtos.elf
${{ env.BUILD_DIR }}/custom_ecu/release/automotive_rtos.hex
${{ env.BUILD_DIR }}/custom_ecu/release/automotive_rtos.bin
# Create release
create-release:
name: Create Release
needs: [build-stm32f407, build-s32k144, build-custom-ecu]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Create release archive
run: |
cd artifacts
tar -czf ../automotive-rtos-release.tar.gz .
sha256sum ../automotive-rtos-release.tar.gz > ../automotive-rtos-release.sha256
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload release assets
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./automotive-rtos-release.tar.gz
asset_name: automotive-rtos-release.tar.gz
asset_content_type: application/gzip
# Notify on failure
notify-failure:
name: Notify on Failure
needs: [build-stm32f407, build-s32k144, build-custom-ecu]
if: failure()
runs-on: ubuntu-latest
steps:
- name: Send notification
run: |
echo "Build failed!"
echo "Branch: ${{ github.ref }}"
echo "Commit: ${{ github.sha }}"
echo "Author: ${{ github.actor }}"
# Send email notification
if [ -n "${{ secrets.NOTIFICATION_EMAIL }}" ]; then
echo "Sending email notification..."
fi
+300
View File
@@ -0,0 +1,300 @@
/**
* @file static-analysis.yml
* @brief Gitea workflow for static analysis
*/
name: Static Analysis
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
workflow_dispatch:
schedule:
- cron: '0 2 * * 1' # Weekly on Monday at 2 AM
env:
PROJECT_NAME: automotive-rtos
BUILD_DIR: build/analysis
jobs:
# Cppcheck analysis
cppcheck:
name: Cppcheck Analysis
runs-on: ubuntu-latest
container:
image: ghcr.io/automotive-rtos/build-env:latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Run cppcheck
run: |
mkdir -p ${{ env.BUILD_DIR }}/cppcheck
cppcheck \
--enable=all \
--inconclusive \
--std=c11 \
--platform=arm32 \
--force \
--inline-suppr \
-Ikernel/include \
-Idrivers/include \
-Imiddleware \
-Iconfig \
--suppress=missingInclude \
--suppress=missingIncludeSystem \
--suppress=unusedFunction \
--xml \
--xml-version=2 \
kernel drivers middleware applications \
2> ${{ env.BUILD_DIR }}/cppcheck/cppcheck.xml
# Convert to HTML
cppcheck-htmlreport \
--file=${{ env.BUILD_DIR }}/cppcheck/cppcheck.xml \
--report-dir=${{ env.BUILD_DIR }}/cppcheck/html \
--source-dir=.
- name: Upload cppcheck report
uses: actions/upload-artifact@v3
with:
name: cppcheck-report
path: ${{ env.BUILD_DIR }}/cppcheck/
- name: Check for critical issues
run: |
critical_count=$(grep -c 'severity="error"' ${{ env.BUILD_DIR }}/cppcheck/cppcheck.xml || true)
echo "Critical issues: $critical_count"
if [ "$critical_count" -gt 0 ]; then
echo "❌ Critical issues found"
exit 1
fi
# MISRA C compliance
misra-compliance:
name: MISRA C:2012 Compliance
runs-on: ubuntu-latest
container:
image: ghcr.io/automotive-rtos/build-env:latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Run MISRA check
run: |
mkdir -p ${{ env.BUILD_DIR }}/misra
# Check if MISRA addon is available
if [ -f "/usr/share/cppcheck/addons/misra.py" ]; then
for dir in kernel drivers middleware applications; do
echo "Checking $dir..."
cppcheck \
--addon=misra \
--std=c11 \
--platform=arm32 \
-Ikernel/include \
-Idrivers/include \
-Imiddleware \
-Iconfig \
--suppress=missingInclude \
"$dir" \
2> ${{ env.BUILD_DIR }}/misra/${dir}_misra.log || true
done
# Count violations
total_violations=0
for log in ${{ env.BUILD_DIR }}/misra/*_misra.log; do
violations=$(grep -c "misra" "$log" || true)
total_violations=$((total_violations + violations))
echo "$(basename $log): $violations violations"
done
echo "Total MISRA violations: $total_violations"
# Check against threshold
if [ "$total_violations" -gt 100 ]; then
echo "❌ Too many MISRA violations"
exit 1
fi
else
echo "⚠ MISRA addon not available"
fi
- name: Upload MISRA report
uses: actions/upload-artifact@v3
with:
name: misra-report
path: ${{ env.BUILD_DIR }}/misra/
# Compiler warnings
compiler-warnings:
name: Compiler Warnings Check
runs-on: ubuntu-latest
container:
image: ghcr.io/automotive-rtos/build-env:latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Check compiler warnings
run: |
mkdir -p ${{ env.BUILD_DIR }}/compiler
# Compile with strict warnings
find kernel drivers middleware applications -name "*.c" | while read file; do
arm-none-eabi-gcc \
-Wall \
-Wextra \
-Wpedantic \
-Wconversion \
-Wshadow \
-Wstrict-prototypes \
-Wmissing-prototypes \
-Wfloat-equal \
-Wundef \
-Wcast-align \
-Wwrite-strings \
-Wredundant-decls \
-Wformat=2 \
-Winit-self \
-Wswitch-default \
-Wswitch-enum \
-Wuninitialized \
-Wmaybe-uninitialized \
-fsyntax-only \
-Ikernel/include \
-Idrivers/include \
-Imiddleware \
-Iconfig \
"$file" 2>> ${{ env.BUILD_DIR }}/compiler/warnings.log
done
warning_count=$(grep -c "warning" ${{ env.BUILD_DIR }}/compiler/warnings.log || true)
echo "Total warnings: $warning_count"
if [ "$warning_count" -gt 50 ]; then
echo "❌ Too many compiler warnings"
exit 1
fi
- name: Upload warnings report
uses: actions/upload-artifact@v3
with:
name: compiler-warnings
path: ${{ env.BUILD_DIR }}/compiler/
# Code complexity analysis
complexity:
name: Code Complexity Analysis
runs-on: ubuntu-latest
container:
image: ghcr.io/automotive-rtos/build-env:latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install lizard
run: |
pip3 install lizard
- name: Run complexity analysis
run: |
mkdir -p ${{ env.BUILD_DIR }}/complexity
lizard \
--CCN 10 \
--length 100 \
--arguments 6 \
--html \
kernel drivers middleware applications \
> ${{ env.BUILD_DIR }}/complexity/complexity.html
# Check for high complexity functions
high_complexity=$(lizard --CCN 20 kernel drivers middleware applications | grep -c "warning" || true)
echo "High complexity functions: $high_complexity"
if [ "$high_complexity" -gt 10 ]; then
echo "⚠ High code complexity detected"
fi
- name: Upload complexity report
uses: actions/upload-artifact@v3
with:
name: complexity-report
path: ${{ env.BUILD_DIR }}/complexity/
# Generate analysis summary
analysis-summary:
name: Generate Analysis Summary
needs: [cppcheck, misra-compliance, compiler-warnings, complexity]
if: always()
runs-on: ubuntu-latest
steps:
- name: Download reports
uses: actions/download-artifact@v3
with:
path: analysis-results
- name: Generate summary
run: |
echo "# Static Analysis Summary" > analysis-summary.md
echo "" >> analysis-summary.md
echo "Date: $(date)" >> analysis-summary.md
echo "" >> analysis-summary.md
echo "## Results" >> analysis-summary.md
echo "" >> analysis-summary.md
for report_dir in analysis-results/*/; do
if [ -d "$report_dir" ]; then
echo "### $(basename $report_dir)" >> analysis-summary.md
echo "" >> analysis-summary.md
# List files
find "$report_dir" -type f | while read file; do
echo "- $(basename $file)" >> analysis-summary.md
done
echo "" >> analysis-summary.md
fi
done
- name: Upload summary
uses: actions/upload-artifact@v3
with:
name: analysis-summary
path: analysis-summary.md
# Notify on failure
notify:
name: Notify on Failure
needs: [cppcheck, misra-compliance, compiler-warnings, complexity]
if: failure()
runs-on: ubuntu-latest
steps:
- name: Send notification
run: |
echo "Static analysis failed!"
echo "Branch: ${{ github.ref }}"
echo "Commit: ${{ github.sha }}"
# Send webhook notification
if [ -n "${{ secrets.WEBHOOK_URL }}" ]; then
curl -X POST \
-H "Content-Type: application/json" \
-d '{
"text": "Static analysis failed for commit '"${{ github.sha }}"'",
"branch": "'"${{ github.ref }}"'"
}' \
"${{ secrets.WEBHOOK_URL }}"
fi
+309
View File
@@ -0,0 +1,309 @@
/**
* @file test.yml
* @brief Gitea workflow for running tests
*/
name: Test
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # Daily at midnight
env:
PROJECT_NAME: automotive-rtos
BUILD_DIR: build
jobs:
# Unit tests
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
container:
image: ghcr.io/automotive-rtos/build-env:latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive
- name: Cache test build
uses: actions/cache@v3
with:
path: ${{ env.BUILD_DIR }}/tests
key: unit-tests-${{ hashFiles('tests/unit/**/*.c', 'kernel/**/*.c', 'kernel/**/*.h') }}
- name: Build unit tests
run: |
mkdir -p ${{ env.BUILD_DIR }}/tests/unit
for test_file in tests/unit/test_*.c; do
test_name=$(basename "$test_file" .c)
echo "Building $test_name..."
gcc \
-Ikernel/include \
-Idrivers/include \
-Imiddleware \
-Iconfig \
-Itests \
-Ithird_party/unity \
"$test_file" \
third_party/unity/unity.c \
-o "${{ env.BUILD_DIR }}/tests/unit/$test_name" \
-Wall -Wextra -Werror \
-g -O0 \
-coverage
done
- name: Run unit tests
run: |
passed=0
failed=0
for test_binary in ${{ env.BUILD_DIR }}/tests/unit/test_*; do
if [ -x "$test_binary" ]; then
test_name=$(basename "$test_binary")
echo "Running $test_name..."
if timeout 60 "$test_binary" > "$test_binary.log" 2>&1; then
echo "✓ $test_name passed"
passed=$((passed + 1))
else
echo "✗ $test_name failed"
cat "$test_binary.log"
failed=$((failed + 1))
fi
fi
done
echo "Passed: $passed"
echo "Failed: $failed"
if [ $failed -gt 0 ]; then
exit 1
fi
- name: Generate coverage report
run: |
cd ${{ env.BUILD_DIR }}/tests/unit
gcov *.gcda
mkdir -p ../../../${{ env.BUILD_DIR }}/coverage
gcovr \
--root ../../.. \
--exclude tests \
--exclude third_party \
--html \
--html-details \
-o ../../../${{ env.BUILD_DIR }}/coverage/index.html
- name: Upload coverage report
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: ${{ env.BUILD_DIR }}/coverage/
- name: Upload test logs
if: always()
uses: actions/upload-artifact@v3
with:
name: unit-test-logs
path: ${{ env.BUILD_DIR }}/tests/unit/*.log
# Integration tests
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
container:
image: ghcr.io/automotive-rtos/build-env:latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive
- name: Build integration tests
run: |
mkdir -p ${{ env.BUILD_DIR }}/tests/integration
for test_file in tests/integration/test_*.c; do
test_name=$(basename "$test_file" .c)
echo "Building $test_name..."
gcc \
-Ikernel/include \
-Idrivers/include \
-Imiddleware \
-Iconfig \
-Itests \
-Ithird_party/unity \
"$test_file" \
kernel/src/*.c \
drivers/src/*.c \
middleware/can_stack/src/*.c \
third_party/unity/unity.c \
-o "${{ env.BUILD_DIR }}/tests/integration/$test_name" \
-Wall -Wextra \
-g -O0 \
-pthread
done
- name: Run integration tests
run: |
passed=0
failed=0
for test_binary in ${{ env.BUILD_DIR }}/tests/integration/test_*; do
if [ -x "$test_binary" ]; then
test_name=$(basename "$test_binary")
echo "Running $test_name..."
if timeout 120 "$test_binary" > "$test_binary.log" 2>&1; then
echo "✓ $test_name passed"
passed=$((passed + 1))
else
echo "✗ $test_name failed"
cat "$test_binary.log"
failed=$((failed + 1))
fi
fi
done
echo "Passed: $passed"
echo "Failed: $failed"
if [ $failed -gt 0 ]; then
exit 1
fi
- name: Upload test logs
if: always()
uses: actions/upload-artifact@v3
with:
name: integration-test-logs
path: ${{ env.BUILD_DIR }}/tests/integration/*.log
# System tests
system-tests:
name: System Tests
runs-on: ubuntu-latest
container:
image: ghcr.io/automotive-rtos/build-env:latest
options: --privileged
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive
- name: Build system tests
run: |
mkdir -p ${{ env.BUILD_DIR }}/tests/system
for test_file in tests/system/test_*.c; do
test_name=$(basename "$test_file" .c)
echo "Building $test_name..."
gcc \
-Ikernel/include \
-Idrivers/include \
-Imiddleware \
-Iconfig \
-Itests \
-Ithird_party/unity \
"$test_file" \
kernel/src/*.c \
drivers/src/*.c \
middleware/**/*.c \
third_party/unity/unity.c \
-o "${{ env.BUILD_DIR }}/tests/system/$test_name" \
-Wall -Wextra \
-g -O0 \
-pthread \
-DVIRTUAL_HARDWARE
done
- name: Run system tests
run: |
passed=0
failed=0
for test_binary in ${{ env.BUILD_DIR }}/tests/system/test_*; do
if [ -x "$test_binary" ]; then
test_name=$(basename "$test_binary")
echo "Running $test_name..."
if timeout 300 "$test_binary" > "$test_binary.log" 2>&1; then
echo "✓ $test_name passed"
passed=$((passed + 1))
else
echo "✗ $test_name failed"
cat "$test_binary.log"
failed=$((failed + 1))
fi
fi
done
echo "Passed: $passed"
echo "Failed: $failed"
if [ $failed -gt 0 ]; then
exit 1
fi
- name: Upload test logs
if: always()
uses: actions/upload-artifact@v3
with:
name: system-test-logs
path: ${{ env.BUILD_DIR }}/tests/system/*.log
# Generate test report
test-report:
name: Generate Test Report
needs: [unit-tests, integration-tests, system-tests]
if: always()
runs-on: ubuntu-latest
steps:
- name: Download test logs
uses: actions/download-artifact@v3
with:
path: test-logs
- name: Generate summary
run: |
echo "# Test Summary" > test-summary.md
echo "" >> test-summary.md
echo "Date: $(date)" >> test-summary.md
echo "" >> test-summary.md
echo "## Results" >> test-summary.md
echo "" >> test-summary.md
for log_dir in test-logs/*/; do
if [ -d "$log_dir" ]; then
echo "### $(basename $log_dir)" >> test-summary.md
echo "" >> test-summary.md
for log_file in "$log_dir"/*.log; do
if [ -f "$log_file" ]; then
test_name=$(basename "$log_file" .log)
if grep -q "FAIL" "$log_file"; then
echo "- ❌ $test_name" >> test-summary.md
else
echo "- ✅ $test_name" >> test-summary.md
fi
fi
done
echo "" >> test-summary.md
fi
done
- name: Upload summary
uses: actions/upload-artifact@v3
with:
name: test-summary
path: test-summary.md