BeagleBone AI-如何设置CAN总线

时间:2020-06-05 03:39:35

标签: linux linux-kernel u-boot can-bus

我无法在Internet上找到任何资源来在Beagle Bone AI上设置CAN总线,并且安装和运行时遇到了很多麻烦,但是http://beagleboard.org/chat上的zmatt基本上为我完成了一切为了帮助解决这个问题,#1,请大家感谢zmatt,#2,我想在这里分享我的发现,这样其他人就不需要经历我经历的所有痛苦就可以解决这个问题。

基本问题是BeagleBone AI无法通过CAN总线开箱即用。主要原因是默认情况下未正确配置pinxmux。

解决问题的步骤:

为您的设备下载Linux内核的版本。我测试过:

 https://elinux.org/Beagleboard:Latest-images-testing
 am57xx-debian-10.3-console-armhf-2020-04-06-1gb.img.xz

注意:这是一个“控制台”版本,这意味着您必须自己安装所有应用程序。基本上,每次您尝试执行命令失败时,都会安装google Linux(无论命令失败)。否则,您可以尝试使用基本的Beagle Bone AI发行版之一,该发行版默认包含应用程序。

设置网络配置,以便您可以在BBAI中下载所需的任何内容。就我而言,我正在将BBAI连接到WIFI,因此请通过以下方式进行连接: https://fis.gatech.edu/how-to-configure-bbw-wifi/

下载设备树源代码:

Note!!!! Which ever version of Linux you are using, you MUST make sure the source code branch you are using matches your Linux version!!!!
   cd ~
   mkdir DeviceTree
   #The following command will create a folder BeagleBoard-DeviceTrees in the current directory with the device tree.
   git clone https://github.com/beagleboard/BeagleBoard-DeviceTrees.git
   #For instance, if you are using version 4.14 of the TI linux, set the GIT branch to:
   #Note 2: make sure it is the TI version (-ti)
   git checkout v4.14.x-ti

好的,这就是秘密调味料。使用zmatt创建的以下DTS。将文件保存到〜/ DeviceTree / BeagleBoard-DeviceTrees / src / arm / bbai-custom.dts

文件内容:

#include "am5729-beagleboneai.dts"

&{/chosen} {
    base_dtb = "bbai-custom.dts";   // <-- name of this file goes here
};

#define P9_24   ( 0x3400 + 4 * 163 )
#define P9_26a  ( 0x3400 + 4 * 162 )
#define P9_26b  ( 0x3400 + 4 *  81 )

&dra7_pmx_core {
    can1_pins_active: can1-active {
        pinctrl-single,pins = <
            DRA7XX_CORE_IOPAD( P9_24,  PIN_INPUT_PULLUP  | MUX_MODE2  ) // rx
            DRA7XX_CORE_IOPAD( P9_26a, PIN_OUTPUT_PULLUP | MUX_MODE2  ) // tx
        >;
    };

    can1_pins_sleep: can1-sleep {
        pinctrl-single,pins = <
            DRA7XX_CORE_IOPAD( P9_24,  PIN_OUTPUT_PULLUP | MUX_MODE15 ) // rx (disabled)
            DRA7XX_CORE_IOPAD( P9_26a, PIN_OUTPUT_PULLUP | MUX_MODE15 ) // tx (disabled)
        >;
    };

    can1_pins_init: can1-init {
        pinctrl-single,pins = <
            DRA7XX_CORE_IOPAD( P9_26b, PIN_OUTPUT        | MUX_MODE15 ) // disable unused shared pin
        >;
    };
};

&dcan2 {  // <---- not a typo
    status = "ok";
    pinctrl-names = "init", "default", "sleep", "active";
    pinctrl-0 = <&can1_pins_sleep>, <&can1_pins_init>;
    pinctrl-1 = <&can1_pins_sleep>;
    pinctrl-2 = <&can1_pins_sleep>;
    pinctrl-3 = <&can1_pins_active>;
};

