Skip to the content
2 layers70 × 50 mmSTM32 CAN PCB, the printed circuit board in 3D

STM32 双节点车载 CAN 网络:通信矩阵(DBC/cantools)+FreeRTOS+UDS(ISO 14229)/ISO-TP+CAN Bootloader+CRC32 防变砖+KiCad 一体板

Size
70 × 50 mm
Copper layers
2
Thickness
1.6 mm
Parts
52
Nets
87
Pads
226
Tracks, vias
494, 34
Pours
2
Routed
Yes
KiCad
KiCad 10.0 (file 20260206)
Created
16 Aug 2026
Updated
16 Aug 2026

Overview

STM32 CAN PCB is an open-source printed circuit board by ting-yu-max, from the ting-yu-max/stm32-can-network repository on GitHub. It is a 2-layer board of 70 × 50 mm with 52 parts on 87 nets, routed with 494 tracks and 34 vias.

It is built around the SN65HVD230D, AMS1117-3.3 and SS14. Its parts include 21 capacitors, 9 resistors, 8 connectors, 5 ICs and 4 diodes. It belongs with the STM32 boards of this library.

Main components

3

README

README.md

STM32 双节点车载 CAN 网络(通信矩阵 / FreeRTOS / UDS / CAN Bootloader)

两片 STM32F103C8T6 经 CAN 总线组网,模拟车载 ECU 之间的报文通信、诊断与固件刷写。 自制 KiCad 双节点一体板;PC 端经 PCAN-USB 接入总线完成 UDS 联调与 Bootloader 刷写全流程。


功能

  • 双节点组网:Classic CAN 500kbps,采样点 87.5%(APB1=36MHz,Prescaler=9 / BS1=6 / BS2=1),总线两端 120Ω 终端电阻
  • 通信矩阵:6 报文 / 26 信号,DBC 定义(CAN_matrix.dbc),全 Intel 小端位域,含 EngineSpeed、VehicleSpeed、胎压等 16 位跨字节信号;C 编解码层由 cantools 从 DBC 生成
  • FreeRTOS 多任务:RX0 中断只投队列 → RxTask(含 UDS 状态机)→ vehicle_data(互斥量保护)→ DisplayTask 驱动 OLED;应用层周期任务用 vTaskDelayUntil 对齐节拍(10ms 时基派生各周期),实测周期抖动 <1ms
  • UDS 诊断 Server(ISO 14229):0x10 会话控制 / 0x11 ECU 复位 / 0x22 读 DID / 0x27 安全访问 / 0x2E 写 DID,含 NRC 否定响应;功能寻址 0x7DF,物理寻址 0x7E0 / 0x7E1(响应 0x7E8 / 0x7E9);ISO-TP(ISO 15765-2)多帧组包
  • CAN Bootloader:三分区 Boot 16KB @0x08000000 / App 44KB @0x08004000 / Config 4KB @0x0800F000;0x10 进编程会话后 0x34 / 0x36 / 0x37 传输固件,CRC32 + 魔数 0x5A5AA5A5 双校验,校验失败驻留 Bootloader 等待重刷,防变砖
  • 显示:Node B OLED(SSD1306)仪表显示;pc_dashboard/ 另有 PC 端演示页面

硬件

节点MCU + 收发器角色
Node A 动力域 EMSSTM32F103C8T6 + SN65HVD230发动机 / 车速 / 油门 / 胎压 / 档位信号(0x0C0 / 0x0C1 / 0x181 / 0x320)
Node B 车身域 BCMSTM32F103C8T6 + SN65HVD230车门 / 车锁 / 车窗 / 灯光(0x211 / 0x212)+ OLED 显示
PCPCAN-USBUDS 诊断 / Bootloader 刷写 / 总线抓帧

PCB(KiCad 工程、Gerber、BOM/SMT 坐标)在 pcb/:双节点一体板,已焊接调试通过。

通信矩阵(摘自 CAN_matrix.dbc)

ID报文发送方信号(缩放)
0x0C0EMS_EngineStateEMSEngineSpeed ×0.25 rpm、EngineTemp ×1 °C(offset −40)、ThrottlePos ×0.4 %
0x0C1EMS_PedalStatusEMSAccPedal ×0.4 %、BrakePedal ×1 %
0x181GW_VehicleInfoEMSVehicleSpeed ×0.01 km/h、Gear(4bit)、Ignition(2bit)
0x320TPMS_StatusEMSTirePress FL/FR/RL/RR 各 ×0.1 kPa
0x211BCM_DoorStatusBCMDoorFL/FR/RL/RR、DoorLock、WindowFL/FR、Trunk(8×1bit)
0x212BCM_LightStatusBCMLowBeam、HighBeam、LeftTurn、RightTurn、BrakeLight、Hazard(6×1bit)

