关于 Beaglebone Black CAN 协议设置
About Beaglebone Black CAN protocol setting
感谢您收看。
我的 BBB 在 CAN 通信上遇到了几个月的困难...
如果你能给我一点帮助,我将非常高兴!
我正在研究 BBB 和另一个 CAN 设备之间的 CAN 协议。
确认另一台设备可以正常使用 CAN。
我在 windows 笔记本电脑上使用带 Cloud9 平台的 BBB,
在另一台设备上,它使用的是 CAN0。
我已经使用 CAN1 在 BBB 上设置了 'config-pin',我尝试了 'cansend' 实用程序。
另一台设备上的 bitratre 值也设置为相等。
config-pin p9.24 can
config-pin p9.26 can
ip link set can1 up type can bitrate
cansend can1 300#AC.AB.AD.AE.75.49.AD.D1
但似乎仍然没有发送或接收CAN数据包。
(该接收代码写在附加信息中。)
另外,我试图用示波器机器捕捉一些信号,但我根本无法捕捉到任何东西。
然后,我修改了uEnv.txt的一些行,如下所示,位于BBB的引导文件夹中。
###Additional custom capes
uboot_overlay_addr4=/lib/firmware/BB-CAN0-00A0.dtbo
uboot_overlay_addr5=/lib/firmware/BB-CAN1-00A0.dtbo
#uboot_overlay_addr6=/lib/firmware/<file6>.dtbo
#uboot_overlay_addr7=/lib/firmware/<file7>.dtbo
###
但是CAN还是不行,在这个uEnv.txt设置后的config-pin命令显示如下错误
debian@beaglebone:/lib/firmware$ config-pin -q p9.24
ERROR: open() for /sys/devices/platform/ocp/ocp:P9_24_pinmux/state failed, No such file or directory
我真的怀疑驱动程序或 pinmux 设置可能有问题,
因为代码在其他情况下运行良好。
其他覆盖图钉的相同消息。实际上,任何 config-pin
命令都不适用于这些引脚。 (当然CAN总线还没有工作)
我目前使用的是最新的 AM3358 Debian 10.3 (2020-04-06) SD IoT 镜像,软件包似乎都已更新。图像闪烁,没有SD卡。
非常感谢您阅读本文。谢谢!
附加信息:
CAN接收零件码
#include <linux/can.h>
#include <linux/can/raw.h>
#include <net/if.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <fcntl.h>
int InitCanInterface(const char *ifname){
int sock = socket(PF_CAN, SOCK_RAW, CAN_RAW);
fcntl(sock, F_SETFL, O_NONBLOCK);
if (sock == -1){
printf("Fail to create CAN socket for %s - %m \n", ifname);
return -1;
}
printf("Success to create CAN socket for %s\n", ifname);
struct ifreq ifr;
strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1);
int ret = ioctl(sock, SIOCGIFINDEX, &ifr);
if (ret == -1){
perror("Fail to get CAN interface index");
return -1;
}
printf("Success to get CAN interface index: %d\n", ifr.ifr_ifindex);
struct sockaddr_can addr;
addr.can_family = AF_CAN;
addr.can_ifindex = ifr.ifr_ifindex;
ret = bind(sock, (struct sockaddr*)&addr, sizeof(addr));
if (ret == -1){
perror("Fail to bind CAN socket -");
return -1;
}
printf("Success to bind CAN socket\n");
return sock;}
int TransmitCanFrame(const int sock, const uint32_t id, const uint8_t *data, const size_t data_len){
struct can_frame frame;
frame.can_id = id & 0x1ffffff;
frame.can_id |= (1<<31);
memcpy(frame.data, data, data_len);
frame.can_dlc = data_len;
int tx_bytes = write(sock, &frame, sizeof(frame));
if (tx_bytes == -1){
perror("Fail to transmit CAN frame -");
return -1;
}
printf("Success to transmit CAN frame - %d bytes is transmitted\n", tx_bytes);
return 0;
}
#define CAN_FRAME_MAX_LEN 8
int ReceiveCanFrame(const int sock){
struct can_frame frame;
int rx_bytes = read(sock, &frame, sizeof(frame));
if (rx_bytes < 0){
//perror("Fail to receive CAN frame -");
return -1;
}
else if (rx_bytes < (int)sizeof(struct can_frame)){
printf("Incomplete CAN frame is received - rx_bytes: %d/n", rx_bytes);
return -1;
}
else if (frame.can_dlc > CAN_FRAME_MAX_LEN){
printf("Invalid dlc: %u\n", frame.can_dlc);
return -1;
}
if (((frame.can_id >> 29) & 1) ==1) {
printf("Error frame is received\n");
}
else if (((frame.can_id >> 30) & 1) ==1) {
printf("RTR frame is received\n");
}
else {
if (((frame.can_id >> 31) & 1) == 0){
printf("11bit long std CAN frame is received\n");
printf("%#x\n",frame.can_id);
}
else {
printf("29bit long ext CAN frame is received\n");
printf("%#x\n",frame.can_id & 0x0001fffffff );
}
}
for (int ii=0; ii<8; ii++) {
printf("0x%X ", frame.data[ii]);
}
printf("\n");
printf("\n");
return 0;
}
int main(){
int sock = InitCanInterface("can0");
if (sock < 0 ){
return -1;
}
// uint8_t can_data[CAN_FRAME_MAX_LEN] = {};
while(1) {
//printf("hello\n");
//printf("%d",ReceiveCanFrame(sock));
//if(ReceiveCanFrame(sock) == 0)
//printf("No response\n");
ReceiveCanFrame(sock);
sleep(1);
}
return 0;
}
uname -a 输出
debian@beaglebone:/lib/firmware$ uname -a
Linux beaglebone 4.19.94-ti-r64 #1buster SMP PREEMPT Fri May 21 23:57:28 UTC 2021 armv7l GNU/Linux
debian@beaglebone:/lib/firmware$ sudo /opt/scripts/tools/version.sh
git:/opt/scripts/:[e8ae28ccc34a177e9435a0d24cdf8421e081c19a]
eeprom:[A335BNLT00C00620BBBK11BC]
model:[TI_AM335x_BeagleBone_Black]
dogtag:[BeagleBoard.org Debian Buster IoT Image 2020-04-06]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot SPL 2019.04-00002-g07d5700e21 (Mar 06 2020 - 11:24:55 -0600)]:[location: dd MBR]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2019.04-00002-g07d5700e21]:[location: dd MBR]
UBOOT: Booted Device-Tree:[am335x-boneblack-uboot-univ.dts]
UBOOT: Loaded Overlay:[AM335X-PRU-RPROC-4-19-TI-00A0]
UBOOT: Loaded Overlay:[BB-ADC-00A0]
UBOOT: Loaded Overlay:[BB-BONE-eMMC1-01-00A0]
UBOOT: Loaded Overlay:[BB-CAN0-00A0]
UBOOT: Loaded Overlay:[BB-CAN1-00A0]
UBOOT: Loaded Overlay:[BB-HDMI-TDA998x-00A0]
kernel:[4.19.94-ti-r64]
nodejs:[v10.24.0]
/boot/uEnv.txt Settings:
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[uboot_overlay_addr4=/lib/firmware/BB-CAN0-00A0.dtbo]
uboot_overlay_options:[uboot_overlay_addr5=/lib/firmware/BB-CAN1-00A0.dtbo]
uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-19-TI-00A0.dtbo]
uboot_overlay_options:[enable_uboot_cape_universal=1]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade <pkg>]
pkg:[bb-cape-overlays]:[4.14.20210416.0-0~buster+20210416]
pkg:[bb-customizations]:[1.20210708.0-0~buster+20210708]
pkg:[bb-usb-gadgets]:[1.20200504.0-0~buster+20200504]
pkg:[bb-wl18xx-firmware]:[1.20210520.0-0~buster+20210520]
pkg:[kmod]:[26-1]
pkg:[librobotcontrol]:[1.0.5-git20200715.0-0~buster+20200716]
pkg:[firmware-ti-connectivity]:[20190717-2rcnee1~buster+20200305]
groups:[debian : debian adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal bluetooth netdev i2c gpio pwm eqep remoteproc admin spi iio docker tisdk weston-launch xenomai cloud9ide]
cmdline:[console=ttyO0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk1p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100 quiet]
dmesg | grep remote
[ 65.289088] remoteproc remoteproc0: wkup_m3 is available
[ 65.320630] remoteproc remoteproc0: powering up wkup_m3
[ 65.320664] remoteproc remoteproc0: Booting fw image am335x-pm-firmware.elf, size 217148
[ 65.320951] remoteproc remoteproc0: remote processor wkup_m3 is now up
[ 68.227786] remoteproc remoteproc1: 4a334000.pru is available
[ 68.241566] remoteproc remoteproc2: 4a338000.pru is available
dmesg | grep pru
[ 68.227786] remoteproc remoteproc1: 4a334000.pru is available
[ 68.227985] pru-rproc 4a334000.pru: PRU rproc node pru@4a334000 probed successfully
[ 68.241566] remoteproc remoteproc2: 4a338000.pru is available
[ 68.241750] pru-rproc 4a338000.pru: PRU rproc node pru@4a338000 probed successfully
dmesg | grep pinctrl-single
[ 0.943044] pinctrl-single 44e10800.pinmux: 142 pins, size 568
dmesg | grep gpio-of-helper
[ 0.956633] gpio-of-helper ocp:cape-universal: ready
lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
END
用于 CAN 的 dmesg
debian@beaglebone:/lib/firmware$ dmesg | grep can
[ 1.205500] c_can_platform 481cc000.can: c_can_platform device registered (regs=3377e4b7, irq=42)
[ 1.206878] c_can_platform 481d0000.can: c_can_platform device registered (regs=292aef38, irq=43)
[ 1.422353] can: controller area network core (rev 20170425 abi 9)
[ 992.007971] c_can_platform 481d0000.can can1: setting BTR=2701 BRPE=0000
[ 992.016624] IPv6: ADDRCONF(NETDEV_UP): can1: link is not ready
[ 992.017512] IPv6: ADDRCONF(NETDEV_CHANGE): can1: link becomes ready
全uEnv.txt
debian@beaglebone:/lib/firmware$ cat /boot/uEnv.txt
#Docs: http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0
uname_r=4.19.94-ti-r64
#uuid=
#dtb=
###U-Boot Overlays###
###Documentation: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_Overlays
###Master Enable
enable_uboot_overlays=1
###
###Overide capes with eeprom
#uboot_overlay_addr0=/lib/firmware/<file0>.dtbo
#uboot_overlay_addr1=/lib/firmware/<file1>.dtbo
#uboot_overlay_addr2=/lib/firmware/<file2>.dtbo
#uboot_overlay_addr3=/lib/firmware/<file3>.dtbo
###
###Additional custom capes
uboot_overlay_addr4=/lib/firmware/BB-CAN0-00A0.dtbo
uboot_overlay_addr5=/lib/firmware/BB-CAN1-00A0.dtbo
#uboot_overlay_addr6=/lib/firmware/<file6>.dtbo
#uboot_overlay_addr7=/lib/firmware/<file7>.dtbo
###
###Custom Cape
#dtb_overlay=/lib/firmware/<file8>.dtbo
###
###Disable auto loading of virtual capes (emmc/video/wireless/adc)
#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
###
###PRUSS OPTIONS
###pru_rproc (4.14.x-ti kernel)
#uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo
###pru_rproc (4.19.x-ti kernel)
uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-19-TI-00A0.dtbo
###pru_uio (4.14.x-ti, 4.19.x-ti & mainline/bone kernel)
#uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo
###
###Cape Universal Enable
enable_uboot_cape_universal=1
###
###Debug: disable uboot autoload of Cape
#disable_uboot_overlay_addr0=1
#disable_uboot_overlay_addr1=1
#disable_uboot_overlay_addr2=1
#disable_uboot_overlay_addr3=1
###
###U-Boot fdt tweaks... (60000 = 384KB)
#uboot_fdt_buffer=0x60000
###U-Boot Overlays###
cmdline=coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100 quiet
#In the event of edid real failures, uncomment this next line:
#cmdline=coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100 quiet video=HDMI-A-1:1024x768@60e
##enable Generic eMMC Flasher:
##make sure, these tools are installed: dosfstools rsync
#cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh
关于 BBB 或其他系列板的 can 或 socketCAN 的一些帮助可以在这里找到:
https://www.beyondlogic.org/adding-can-to-the-beaglebone-black/
还有:
https://github.com/craigpeacock/CAN-Examples
这些示例有点旧,我注意到 BBB 上的 Linux 发行版,如果从 bbb.io/latest-images 获取它,正在经历 overhaul.
例如,我注意到 config-pin 实用程序仍然有效,但它们的一些覆盖和 BBB 外围设备的 DeviceTrees 正在发送到主线,尤其是。对于 BBAI。
当这些示例不能帮助您配置时,并且这些示例不是我的但我认为它们会有所帮助,Linux 上的 socketCAN,请回复。我正在从这些示例中开发一个简单的 CAN 接口,虽然使用 Linux 很有帮助,但 Device Trees
等一些东西处于变化模式中,我认为这也与配置引脚一致。
例如...
如果你去他们的论坛 forum.beagleboard.org,你会看到 GSOC 的一些人正在研究从配置引脚实用程序到 PRU 内核的示例,这将有助于人们进入共享内存、微控制器游戏.
这是我在他们的论坛页面上找到的配置引脚想法:
https://forum.beagleboard.org/t/beagle-config-logs/30174
我已经在 debian 10.3 (Buster) 的 beaglebone black 上设置了 CAN。
我将 uEnv.txt 保留为默认值并发出这些命令(作为 root)以启用 CAN:
配置引脚 p9.24 可以
配置引脚 p9.26 可以
ip link 设置 can1 类型 can bitrate 1000000
candump can1
一旦成功,您可以使用 uEnv.txt 和 /etc/network/interfaces 自动执行此设置,如此处所述 - https://www.beyondlogic.org/adding-can-to-the-beaglebone-black/ and here - https://www.thomas-wedemeyer.de/beaglebone-canbus-python.html
如果这不起作用,我建议确保没有安装其他可能导致问题的软件或更新 - 尝试在另一张 SD 卡上重新安装 debian,并确保硬件 - 总线驱动程序和接线还可以
我把收发板换成另一个就解决了BBB CAN问题
不要使用cjmcu-230 CAN收发板。我用的是 Waveshare 的那个。 https://www.waveshare.com/sn65hvd230-can-board.htm
两个CAN收发板都使用相同的SN65HVD230芯片,但cjmcu-230板内部似乎存在一些接地引脚电路问题。
希望您遇到这个问题不要浪费时间。
感谢您收看。
我的 BBB 在 CAN 通信上遇到了几个月的困难... 如果你能给我一点帮助,我将非常高兴!
我正在研究 BBB 和另一个 CAN 设备之间的 CAN 协议。 确认另一台设备可以正常使用 CAN。 我在 windows 笔记本电脑上使用带 Cloud9 平台的 BBB, 在另一台设备上,它使用的是 CAN0。
我已经使用 CAN1 在 BBB 上设置了 'config-pin',我尝试了 'cansend' 实用程序。 另一台设备上的 bitratre 值也设置为相等。
config-pin p9.24 can
config-pin p9.26 can
ip link set can1 up type can bitrate
cansend can1 300#AC.AB.AD.AE.75.49.AD.D1
但似乎仍然没有发送或接收CAN数据包。 (该接收代码写在附加信息中。) 另外,我试图用示波器机器捕捉一些信号,但我根本无法捕捉到任何东西。
然后,我修改了uEnv.txt的一些行,如下所示,位于BBB的引导文件夹中。
###Additional custom capes
uboot_overlay_addr4=/lib/firmware/BB-CAN0-00A0.dtbo
uboot_overlay_addr5=/lib/firmware/BB-CAN1-00A0.dtbo
#uboot_overlay_addr6=/lib/firmware/<file6>.dtbo
#uboot_overlay_addr7=/lib/firmware/<file7>.dtbo
###
但是CAN还是不行,在这个uEnv.txt设置后的config-pin命令显示如下错误
debian@beaglebone:/lib/firmware$ config-pin -q p9.24
ERROR: open() for /sys/devices/platform/ocp/ocp:P9_24_pinmux/state failed, No such file or directory
我真的怀疑驱动程序或 pinmux 设置可能有问题, 因为代码在其他情况下运行良好。
其他覆盖图钉的相同消息。实际上,任何 config-pin
命令都不适用于这些引脚。 (当然CAN总线还没有工作)
我目前使用的是最新的 AM3358 Debian 10.3 (2020-04-06) SD IoT 镜像,软件包似乎都已更新。图像闪烁,没有SD卡。
非常感谢您阅读本文。谢谢!
附加信息:
CAN接收零件码
#include <linux/can.h>
#include <linux/can/raw.h>
#include <net/if.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <fcntl.h>
int InitCanInterface(const char *ifname){
int sock = socket(PF_CAN, SOCK_RAW, CAN_RAW);
fcntl(sock, F_SETFL, O_NONBLOCK);
if (sock == -1){
printf("Fail to create CAN socket for %s - %m \n", ifname);
return -1;
}
printf("Success to create CAN socket for %s\n", ifname);
struct ifreq ifr;
strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1);
int ret = ioctl(sock, SIOCGIFINDEX, &ifr);
if (ret == -1){
perror("Fail to get CAN interface index");
return -1;
}
printf("Success to get CAN interface index: %d\n", ifr.ifr_ifindex);
struct sockaddr_can addr;
addr.can_family = AF_CAN;
addr.can_ifindex = ifr.ifr_ifindex;
ret = bind(sock, (struct sockaddr*)&addr, sizeof(addr));
if (ret == -1){
perror("Fail to bind CAN socket -");
return -1;
}
printf("Success to bind CAN socket\n");
return sock;}
int TransmitCanFrame(const int sock, const uint32_t id, const uint8_t *data, const size_t data_len){
struct can_frame frame;
frame.can_id = id & 0x1ffffff;
frame.can_id |= (1<<31);
memcpy(frame.data, data, data_len);
frame.can_dlc = data_len;
int tx_bytes = write(sock, &frame, sizeof(frame));
if (tx_bytes == -1){
perror("Fail to transmit CAN frame -");
return -1;
}
printf("Success to transmit CAN frame - %d bytes is transmitted\n", tx_bytes);
return 0;
}
#define CAN_FRAME_MAX_LEN 8
int ReceiveCanFrame(const int sock){
struct can_frame frame;
int rx_bytes = read(sock, &frame, sizeof(frame));
if (rx_bytes < 0){
//perror("Fail to receive CAN frame -");
return -1;
}
else if (rx_bytes < (int)sizeof(struct can_frame)){
printf("Incomplete CAN frame is received - rx_bytes: %d/n", rx_bytes);
return -1;
}
else if (frame.can_dlc > CAN_FRAME_MAX_LEN){
printf("Invalid dlc: %u\n", frame.can_dlc);
return -1;
}
if (((frame.can_id >> 29) & 1) ==1) {
printf("Error frame is received\n");
}
else if (((frame.can_id >> 30) & 1) ==1) {
printf("RTR frame is received\n");
}
else {
if (((frame.can_id >> 31) & 1) == 0){
printf("11bit long std CAN frame is received\n");
printf("%#x\n",frame.can_id);
}
else {
printf("29bit long ext CAN frame is received\n");
printf("%#x\n",frame.can_id & 0x0001fffffff );
}
}
for (int ii=0; ii<8; ii++) {
printf("0x%X ", frame.data[ii]);
}
printf("\n");
printf("\n");
return 0;
}
int main(){
int sock = InitCanInterface("can0");
if (sock < 0 ){
return -1;
}
// uint8_t can_data[CAN_FRAME_MAX_LEN] = {};
while(1) {
//printf("hello\n");
//printf("%d",ReceiveCanFrame(sock));
//if(ReceiveCanFrame(sock) == 0)
//printf("No response\n");
ReceiveCanFrame(sock);
sleep(1);
}
return 0;
}
uname -a 输出
debian@beaglebone:/lib/firmware$ uname -a
Linux beaglebone 4.19.94-ti-r64 #1buster SMP PREEMPT Fri May 21 23:57:28 UTC 2021 armv7l GNU/Linux
debian@beaglebone:/lib/firmware$ sudo /opt/scripts/tools/version.sh
git:/opt/scripts/:[e8ae28ccc34a177e9435a0d24cdf8421e081c19a]
eeprom:[A335BNLT00C00620BBBK11BC]
model:[TI_AM335x_BeagleBone_Black]
dogtag:[BeagleBoard.org Debian Buster IoT Image 2020-04-06]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot SPL 2019.04-00002-g07d5700e21 (Mar 06 2020 - 11:24:55 -0600)]:[location: dd MBR]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2019.04-00002-g07d5700e21]:[location: dd MBR]
UBOOT: Booted Device-Tree:[am335x-boneblack-uboot-univ.dts]
UBOOT: Loaded Overlay:[AM335X-PRU-RPROC-4-19-TI-00A0]
UBOOT: Loaded Overlay:[BB-ADC-00A0]
UBOOT: Loaded Overlay:[BB-BONE-eMMC1-01-00A0]
UBOOT: Loaded Overlay:[BB-CAN0-00A0]
UBOOT: Loaded Overlay:[BB-CAN1-00A0]
UBOOT: Loaded Overlay:[BB-HDMI-TDA998x-00A0]
kernel:[4.19.94-ti-r64]
nodejs:[v10.24.0]
/boot/uEnv.txt Settings:
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[uboot_overlay_addr4=/lib/firmware/BB-CAN0-00A0.dtbo]
uboot_overlay_options:[uboot_overlay_addr5=/lib/firmware/BB-CAN1-00A0.dtbo]
uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-19-TI-00A0.dtbo]
uboot_overlay_options:[enable_uboot_cape_universal=1]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade <pkg>]
pkg:[bb-cape-overlays]:[4.14.20210416.0-0~buster+20210416]
pkg:[bb-customizations]:[1.20210708.0-0~buster+20210708]
pkg:[bb-usb-gadgets]:[1.20200504.0-0~buster+20200504]
pkg:[bb-wl18xx-firmware]:[1.20210520.0-0~buster+20210520]
pkg:[kmod]:[26-1]
pkg:[librobotcontrol]:[1.0.5-git20200715.0-0~buster+20200716]
pkg:[firmware-ti-connectivity]:[20190717-2rcnee1~buster+20200305]
groups:[debian : debian adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal bluetooth netdev i2c gpio pwm eqep remoteproc admin spi iio docker tisdk weston-launch xenomai cloud9ide]
cmdline:[console=ttyO0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk1p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100 quiet]
dmesg | grep remote
[ 65.289088] remoteproc remoteproc0: wkup_m3 is available
[ 65.320630] remoteproc remoteproc0: powering up wkup_m3
[ 65.320664] remoteproc remoteproc0: Booting fw image am335x-pm-firmware.elf, size 217148
[ 65.320951] remoteproc remoteproc0: remote processor wkup_m3 is now up
[ 68.227786] remoteproc remoteproc1: 4a334000.pru is available
[ 68.241566] remoteproc remoteproc2: 4a338000.pru is available
dmesg | grep pru
[ 68.227786] remoteproc remoteproc1: 4a334000.pru is available
[ 68.227985] pru-rproc 4a334000.pru: PRU rproc node pru@4a334000 probed successfully
[ 68.241566] remoteproc remoteproc2: 4a338000.pru is available
[ 68.241750] pru-rproc 4a338000.pru: PRU rproc node pru@4a338000 probed successfully
dmesg | grep pinctrl-single
[ 0.943044] pinctrl-single 44e10800.pinmux: 142 pins, size 568
dmesg | grep gpio-of-helper
[ 0.956633] gpio-of-helper ocp:cape-universal: ready
lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
END
用于 CAN 的 dmesg
debian@beaglebone:/lib/firmware$ dmesg | grep can
[ 1.205500] c_can_platform 481cc000.can: c_can_platform device registered (regs=3377e4b7, irq=42)
[ 1.206878] c_can_platform 481d0000.can: c_can_platform device registered (regs=292aef38, irq=43)
[ 1.422353] can: controller area network core (rev 20170425 abi 9)
[ 992.007971] c_can_platform 481d0000.can can1: setting BTR=2701 BRPE=0000
[ 992.016624] IPv6: ADDRCONF(NETDEV_UP): can1: link is not ready
[ 992.017512] IPv6: ADDRCONF(NETDEV_CHANGE): can1: link becomes ready
全uEnv.txt
debian@beaglebone:/lib/firmware$ cat /boot/uEnv.txt
#Docs: http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0
uname_r=4.19.94-ti-r64
#uuid=
#dtb=
###U-Boot Overlays###
###Documentation: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_Overlays
###Master Enable
enable_uboot_overlays=1
###
###Overide capes with eeprom
#uboot_overlay_addr0=/lib/firmware/<file0>.dtbo
#uboot_overlay_addr1=/lib/firmware/<file1>.dtbo
#uboot_overlay_addr2=/lib/firmware/<file2>.dtbo
#uboot_overlay_addr3=/lib/firmware/<file3>.dtbo
###
###Additional custom capes
uboot_overlay_addr4=/lib/firmware/BB-CAN0-00A0.dtbo
uboot_overlay_addr5=/lib/firmware/BB-CAN1-00A0.dtbo
#uboot_overlay_addr6=/lib/firmware/<file6>.dtbo
#uboot_overlay_addr7=/lib/firmware/<file7>.dtbo
###
###Custom Cape
#dtb_overlay=/lib/firmware/<file8>.dtbo
###
###Disable auto loading of virtual capes (emmc/video/wireless/adc)
#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
###
###PRUSS OPTIONS
###pru_rproc (4.14.x-ti kernel)
#uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo
###pru_rproc (4.19.x-ti kernel)
uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-19-TI-00A0.dtbo
###pru_uio (4.14.x-ti, 4.19.x-ti & mainline/bone kernel)
#uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo
###
###Cape Universal Enable
enable_uboot_cape_universal=1
###
###Debug: disable uboot autoload of Cape
#disable_uboot_overlay_addr0=1
#disable_uboot_overlay_addr1=1
#disable_uboot_overlay_addr2=1
#disable_uboot_overlay_addr3=1
###
###U-Boot fdt tweaks... (60000 = 384KB)
#uboot_fdt_buffer=0x60000
###U-Boot Overlays###
cmdline=coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100 quiet
#In the event of edid real failures, uncomment this next line:
#cmdline=coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100 quiet video=HDMI-A-1:1024x768@60e
##enable Generic eMMC Flasher:
##make sure, these tools are installed: dosfstools rsync
#cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh
关于 BBB 或其他系列板的 can 或 socketCAN 的一些帮助可以在这里找到:
https://www.beyondlogic.org/adding-can-to-the-beaglebone-black/
还有:
https://github.com/craigpeacock/CAN-Examples
这些示例有点旧,我注意到 BBB 上的 Linux 发行版,如果从 bbb.io/latest-images 获取它,正在经历 overhaul.
例如,我注意到 config-pin 实用程序仍然有效,但它们的一些覆盖和 BBB 外围设备的 DeviceTrees 正在发送到主线,尤其是。对于 BBAI。
当这些示例不能帮助您配置时,并且这些示例不是我的但我认为它们会有所帮助,Linux 上的 socketCAN,请回复。我正在从这些示例中开发一个简单的 CAN 接口,虽然使用 Linux 很有帮助,但 Device Trees
等一些东西处于变化模式中,我认为这也与配置引脚一致。
例如...
如果你去他们的论坛 forum.beagleboard.org,你会看到 GSOC 的一些人正在研究从配置引脚实用程序到 PRU 内核的示例,这将有助于人们进入共享内存、微控制器游戏.
这是我在他们的论坛页面上找到的配置引脚想法:
https://forum.beagleboard.org/t/beagle-config-logs/30174
我已经在 debian 10.3 (Buster) 的 beaglebone black 上设置了 CAN。
我将 uEnv.txt 保留为默认值并发出这些命令(作为 root)以启用 CAN:
配置引脚 p9.24 可以
配置引脚 p9.26 可以
ip link 设置 can1 类型 can bitrate 1000000
candump can1
一旦成功,您可以使用 uEnv.txt 和 /etc/network/interfaces 自动执行此设置,如此处所述 - https://www.beyondlogic.org/adding-can-to-the-beaglebone-black/ and here - https://www.thomas-wedemeyer.de/beaglebone-canbus-python.html
如果这不起作用,我建议确保没有安装其他可能导致问题的软件或更新 - 尝试在另一张 SD 卡上重新安装 debian,并确保硬件 - 总线驱动程序和接线还可以
我把收发板换成另一个就解决了BBB CAN问题
不要使用cjmcu-230 CAN收发板。我用的是 Waveshare 的那个。 https://www.waveshare.com/sn65hvd230-can-board.htm
两个CAN收发板都使用相同的SN65HVD230芯片,但cjmcu-230板内部似乎存在一些接地引脚电路问题。
希望您遇到这个问题不要浪费时间。