STM32CubeIDE source code for the 4th iteration of my single pair Ethernet (SPE) switch, written in C. The hardware can be found in switch-v4-hardware.
Also see my post on r/embedded!
This repository is split into firmwares for the primary and secondary MCUs on the switch board:
- The primary MCU does most of the configuration and management of the switch.
- The secondarhy MCU manages power to connected devices using Power over Datalines (PoDL).
Currently only the primary MCU firmware is working.
Most of the non-generated code can be found in the Bootloader and Application directories. This project uses the ARM Trustzone architecture to have a secure bootloader and a non-secure application.
The secure bootloader is responsible for the following:
- Setting up peripheral attribution and initialising secure peripherals
- Calculating the SHA-256 hashes of the secure and non-secure firmwares to check for tampering/degradation
- Selecting a non-secure firmware image to boot from
- Storing encrypted metadata and event counters in the external FRAM
- Logging
- Error handling
- Background scrubbing for ECC errors (WIP)
- Writing new firmware images (WIP)
- Communicating with the secondary MCU (WIP)
The non-secure firmware is responsible for the following:
- Initialising non-secure peripherals
- Initialising the switch and PHY chips
- Running the networking stack
- Publishing diagnostic information with Zenoh Pico
- Switch and PHY maintenance
- Firmware updates (WIP)
- Running PTP (WIP)
- Running STP (WIP)
- SJA1105 Driver (by me)
- PHY Drivers (by me)
- Zenoh Pico
- Nanopb
- mstp-lib (provisionally)