信号明细与编解码说明见 docs/communication_matrix.md。

Bootloader

分区布局(STM32F103C8 64KB Flash):

text
0x08000000 ┌─────────────────┐
           │ Boot   16KB     │  裸机(无 FreeRTOS),-Os,CAN + UDS 0x34/36/37
0x08004000 ├─────────────────┤
           │ App    44KB     │  FreeRTOS 应用(VTOR 偏移 0x4000)
0x0800F000 ├─────────────────┤
           │ Config 4KB      │  +0x00 魔数 0x5A5AA5A5 / +0x04 长度 / +0x08 CRC32 / +0x0C 版本 BCD
0x08010000 └─────────────────┘
  • 上电 200ms 窗口内收到 0x10 编程会话请求则驻留 Bootloader,否则跳转 App
  • 刷写序列:0x10 → 0x34 请求下载 → 0x36 逐块传输(块最大 512B)→ 0x37 结束 → CRC32 校验通过写 Config 区 → 0x11 复位进新 App
  • 跳转 App 三步:取 App 向量表的 MSP / Reset_Handler 地址 → 设 VTOR → 设 MSP 后跳转
  • 不做 A/B 双分区:64KB Flash 放不下两份 App(16+44+4 已占满),校验失败驻留 Bootloader 即可保证不变砖

构建

工具链(cmake/gcc-arm-none-eabi.cmake 自动定位,优先级): ① 环境变量 ARM_TOOLCHAIN_BIN 指定的 bin 目录 → ② STM32CubeIDE 自带 gnu-tools-for-stm32(自动扫描 %LOCALAPPDATA%)→ ③ PATH 里的 arm-none-eabi-gcc。

bash
cmake --preset Debug
cmake --build --preset Debug      # 一次编出 node_a / node_b / bootloader 三个目标

实测占用(arm-gcc 14.3.1,App 为 Debug -O0,Bootloader 固定 -Os):

目标Flash区间上限RAM
bootloader12.1 KBBoot 16 KB4.5 KB / 20 KB
node_a35.4 KBApp 44 KB11.3 KB / 20 KB
node_b37.6 KBApp 44 KB12.3 KB / 20 KB

HAL / CMSIS / FreeRTOS 驱动已内置,不需要先跑 CubeMX;.ioc 仅供查看 / 微调外设配置。

刷写与联调(PCAN-USB)

  • tools/flash_firmware.py:Bootloader 刷写脚本(0x34 / 0x36 / 0x37 + CRC32)
  • tools/uds_tester_mvp.py / test_uds_sim.py / uds_sim.py:UDS 请求发送与响应检查
  • tools/can_probe.py:总线报文监听
  • 完整步骤见 tools/PCAN联调指南.md

目录结构

text
├── README.md / CAN_matrix.dbc / STM32_CAN_Project.ioc
├── CMakeLists.txt / CMakePresets.json     # 一次构建 node_a / node_b / bootloader
├── STM32F103XX_FLASH.ld / STM32F103XX_BOOT.ld
├── Core/
│   ├── Inc/app/    can_matrix / can_codec / can_driver / iso_tp / uds_server /
│   │                vehicle_data / rtos_tasks / node_app / oled_*
│   └── Src/app/    同名实现 + node_a_app.c / node_b_app.c / retarget.c
│   └── Src/boot/   bootloader_main / boot_can / boot_flash / boot_uds(裸机)
├── Drivers/ Middlewares/                  # STM32F1 HAL + FreeRTOS v10.2.1 (heap_4)
├── docs/communication_matrix.md
├── tools/                                 # PCAN 刷写 / UDS tester / 抓包脚本
├── pc_dashboard/demo.html
└── pcb/                                   # KiCad 工程 + Gerber + BOM/SMT

安全边界

实验全程只在自己两块节点板之间通信,未接触真实车辆 OBD 接口。了解 ISO 26262 / ASIL 功能安全基本概念,本项目定位学习验证,不做量产级宣称。

License

MIT。

Parts