// Here's the obnoxious part: since u-boot doesn't have same pin defaults yet, all pins not  
// explicitly setup above should be overridden here.  This will eventually no longer be needed.  
&cape_pins_default {
    pinctrl-single,pins = <
        DRA7XX_CORE_IOPAD(0x379C, MUX_MODE14) /* AB8: P8.3: mmc3_dat6.off */
        DRA7XX_CORE_IOPAD(0x37A0, MUX_MODE14) /* AB5: P8.4: mmc3_dat7.off */
        DRA7XX_CORE_IOPAD(0x378C, MUX_MODE14) /* AC9: P8.5: mmc3_dat2.off */
        DRA7XX_CORE_IOPAD(0x3790, MUX_MODE14) /* AC3: P8.6: mmc3_dat3.off */
        DRA7XX_CORE_IOPAD(0x36EC, MUX_MODE14) /* G14: P8.7: mcasp1_axr14.off */
        DRA7XX_CORE_IOPAD(0x36F0, MUX_MODE14) /* F14: P8.8: mcasp1_axr15.off */
        DRA7XX_CORE_IOPAD(0x3698, MUX_MODE14) /* E17: P8.9: xref_clk1.off */
        DRA7XX_CORE_IOPAD(0x36E8, MUX_MODE14) /* A13: P8.10: mcasp1_axr13.off */
        DRA7XX_CORE_IOPAD(0x3510, MUX_MODE14) /* AH4: P8.11: vin1a_d7.off */
        DRA7XX_CORE_IOPAD(0x350C, MUX_MODE14) /* AG6: P8.12: vin1a_d6.off */
        DRA7XX_CORE_IOPAD(0x3590, PIN_INPUT | MUX_MODE12) /* D3: P8.13: vin2a_d10.off */
        DRA7XX_CORE_IOPAD(0x3598, MUX_MODE14) /* D5: P8.14: vin2a_d12.off */
        DRA7XX_CORE_IOPAD(0x3570, MUX_MODE14) /* D1: P8.15a: vin2a_d2.off */
        DRA7XX_CORE_IOPAD(0x35B4, MUX_MODE13) /* A3: P8.15b: vin2a_d19.off */
        DRA7XX_CORE_IOPAD(0x35BC, MUX_MODE13) /* B4: P8.16: vin2a_d21.off */
        DRA7XX_CORE_IOPAD(0x3624, MUX_MODE14) /* A7: P8.17: vout1_d18.off */
        DRA7XX_CORE_IOPAD(0x3588, PIN_INPUT | MUX_MODE12) /* F5: P8.18: vin2a_d8.off */
        DRA7XX_CORE_IOPAD(0x358C, PIN_INPUT | MUX_MODE12) /* E6: P8.19: vin2a_d9.off */
        DRA7XX_CORE_IOPAD(0x3780, MUX_MODE14) /* AC4: P8.20: mmc3_cmd.off */
        DRA7XX_CORE_IOPAD(0x377C, MUX_MODE14) /* AD4: P8.21: mmc3_clk.off */
        DRA7XX_CORE_IOPAD(0x3798, MUX_MODE14) /* AD6: P8.22: mmc3_dat5.off */
        DRA7XX_CORE_IOPAD(0x3794, MUX_MODE14) /* AC8: P8.23: mmc3_dat4.off */
        DRA7XX_CORE_IOPAD(0x3788, MUX_MODE14) /* AC6: P8.24: mmc3_dat1.off */
        DRA7XX_CORE_IOPAD(0x3784, MUX_MODE14) /* AC7: P8.25: mmc3_dat0.off */
        DRA7XX_CORE_IOPAD(0x35B8, MUX_MODE13) /* B3: P8.26: vin2a_d20.off */
        DRA7XX_CORE_IOPAD(0x35D8, MUX_MODE14) /* E11: P8.27a: vout1_vsync.off */
        DRA7XX_CORE_IOPAD(0x3628, MUX_MODE14) /* A8: P8.27b: vout1_d19.off */
        DRA7XX_CORE_IOPAD(0x35C8, MUX_MODE14) /* D11: P8.28a: vout1_clk.off */
        DRA7XX_CORE_IOPAD(0x362C, MUX_MODE14) /* C9: P8.28b: vout1_d20.off */
        DRA7XX_CORE_IOPAD(0x35D4, MUX_MODE14) /* C11: P8.29a: vout1_hsync.off */
        DRA7XX_CORE_IOPAD(0x3630, MUX_MODE14) /* A9: P8.29b: vout1_d21.off */
        DRA7XX_CORE_IOPAD(0x35CC, MUX_MODE14) /* B10: P8.30a: vout1_de.off */
        DRA7XX_CORE_IOPAD(0x3634, MUX_MODE14) /* B9: P8.30b: vout1_d22.off */
        DRA7XX_CORE_IOPAD(0x3614, MUX_MODE14) /* C8: P8.31a: vout1_d14.off */
        DRA7XX_CORE_IOPAD(0x373C, MUX_MODE14) /* G16: P8.31b: mcasp4_axr0.off */
        DRA7XX_CORE_IOPAD(0x3618, MUX_MODE14) /* C7: P8.32a: vout1_d15.off */
        DRA7XX_CORE_IOPAD(0x3740, MUX_MODE14) /* D17: P8.32b: mcasp4_axr1.off */
        DRA7XX_CORE_IOPAD(0x3610, MUX_MODE14) /* C6: P8.33a: vout1_d13.off */
        DRA7XX_CORE_IOPAD(0x34E8, MUX_MODE14) /* AF9: P8.33b: vin1a_fld0.off */
        DRA7XX_CORE_IOPAD(0x3608, MUX_MODE14) /* D8: P8.34a: vout1_d11.off */
        DRA7XX_CORE_IOPAD(0x3564, MUX_MODE14) /* G6: P8.34b: vin2a_vsync0.off */
        DRA7XX_CORE_IOPAD(0x360C, MUX_MODE14) /* A5: P8.35a: vout1_d12.off */
        DRA7XX_CORE_IOPAD(0x34E4, MUX_MODE14) /* AD9: P8.35b: vin1a_de0.off */
        DRA7XX_CORE_IOPAD(0x3604, MUX_MODE14) /* D7: P8.36a: vout1_d10.off */
        DRA7XX_CORE_IOPAD(0x3568, MUX_MODE14) /* F2: P8.36b: vin2a_d0.off */
        DRA7XX_CORE_IOPAD(0x35FC, MUX_MODE14) /* E8: P8.37a: vout1_d8.off */
        DRA7XX_CORE_IOPAD(0x3738, MUX_MODE14) /* A21: P8.37b: mcasp4_fsx.off */
        DRA7XX_CORE_IOPAD(0x3600, MUX_MODE14) /* D9: P8.38a: vout1_d9.off */
        DRA7XX_CORE_IOPAD(0x3734, MUX_MODE14) /* C18: P8.38b: mcasp4_aclkx.off */
        DRA7XX_CORE_IOPAD(0x35F4, MUX_MODE14) /* F8: P8.39: vout1_d6.off */
        DRA7XX_CORE_IOPAD(0x35F8, MUX_MODE14) /* E7: P8.40: vout1_d7.off */
        DRA7XX_CORE_IOPAD(0x35EC, MUX_MODE14) /* E9: P8.41: vout1_d4.off */
        DRA7XX_CORE_IOPAD(0x35F0, MUX_MODE14) /* F9: P8.42: vout1_d5.off */
        DRA7XX_CORE_IOPAD(0x35E4, MUX_MODE14) /* F10: P8.43: vout1_d2.off */
        DRA7XX_CORE_IOPAD(0x35E8, MUX_MODE14) /* G11: P8.44: vout1_d3.off */
        DRA7XX_CORE_IOPAD(0x35DC, MUX_MODE14) /* F11: P8.45a: vout1_d0.off */
        DRA7XX_CORE_IOPAD(0x361C, MUX_MODE14) /* B7: P8.45b: vout1_d16.off */
        DRA7XX_CORE_IOPAD(0x35E0, MUX_MODE14) /* G10: P8.46a: vout1_d1.off */
        DRA7XX_CORE_IOPAD(0x3638, MUX_MODE14) /* A10: P8.46b: vout1_d23.off */
        DRA7XX_CORE_IOPAD(0x372C, MUX_MODE14) /* B19: P9.11a: mcasp3_axr0.off */
        DRA7XX_CORE_IOPAD(0x3620, MUX_MODE14) /* B8: P9.11b: vout1_d17.off */
        DRA7XX_CORE_IOPAD(0x36AC, MUX_MODE14) /* B14: P9.12: mcasp1_aclkr.off */
        DRA7XX_CORE_IOPAD(0x3730, MUX_MODE14) /* C17: P9.13: mcasp3_axr1.off */
        DRA7XX_CORE_IOPAD(0x35AC, MUX_MODE10) /* D6: P9.14: vin2a_d17.off */
        DRA7XX_CORE_IOPAD(0x3514, MUX_MODE14) /* AG4: P9.15: vin1a_d8.off */
        DRA7XX_CORE_IOPAD(0x35B0, MUX_MODE13) /* C5: P9.16: vin2a_d18.off */
        DRA7XX_CORE_IOPAD(0x37CC, MUX_MODE14) /* B24: P9.17a: spi2_cs0.off */
        DRA7XX_CORE_IOPAD(0x36B8, MUX_MODE14) /* F12: P9.17b: mcasp1_axr1.off */
        DRA7XX_CORE_IOPAD(0x37C8, MUX_MODE14) /* G17: P9.18a: spi2_d0.off */
        DRA7XX_CORE_IOPAD(0x36B4, MUX_MODE14) /* G12: P9.18b: mcasp1_axr0.off */
        DRA7XX_CORE_IOPAD(0x3440, PIN_INPUT_PULLUP | MUX_MODE7) /* R6: P9.19a: gpmc_a0.i2c4_scl */
        DRA7XX_CORE_IOPAD(0x357C, PIN_INPUT_PULLUP | MUX_MODE12 ) /* F4: P9.19b: vin2a_d5.pr1_pru1_gpi2 */
        DRA7XX_CORE_IOPAD(0x3444, PIN_INPUT_PULLUP | MUX_MODE7) /* T9: P9.20a: gpmc_a1.i2c4_sda */
        DRA7XX_CORE_IOPAD(0x3578, PIN_INPUT_PULLUP | MUX_MODE12) /* D2: P9.20b: vin2a_d4.pr1_pru1_gpi1 */
        DRA7XX_CORE_IOPAD(0x34F0, MUX_MODE14) /* AF8: P9.21a: vin1a_vsync0.off */
        DRA7XX_CORE_IOPAD(0x37C4, MUX_MODE14) /* B22: P9.21b: spi2_d1.off */
        DRA7XX_CORE_IOPAD(0x369C, MUX_MODE14) /* B26: P9.22a: xref_clk2.off */
        DRA7XX_CORE_IOPAD(0x37C0, MUX_MODE14) /* A26: P9.22b: spi2_sclk.off */
        DRA7XX_CORE_IOPAD(0x37B4, MUX_MODE14) /* A22: P9.23: spi1_cs1.off */
    //  DRA7XX_CORE_IOPAD(0x368C, MUX_MODE14) /* F20: P9.24: gpio6_15.off */
        DRA7XX_CORE_IOPAD(0x3694, MUX_MODE14) /* D18: P9.25: xref_clk0.off */
    //  DRA7XX_CORE_IOPAD(0x3688, MUX_MODE14) /* E21: P9.26a: gpio6_14.off */
    //  DRA7XX_CORE_IOPAD(0x3544, MUX_MODE14) /* AE2: P9.26b: vin1a_d20.off */
        DRA7XX_CORE_IOPAD(0x35A0, MUX_MODE14) /* C3: P9.27a: vin2a_d14.off */
        DRA7XX_CORE_IOPAD(0x36B0, MUX_MODE14) /* J14: P9.27b: mcasp1_fsr.off */
        DRA7XX_CORE_IOPAD(0x36E0, MUX_MODE14) /* A12: P9.28: mcasp1_axr11.off */
        DRA7XX_CORE_IOPAD(0x36D8, MUX_MODE14) /* A11: P9.29a: mcasp1_axr9.off */
        DRA7XX_CORE_IOPAD(0x36A8, MUX_MODE14) /* D14: P9.29b: mcasp1_fsx.off */
        DRA7XX_CORE_IOPAD(0x36DC, MUX_MODE14) /* B13: P9.30: mcasp1_axr10.off */
        DRA7XX_CORE_IOPAD(0x36D4, MUX_MODE14) /* B12: P9.31a: mcasp1_axr8.off */
        DRA7XX_CORE_IOPAD(0x36A4, MUX_MODE14) /* C14: P9.31b: mcasp1_aclkx.off */
        DRA7XX_CORE_IOPAD(0x36A0, MUX_MODE14) /* C23: P9.41a: xref_clk3.off */
        DRA7XX_CORE_IOPAD(0x3580, MUX_MODE14) /* C1: P9.41b: vin2a_d6.off */
        DRA7XX_CORE_IOPAD(0x36E4, MUX_MODE14) /* E14: P9.42a: mcasp1_axr12.off */
        DRA7XX_CORE_IOPAD(0x359C, MUX_MODE14) /* C2: P9.42b: vin2a_d13.off */
    >;
};

