Firefly开源社区

标题: 如何引出3个CAN [打印本页]

作者: tieshou200    时间: 2022-5-9 15:39
标题: 如何引出3个CAN
就是咱们硬件上用CAN1和CAN2引脚,但加载后,开发板可以查看到can0和can1
root@firefly:~# ip link set can0 down
root@firefly:~# ip link set can0 type can bitrate 250000
root@firefly:~# ip link set can0 up
root@firefly:~# ip link set can1 down
root@firefly:~# ip link set can1 type can bitrate 250000
root@firefly:~# ip link set can1 up
root@firefly:~# ifconfig
can0: flags=193<UP,RUNNING,NOARP>  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
        device interrupt 60

can1: flags=193<UP,RUNNING,NOARP>  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
        device interrupt 61


而且从实际使用上看,
can0设备对应CAN2引脚
can1设备对应CAN1引脚
请问这个是怎么回事?

另外,我的项目里想用3个can,那can0被占了可怎么办?
tchip_askquestions

log.txt.zip

760 Bytes, 下载次数: 0, 下载积分: 灯泡 -1 , 经验 -1


作者: Liuth    时间: 2022-5-9 16:28
1. 板子印刷错误导致编号对不上,不影响使用
2. can0 的接口被 i2c1 占用
3. 即使你关闭 i2c1 也用不了 can0,因为硬件上没做出接口
下载页面应该是有底板原理图的,可以查看有哪些硬件资源,原理图里搜不到的那就是没有,除非自己制作底板
作者: tieshou200    时间: 2022-5-10 09:12
Liuth 发表于 2022-5-9 16:28
1. 板子印刷错误导致编号对不上,不影响使用
2. can0 的接口被 i2c1 占用
3. 即使你关闭 i2c1 也用不了 c ...

对对对大神,我就是要自己制作底板,需要引出3个CAN。
我的疑问就是硬件的CAN1和CAN2引脚,怎么创建出来的设备是can0、can1呢,那我硬件CAN0创建的设备可怎么命名呢?
如果要修改软件的命名,在哪个地方能够修改呢?
作者: dengkx    时间: 2022-5-10 09:15
tieshou200 发表于 2022-5-10 09:12
对对对大神,我就是要自己制作底板,需要引出3个CAN。
我的疑问就是硬件的CAN1和CAN2引脚,怎么创建出来 ...

软件can0/1是看谁先被创建的,和硬件的can1、2没有关系
作者: Liuth    时间: 2022-5-10 09:17
自己做底板那 i2c1 引脚就是 can0,在设备树里关闭 i2c1 ,开启 can0
驱动创建设备是按照0开始的,所以第一个创建的就是can0,无论硬件上具体是哪个
你把can0 1 2 都打开,就能对上了
作者: dengkx    时间: 2022-5-10 09:34
tieshou200 发表于 2022-5-10 09:12
对对对大神,我就是要自己制作底板,需要引出3个CAN。
我的疑问就是硬件的CAN1和CAN2引脚,怎么创建出来 ...

网口名字在alloc_netdev_mqs函数里设置,can在alloc_candev_mqs设置
作者: tieshou200    时间: 2022-5-10 12:04
dengkx 发表于 2022-5-10 09:34
网口名字在alloc_netdev_mqs函数里设置,can在alloc_candev_mqs设置

太感谢了
作者: tieshou200    时间: 2022-5-10 13:30
Liuth 发表于 2022-5-10 09:17
自己做底板那 i2c1 引脚就是 can0,在设备树里关闭 i2c1 ,开启 can0
驱动创建设备是按照0开始的,所以第 ...

明白了,万分感谢




欢迎光临 Firefly开源社区 (https://dev.t-firefly.com/) Powered by Discuz! X3.1