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
+194
View File
@@ -0,0 +1,194 @@
#!/bin/bash
#==============================================================================
# Build all targets for Automotive RTOS
#==============================================================================
set -e
# Script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
# Color codes
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Build configuration
BUILD_DIR="${PROJECT_ROOT}/build"
TARGETS=("stm32f407_discovery" "nxp_s32k144_evb" "custom_ecu")
BUILD_TYPES=("debug" "release")
# Create directories
mkdir -p "${BUILD_DIR}"
# Print banner
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN} Automotive RTOS Build System${NC}"
echo -e "${GREEN}========================================${NC}"
echo ""
# Function to check if toolchain is available
check_toolchain() {
if ! command -v arm-none-eabi-gcc >/dev/null 2>&1; then
echo -e "${RED}Error: arm-none-eabi-gcc not found in PATH${NC}"
echo -e "${YELLOW}Please run: bash scripts/setup_environment.sh${NC}"
echo -e "${YELLOW}Or install ARM toolchain manually${NC}"
exit 1
fi
}
# Function to build target
build_target() {
local target=$1
local build_type=$2
echo -e "${YELLOW}Building ${target} (${build_type})...${NC}"
local build_dir="${BUILD_DIR}/${target}/${build_type}"
mkdir -p "${build_dir}"
# Check if CMakeLists.txt exists
if [ ! -f "${PROJECT_ROOT}/CMakeLists.txt" ]; then
echo -e "${YELLOW}No CMakeLists.txt found. Creating basic build...${NC}"
# Simple direct compilation without CMake
cd "${build_dir}"
# Compile kernel sources
for src in "${PROJECT_ROOT}"/kernel/src/*.c; do
if [ -f "$src" ]; then
echo " Compiling $(basename $src)..."
arm-none-eabi-gcc -c "$src" \
-I"${PROJECT_ROOT}/kernel/include" \
-I"${PROJECT_ROOT}/config" \
-mcpu=cortex-m4 -mthumb -O2 -Wall
fi
done
# Link object files
if ls *.o >/dev/null 2>&1; then
echo " Linking..."
arm-none-eabi-gcc -o automotive_rtos.elf *.o \
-mcpu=cortex-m4 -mthumb -nostdlib -T"${PROJECT_ROOT}/board/${target}/linker_script.ld"
echo -e "${GREEN}✓ Build successful${NC}"
else
echo -e "${YELLOW}No source files found to compile${NC}"
fi
return 0
fi
# Build with CMake if available
if command -v cmake >/dev/null 2>&1; then
cd "${build_dir}"
cmake "${PROJECT_ROOT}" \
-DTARGET_BOARD=${target} \
-DCMAKE_BUILD_TYPE=${build_type} \
-DCMAKE_TOOLCHAIN_FILE="${PROJECT_ROOT}/cmake/toolchain-${target}.cmake" \
2>/dev/null || {
echo -e "${YELLOW}CMake configuration failed. Trying direct build...${NC}"
return 1
}
make -j$(nproc 2>/dev/null || echo 4) 2>/dev/null || {
echo -e "${YELLOW}Make failed${NC}"
return 1
}
else
echo -e "${YELLOW}CMake not found. Skipping ${target}${NC}"
return 1
fi
echo -e "${GREEN}${target} (${build_type}) built successfully${NC}"
echo ""
return 0
}
# Main build process
main() {
# Parse arguments
local clean_build=false
local specific_target=""
local specific_type=""
while [[ $# -gt 0 ]]; do
case $1 in
--clean)
clean_build=true
shift
;;
--target)
specific_target="$2"
shift 2
;;
--type)
specific_type="$2"
shift 2
;;
-h|--help)
echo "Usage: $0 [OPTIONS]"
echo " --clean Clean build"
echo " --target <name> Build specific target"
echo " --type <type> Build type (debug/release)"
echo " -h, --help Show this help"
exit 0
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
# Check toolchain
check_toolchain
# Clean build if requested
if [ "${clean_build}" = true ]; then
echo -e "${YELLOW}Cleaning build directory...${NC}"
rm -rf "${BUILD_DIR}"
mkdir -p "${BUILD_DIR}"
echo -e "${GREEN}✓ Clean complete${NC}"
echo ""
fi
# Build targets
local build_failed=0
if [ -n "$specific_target" ]; then
TARGETS=("$specific_target")
fi
if [ -n "$specific_type" ]; then
BUILD_TYPES=("$specific_type")
fi
for target in "${TARGETS[@]}"; do
for build_type in "${BUILD_TYPES[@]}"; do
if ! build_target "${target}" "${build_type}"; then
build_failed=1
fi
done
done
# Print summary
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN} Build Summary${NC}"
echo -e "${GREEN}========================================${NC}"
if [ ${build_failed} -eq 0 ]; then
echo -e "${GREEN}✓ All builds successful${NC}"
exit 0
else
echo -e "${YELLOW}⚠ Some builds had issues${NC}"
echo -e "${YELLOW}Check the build output above for details${NC}"
exit 1
fi
}
# Run main
main "$@"