모종의 음모/CAN2026. 7. 24. 14:34

벌써 3년전에 가볍게(?) 해봤었네..

또 까먹다니 이 기억력 어쩔.. ㅠㅠ

그때와 다른건.. 작년 부터 /boot/config.txt의 경로가 달라졌다는 정도?

$ uname -a
Linux raspberrypi 6.12.25+rpt-rpi-v7 #1 SMP Raspbian 1:6.12.25-1+rpt1 (2025-04-30) armv7l GNU/Linux

$ cat /boot/config.txt
DO NOT EDIT THIS FILE

The file you are looking for has moved to /boot/firmware/config.txt

$ cat /boot/firmware/config.txt
[all]
dtoverlay=mcp2515-can0,oscillator=8000000,interrupt=12
dtoverlay=spi-bcm2835-overlay

$ sudo ip link set can0 up type can bitrate 125000
$ ifconfig can0
can0: flags=193<UP,RUNNING,NOARP>  mtu 16
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 10  (UNSPEC)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

$ dmesg | grep -i can
[   12.948060] CAN device driver interface
[   13.070005] mcp251x spi0.0 can0: MCP2515 successfully initialized.

$ lsmod |grep can
can_dev                40960  1 mcp251x

 

loopback 설정. ifconfig 상으로는 별다른 티가 안난다

$ sudo ip link set can0 up type can bitrate 125000 loopback on
$ sudo ifconfig can0
can0: flags=193<UP,RUNNING,NOARP>  mtu 16
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 10  (UNSPEC)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[링크 : https://forums.raspberrypi.com/viewtopic.php?t=7027&start=225]

 

아무튼 loopback을 활성화 하고 ssh 로 창 두개 열어서 한쪽은 candump 실행해두고

다른 한쪽에서 cansend로 보내면 보내진다.

$ cansend can0 5A1#11.2233.44556677.88
$ candump can0
  can0  5A1   [8]  11 22 33 44 55 66 77 88
  can0  5A1   [8]  11 22 33 44 55 66 77 88

 

$ demsg | tail
[  965.109222] can: controller area network core
[  965.109370] NET: Registered PF_CAN protocol family
[  965.136117] can: raw protocol
[ 1028.671698] mcp251x spi0.0 can0: bus-off

[링크 : https://whiteknight3672.tistory.com/346]

[링크 : https://blog.naver.com/mts90/221644429413]

[링크 : https://wp.mytv.kr/2019/10/31/raspberry-pi-에서-can-통신-사용하기/] 결선도

2023.10.31 - [모종의 음모/CAN] - MCP2515 on rpi

2025.02.19 - [모종의 음모/CAN] - candump, cansend와 vcan

 

+

MCP2515 / TJA1050

 

D0695323C  라고 써있어서

이게 8 MHz 인지 16 MHz 인질 모르겠다. 검색해도 안나온다.

일단 두대를 보니 서로 다른게 써있어서 그냥 시리얼 번호라고 생각하는 중.

 

일단은 3.3V했는데 이러면 외부로 신호는 발생시키지 못할 듯.

 

예전에도 본건 데 전원이 잘못되었다고 개조를 해야 한다고 하는데

지금 다시 읽어보니 라즈베리 파이 gpio 가 3.3V 라서 아두이노와는 다르게 5V로 주면 라즈베리가 데미지 입게된다.

Because MCP2515 must be powered from 3,3V, because MCP2515 is directly connected to Pi GPIO and GPIO only accept 3,3V

[링크 : https://forums.raspberrypi.com/viewtopic.php?t=141052]

 

데이터 시트를 찾아보면

MCP2515는 2.7 V~5.5 V 면 되지만 SPI 도 Vdd 전압 따라가게 되면 흐음..

[링크 : https://ww1.microchip.com/downloads/en/DeviceDoc/MCP2515-Stand-Alone-CAN-Controller-with-SPI-20001801J.pdf]

 

CAN tranceiver칩은 4.75~5.25V 사이에 전압을 공급해야 한다.

[링크 : https://www.nxp.com/docs/en/data-sheet/TJA1050.pdf]

 

걍 속편하게 SPI 쪽만 레벨 시프터 쓸까? 개조가 나을까..

 

'모종의 음모 > CAN' 카테고리의 다른 글

obd can  (0) 2026.07.23
DeviceNet CAN  (0) 2025.04.01
candump, cansend와 vcan  (0) 2025.02.19
linux can 테스트(가상 CAN IF)  (0) 2025.02.18
can-utils(cansend, candump)  (0) 2025.02.18
Posted by 구차니