# saharelnagar/ota_graduationproject2020 architecture

> Architecture diagram of the GitHub repository saharelnagar/ota_graduationproject2020, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/saharelnagar/ota_graduationproject2020
- Repository: https://github.com/saharelnagar/ota_graduationproject2020

## Overview

##### Project type and purpose
- This is an embedded, multi-ECU system implementing Over-The-Air (OTA) firmware updates for a smart vehicle.
- Key subsystems are:
- GateWay_ECU — a TI TM4C123-based CAN gateway running AUTOSAR-style BSW, RTE, and application SW-C modules handling download, decryption, storage, and distribution of updates.
- STM_ECU — an STM32F4-based LCD controller with its own bootloader and display application.
- TivaC_ECU — another TM4C123-based module with bootloader and gateway code (parallel or legacy).
- Telematics Unit — an ESP8266/ESP32 Arduino sketch connecting to the cloud to fetch updates.

##### File structure
- GateWay_ECU/software/BSW, RTE, SW_C → layered AUTOSAR BSW (MCAL, Communication, Memory, Infrastructure), RTE interface, and Software Components (Decryption_SWC, DownloadUpdate_SWC, StoreUpdate_SWC, TransmitECUsUpdate_SWC).
- GateWay_ECU/software/build → Code Composer Studio project for TM4C.
- STM_ECU folder: Atollic projects for LCD application and bootloader, plus resource packages for UI pages.
- TivaC_ECU: Keil/UVision and project structure mirroring GateWay functionality and bare-metal driverlib.
- Telematics Unit: single Arduino .ino sketch.

##### README
- Title “OTA_GraduationProject2020” confirms an OTA update use case for vehicle electronics.

##### Main components and their interactions
a. Hardware nodes:
- Telematics Unit (ESP32)
- CAN Bus (physical network)
- Gateway ECU (TM4C123)
- Secondary ECUs: STM_ECU (STM32F4 LCD), TivaC_ECU (TM4C123)
- Non-volatile Flash memory on each ECU
- Cloud update server (external service)
b. Software layers inside each ECU:
- MCAL/DriverLib → direct hardware interfaces (CAN driver, UART, GPIO, Flash/Eeprom)
- BSW modules → CANIf, MemIf, Ea/Eep/Fls/Fee, NvM, Platform/Infras­tructure
- RTE → virtual bus abstracting inter-SWC calls
- SW-C modules → DownloadUpdate, Decryption, StoreUpdate, TransmitECUsUpdate
- Bootloader (separate build target)
- Application (LCD or gateway logic)
c. Data flows:
- Cloud → Telematics Unit over Wi-Fi (HTTP/MQTT)
- Telematics Unit → Gateway ECU over UART or CAN
- Gateway ECU SW-C DownloadUpdate → decrypt → write to Flash via MemIf/Eep → confirm
- Gateway ECU → Broadcast new firmware packages to STM_ECU & TivaC_ECU over CAN
- Each ECU’s bootloader verifies and flashes new application image

