【发布时间】:2022-04-26 00:39:44
【问题描述】:
我想使用 comms cape 2 为我的 BBB 启用 RS-485 AND CANbus 通信。
我曾经通过 /boot/uEnv.txt 设置我的 Beaglebone black,方法是用 EEProm 覆盖,如下所示:
###Overide capes with eeprom
uboot_overlay_addr0=/lib/firmware/BB-UART1-00A0.dtbo
uboot_overlay_addr1=/lib/firmware/BB-UART2-00A0.dtbo
uboot_overlay_addr2=/lib/firmware/BB-UART4-00A0.dtbo
uboot_overlay_addr3=/lib/firmware/BB-UART5-00A0.dtbo
然后我使用 ttyS4 进行 RS-485 通信。
虽然它曾经适用于某些 BBB,但在许多其他 BBB 上已不再适用,并且引发了许多问题:
- 如果我这样做,CANbus 将停止工作 - 可能会弄乱 CANbus 的 UART;
- 如果我不使用 CANbus,此设置似乎不再适用于 RS-485 本身 - 我猜想根据安装的 linux 版本有所改变。
长话短说,我想找到一种现代方法来 1) 设置 RS-485 通信和 2) 设置 CANbus 通信,以便它们同时工作。
还有,我如何独立于我自己的软件测试 RS-485 通信的工作?
我在网上找到的:
这里的官方 cape comms 文档https://github.com/beagleboard/capes/tree/master/beaglebone/Comms 告诉如何设置如下:
For the RS485, you just need
config-pin p9.11 uart
config-pin p9.13 uart
...and then use /dev/ttyS4
For the CAN, you just need
config-pin p9.24 can
config-pin p9.26 can
但在我的情况下,设置config-pin p9.11 uart 会导致以下错误:
ERROR: open() for /sys/devices/platform/ocp/ocp:P9_11_pinmux/state failed, No such file or directory
这个 SO beaglebone black: no slots while enable uart 告诉如何设置 UART5。 他们说要禁用视频,我做到了。 并:
config-pin P8_37 uart
config-pin P8_38 uart
这对我有用,我的意思是没有产生错误。
然后我在自己的软件中使用了ttS5,但我在 RS-485 上看不到任何东西。
这时候我有点疑惑:比如,要不要覆盖EEPROM?我应该坚持禁用视频、声音等。为什么 UART4 的 config-pin 不起作用? UART 5是否对应ttyS5?以及如何确保我使用的 ttySX 真正适用于 RS-485 通讯?
提前致谢。
附录:我当前的/boot/uEnv.txt
#Docs: http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0
uname_r=4.19.94-ti-r42
#uuid=
#dtb=
###U-Boot Overlays###
###Documentation: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U$
###Master Enable
enable_uboot_overlays=1
###
###Overide capes with eeprom
#uboot_overlay_addr0=/lib/firmware/BB-UART1-00A0.dtbo
#uboot_overlay_addr1=/lib/firmware/BB-UART2-00A0.dtbo
uboot_overlay_addr2=/lib/firmware/BB-UART4-00A0.dtbo
uboot_overlay_addr3=/lib/firmware/BB-UART5-00A0.dtbo
###
###Additional custom capes
#uboot_overlay_addr4=/lib/firmware/<file4>.dtbo
#uboot_overlay_addr5=/lib/firmware/<file5>.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_qual$
#In the event of edid real failures, uncomment this next line:
#cmdline=coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_qua$
##enable Generic eMMC Flasher:
##make sure, these tools are installed: dosfstools rsync
#cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh
【问题讨论】:
-
我认为 Cape 是“自动”检测到的。也许不吧。我会进行更多研究并获得想法。
-
/dev/ttyS(n) 是一个符号链接。因此,不使用 /dev/ttyO(n),而是使用符号链接。
-
你好......你有没有想过这个?如果没有,也许更新到 udev 规则会有所帮助?另外,我发现 .dts 文件现在是内核的一部分。查看 /home/UserName/linux-5.17.4/arch/arm/boot/dts 。
-
Hey De Funct,是的,我已经添加了自己的答案。希望对您有所帮助。
标签: embedded-linux beagleboneblack can-bus rs485