Getting CAN to work on the mikroBUS interface of the BeaglePlay

Hello. Wanted to share how I got the MCAN0 interface working in conjunction with a mikroBUS Single Wire CAN Click. First thing to note is the TX and RX are swapped on the MCAN0 interface which in turn means the CAN Click boards will not work as is. I had to modify the board to swap RX and TX. I did this by cutting the traces on the backside of the click board and then running wires from the IC to the click pins.

Next is modifying the Device Tree to enable the MCAN0 controller. I wasn’t really certain on how to go about this but thanks to a few examples and looking at the existing BeaglePlay DTS files I managed to get it working. I’m also certain there’s better ways to do this but I don’t know any better to say what they are. But I do want to say thanks to Nishanth Menon on here, Discord and Youtube for their great replies to other and videos that helped me get this working.

First I watched this Steps to modify and build device tree for BeaglePlay to learn the steps to modify and build the DTS files.

With the how out of the way, now modify k3-am625-beagleplay.dts located at /opt/source/dtb-5.10-ti/src/arm64/. Under the ‘aliases’ section add ‘can0 = &main_mcan0’, it will look like the following, minus the existing entries, leave those as is:

aliases {
                can0 = &main_mcan0;

Next we need to add the PIN mux control under the ‘&main_pmx0’ section, leave everything else there and add it at the bottom, like so:

&main_pmx0 {

        mikrobus_uart_pins_can: mikrobus-uart-pins-can {
                pinctrl-single,pins = <
                        AM62X_IOPAD(0x01dc, PIN_INPUT, 0) /* (E15) MCAN0_RX */
                        AM62X_IOPAD(0x01d8, PIN_OUTPUT, 0) /* (C15) MCAN0_TX */

Now find the ‘&main_mcan0’ section and modify it to look like the following:

&main_mcan0 {
        status = "okay";
        symlink = "play/mikrobus/can";

This should now enable the CAN bus and allow us to switch the MUX over to it as well. Next and because I’m new at this I used an example overlay file and modified it to the following:

// SPDX-License-Identifier: GPL-2.0
 * DT Overlay for disabling mikrobus device driver.
 * Copyright (C) 2023 Jason Kridner, Foundation


&{/chosen} {
        overlays {
                K3-am625-beagleplay-release-mikrobus-can = __TIMESTAMP__;

&mikrobus0 {
        status = "disabled";

 * Setup default muxes for peripheral drivers to do them instead
 * of depending on mikrobus driver to select

&main_i2c3 {
        pinctrl-names = "default";
        pinctrl-0 = <&mikrobus_i2c_pins_default>;

&main_spi2 {
        pinctrl-names = "default";
        pinctrl-0 = <&mikrobus_spi_pins_gpio>;

&main_mcan0 {
        status = "okay";
        symlink = "play/mikrobus/can";
        pinctrl-names = "default";
        pinctrl-0 = <&mikrobus_uart_pins_can>;

&main_gpio1 {
        pinctrl-names = "default";
        pinctrl-0 = <&mikrobus_gpio_pins_default>;

Saving it as ‘k3-am625-beagleplay-release-mikrobus-can.dts’. The important things here is we disable the mikroBUS, switch the UART pin MUX over to MCAN0 and switched the SPI pins to GPIO. RST and SPI2_CS0 are connected to the SWCAN transceiver mode pins.

With both files modified now I ran

sudo make install_arm64

Basically following the video. Now enable the overlay and then reboot:

echo "    fdtoverlays /overlays/k3-am625-beagleplay-release-mikrobus-can.dtbo" | sudo tee -a /boot/firmware/extlinux/extlinux.conf
sudo reboot

Once the BeaglePlay reboots you should see the can0 interface, i truncated the other interfaces:

debian@BeaglePlay:~$ ip link
5: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10

To set the GPIO pins for the transceiver mode I used the following:

gpioset 601000.gpio 12=1
gpioset 601000.gpio 13=1

GPIO 12 is the RST pin and 13 is CS0.

Now setup the CAN interface:

sudo ip link set can0 type can bitrate 33333
sudo ip link set can0 up

After that the CAN bus should be functional.

Good Luck.


Thanks Lyle for the hints with the device tree challenge.
In case someone wants to connect a standard CAN transceiver to the Beagleplay header with these overlay tweeks then please consider:

Pin 6 - CAN-TX
Pin 7 - CAN-RX

Just type the following to switch the interface on:
ip link set can0 up type can bitrate 500000
To dump the CAN traffic:
candump -cae can0,0:0,#FFFFFFFF

If you want to enable automatic startup of can0 interface at boot then following is helpful (and doesn’t need above anymore)
nano /etc/network/interfaces

Add following:

allow-hotplug can0
iface can0 can static
bitrate 500000

Hello, I try to bring a similar CAN SPI Click to life (MIKROE-986).

It seems to work partially:

debian@BeaglePlay:~$ dmesg | grep can
[ 11.613894] m_can_platform 20701000.can: m_can device registered (irq=45, version=32)
[ 2345.517514] m_can_platform 20701000.can can0: bit-timing not yet defined
[ 2345.524285] m_can_platform 20701000.can can0: failed to open can device
[ 2367.406384] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready

Has anyone done this before? How do I get on?
In principle, I would like to use the BeaglePlay with CAN Click in the same way as BB Black with CAN on the Comm Cape 02 and then integrate the Play into the CAN network.