### Resources * [Photos of breadboard wiring](https://photos.app.goo.gl/1UUAHhRngzwiVWha9) * [MCP2515 breakout board from Amazon](https://smile.amazon.com/gp/product/B01HXI5LH8/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1) * [BeagleBone Black headers](https://elinux.org/Beagleboard:Cape_Expansion_Headers) * [Macchina M2 schematics](https://github.com/macchina/m2-hardware/tree/master/M2-B) ### /boot/uEnv.txt ``` uname_r=4.14.78-bone17 enable_uboot_overlays=1 uboot_overlay_addr0=/lib/firmware/BB-SPIDEV0-00A0.dtbo uboot_overlay_addr1=/lib/firmware/MCP2515.dtbo disable_uboot_overlay_emmc=1 disable_uboot_overlay_video=1 disable_uboot_overlay_audio=1 disable_uboot_overlay_wireless=1 disable_uboot_overlay_adc=1 uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo enable_uboot_cape_universal=1 cmdline=coherent_pool=1M net.ifnames=0 quiet ``` #### device tree overlays * [MCP2515.dts](https://github.com/battlesnake/beaglebone-spi0-mcp2515/blob/master/MCP2515.dts) * [related mailing list discussion](https://groups.google.com/d/msg/beagleboard/nyyq1wQtGQc/iwGNUBM0EwAJ) * [BB-SPIDEV0-00A0.dts](https://github.com/beagleboard/bb.org-overlays/blob/master/src/arm/BB-SPIDEV0-00A0.dts) #### u-boot log ``` loading /boot/vmlinuz-4.14.78-bone17 ... 7438848 bytes read in 547 ms (13 MiB/s) uboot_overlays: [uboot_base_dtb=am335x-boneblack-uboot-univ.dtb] ... uboot_overlays: [uboot_base_dtb=am335x-boneblack-uboot.dtb] ... uboot_overlays: Switching too: dtb=am335x-boneblack-uboot.dtb ... loading /boot/dtbs/4.14.78-bone17/am335x-boneblack-uboot.dtb ... 58502 bytes read in 97 ms (588.9 KiB/s) uboot_overlays: [fdt_buffer=0x60000] ... uboot_overlays: loading /lib/firmware/BB-SPIDEV0-00A0.dtbo ... 1523 bytes read in 150 ms (9.8 KiB/s) uboot_overlays: loading /lib/firmware/MCP2515.dtbo ... 2119 bytes read in 463 ms (3.9 KiB/s) uboot_overlays: uboot loading of [/lib/firmware/BB-BONE-eMMC1-01-00A0.dtbo] disabled by /boot/uEnv.txt [disable_uboot_overlay_emmc=1]... uboot_overlays: uboot loading of [/lib/firmware/BB-HDMI-TDA998x-00A0.dtbo] disabled by /boot/uEnv.txt [disable_uboot_overlay_video=1]... uboot_overlays: uboot loading of [/lib/firmware/BB-ADC-00A0.dtbo] disabled by /boot/uEnv.txt [disable_uboot_overlay_adc=1]... uboot_overlays: loading /lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo ... 3513 bytes read in 605 ms (4.9 KiB/s) uboot_overlays: cape universal disabled, external cape enabled or detected... loading /boot/initrd.img-4.14.78-bone17 ... 4456483 bytes read in 361 ms (11.8 MiB/s) debug: [console=ttyO0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait ``` ### Kernel #### 4.14.78-bone17 ``` debian@beaglebone:~$ uname -a Linux beaglebone 4.14.78-bone17 #3 PREEMPT Fri Dec 21 10:18:33 CST 2018 armv7l GNU/Linux ``` * `git clone https://github.com/RobertCNelson/bb-kernel` * `git checkout am33x-v4.14` * run the build script `./build_kernel.sh` * copy kernel image, kernel module tarball and dtb tarball in located in `deploy` to the BeagleBone/PocketBeagle ``` pdp7@sp3:~/dev/bb-kernel$ scp config-4.14.78-bone17 4.14.78-bone17.zImage 4.14.78-bone17-modules.tar.gz 4.14.78-bone17-dtbs.tar.gz debian@192.168.6.2:/tmp debian@beaglebone:~$ sudo cp 4.14.78-bone17.zImage /boot/vmlinuz-4.14.78-bone17 debian@beaglebone:~$ sudo tar -C / -xzvf ~/4.14.78-bone17-modules.tar.gz debian@beaglebone:~$ sudo tar -C /boot/dtbs/4.14.78-bone17 -xzvf 4.14.78-bone17-dtbs.tar.gz ``` #### crude method to print debug info `git diff` of `~/dev/bb-kernel/KERNEL` ```diff diff --git a/drivers/net/can/spi/mcp251x.c b/drivers/net/can/spi/mcp251x.c index f3f05fea8e1f..7b8afcdbbbce 100644 --- a/drivers/net/can/spi/mcp251x.c +++ b/drivers/net/can/spi/mcp251x.c @@ -320,18 +320,26 @@ static int mcp251x_spi_trans(struct spi_device *spi, int len) }; struct spi_message m; int ret; - + pr_err("DEBUG SWCAN: mcp251x_spi_trans: spi=%p\n", spi); + pr_err("DEBUG SWCAN: mcp251x_spi_trans: len=0x%02x\n", len); + pr_err("DEBUG SWCAN: mcp251x_spi_trans: spi_message_init(&m)\n"); spi_message_init(&m); + pr_err("DEBUG SWCAN: mcp251x_spi_trans: m=%p\n", &m); + pr_err("DEBUG SWCAN: mcp251x_spi_trans: mcp251x_enable_dma=0x%02x\n", mcp251x_enable_dma); if (mcp251x_enable_dma) { + pr_err("DEBUG SWCAN: mcp251x_spi_trans: t.tx_dma=0x%02x\n", t.tx_dma); + pr_err("DEBUG SWCAN: mcp251x_spi_trans: t.rx_dma=0x%02x\n", t.rx_dma); t.tx_dma = priv->spi_tx_dma; t.rx_dma = priv->spi_rx_dma; m.is_dma_mapped = 1; } + pr_err("DEBUG SWCAN: mcp251x_spi_trans: spi_message_add_tail(&t, &m)\n"); spi_message_add_tail(&t, &m); ret = spi_sync(spi, &m); + pr_err("DEBUG SWCAN: mcp251x_spi_trans: ret=0x%02x\n", ret); if (ret) dev_err(&spi->dev, "spi transfer failed: ret = %d\n", ret); return ret; @@ -342,11 +350,14 @@ static u8 mcp251x_read_reg(struct spi_device *spi, uint8_t reg) struct mcp251x_priv *priv = spi_get_drvdata(spi); u8 val = 0; + pr_err("DEBUG SWCAN: mcp251x_read_reg: spi=%p\n", spi); + pr_err("DEBUG SWCAN: mcp251x_read_reg: reg=0x%02x\n", reg); priv->spi_tx_buf[0] = INSTRUCTION_READ; priv->spi_tx_buf[1] = reg; mcp251x_spi_trans(spi, 3); val = priv->spi_rx_buf[2]; + pr_err("DEBUG SWCAN: mcp251x_read_reg: val=0x%02x\n", val); return val; } @@ -626,14 +637,20 @@ static int mcp251x_setup(struct net_device *net, struct mcp251x_priv *priv, static int mcp251x_hw_reset(struct spi_device *spi) { - struct mcp251x_priv *priv = spi_get_drvdata(spi); + struct mcp251x_priv *priv; u8 reg; int ret; + pr_err("DEBUG SWCAN: mcp251x_hw_reset(): spi=%p\n", spi); + priv = spi_get_drvdata(spi); + pr_err("DEBUG SWCAN: mcp251x_hw_reset(): priv=%p\n", priv); + /* Wait for oscillator startup timer after power up */ mdelay(MCP251X_OST_DELAY_MS); priv->spi_tx_buf[0] = INSTRUCTION_RESET; + pr_err("DEBUG SWCAN: mcp251x_hw_reset(): spriv->spi_tx_buf[0]=0x%02x\n", priv->spi_tx_buf[0]); + pr_err("DEBUG SWCAN: mcp251x_hw_reset(): call mcp251x_spi_trans(spi, 1)\n"); ret = mcp251x_spi_trans(spi, 1); if (ret) return ret; @@ -641,7 +658,13 @@ static int mcp251x_hw_reset(struct spi_device *spi) /* Wait for oscillator startup timer after reset */ mdelay(MCP251X_OST_DELAY_MS); + pr_err("DEBUG SWCAN: mcp251x_hw_reset(): CANSTAT=0x%02x\n", CANSTAT); + pr_err("DEBUG SWCAN: mcp251x_hw_reset(): call mcp251x_read_reg()\n"); reg = mcp251x_read_reg(spi, CANSTAT); + pr_err("DEBUG SWCAN: mcp251x_hw_reset(): reg=0x%02x\n", reg); + pr_err("DEBUG SWCAN: mcp251x_hw_reset(): CANCTRL_REQOP_MASK=0x%02x\n", CANCTRL_REQOP_MASK); + pr_err("DEBUG SWCAN: mcp251x_hw_reset(): CANCTRL_REQOP_CONF=0x%02x\n", CANCTRL_REQOP_CONF); + pr_err("DEBUG SWCAN: mcp251x_hw_reset(): (reg & CANCTRL_REQOP_MASK)=0x%02x\n", (reg & CANCTRL_REQOP_MASK)); if ((reg & CANCTRL_REQOP_MASK) != CANCTRL_REQOP_CONF) return -ENODEV; @@ -653,12 +676,17 @@ static int mcp251x_hw_probe(struct spi_device *spi) u8 ctrl; int ret; + pr_err("DEBUG SWCAN: mcp251x_hw_probe: spi=%p\n", spi); + ret = mcp251x_hw_reset(spi); + pr_err("DEBUG SWCAN: mcp251x_hw_probe: ret=%d\n", ret); if (ret) return ret; + pr_err("DEBUG SWCAN: mcp251x_hw_probe: CANCTRL=0x%02x\n", CANCTRL); ctrl = mcp251x_read_reg(spi, CANCTRL); - + pr_err("DEBUG SWCAN: mcp251x_hw_probe: ctrl=0x%02x\n", ctrl); + pr_err("DEBUG SWCAN: mcp251x_hw_probe: ((ctrl & 0x17)=0x%02x\n", (ctrl & 0x17)); dev_dbg(&spi->dev, "CANCTRL 0x%02x\n", ctrl); /* Check for power up default value */ @@ -1034,14 +1062,41 @@ static int mcp251x_can_probe(struct spi_device *spi) struct clk *clk; int freq, ret; + printk(KERN_ERR "DEBUG SWCAN: mcp251x_can_probe()\n"); + pr_err("DEBUG SWCAN: mcp251x_can_probe()\n"); + pr_err("DEBUG SWCAN: mcp251x_can_probe(): spi=%p\n", spi); + pr_err("DEBUG SWCAN: mcp251x_can_probe(): spi->chip_select=0x%02x\n", spi->chip_select); + pr_err("DEBUG SWCAN: mcp251x_can_probe(): spi->irq=0x%02x\n", spi->irq); + pr_err("DEBUG SWCAN: mcp251x_can_probe(): spi->modalias=%s\n", spi->modalias); + pr_err("DEBUG SWCAN: mcp251x_can_probe(): spi->cs_gpio=0x%02x\n", spi->cs_gpio); + pr_err("DEBUG SWCAN: mcp251x_can_probe(): spi->controller=%p\n", spi->controller); + pr_err("DEBUG SWCAN: mcp251x_can_probe(): spi->controller->bus_num=0x%02x\n", spi->controller->bus_num); + + pr_err("DEBUG SWCAN: mcp251x_can_probe(): spi->dev=%p\n", spi->dev); + pr_err("DEBUG SWCAN: mcp251x_can_probe(): spi->dev->of_node=%p\n", spi->dev.of_node); + pr_err("DEBUG SWCAN: mcp251x_can_probe(): spi->dev->parent=%p\n", spi->dev.parent); + pr_err("DEBUG SWCAN: mcp251x_can_probe(): spi->dev->init_name=%s\n", spi->dev.init_name); + if(spi->dev.type != NULL) { + pr_err("DEBUG SWCAN: mcp251x_can_probe(): spi->dev->type->name=%s\n", spi->dev.type->name); + } + if(spi->dev.bus != NULL) { + pr_err("DEBUG SWCAN: mcp251x_can_probe(): spi->dev->bus->name=%s\n", spi->dev.bus->name); + pr_err("DEBUG SWCAN: mcp251x_can_probe(): spi->dev->bus->dev_name=%s\n", spi->dev.bus->dev_name); + pr_err("DEBUG SWCAN: mcp251x_can_probe(): spi->dev->bus->dev_root=%s\n", spi->dev.bus->dev_root); + } clk = devm_clk_get(&spi->dev, NULL); + pr_err("DEBUG SWCAN: mcp251x_can_probe(): clk=%p\n", clk); + pr_err("DEBUG SWCAN: mcp251x_can_probe(): pdata=%p\n", pdata); if (IS_ERR(clk)) { if (pdata) freq = pdata->oscillator_frequency; else return PTR_ERR(clk); } else { + pr_err("DEBUG SWCAN: mcp251x_can_probe(): freq = clk_get_rate(clk)\n"); freq = clk_get_rate(clk); + pr_err("DEBUG SWCAN: mcp251x_can_probe(): freq=0x%02x\n", freq); + pr_err("DEBUG SWCAN: mcp251x_can_probe(): freq=%d\n", freq); } /* Sanity check */ @@ -1050,11 +1105,13 @@ static int mcp251x_can_probe(struct spi_device *spi) /* Allocate can/net device */ net = alloc_candev(sizeof(struct mcp251x_priv), TX_ECHO_SKB_MAX); + pr_err("DEBUG SWCAN: mcp251x_can_probe(): net=%p\n", net); if (!net) return -ENOMEM; if (!IS_ERR(clk)) { ret = clk_prepare_enable(clk); + pr_err("DEBUG SWCAN: mcp251x_can_probe(): ret = clk_prepare_enable(clk): 0x%02x\n", ret); if (ret) goto out_free; } @@ -1144,6 +1201,7 @@ static int mcp251x_can_probe(struct spi_device *spi) SET_NETDEV_DEV(net, &spi->dev); /* Here is OK to not lock the MCP, no one knows about it yet */ + pr_err("DEBUG SWCAN: mcp251x_can_probe(): call mcp251x_hw_probe()\n"); ret = mcp251x_hw_probe(spi); if (ret) { if (ret == -ENODEV) @@ -1181,6 +1239,9 @@ static int mcp251x_can_remove(struct spi_device *spi) struct mcp251x_priv *priv = spi_get_drvdata(spi); struct net_device *net = priv->net; + printk(KERN_ERR "DEBUG SWCAN: mcp251x_can_remove\n"); + pr_err("DEBUG SWCAN: mcp251x_can_remove\n"); + unregister_candev(net); mcp251x_power_enable(priv->power, 0); @@ -1258,7 +1319,7 @@ static struct spi_driver mcp251x_can_driver = { }; module_spi_driver(mcp251x_can_driver); -MODULE_AUTHOR("Chris Elston , " - "Christian Pellegrin "); +MODULE_AUTHOR("TEST TEST TEST, " + "FOO FOO FOO FOO "); MODULE_DESCRIPTION("Microchip 251x CAN driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index 9bf64e6eca9b..ea7d4f16a96f 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -1341,6 +1341,12 @@ static int omap2_mcspi_probe(struct platform_device *pdev) struct device_node *node = pdev->dev.of_node; const struct of_device_id *match; + pr_err("DEBUG SWCAN: omap2_mcspi_probe(): pdev=%p\n", pdev); + pr_err("DEBUG SWCAN: omap2_mcspi_probe(): node=%p\n", node); + pr_err("DEBUG SWCAN: omap2_mcspi_probe(): node->name=%s\n", node->name); + pr_err("DEBUG SWCAN: omap2_mcspi_probe(): node->type=%s\n", node->type); + pr_err("DEBUG SWCAN: omap2_mcspi_probe(): node->full_name=%s\n", node->full_name); + master = spi_alloc_master(&pdev->dev, sizeof *mcspi); if (master == NULL) { dev_dbg(&pdev->dev, "master allocation failed\n"); ``` #### related output during boot ``` debian@beaglebone:~$ dmesg |egrep -i '(can|spi)' [ 0.583800] DEBUG SWCAN: omap2_mcspi_probe(): pdev=dc204000 [ 0.589564] DEBUG SWCAN: omap2_mcspi_probe(): node=dcb55868 [ 0.595211] DEBUG SWCAN: omap2_mcspi_probe(): node->name=spi [ 0.600914] DEBUG SWCAN: omap2_mcspi_probe(): node->type= [ 0.606872] DEBUG SWCAN: omap2_mcspi_probe(): node->full_name=/ocp/spi@48030000 [ 0.615207] omap2_mcspi 48030000.spi: chipselect 0 already in use [ 0.621428] spi_master spi0: spi_device register error /ocp/spi@48030000/channel@0 [ 0.629074] spi_master spi0: Failed to create SPI device for /ocp/spi@48030000/channel@0 [ 0.630422] CAN device driver interface [ 0.777127] can: controller area network core (rev 20170425 abi 9) [ 19.139857] DEBUG SWCAN: mcp251x_can_probe() [ 19.406838] DEBUG SWCAN: mcp251x_can_probe() [ 19.544275] DEBUG SWCAN: mcp251x_can_probe(): spi=db56f400 [ 19.782634] DEBUG SWCAN: mcp251x_can_probe(): spi->chip_select=0x00 [ 19.997762] DEBUG SWCAN: mcp251x_can_probe(): spi->irq=0x3e [ 20.192506] DEBUG SWCAN: mcp251x_can_probe(): spi->modalias=mcp2515 [ 20.482613] DEBUG SWCAN: mcp251x_can_probe(): spi->cs_gpio=0xfffffffe [ 20.724291] DEBUG SWCAN: mcp251x_can_probe(): spi->controller=db56e000 [ 20.969237] DEBUG SWCAN: mcp251x_can_probe(): spi->controller->bus_num=0x00 [ 21.236271] DEBUG SWCAN: mcp251x_can_probe(): spi->dev=db56f578 [ 21.544405] DEBUG SWCAN: mcp251x_can_probe(): spi->dev->of_node=dcb55c1c [ 21.756169] DEBUG SWCAN: mcp251x_can_probe(): spi->dev->parent=db56e000 [ 22.020346] DEBUG SWCAN: mcp251x_can_probe(): spi->dev->init_name=(null) [ 22.246402] DEBUG SWCAN: mcp251x_can_probe(): spi->dev->bus->name=spi [ 22.398573] DEBUG SWCAN: mcp251x_can_probe(): spi->dev->bus->dev_name=(null) [ 22.528325] DEBUG SWCAN: mcp251x_can_probe(): spi->dev->bus->dev_root=(null) [ 22.764404] DEBUG SWCAN: mcp251x_can_probe(): clk=da9ffdc0 [ 22.896335] DEBUG SWCAN: mcp251x_can_probe(): pdata= (null) [ 23.016319] DEBUG SWCAN: mcp251x_can_probe(): freq = clk_get_rate(clk) [ 23.180345] DEBUG SWCAN: mcp251x_can_probe(): freq=0x7a1200 [ 23.324322] DEBUG SWCAN: mcp251x_can_probe(): freq=8000000 [ 23.428366] DEBUG SWCAN: mcp251x_can_probe(): net=db035000 [ 23.577246] DEBUG SWCAN: mcp251x_can_probe(): ret = clk_prepare_enable(clk): 0x00 [ 23.732564] DEBUG SWCAN: mcp251x_can_probe(): call mcp251x_hw_probe() [ 23.921356] DEBUG SWCAN: mcp251x_hw_probe: spi=db56f400 [ 24.070978] DEBUG SWCAN: mcp251x_hw_reset(): spi=db56f400 [ 24.212109] DEBUG SWCAN: mcp251x_hw_reset(): priv=db0354a0 [ 24.574375] DEBUG SWCAN: mcp251x_hw_reset(): spriv->spi_tx_buf[0]=0xc0 [ 24.986092] DEBUG SWCAN: mcp251x_hw_reset(): call mcp251x_spi_trans(spi, 1) [ 25.224786] DEBUG SWCAN: mcp251x_spi_trans: spi=db56f400 [ 25.404450] DEBUG SWCAN: mcp251x_spi_trans: len=0x01 [ 25.577669] DEBUG SWCAN: mcp251x_spi_trans: spi_message_init(&m) [ 25.703873] DEBUG SWCAN: mcp251x_spi_trans: m=dc3a9a18 [ 25.781107] DEBUG SWCAN: mcp251x_spi_trans: mcp251x_enable_dma=0x00 [ 25.895224] DEBUG SWCAN: mcp251x_spi_trans: spi_message_add_tail(&t, &m) [ 26.003786] DEBUG SWCAN: mcp251x_spi_trans: ret=0x00 [ 26.161376] DEBUG SWCAN: mcp251x_hw_reset(): CANSTAT=0x0e [ 26.249032] DEBUG SWCAN: mcp251x_hw_reset(): call mcp251x_read_reg() [ 26.338096] DEBUG SWCAN: mcp251x_read_reg: spi=db56f400 [ 26.424309] DEBUG SWCAN: mcp251x_read_reg: reg=0x0e [ 26.533882] DEBUG SWCAN: mcp251x_spi_trans: spi=db56f400 [ 26.716317] DEBUG SWCAN: mcp251x_spi_trans: len=0x03 [ 26.956309] DEBUG SWCAN: mcp251x_spi_trans: spi_message_init(&m) [ 27.184288] DEBUG SWCAN: mcp251x_spi_trans: m=dc3a99f8 [ 27.299986] DEBUG SWCAN: mcp251x_spi_trans: mcp251x_enable_dma=0x00 [ 27.422636] DEBUG SWCAN: mcp251x_spi_trans: spi_message_add_tail(&t, &m) [ 27.472426] DEBUG SWCAN: mcp251x_spi_trans: ret=0x00 [ 27.526856] DEBUG SWCAN: mcp251x_read_reg: val=0x80 [ 27.584687] DEBUG SWCAN: mcp251x_hw_reset(): reg=0x80 [ 27.611370] DEBUG SWCAN: mcp251x_hw_reset(): CANCTRL_REQOP_MASK=0xe0 [ 27.640533] DEBUG SWCAN: mcp251x_hw_reset(): CANCTRL_REQOP_CONF=0x80 [ 27.675986] DEBUG SWCAN: mcp251x_hw_reset(): (reg & CANCTRL_REQOP_MASK)=0x80 [ 27.700828] DEBUG SWCAN: mcp251x_hw_probe: ret=0 [ 27.722323] DEBUG SWCAN: mcp251x_hw_probe: CANCTRL=0x0f [ 27.793728] DEBUG SWCAN: mcp251x_read_reg: spi=db56f400 [ 27.801947] DEBUG SWCAN: mcp251x_read_reg: reg=0x0f [ 27.808908] DEBUG SWCAN: mcp251x_spi_trans: spi=db56f400 [ 27.819537] DEBUG SWCAN: mcp251x_spi_trans: len=0x03 [ 27.829695] DEBUG SWCAN: mcp251x_spi_trans: spi_message_init(&m) [ 27.840546] DEBUG SWCAN: mcp251x_spi_trans: m=dc3a9a20 [ 27.852489] DEBUG SWCAN: mcp251x_spi_trans: mcp251x_enable_dma=0x00 [ 27.861291] DEBUG SWCAN: mcp251x_spi_trans: spi_message_add_tail(&t, &m) [ 27.876376] DEBUG SWCAN: mcp251x_spi_trans: ret=0x00 [ 27.887315] DEBUG SWCAN: mcp251x_read_reg: val=0x87 [ 27.894647] DEBUG SWCAN: mcp251x_hw_probe: ctrl=0x87 [ 27.906539] DEBUG SWCAN: mcp251x_hw_probe: ((ctrl & 0x17)=0x07 [ 27.920619] mcp251x spi0.0: CANCTRL 0x87 [ 27.920632] DEBUG SWCAN: mcp251x_spi_trans: spi=db56f400 [ 27.933568] DEBUG SWCAN: mcp251x_spi_trans: len=0x03 [ 27.947507] DEBUG SWCAN: mcp251x_spi_trans: spi_message_init(&m) [ 27.960343] DEBUG SWCAN: mcp251x_spi_trans: m=dc3a9a28 [ 27.972333] DEBUG SWCAN: mcp251x_spi_trans: mcp251x_enable_dma=0x00 [ 27.984992] DEBUG SWCAN: mcp251x_spi_trans: spi_message_add_tail(&t, &m) [ 27.993782] DEBUG SWCAN: mcp251x_spi_trans: ret=0x00 [ 28.017187] mcp251x spi0.0 can0: MCP2515 successfully initialized. ``` #### boot without DEBUG SWCAN output: ``` debian@beaglebone:~$ dmesg |egrep -i '(can|spi)' |grep -v SWCAN [ 0.614363] omap2_mcspi 48030000.spi: chipselect 0 already in use [ 0.620587] spi_master spi0: spi_device register error /ocp/spi@48030000/channel@0 [ 0.628235] spi_master spi0: Failed to create SPI device for /ocp/spi@48030000/channel@0 [ 0.629583] CAN device driver interface [ 0.772846] can: controller area network core (rev 20170425 abi 9) [ 40.501537] mcp251x spi0.0: CANCTRL 0x87 [ 40.580953] mcp251x spi0.0 can0: MCP2515 successfully initialized. ``` ### Macchina instructions **[PocketBeagle + M2 + Adapter(BETA)](https://docs.macchina.cc/pb_adapter/)** * Command: ``` sudo ip link set can0 type can bitrate 500000 listen-only on sudo ifconfig can0 up ``` * Output: ``` [ 398.308395] DEBUG SWCAN: mcp251x_hw_reset(): spi=db56f000 [ 398.313948] DEBUG SWCAN: mcp251x_hw_reset(): priv=db19dca0 [ 398.326430] DEBUG SWCAN: mcp251x_hw_reset(): spriv->spi_tx_buf[0]=0xc0 [ 398.333031] DEBUG SWCAN: mcp251x_hw_reset(): call mcp251x_spi_trans(spi, 1) [ 398.341604] DEBUG SWCAN: mcp251x_spi_trans: spi=db56f000 [ 398.347879] DEBUG SWCAN: mcp251x_spi_trans: len=0x01 [ 398.353783] DEBUG SWCAN: mcp251x_spi_trans: spi_message_init(&m) [ 398.361180] DEBUG SWCAN: mcp251x_spi_trans: m=dc15dcc0 [ 398.367447] DEBUG SWCAN: mcp251x_spi_trans: mcp251x_enable_dma=0x00 [ 398.374658] DEBUG SWCAN: mcp251x_spi_trans: spi_message_add_tail(&t, &m) [ 398.382433] DEBUG SWCAN: mcp251x_spi_trans: ret=0x00 [ 398.393490] DEBUG SWCAN: mcp251x_hw_reset(): CANSTAT=0x0e [ 398.398983] DEBUG SWCAN: mcp251x_hw_reset(): call mcp251x_read_reg() [ 398.406623] DEBUG SWCAN: mcp251x_read_reg: spi=db56f000 [ 398.413021] DEBUG SWCAN: mcp251x_read_reg: reg=0x0e [ 398.419154] DEBUG SWCAN: mcp251x_spi_trans: spi=db56f000 [ 398.425728] DEBUG SWCAN: mcp251x_spi_trans: len=0x03 [ 398.431861] DEBUG SWCAN: mcp251x_spi_trans: spi_message_init(&m) [ 398.439086] DEBUG SWCAN: mcp251x_spi_trans: m=dc15dca0 [ 398.445573] DEBUG SWCAN: mcp251x_spi_trans: mcp251x_enable_dma=0x00 [ 398.453127] DEBUG SWCAN: mcp251x_spi_trans: spi_message_add_tail(&t, &m) [ 398.461064] DEBUG SWCAN: mcp251x_spi_trans: ret=0x00 [ 398.466991] DEBUG SWCAN: mcp251x_read_reg: val=0x80 [ 398.473231] DEBUG SWCAN: mcp251x_hw_reset(): reg=0x80 [ 398.479280] DEBUG SWCAN: mcp251x_hw_reset(): CANCTRL_REQOP_MASK=0xe0 [ 398.486604] DEBUG SWCAN: mcp251x_hw_reset(): CANCTRL_REQOP_CONF=0x80 [ 398.493851] DEBUG SWCAN: mcp251x_hw_reset(): (reg & CANCTRL_REQOP_MASK)=0x80 [ 398.501795] DEBUG SWCAN: mcp251x_spi_trans: spi=db56f000 [ 398.507978] DEBUG SWCAN: mcp251x_spi_trans: len=0x03 [ 398.513795] DEBUG SWCAN: mcp251x_spi_trans: spi_message_init(&m) [ 398.520675] DEBUG SWCAN: mcp251x_spi_trans: m=dc15dcc0 [ 398.526665] DEBUG SWCAN: mcp251x_spi_trans: mcp251x_enable_dma=0x00 [ 398.533783] DEBUG SWCAN: mcp251x_spi_trans: spi_message_add_tail(&t, &m) [ 398.541594] DEBUG SWCAN: mcp251x_spi_trans: ret=0x00 [ 398.547634] DEBUG SWCAN: mcp251x_spi_trans: spi=db56f000 [ 398.553911] DEBUG SWCAN: mcp251x_spi_trans: len=0x03 [ 398.559793] DEBUG SWCAN: mcp251x_spi_trans: spi_message_init(&m) [ 398.567203] DEBUG SWCAN: mcp251x_spi_trans: m=dc15dcc0 [ 398.573597] DEBUG SWCAN: mcp251x_spi_trans: mcp251x_enable_dma=0x00 [ 398.581274] DEBUG SWCAN: mcp251x_spi_trans: spi_message_add_tail(&t, &m) [ 398.589295] DEBUG SWCAN: mcp251x_spi_trans: ret=0x00 [ 398.595452] DEBUG SWCAN: mcp251x_spi_trans: spi=db56f000 [ 398.601959] DEBUG SWCAN: mcp251x_spi_trans: len=0x04 [ 398.608280] DEBUG SWCAN: mcp251x_spi_trans: spi_message_init(&m) [ 398.615300] DEBUG SWCAN: mcp251x_spi_trans: m=dc15dcc0 [ 398.621398] DEBUG SWCAN: mcp251x_spi_trans: mcp251x_enable_dma=0x00 [ 398.628598] DEBUG SWCAN: mcp251x_spi_trans: spi_message_add_tail(&t, &m) [ 398.636313] DEBUG SWCAN: mcp251x_spi_trans: ret=0x00 [ 398.642158] DEBUG SWCAN: mcp251x_read_reg: spi=db56f000 [ 398.648558] DEBUG SWCAN: mcp251x_read_reg: reg=0x2a [ 398.654376] DEBUG SWCAN: mcp251x_spi_trans: spi=db56f000 [ 398.660631] DEBUG SWCAN: mcp251x_spi_trans: len=0x03 [ 398.666940] DEBUG SWCAN: mcp251x_spi_trans: spi_message_init(&m) [ 398.673955] DEBUG SWCAN: mcp251x_spi_trans: m=dc15dca0 [ 398.680004] DEBUG SWCAN: mcp251x_spi_trans: mcp251x_enable_dma=0x00 [ 398.687182] DEBUG SWCAN: mcp251x_spi_trans: spi_message_add_tail(&t, &m) [ 398.694850] DEBUG SWCAN: mcp251x_spi_trans: ret=0x00 [ 398.700720] DEBUG SWCAN: mcp251x_read_reg: val=0x00 [ 398.706462] DEBUG SWCAN: mcp251x_read_reg: spi=db56f000 [ 398.712733] DEBUG SWCAN: mcp251x_read_reg: reg=0x29 [ 398.718717] DEBUG SWCAN: mcp251x_spi_trans: spi=db56f000 [ 398.725170] DEBUG SWCAN: mcp251x_spi_trans: len=0x03 [ 398.731285] DEBUG SWCAN: mcp251x_spi_trans: spi_message_init(&m) [ 398.738455] DEBUG SWCAN: mcp251x_spi_trans: m=dc15dca0 [ 398.744922] DEBUG SWCAN: mcp251x_spi_trans: mcp251x_enable_dma=0x00 [ 398.752612] DEBUG SWCAN: mcp251x_spi_trans: spi_message_add_tail(&t, &m) [ 398.760653] DEBUG SWCAN: mcp251x_spi_trans: ret=0x00 [ 398.766578] DEBUG SWCAN: mcp251x_read_reg: val=0x91 [ 398.772830] DEBUG SWCAN: mcp251x_read_reg: spi=db56f000 [ 398.779031] DEBUG SWCAN: mcp251x_read_reg: reg=0x28 [ 398.784881] DEBUG SWCAN: mcp251x_spi_trans: spi=db56f000 [ 398.791090] DEBUG SWCAN: mcp251x_spi_trans: len=0x03 [ 398.796982] DEBUG SWCAN: mcp251x_spi_trans: spi_message_init(&m) [ 398.804014] DEBUG SWCAN: mcp251x_spi_trans: m=dc15dca0 [ 398.810116] DEBUG SWCAN: mcp251x_spi_trans: mcp251x_enable_dma=0x00 [ 398.817285] DEBUG SWCAN: mcp251x_spi_trans: spi_message_add_tail(&t, &m) [ 398.824987] DEBUG SWCAN: mcp251x_spi_trans: ret=0x00 [ 398.830844] DEBUG SWCAN: mcp251x_read_reg: val=0x01 [ 398.836681] mcp251x spi0.0: CNF: 0x00 0x91 0x01 [ 398.836691] DEBUG SWCAN: mcp251x_spi_trans: spi=db56f000 [ 398.844573] DEBUG SWCAN: mcp251x_spi_trans: len=0x03 [ 398.850563] DEBUG SWCAN: mcp251x_spi_trans: spi_message_init(&m) [ 398.857816] DEBUG SWCAN: mcp251x_spi_trans: m=dc15dcc0 [ 398.863933] DEBUG SWCAN: mcp251x_spi_trans: mcp251x_enable_dma=0x00 [ 398.871654] DEBUG SWCAN: mcp251x_spi_trans: spi_message_add_tail(&t, &m) [ 398.879869] DEBUG SWCAN: mcp251x_spi_trans: ret=0x00 [ 398.886036] DEBUG SWCAN: mcp251x_spi_trans: spi=db56f000 [ 398.892646] DEBUG SWCAN: mcp251x_spi_trans: len=0x03 [ 398.898856] DEBUG SWCAN: mcp251x_spi_trans: spi_message_init(&m) [ 398.906098] DEBUG SWCAN: mcp251x_spi_trans: m=dc15dcc0 [ 398.912481] DEBUG SWCAN: mcp251x_spi_trans: mcp251x_enable_dma=0x00 [ 398.919983] DEBUG SWCAN: mcp251x_spi_trans: spi_message_add_tail(&t, &m) [ 398.927752] DEBUG SWCAN: mcp251x_spi_trans: ret=0x00 [ 398.933629] DEBUG SWCAN: mcp251x_spi_trans: spi=db56f000 [ 398.939806] DEBUG SWCAN: mcp251x_spi_trans: len=0x03 [ 398.945642] DEBUG SWCAN: mcp251x_spi_trans: spi_message_init(&m) [ 398.952561] DEBUG SWCAN: mcp251x_spi_trans: m=dc15dcc8 [ 398.958712] DEBUG SWCAN: mcp251x_spi_trans: mcp251x_enable_dma=0x00 [ 398.965897] DEBUG SWCAN: mcp251x_spi_trans: spi_message_add_tail(&t, &m) [ 398.974020] DEBUG SWCAN: mcp251x_spi_trans: ret=0x00 [ 398.980023] DEBUG SWCAN: mcp251x_spi_trans: spi=db56f000 [ 398.986259] DEBUG SWCAN: mcp251x_spi_trans: len=0x03 [ 398.992181] DEBUG SWCAN: mcp251x_spi_trans: spi_message_init(&m) [ 398.999035] DEBUG SWCAN: mcp251x_spi_trans: m=dc15dcc8 [ 399.005079] DEBUG SWCAN: mcp251x_spi_trans: mcp251x_enable_dma=0x00 [ 399.012370] DEBUG SWCAN: mcp251x_spi_trans: spi_message_add_tail(&t, &m) [ 399.020403] DEBUG SWCAN: mcp251x_spi_trans: ret=0x00 ``` * Command: ``` candump -cae can0,0:0,#FFFFFFFF ``` * Output: ``` [ 451.428585] can: raw protocol (rev 20170425) ``` * ifconfig ``` debian@beaglebone:~$ ifconfig can0 can0: flags=193 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 ```