danzimmerman / dz_rpi_config

Bash and other linux config tools, version controlled.
0 stars 0 forks source link

Debug canbus/SPI setup in /boot/firmware/config.txt. RP1 support problem with Ubuntu Server? #1

Closed danzimmerman closed 3 weeks ago

danzimmerman commented 1 month ago

Thought to be closed by https://github.com/danzimmerman/dz_rpi_config/commit/13fe295029373262766fa7f58cfeabf76565c13d, but needs debugging.

Leaving it manual for now

danzimmerman commented 1 month ago

Tried this to decrease SPI frequency and add -overlay to the MCP2515. Didn't work.

danzimmerman commented 1 month ago

Look into parsing loaded overlays and what should be there for CAN:

https://forums.raspberrypi.com/viewtopic.php?t=336527#p2014109

Also take a look at:

https://forums.raspberrypi.com/viewtopic.php?t=362751 https://www.raspberrypi.com/documentation/computers/configuration.html#part3.1

and

https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README

In particular

Name:   mcp2515
Info:   Configures the MCP2515 CAN controller on spi0/1/2
        For devices on spi1 or spi2, the interfaces should be enabled
        with one of the spi1-1/2/3cs and/or spi2-1/2/3cs overlays.
Load:   dtoverlay=mcp2515,<param>=<val>
Params: spi<n>-<m>              Configure device at spi<n>, cs<m>
                                (boolean, required)

        oscillator              Clock frequency for the CAN controller (Hz)

        speed                   Maximum SPI frequence (Hz)

        interrupt               GPIO for interrupt signal

Currently trying

dtoverlay=mcp2515,spi0-0,oscillator=16000000,interrupt=25,spimaxfrequency=500000
dtoverlay=mcp2515,spi0-1,oscillator=16000000,interrupt=23,spimaxfrequency=500000

But still doesn't work. need to try a better power supply. Pi 5 needs 5A max!

danzimmerman commented 4 weeks ago

Try "speed" not "spimaxfrequency"

dtoverlay=mcp2515,spi0-0,oscillator=16000000,speed=250000
danzimmerman commented 4 weeks ago

Didn't work with either CAN chip. Now trying the above strictly verbatim. Nope. https://forums.raspberrypi.com/viewtopic.php?t=369458

danzimmerman commented 4 weeks ago

See here re new I/O https://www.raspberrypi.com/news/rp1-the-silicon-controlling-raspberry-pi-5-i-o-designed-here-at-raspberry-pi/

danzimmerman commented 4 weeks ago

Should try raspbian https://forums.raspberrypi.com/viewtopic.php?t=367944

danzimmerman commented 4 weeks ago

Yeah looks like maybe the RP1 I/O is getting upstreamed now:

https://www.phoronix.com/news/Raspberry-Pi-5-RP1-Linux-RFC

danzimmerman commented 4 weeks ago

https://forums.raspberrypi.com/viewtopic.php?t=357292

danzimmerman commented 4 weeks ago

Newer article on the upstreaming of RP1 support: https://www.phoronix.com/news/Raspberry-Pi-RP1-Linux-Patches

This patchset is an attempt to provide a minimum infrastructure to allow the RP1 chipset to be discovered and perpherals it contains to be added from a devictree overlay loaded during RP1 PCI endpoint enumeration. Followup patches should add support for the several peripherals contained in RP1.

Ubuntu Server for the Pi 5 is not using the mainline kernel I believe, but it may be that support is still complicated.

Other possible resources:

https://forums.raspberrypi.com/viewtopic.php?t=365275

https://bugs.launchpad.net/ubuntu/+source/linux-raspi

danzimmerman commented 4 weeks ago

Raspbian works fine with the Waveshare 2CH Isolated hat, see config.txt here:

dan@meitner:~ $ sudo dmesg | grep spi0
[    2.642716] mcp251x spi0.1 can0: MCP2515 successfully initialized.
[    2.660117] mcp251x spi0.0 can1: MCP2515 successfully initialized.
3: can0: <NOARP,ECHO> mtu 16 qdisc noop state DOWN group default qlen 10
    link/can
4: can1: <NOARP,ECHO> mtu 16 qdisc noop state DOWN group default qlen 10
    link/can
danzimmerman commented 4 weeks ago

Linux version info

dan@<computer>:~/dz_rpi_config $ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
dan@<computer>:~/dz_rpi_config $ uname -a
Linux <computer> 6.6.31+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.6.31-1+rpt1 (2024-05-29) aarch64 GNU/Linux
danzimmerman commented 4 weeks ago

Interestingly only on the 6.6.31 kernel here?

danzimmerman commented 3 weeks ago

I'm going to call this closed. Waiting on RP1 support in the mainline kernel, I think.

Will have to build ROS 2 from source for now.