How kdt-fibonacci/fota-reprogramming works
1. This repo is not a single application; it is a distributed FOTA system with four main deployables: three Infineon AURIX TC375 ECU firmwares, a Linux-based FOTA server, and a Raspberry Pi 4 “master” controller.
2. The three ECU projects are separate firmware trees under Ecu_Gateway_TC375_LK, Ecu_Lighting_TC375_LK, and Ecu_Motion_TC375_LK. They share the same platform structure: Configurations, Basics, Libraries, Utils, and Cpu0_Main.c / Cpu1_Main.c / Cpu2_Main.c, which reflects the multicore TriCore startup model.
3. The communication layer is built as an AUTOSAR-like stack. At the bottom are CAN and Ethernet drivers; above them sit CanIf, CanTp, PduR, SoAd, LwIP, DoIP, and Dcm. This is the main transport boundary between update control traffic and ECU application logic.
4. Ethernet-specific pieces matter here: the projects include LwIP and a DP83825I PHY driver, so the system can carry diagnostics/update traffic over IP/DoIP as well as over CAN. The gateway project is especially important as the bridge between in-vehicle network traffic and Ethernet-facing diagnostics.
5. The lighting and motion ECUs add a dedicated reprogramming subsystem under Basics/Reprogram. That layer contains the FOTA orchestration (FotaHandler), update engine, swap/diagnostic logic, CRC checking, and flash access. Architecturally, this is the “local update executor” that validates and installs an image after it is delivered by the comm stack.
6. The gateway project is more network-oriented and includes test entry points such as Tests/Cpu0_Main_Gateway_MockFotaMaster.c and Tests/Cpu0_Main_Target_Gw.c, which suggests it can be built in alternate modes for integration testing or role swapping.
7. The reusable hardware/platform boundary is isolated under Libraries. These include Infineon iLLD drivers, SFR/register definitions, compiler abstractions, pin maps, and common service modules. In the diagram, this is the vendor/HAL layer beneath the ECU-specific application code.
8. Utils and Basics/SchM provide cross-cutting runtime support such as timing, logging/debug configuration, and scheduler management. These are not the business logic; they are the shared runtime scaffolding used by the ECU cores and communication stacks.
9. The Linux server in FOTA_Linux_Server is the backend control plane. Its C sources are split into crypto, file, logger, mqtt_handler, ota, server, and utils, with a small dashboard UI under dashboard/. This node likely handles package intake, storage, authentication/verification, and external command/control.
10. The Raspberry Pi project in FOTA_Master_RPI4 is the orchestrator/edge gateway. It includes ota_comm.cpp, ota_security.cpp, and ota_uds_engine.cpp, plus an LCD UI and monitor subsystem. It also ships ecu_versions.json and public.pem, which suggests it tracks ECU firmware versions and performs public-key-based trust or verification.
11. The end-to-end data flow is: operator uploads or manages an artifact through the Linux server/dashboard, the server stores and validates it, the Raspberry Pi master coordinates the update session, and the target ECU receives the image through CAN or Ethernet diagnostics, then performs verify/swap/flash/reboot locally.
12. The README’s state-machine image is important architecturally: update handling is explicitly state-driven rather than a single linear procedure. For a diagram, model the system around states such as idle, prepare, transfer, verify, swap, and restart, with transitions driven by the master/server and completed by the ECU reprogramming layer.
13. A clean diagram would show hard boundaries around: embedded ECU runtime, network/diagnostics transport, local flash/update executor, backend server, and Raspberry Pi orchestrator. The communication paths between those boundaries are the key architecture of this repo.
Main entry points: main.cpp Master core · Reprogram Reprogramming · src Server app · ComStack Com stack
Components 21
ECU firmware
Three AURIX TC375 firmware trees with shared embedded structure.
- Shared ECU core · Common embedded scaffold: configuration, multicore startup, runtime support, and vendor HAL.
- Com stack · AUTOSAR-like transport stack spanning CAN and Ethernet diagnostics/update traffic.
Ecu_Lighting_TC375_LK/Basics/ComStack - Reprogramming · Local update executor that verifies, swaps, flashes, and reboots after delivery.
Ecu_Lighting_TC375_LK/Basics/Reprogram - Vendor HAL · Reusable hardware boundary with Infineon iLLD, SFRs, compiler abstractions, pin maps, and common services.
Ecu_Lighting_TC375_LK/Libraries - Runtime support · Cross-cutting timing, logging, debug, and scheduler scaffolding used by ECU cores and stacks.
Ecu_Lighting_TC375_LK/Basics/SchM - Lighting ECU · Lighting-target firmware tree with communication stack and local FOTA executor.
Ecu_Lighting_TC375_LK - Motion ECU · Motion-target firmware tree with communication stack and local FOTA executor.
Ecu_Motion_TC375_LK - CAN layer · CAN driver, interface, and transport layers for in-vehicle diagnostics and update traffic.
Ecu_Lighting_TC375_LK/Basics/ComStack/Can - Ethernet path · Ethernet-facing diagnostics path including GETH/PHY, LwIP, SoAd, DoIP, and DCM integration.
Ecu_Lighting_TC375_LK/Basics/ComStack/DoIP - Update states · State-driven update flow: idle, prepare, transfer, verify, swap, and restart.
Ecu_Lighting_TC375_LK/Basics/Reprogram/FotaHandler.c - Flash access · Flash programming, swap diagnostics, CRC validation, and update-core logic.
Ecu_Lighting_TC375_LK/Basics/Reprogram/Flash
Gateway ECU
Network-oriented ECU variant with alternate test entry points.
- Gateway app · Gateway firmware role and its alternate build/test entry points for integration and role swapping.
Ecu_Gateway_TC375_LK
Backend control
Linux server and dashboard for artifact intake and orchestration.
- Server app · Linux-based control plane for package intake, storage, validation, and orchestration.
FOTA_Linux_Server/src - Dashboard · Operator UI used to upload and manage firmware artifacts.
FOTA_Linux_Server/dashboard - Crypto/files · Authentication, verification, artifact storage, logging, and utility services.
FOTA_Linux_Server/src/crypto.c - MQTT/server · External command/control and session coordination surfaces.
FOTA_Linux_Server/src/mqtt_handler.c
Edge master
Raspberry Pi controller that coordinates the update session.
- Master core · Raspberry Pi controller that coordinates the end-to-end OTA session.
FOTA_Master_RPI4/main.cpp - OTA comm · Edge-side communication layer that drives update sessions toward ECUs.
FOTA_Master_RPI4/ota_comm.cpp - OTA security · Security and trust handling, including public-key material for verification.
FOTA_Master_RPI4/ota_security.cpp - UDS engine · Diagnostic/update session engine used by the master to talk to targets.
FOTA_Master_RPI4/ota_uds_engine.cpp - LCD monitor · LCD UI and monitor subsystem for operator feedback and state display.
FOTA_Master_RPI4/lcd
Connections 24
- Shared ECU core → Com stack: hosts · Shared ECU runtime embeds the transport stack.
- Shared ECU core → Reprogramming: hosts · Lighting and motion ECUs add local FOTA execution on top of shared runtime.
- Shared ECU core → Vendor HAL: depends on · Common firmware relies on vendor HAL and platform services.
- Shared ECU core → Runtime support: uses · Scheduler, timing, and debug scaffolding underpin the embedded cores.
- Com stack → CAN layer: CAN · Bus diagnostics and update traffic flow through CAN layers.
- Com stack → Ethernet path: Ethernet/IP · DoIP and Ethernet diagnostics flow through the IP path.
- Ethernet path → Reprogramming: delivers updates · Ethernet diagnostics carry image transfer into the local executor.
- CAN layer → Reprogramming: delivers updates · CAN transport can deliver update payloads to the executor.
- Reprogramming → Update states: drives · Update handling is explicitly state-driven.
- Update states → Flash access: executes · State transitions culminate in verify, swap, and flash operations.
- Gateway app → Ethernet path: bridges · Gateway is the main bridge between in-vehicle traffic and Ethernet-facing diagnostics.
- Gateway app → CAN layer: routes · Gateway firmware also participates in CAN-side routing and role swapping.
- Gateway app → Shared ECU core: shares platform · Gateway follows the same multicore/platform structure as other ECUs.
- Dashboard → Server app: feeds · Operator uploads and dashboard actions feed the backend control plane.
- Server app → Crypto/files: validates · Backend applies crypto, file handling, logging, and utility services.
- Server app → MQTT/server: orchestrates · Server exposes control-plane coordination for OTA workflows.
- Server app → Master core: publishes artifacts · Backend supplies versioned firmware packages to the edge master.
- Master core → OTA comm: coordinates · Master core runs the OTA communication session.
- Master core → OTA security: verifies · Master uses local trust material and security routines.
- Master core → UDS engine: drives · Master invokes the UDS engine for diagnostics/update transport.
- Master core → LCD monitor: reports · Master surfaces session state to the LCD monitor/UI.
- OTA comm → Com stack: talks to · Edge master exchanges diagnostics/update traffic with ECU comm stacks.
- UDS engine → Reprogramming: triggers · UDS session commands trigger local prepare/transfer/verify/swap actions.
- MQTT/server → Master core: commands · Backend control plane can initiate or supervise master sessions.