bigtreetech / Pad7

52 stars 7 forks source link

mcp2515 CAN setup troubleshooting #2

Closed Pritolus closed 1 year ago

Pritolus commented 1 year ago

My Pad 7 is running stock hardware (CB1) and the preinstalled Debian/Klipper updated to latest versions. I have followed the manual and included the mcp2515 overlay in /boot/BoardEnv.txt:

## uncomment MCP2515 spi to canbus module
overlays=mcp2515

Following the troubleshooting instructions in the FAQ, I have ensured that the CS-Choose switch is moved to the right for CB1 operation. I have opened /etc/network/interfaces.d/can0 and confirmed that the contents are correct according to the manual:

allow-hotplug can0
iface can0 can static
    bitrate 1000000
    up ifconfig $IFACE txqueuelen 1024

Following further instructions to verify CAN is working: dmesg | grep can currently returns nothing. ifconfig does not show can0. There is no can0 in /dev/ I was able to get can0 to show up in ifconfig earlier, but I'm not sure why it disappeared. dmesg | grep mcp would then show that mcp2515 had failed to initialize on spidev0. It would fail to initialize since it's wired to spidev1, and I don't know why or how it was set up for spidev0. dmesg | grep can would return nothing. It seems that the RGB LEDs in the top right corner of the Pad 7 stopped working around the same time.

I have tried to uncomment the overlay for spidev1.0 to see if that helped, and it didn't seem to make a difference.

## uncomment to release 'spidev1.0' to user space
overlays=spidev1_0

I have tried various settings in /boot/BoardEnvs.txt and /boot/system.cfg without any luck so far. I have attached both files to show the configs as of writing.

This is my first time using Klipper, as well as CB1. My previous experience with RPi and Linux is quite limited. I am however very familiar with electronics and firmware so I'm hoping to learn quickly. system_cfg.txt BoardEnv.txt

UPDATE: Removing ws2812, light and spidev1_0 from the overlays section of /boot/BoardEnv.txt (leaving only bootlogo, overlay_prefix, console=display and overlays=mcp2515) as well as setting AUTO_BRIGHTNESS="OFF" in /boot/system.cfg now returns information on mcp2515 when using dmesg:

biqu@BTT-Pad7:~$ dmesg | grep mcp
[    2.291573] mcp2515@0 enforce active low on chipselect handle
[    2.332863] mcp251x spi0.0: Cannot initialize MCP2515. Wrong wiring?
[    2.339344] mcp251x spi0.0: Probe failed, err=19

ifconfig still does not show can0:

biqu@BTT-Pad7:~$ ifconfig
eth0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 2e:46:7b:aa:62:bd  txqueuelen 1000  (Ethernet)
        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
        device interrupt 34

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 5801  bytes 2149277 (2.0 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5801  bytes 2149277 (2.0 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.79  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::adc8:a9d6:3d4c:ce47  prefixlen 64  scopeid 0x20<link>
        ether 94:a4:08:ed:9d:ad  txqueuelen 1000  (Ethernet)
        RX packets 4236  bytes 577233 (563.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2785  bytes 1287711 (1.2 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ls /dev still does not show can0:

biqu@BTT-Pad7:~$ ls /dev
autofs           hwrng         mmcblk1p2       tty1   tty29  tty48  ttyS0    vcsa4
block            i2c-0         mqueue          tty10  tty3   tty49  ttyS1    vcsa5
btrfs-control    i2c-1         net             tty11  tty30  tty5   ttyS2    vcsa6
bus              i2c-2         null            tty12  tty31  tty50  ttyS3    vcsu
cec0             initctl       ppp             tty13  tty32  tty51  ttyS4    vcsu1
char             input         psaux           tty14  tty33  tty52  ttyS5    vcsu2
console          kmsg          ptmx            tty15  tty34  tty53  uhid     vcsu3
core             log           pts             tty16  tty35  tty54  uinput   vcsu4
cpu_dma_latency  loop0         random          tty17  tty36  tty55  uleds    vcsu5
cuse             loop1         rfkill          tty18  tty37  tty56  urandom  vcsu6
disk             loop2         rtc             tty19  tty38  tty57  vcs      watchdog
dri              loop3         rtc0            tty2   tty39  tty58  vcs1     watchdog0
ecryptfs         loop4         shm             tty20  tty4   tty59  vcs2     zero
fb0              loop5         snd             tty21  tty40  tty6   vcs3     zram0
fd               loop6         stderr          tty22  tty41  tty60  vcs4     zram1
full             loop7         stdin           tty23  tty42  tty61  vcs5     zram2
fuse             loop-control  stdout          tty24  tty43  tty62  vcs6
gpiochip0        mapper        sunxi-reg       tty25  tty44  tty63  vcsa
gpiochip1        mem           sunxi_soc_info  tty26  tty45  tty7   vcsa1
hidraw0          mmcblk1       tty             tty27  tty46  tty8   vcsa2
hugepages        mmcblk1p1     tty0            tty28  tty47  tty9   vcsa3

Attached files for new config: system_cfg_new.txt BoardEnv_new.txt

Pritolus commented 1 year ago

For the sake of my sanity, I tried moving the CS-Choose switch (located under a cover beneath the CB1 heatsink on the back) to the left and now the mcp2515 initializes successfully! Either some wires are crossed or I'm misreading the legend ... I'm still not seeing any can interface in /dev but I guess I'm not supposed to since it shows up in the ifconfig. Current configuration is identical to the system_cfg_new.txt and BoardEnv_new.txt from above. Output from dmesg | grep can and ifconfig:

biqu@BTT-Pad7:~$ dmesg | grep can
[    2.324192] mcp251x spi0.0 can0: MCP2515 successfully initialized.
[    3.437343] can: controller area network core
[    4.103010] mv64xxx_i2c 7081400.i2c: can't get pinctrl, bus recovery not supported
[   10.530170] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready
biqu@BTT-Pad7:~$ ifconfig
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 1024  (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

eth0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 2e:46:7b:aa:62:bd  txqueuelen 1000  (Ethernet)
        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
        device interrupt 34

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 1543  bytes 617415 (602.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1543  bytes 617415 (602.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.79  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::adc8:a9d6:3d4c:ce47  prefixlen 64  scopeid 0x20<link>
        ether 94:a4:08:ed:9d:ad  txqueuelen 1000  (Ethernet)
        RX packets 1073  bytes 158555 (154.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 669  bytes 317263 (309.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0