The BMS GUI talks to the car over CAN FD (can-bridge uses SocketCAN FD). On the Pi this is a bare MCP2518FD on SPI0.0, shown as can0.
Match BMS FDCAN2 (GUI / Raspi FD bus): 250 kbit/s nominal / 2 Mbit/s data, BRS on. (FDCAN1 classic 500 kbit/s is a different bus. Do not use that bus here.)
| MCP2518FD | Pi GPIO (BCM) | Board pin |
|---|---|---|
| MOSI / SI | 10 | 19 |
| MISO / SO | 9 | 21 |
| SCLK | 11 | 23 |
| CS | 8 (CE0) | 24 |
| INT | 25 | 22 |
| 3V3 / GND | 3V3 / GND | 1 or 17 / 6 |
- Crystal on the breakout: 40 MHz (must match the overlay
oscillator=). - Chip SDO -> Pi MISO, SDI -> Pi MOSI (do not swap).
- If the module has
/RESET, hold it high (3V3). - CANH / CANL -> BMS GUI FD bus when ready. Terminate only if this node is at an end of the stub.
# Idempotent: writes /boot/firmware/config.txt overlay
sudo ./scripts/setup-mcp2518fd-spi.sh
# Apply device tree
sudo reboot
# After reboot
sudo ./scripts/setup-mcp2518fd-spi.sh --statusOverlay installed (under [all] in /boot/firmware/config.txt):
dtparam=spi=on
dtoverlay=mcp251xfd,spi0-0,interrupt=25,oscillator=40000000,speed=10000000Script helpers:
sudo ./scripts/setup-mcp2518fd-spi.sh --probe # rebind driver -> SPI TX burst (Saleae)
sudo ./scripts/setup-mcp2518fd-spi.sh --status # pinmux, dmesg, can0 typetest/setup_vcan.sh (installed as /usr/local/sbin/bms-setup-vcan by scripts/install-boot-services.sh) brings hardware can0 up as:
ip link set can0 type can bitrate 250000 dbitrate 2000000 fd on
ip link set can0 upbms-can0.service runs that on boot before can-bridge. If the MCP2518FD is not present, boot uses vcan can0 for lab use.
- Overlay is loaded.
pinctrlshows GPIO9-11 as SPI0. - Run
sudo ./scripts/setup-mcp2518fd-spi.sh --probewhile a logic analyzer watches CE0 / SCLK / MOSI (board pins 24 / 23 / 19). - Expect a short SPI burst. MISO idle is normal when nothing is connected.
dmesgwill reportosc=0x00000000/ failed detect. This is expected without the MCP2518FD.can0stays vcan until the chip probes successfully.
sudo ./scripts/setup-mcp2518fd-spi.sh --status
# expect: mcp251xfd bound, can0 is NOT vcan
sudo /usr/local/sbin/bms-setup-vcan --can0-only
ip -details link show can0 # FD, 250000 / 2000000, UP
sudo systemctl restart can-bridgeStop the lab gateway when you use the real bus: sudo systemctl stop bms-vcan-lab.
| Channel | Signal | Board pin |
|---|---|---|
| 0 | SCLK | 23 |
| 1 | MOSI | 19 |
| 2 | MISO | 21 |
| 3 | CE0 | 24 |
| 4 (opt) | INT | 22 |
SPI Mode 0, MSB first, sample rate >= 20 MS/s. Arm capture, then run --probe.