### Reference * [BeagleBone Black with MCP2515 breakout board.md](https://gist.github.com/pdp7/20dddbeffe83082e3c94ab0903563783) * [PocketBeagle header pinout diagram](https://raw.githubusercontent.com/wiki/beagleboard/pocketbeagle/images/PocketBeagle_pinout.png) * [PocketBeagle System Reference Manual](https://github.com/beagleboard/pocketbeagle/wiki/System-Reference-Manual) * [PocketBeagle + M2 Interface + Adapter](https://github.com/macchina/pocketbeagle-adapter-hardware) * [PDF](https://github.com/macchina/pocketbeagle-adapter-hardware/blob/master/SCH-01010%20R0%20SCHEM_RELEASE.PDF) * [Macchina M2 schematics](https://github.com/macchina/m2-hardware/tree/master/M2-B) * [PDF](https://github.com/macchina/m2-hardware/blob/master/M2-B/Interface%20Board%20PCB.pdf) ### Pin Mapping * Macchina SPI0 for SWCAN MCP2515 is PocketBeagle SPI1 * PocketBeagle adapter * Macchina PB adapter J3 is PB P1 * Macchina PB adapter J2 is next to J3 / PB P1 * Macchina PB adapter J4 is PB P2 * Macchina PB adapter J1 is next to J4 / PB P2 * M2 board * M2 J3 plugs into PB adapter J2, next to PB P1 (which is PB adapter J3) * M2 J4 plugs into PB adapter J1, next to PB P2 (which is PB adapter J4) * M2 board to PocketBeagle P1/P2 headers ``` M2 J4.20: SWC nINT <-> P2.8 M2 J3.6 : SWC_nRESET <-> P2.32 M2 J4.9 : SWC_M0 <-> P2.6 M2 J4.28: SWC_M1 <-> P2.18 M2 J3.30: SWC_CLK <-> NC M2 J4.25: SWC_SOF <-> NC M2 J4.29: SWC_nRX0BF <-> NC M2 J4.30: SWC_nRX1BF <-> NC ``` * M2 board to Macchina PocketBeagle adapter board ``` M2 J4.27: SPI0_CLK <-> PB adapter J2.27: SPI1_CLK M2 J4.24: SPI0_MISO <-> PB adapter J2.24: SPI1_MISO M2 J4.26: SPI0_MOSI <-> PB adapter J2.26: SPI1_MOSI M2 J3.25: SPI0_nCS3 <-> PB adapter J1.25: SPI1_CS ``` * Macchina PocketBeagle adapter to PocketBeagle P1/P2 header ``` PB adapter J4.25: SPI1_MOSI <-> PB 2.25: SPI1_MOSI PB adapter J4.27: SPI1_MISO <-> PB 2.27: SPI1_MISO PB adapter J4.29: SPI1_CLK <-> PB 2.29: SPI1_CLK PB adapter J4.31: SPI1_CS <-> PB 2.31: SPI1_CS ``` * Macchina SWCAN mapping to PocketBeagle header _(from Josh)_ ``` 1006 Signals 1006 headers2 1010/PB header SWC nRESET J3P6 P2-32 SPI0_nCS3 J3P25 P2-31 SPI0 MISO J4P24 P2-27 SPI0 MOSI J4P26 P2-25 SPI0 CLK J4P27 P2-29 SWC nINT J4P20 P2-8 SWC nRX0BF J4P29 NC SWC nRX1BF J4P30 NC SWC SOF J4P25 NC SWC CLK J3P30 NC SWC M0 J4P9 P2-6 SWC M1 J4P28 P2-18 ``` ### Device Tree Overlay * Based on [MCP2515.dts](https://github.com/battlesnake/beaglebone-spi0-mcp2515/blob/master/MCP2515.dts) * File: `/opt/source/bb.org-overlays/src/arm/PB-MCP2515.dts` ``` /dts-v1/; /plugin/; #include #include #include /* Macchina SPI0 for SWCAN MCP2515 is PocketBeagle SPI1 Macchina PB adapter J3 is PB P1 Macchina PB adapter J2 is next to J3 / PB P1 Macchina PB adapter J4 is PB P2 Macchina PB adapter J1 is next to J4 / PB P2 https://github.com/macchina/pocketbeagle-adapter-hardware/blob/master/SCH-01010%20R0%20SCHEM_RELEASE.PDF https://github.com/macchina/m2-hardware/tree/master/M2-B https://github.com/macchina/m2-hardware/blob/master/M2-B/Interface%20Board%20PCB.pdf M2 J3 is plugs into PB adapter J2, next to PB P1 (which is PB adapter J3) M2 J4 is plugs into PB adapter J1, next to PB P2 (which is PB adapter J4) M2 J4.20: SWC nINT <-> P2.8 M2 J3.6 : SWC_nRESET <-> P2.32 M2 J4.9 : SWC_M0 <-> P2.6 M2 J4.28: SWC_M1 <-> P2.18 M2 J3.30: SWC_CLK <-> NC M2 J4.25: SWC_SOF <-> NC M2 J4.29: SWC_nRX0BF <-> NC M2 J4.30: SWC_nRX1BF <-> NC M2 J4.27: SPI0_CLK <-> PB adapter J2.27: SPI1_CLK M2 J4.24: SPI0_MISO <-> PB adapter J2.24: SPI1_MISO M2 J4.26: SPI0_MOSI <-> PB adapter J2.26: SPI1_MOSI M2 J3.25: SPI0_nCS3 <-> PB adapter J1.25: SPI1_CS PB adapter J4.25: SPI1_MOSI <-> PB 2.25: SPI1_MOSI PB adapter J4.27: SPI1_MISO <-> PB 2.27: SPI1_MISO PB adapter J4.29: SPI1_CLK <-> PB 2.29: SPI1_CLK PB adapter J4.31: SPI1_CS <-> PB 2.31: SPI1_CS 1006 Signals 1006 headers2 1010/PB header SWC nRESET J3P6 P2-32 SPI0_nCS3 J3P25 P2-31 SPI0 MISO J4P24 P2-27 SPI0 MOSI J4P26 P2-25 SPI0 CLK J4P27 P2-29 SWC nINT J4P20 P2-8 SWC nRX0BF J4P29 NC SWC nRX1BF J4P30 NC SWC SOF J4P25 NC SWC CLK J3P30 NC SWC M0 J4P9 P2-6 SWC M1 J4P28 P2-18 */ / { fragment@0 { target = <&ocp>; __overlay__ { /* M2 J4.20: SWC nINT <-> P2.8 <&gpio1 28 0>, needs GPIO input M2 J3.6 : SWC_nRESET <-> P2.32 GPIO 112 / PRU0.2, <&gpio3 16 0>, needs GPIO OUTPUT M2 J4.9 : SWC_M0 <-> P2.6 M2 J4.28: SWC_M1 <-> P2.18 */ P2_08_pinmux { status = "disabled"; }; /* SWC nINT */ P2_32_pinmux { status = "disabled"; }; /* SWC nRESET */ P2_25_pinmux { status = "disabled"; }; /* MOSI - gpio1_9 */ P2_27_pinmux { status = "disabled"; }; /* MISO - gpio1_8 */ P2_29_pinmux { status = "disabled"; }; /* CLK - gpio0_7 */ P2_31_pinmux { status = "disabled"; }; /* CS - gpio0_19 */ }; }; fragment@1 { target = <&spi1>; __overlay__ { status = "okay"; spidev@1 { status = "disabled"; }; }; }; fragment@2 { target = <&spi1>; __overlay__ { status = "okay"; pinctrl-names = "default"; /* M2 J4.20: SWC nINT <-> P2.8 <&gpio1 28 0>, needs GPIO input M2 J3.6 : SWC_nRESET <-> P2.32 GPIO 112 / PRU0.2, <&gpio3 16 0>, needs GPIO OUTPUT M2 J4.9 : SWC_M0 <-> P2.6 GPIO 57, needs GPIO OUTPUT M2 J4.28: SWC_M1 <-> P2.18 GPIO 47, needs GPIO OUTPUT */ pinctrl-0 = < /* connected to MCP2515 pin 19 _RESET hopefully pullup will enable the chip */ &P2_32_gpio_pu_pin /* SWC nINT */ &P2_08_gpio_input_pin /* SPI1 */ &P2_31_spi_cs_pin &P2_29_spi_sclk_pin &P2_27_spi_pin &P2_25_spi_pin >; channel@0{ status = "disabled"; }; channel@1{ status = "disabled"; }; }; }; fragment@3 { target = <&am33xx_pinmux>; __overlay__ { mcp2515_int: mcp2515_int { pinctrl-single,pins = < 0x00c 0x37 >; }; }; }; fragment@4 { target-path = "/"; __overlay__ { mcp2515_clock: mcp2515_clock { compatible = "fixed-clock"; #clock-cells = <0>; clock-frequency = <8000000>; }; }; }; fragment@5 { target = <&spi1>; __overlay__ { #address-cells = <1>; #size-cells = <0>; can0: mcp2515@0 { status = "okay"; reg = <0>; compatible = "microchip,mcp2515"; pinctrl-names = "default"; pinctrl-0 = <&mcp2515_int>; spi-max-frequency = <10000000>; interrupt-parent = <&gpio1>; interrupts = <3 2>; clocks = <&mcp2515_clock>; mcp251x,oscillator-frequency = <8000000>; mcp251x,irq-gpios = <&gpio1 28 0>; mcp251x,stay-awake = <1>; mcp251x,enable-clkout = <1>; }; }; }; __overrides__ { oscillator = <&mcp2515_clock>,"clock-frequency:0"; spimaxfrequency = <&can0>,"spi-max-frequency:0"; interrupt = <&mcp2515_int>,"pinctrl-single,pins:0",<&can0>,"interrupts:0"; }; }; ``` ### /boot/uEnv.txt ``` uname_r=4.14.78-bone17 enable_uboot_overlays=1 uboot_overlay_addr0=/lib/firmware/PB-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 ``` ### u-boot output not able to connect to the UART serial console pins ### kernel log output ``` debian@beaglebone:~$ dmesg |egrep -i '(can|spi)' [ 0.678208] DEBUG SWCAN: omap2_mcspi_probe(): pdev=dc29aa00 [ 0.683917] DEBUG SWCAN: omap2_mcspi_probe(): node=dcb46574 [ 0.689537] DEBUG SWCAN: omap2_mcspi_probe(): node->name=spi [ 0.695233] DEBUG SWCAN: omap2_mcspi_probe(): node->type= [ 0.701250] DEBUG SWCAN: omap2_mcspi_probe(): node->full_name=/ocp/spi@48030000 [ 0.710596] DEBUG SWCAN: omap2_mcspi_probe(): pdev=dc29a600 [ 0.716327] DEBUG SWCAN: omap2_mcspi_probe(): node=dcb46c30 [ 0.721949] DEBUG SWCAN: omap2_mcspi_probe(): node->name=spi [ 0.727648] DEBUG SWCAN: omap2_mcspi_probe(): node->type= [ 0.733606] DEBUG SWCAN: omap2_mcspi_probe(): node->full_name=/ocp/spi@481a0000 [ 0.743154] CAN device driver interface [ 0.836331] can: controller area network core (rev 20170425 abi 9) [ 44.495014] c_can_platform 481cc000.can: c_can_platform device registered (regs=fa1cc000, irq=39) [ 44.512821] c_can_platform 481d0000.can: c_can_platform device registered (regs=fa1d0000, irq=40) [ 44.682439] DEBUG SWCAN: mcp251x_can_probe() [ 44.768626] DEBUG SWCAN: mcp251x_can_probe() [ 44.816975] DEBUG SWCAN: mcp251x_can_probe(): spi=db5f7000 [ 44.868120] DEBUG SWCAN: mcp251x_can_probe(): spi->chip_select=0x00 [ 44.944837] DEBUG SWCAN: mcp251x_can_probe(): spi->irq=0x6c [ 45.000736] DEBUG SWCAN: mcp251x_can_probe(): spi->modalias=mcp2515 [ 45.068239] DEBUG SWCAN: mcp251x_can_probe(): spi->cs_gpio=0xfffffffe [ 45.162986] DEBUG SWCAN: mcp251x_can_probe(): spi->controller=db5f7c00 [ 45.248749] DEBUG SWCAN: mcp251x_can_probe(): spi->controller->bus_num=0x01 [ 45.315951] DEBUG SWCAN: mcp251x_can_probe(): spi->dev=db5f7178 [ 45.392820] DEBUG SWCAN: mcp251x_can_probe(): spi->dev->of_node=dcb46fb0 [ 45.480687] DEBUG SWCAN: mcp251x_can_probe(): spi->dev->parent=db5f7c00 [ 45.572699] DEBUG SWCAN: mcp251x_can_probe(): spi->dev->init_name=(null) [ 45.644760] DEBUG SWCAN: mcp251x_can_probe(): spi->dev->bus->name=spi [ 45.720787] DEBUG SWCAN: mcp251x_can_probe(): spi->dev->bus->dev_name=(null) [ 45.808669] DEBUG SWCAN: mcp251x_can_probe(): spi->dev->bus->dev_root=(null) [ 45.864841] DEBUG SWCAN: mcp251x_can_probe(): clk=db4baac0 [ 45.904797] DEBUG SWCAN: mcp251x_can_probe(): pdata= (null) [ 45.972637] DEBUG SWCAN: mcp251x_can_probe(): freq = clk_get_rate(clk) [ 45.996824] DEBUG SWCAN: mcp251x_can_probe(): freq=0x7a1200 [ 46.068733] DEBUG SWCAN: mcp251x_can_probe(): freq=8000000 [ 46.100736] DEBUG SWCAN: mcp251x_can_probe(): net=db4f5000 [ 46.153809] DEBUG SWCAN: mcp251x_can_probe(): ret = clk_prepare_enable(clk): 0x00 [ 46.196778] DEBUG SWCAN: mcp251x_can_probe(): call mcp251x_hw_probe() [ 46.284777] DEBUG SWCAN: mcp251x_hw_probe: spi=db5f7000 [ 46.326284] DEBUG SWCAN: mcp251x_hw_reset(): spi=db5f7000 [ 46.396639] DEBUG SWCAN: mcp251x_hw_reset(): priv=db4f54a0 [ 46.449319] DEBUG SWCAN: mcp251x_hw_reset(): spriv->spi_tx_buf[0]=0xc0 [ 46.540123] DEBUG SWCAN: mcp251x_hw_reset(): call mcp251x_spi_trans(spi, 1) [ 46.633862] DEBUG SWCAN: mcp251x_spi_trans: spi=db5f7000 [ 46.700490] DEBUG SWCAN: mcp251x_spi_trans: len=0x01 [ 46.778159] DEBUG SWCAN: mcp251x_spi_trans: spi_message_init(&m) [ 46.848734] DEBUG SWCAN: mcp251x_spi_trans: m=db54fa18 [ 46.908692] DEBUG SWCAN: mcp251x_spi_trans: mcp251x_enable_dma=0x00 [ 46.952761] DEBUG SWCAN: mcp251x_spi_trans: spi_message_add_tail(&t, &m) [ 47.048851] DEBUG SWCAN: mcp251x_spi_trans: ret=0x00 [ 47.133602] DEBUG SWCAN: mcp251x_hw_reset(): CANSTAT=0x0e [ 47.200809] DEBUG SWCAN: mcp251x_hw_reset(): call mcp251x_read_reg() [ 47.276681] DEBUG SWCAN: mcp251x_read_reg: spi=db5f7000 [ 47.340710] DEBUG SWCAN: mcp251x_read_reg: reg=0x0e [ 47.410452] DEBUG SWCAN: mcp251x_spi_trans: spi=db5f7000 [ 47.475826] DEBUG SWCAN: mcp251x_spi_trans: len=0x03 [ 47.513467] DEBUG SWCAN: mcp251x_spi_trans: spi_message_init(&m) [ 47.576818] DEBUG SWCAN: mcp251x_spi_trans: m=db54f9f8 [ 47.672606] DEBUG SWCAN: mcp251x_spi_trans: mcp251x_enable_dma=0x00 [ 47.720866] DEBUG SWCAN: mcp251x_spi_trans: spi_message_add_tail(&t, &m) [ 47.838350] DEBUG SWCAN: mcp251x_spi_trans: ret=0x00 [ 47.891933] DEBUG SWCAN: mcp251x_read_reg: val=0xff [ 47.928921] DEBUG SWCAN: mcp251x_hw_reset(): reg=0xff [ 47.996653] DEBUG SWCAN: mcp251x_hw_reset(): CANCTRL_REQOP_MASK=0xe0 [ 48.064860] DEBUG SWCAN: mcp251x_hw_reset(): CANCTRL_REQOP_CONF=0x80 [ 48.148717] DEBUG SWCAN: mcp251x_hw_reset(): (reg & CANCTRL_REQOP_MASK)=0xe0 [ 48.180696] DEBUG SWCAN: mcp251x_hw_probe: ret=-19 [ 48.276724] mcp251x spi1.0: Cannot initialize MCP2515. Wrong wiring? [ 48.349867] mcp251x spi1.0: Probe failed, err=19 ```