52
QtyValueFootprintReferences
15100nFCapacitor_SMD:C_0603_1608MetricC3, C4, C6, C8, C9, C10, C11, C12, C15, C16, C17, C18, C19, C20, C21
422pFCapacitor_SMD:C_0603_1608MetricC5, C7, C13, C14
31kResistor_SMD:R_0603_1608MetricR1, R6, R11
210kResistor_SMD:R_0603_1608MetricR2, R9
210µFCapacitor_SMD:C_0805_2012MetricC1, C2
2120ΩResistor_SMD:R_0603_1608MetricR3, R10
24.7kResistor_SMD:R_0603_1608MetricR7, R8
28MHzCrystal:Crystal_HC49-U_VerticalY1, Y2
2BOOT0Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_VerticalJ2, J8
2ResetButton_Switch_THT:SW_TH_Tactile_Omron_B3F-100xSW1, SW3
2SN65HVD230Package_SO:SOIC-8_3.9x4.9mm_P1.27mmU2, U5
2STM32F103C8TxPackage_QFP:LQFP-48_7x7mm_P0.5mmU1, U4
2SWDConnector_PinHeader_2.54mm:PinHeader_1x04_P2.54mm_VerticalJ3, J9
2状态LED_SMD:LED_0805_2012MetricLED2, LED3
15V_INTerminalBlock:TerminalBlock_Xinya_XY308-2.54-2P_1x02_P2.54mm_HorizontalJ1
1AMS1117-3.3Package_TO_SOT_SMD:SOT-223-3_TabPin2U3
1CANTerminalBlock:TerminalBlock_Xinya_XY308-2.54-3P_1x03_P2.54mm_HorizontalJ4
1KEYButton_Switch_THT:SW_TH_Tactile_Omron_B3F-100xSW2
1OLEDConnector_PinHeader_2.54mm:PinHeader_1x04_P2.54mm_VerticalJ7
1RedLED_SMD:LED_0805_2012MetricLED1
1SS14Diode_SMD:D_SMAD1
1USARTConnector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_VerticalJ6

Similar boards

  • 2 layers47.5 × 71.5 mmESP32 Wifi2CAN Rev0.1, the printed circuit board in 3D

    ESP32 Wifi2CAN Rev0.1

    ampnics/CAN-to-WiFi-Converter-Dongle-

    CAN to WiFi Converter PCB using ESP32! This step-by-step tutorial covers schematic creation, PCB layout, and best practices for signal integrity. Perfect for automotive and IoT applications!

    72 parts9
  • 2 layers77.5 × 72.5 mmDenjibenkiban, the printed circuit board in 3D

    Denjibenkiban

    25rb1082-del/test

    Create repository

    54 parts
  • 2 layers92 × 59 mmTreadle, the printed circuit board in 3D

    Treadle

    Robsic/throttle-brake-interface-board

    Drive-by-Wire throttle and brake interface board for autonomous electric golf cart

    48 parts
  • 4 layers68 × 83.4 mmBMS Temp Board V1, the printed circuit board in 3D

    BMS Temp Board V1

    sundevilmotorsports/ev-pcb-dev

    PCB development repository SDM EV

    73 parts3
  • 2 layers71.9 × 50 mmRejsaCAN board, the printed circuit board in 3D

    RejsaCAN board

    hancho6319/My_PCB_Designs_repo

    79 parts
  • 2 layers96 × 74.4 mmMonolith, the printed circuit board in 3D

    Monolith

    luftaquila/monolith

    DIY wireless real-time datalogging platform for Student Formula and Baja.

    138 parts45
  • 4 layers180 × 120 mmMG ZS V2, the printed circuit board in 3D

    MG ZS V2

    damienmaguire/MG-EV-Inverter

    Reverse engineering of the drive motor and inverter used in MG Electric Vehicles

    177 parts17GPL-3.0
  • 4 layers110 × 80 mmPNP MOBO V2, the printed circuit board in 3D

    PNP MOBO V2

    GabrielD98/PickUS_and_PlacUS

    pick and place de PCB pour projet S4 de robotique

    126 parts5MIT

Questions

How big is the STM32 CAN PCB PCB?

It measures 70 × 50 mm and has 2 copper layers, 1.6 mm thick.

What parts does the STM32 CAN PCB use?

52 parts, built around the SN65HVD230D, AMS1117-3.3 and SS14. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the STM32 CAN PCB KiCad files?

From the ting-yu-max/stm32-can-network repository on GitHub, at the commit this page was made from: the board is pcb/STM32_CAN_PCB.kicad_pcb and its schematic pcb/STM32_CAN_PCB.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the STM32 CAN PCB design in my own project?

Its repository states no licence, so its author keeps all rights: ask ting-yu-max before reusing the design.