##### Architectural patterns and technologies
- AUTOSAR-inspired layered architecture in GateWay_ECU (separation of MCAL, BSW, RTE, SW-Cs)
- Bare-metal RTOS-less approach with startup code, interrupt handlers
- Bootloader-application separation
- CAN network for intra-vehicle communication
- Wi-Fi/Arduino for telematics/cloud link
- Use of CCS and Keil toolchains

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Physical Nodes
    Cloud["Cloud Update Server"]:::external
    Tele["Telematics Unit\n(ESP32)"]:::hardware
    CANBus["CAN Bus"]:::bus

    %% Gateway ECU
    subgraph "Gateway ECU (TM4C123)" 
        direction TB
        GW_MCAL["MCAL/DriverLib"]:::mcal
        GW_BSW["BSW Modules"]:::bsw
        GW_RTE["RTE"]:::rte
        subgraph "SW-C Modules"
            direction TB
            SWC_DL["DownloadUpdate_SWC"]:::swc
            SWC_DEC["Decryption_SWC"]:::swc
            SWC_STO["StoreUpdate_SWC"]:::swc
            SWC_TRX["TransmitECUsUpdate_SWC"]:::swc
        end
        GW_BUILD["CCS Build Project"]:::tool
        GW_BOOT["Bootloader"]:::boot
    end

    %% STM ECU
    subgraph "STM_ECU (STM32F4 LCD)" 
        direction TB
        STM_HAL["HAL/StdPeriph libs"]:::mcal
        STM_BOOT["Bootloader"]:::boot
        STM_APP["LCD Application"]:::app
        STM_UI["UI Resource Packages"]:::resource
    end

    %% TivaC ECU
    subgraph "TivaC_ECU (TM4C123)" 
        direction TB
        TIVA_DRV["DriverLib"]:::mcal
        TIVA_INC["MCU Headers/Includes"]:::mcal
        TIVA_SRC["Bare-metal Source"]:::mcal
        TIVA_RTE["RTE"]:::rte
        TIVA_APP["Gateway Application"]:::app
        TIVA_BOOT["Bootloader"]:::boot
    end

    %% Data Flows
    Cloud -->|"HTTP/MQTT"| Tele
    Tele -->|"UART/CAN"| GW_MCAL
    GW_MCAL --> GW_BSW
    GW_BSW --> GW_RTE
    GW_RTE --> SWC_DL
    SWC_DL -->|"decrypt"| SWC_DEC
    SWC_DEC -->|"write Flash"| SWC_STO
    SWC_STO -->|"confirm"| SWC_TRX
    SWC_TRX -->|"Firmware Packet"| CANBus
    CANBus -->|"Broadcast"| STM_BOOT
    STM_BOOT -->|"verify & flash"| STM_APP
    CANBus -->|"Broadcast"| TIVA_BOOT
    TIVA_BOOT -->|"verify & flash"| TIVA_APP

    %% Click Events
    click GW_BSW "https://github.com/saharelnagar/ota_graduationproject2020/tree/master/GateWay_ECU/software/BSW"
    click GW_RTE "https://github.com/saharelnagar/ota_graduationproject2020/tree/master/GateWay_ECU/software/RTE"
    click SWC_DEC "https://github.com/saharelnagar/ota_graduationproject2020/tree/master/GateWay_ECU/software/SW_C/Decryption_SWC"
    click SWC_DL "https://github.com/saharelnagar/ota_graduationproject2020/tree/master/GateWay_ECU/software/SW_C/DownloadUpdate_SWC"
    click SWC_STO "https://github.com/saharelnagar/ota_graduationproject2020/tree/master/GateWay_ECU/software/SW_C/StoreUpdate_SWC"
    click SWC_TRX "https://github.com/saharelnagar/ota_graduationproject2020/tree/master/GateWay_ECU/software/SW_C/TransmitECUsUpdate_SWC"
    click GW_BUILD "https://github.com/saharelnagar/ota_graduationproject2020/tree/master/GateWay_ECU/software/build/CCS"
    click STM_APP "https://github.com/saharelnagar/ota_graduationproject2020/tree/master/STM_ECU/LCD_Atollic/LCD"
    click STM_BOOT "https://github.com/saharelnagar/ota_graduationproject2020/tree/master/STM_ECU/bootloader_atolic"
    click STM_UI "https://github.com/saharelnagar/ota_graduationproject2020/tree/master/STM_ECU/grad_LCD/smart_car"
    click TIVA_BOOT "https://github.com/saharelnagar/ota_graduationproject2020/tree/master/TivaC_ECU/Bootloader_APP"
    click TIVA_APP "https://github.com/saharelnagar/ota_graduationproject2020/tree/master/TivaC_ECU/GateWay"
    click TIVA_RTE "https://github.com/saharelnagar/ota_graduationproject2020/tree/master/TivaC_ECU/GateWay/RTE"
    click TIVA_DRV "https://github.com/saharelnagar/ota_graduationproject2020/tree/master/TivaC_ECU/driverlib"
    click TIVA_INC "https://github.com/saharelnagar/ota_graduationproject2020/tree/master/TivaC_ECU/inc"
    click TIVA_SRC "https://github.com/saharelnagar/ota_graduationproject2020/tree/master/TivaC_ECU/src"
    click Tele "https://github.com/saharelnagar/ota_graduationproject2020/blob/master/Telemetics Unit/Esp_Application/Esp_Application.ino"

    %% Styles
    classDef hardware fill:#d3d3d3,stroke:#333,stroke-width:1px
    classDef external fill:#fff2cc,stroke:#333,stroke-width:1px
    classDef bus fill:#e0e0e0,stroke:#666,stroke-width:1px,stroke-dasharray: 5 5
    classDef mcal fill:#cce5ff,stroke:#004085,stroke-width:1px
    classDef bsw fill:#d4edda,stroke:#155724,stroke-width:1px
    classDef rte fill:#e2f0d9,stroke:#2e7d32,stroke-width:1px
    classDef swc fill:#ffe5b4,stroke:#ff8c00,stroke-width:1px
    classDef tool fill:#f0f0f0,stroke:#999,stroke-width:1px
    classDef boot fill:#f8d7da,stroke:#721c24,stroke-width:1px
    classDef app fill:#d1ecf1,stroke:#0c5460,stroke-width:1px
    classDef resource fill:#fcf8e3,stroke:#8a6d3b,stroke-width:1px
```