保存DTS文本文件后,我们需要对其进行编译。 GIT存储库使我们可以轻松地编译该文件。

要编译:

  cd ~/DeviceTree/BeagleBoard-DeviceTrees

  #This should create a bbai-custom.dtb file
  make src/arm/bbai-custom.dtb

  #Verify that the file ~/DeviceTree/BeagleBoard-DeviceTrees/src/arm/bbai-custom.dtb after compiling.

移动输出二进制文件

  #Copy the output binary to the /boot directory so when we boot we can detect and use it.
  sudo cp src/arm/bbai-custom.dtb /boot/dtbs/bbai-custom.dtb

修改U-Boot引导设置文件:

  #Use whatever text editor you like to modify the following file
  sudo nano /boot/uEnv.txt

  Add the following to the file
  dtb=bbai-custom.dtb

  Save the file
  Reboot the machine

通过输入以下内容测试其是否有效:

  #Type the following command in and can0 should be in the list
  ip link

最终警告!我试图写下为获得此设置所做的一切,但我并非100%肯定上述所有步骤都是正确的。如果我做了一些复制粘贴,路径错误或其他操作,请在两行之间阅读。

希望所有这些都有帮助。

1 个答案:

答案 0 :(得分:0)

关于它的价值,我几个月前问了这个问题(后来我在BB邮件列表中亲自回答了这个问题):https://groups.google.com/d/msg/beagleboard/-0BqofMNKVw/FpOSb4rzAAAJ

我基本上做了您所做的事情,但是我的.dts文件较短。我不必重新指定所有其他引脚,它可以像这样正常工作:

#include "am5729-beagleboneai.dts"

/ {
    chosen {
        base_dtb = "am5729-beagleboneai-kitepower.dts";
        base_dtb_timestamp = __TIMESTAMP__;
    };
};

// The second name (pinmux_dcan2_pins) seems not used
&dra7_pmx_core {
    dcan2_pins: pinmux_dcan2_pins {
        pinctrl-single,pins = <
            /* P9_24: uart1_txd.d_can2_rx */
            DRA7XX_CORE_IOPAD(0x368C, PIN_INPUT_PULLUP | MUX_MODE2)
            /* P9_26: uart1_rxd.d_can2_tx */
            DRA7XX_CORE_IOPAD(0x3688, PIN_OUTPUT_PULLUP | MUX_MODE2)
        >;
    };
};

// Initially defined in dra7 (which is included through multiple layers) as disabled
&dcan2 {
    pinctrl-names = "default"; // Not sure what this is used for
    pinctrl-0 = <&dcan2_pins>;
    status = "okay";
};