Firmware and protocols
Bare-metal first, an RTOS when the problem needs one, and protocol stacks written from the standard, so I know what every byte on the wire means.
How I write firmware
- Bare-metal by default. FreeRTOS when the job has real concurrency.
- Static allocation only. No heap, so memory use is known at build time.
- MISRA C:2023 as the coding standard.
- Protocol stacks written from the published standards instead of vendor middleware.
- Every protocol implementation checked on the bench, frame by frame, against live bus traffic.
- A design document, a test procedure and a user manual for each product, so requirements, code and tests can be traced to each other.
Standards I work to
| Protocol | Standard |
|---|---|
| Classical CAN and CAN FD | ISO 11898-1 |
| ISO-TP transport layer | ISO 15765-2:2016 |
| UDS diagnostics | ISO 14229-1:2020 |
| Modbus RTU and Modbus TCP | The Modbus Organization specifications |
UDS services
Diagnostic services I have implemented, on both the tester side and the ECU side of a link. Security Access has its own note: UDS SecurityAccess (0x27), byte by byte.
| Service | Name |
|---|---|
0x10 | Diagnostic Session Control |
0x11 | ECU Reset |
0x19 | Read DTC Information |
0x22 | Read Data By Identifier |
0x27 | Security Access |
0x2E | Write Data By Identifier |
0x2F | Input Output Control By Identifier |
0x34 to 0x37 | Request Download, Transfer Data and Request Transfer Exit |
0x3E | Tester Present |
ISO-TP on the wire
A CAN frame carries 8 bytes. ISO-TP is how a longer message is split across several frames and put back together. Move the slider to see the frames for any payload length.
- Sent by the sender
- Sent by the receiver
The Flow Control frame also sets the pacing between frames. That is covered in the note ISO-TP flow control and STmin timing in practice.
Platforms
- STM32 F1, F4 and H7, with STM32CubeIDE and Keil.
- ESP32 with ESP-IDF and FreeRTOS.
- PIC16F877A and ATmega328P for smaller jobs.
- Debugging over JTAG and SWD, with an oscilloscope on the bus.