BeagleBone Black:如何激活 UART 4 或 5 以启用 RS-485 通信

BeagleBone Black: how to activate UART 4 or 5 to enable RS-485 communication

我想使用通信 cape 2 为我的 BBB 启用 RS-485 AND CANbus 通信。

我曾经通过 /boot/uEnv.txt 通过用 EEProm 覆盖来设置我的 Beaglebone black,如下所示:

###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 上已不再适用,并且引发了许多问题:

  1. 如果我这样做,CANbus 将停止工作——可能会弄乱 CANbus 的 UART;
  2. 如果我不使用 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 讲述了如何设置 UART5。 他们说要禁用视频,我做到了。 以及:

config-pin P8_37 uart
config-pin P8_38 uart

这对我有效,我的意思是没有产生错误。 然后我在自己的软件中使用了ttS5,但是在RS-485上我什么也看不到。

这时候我有点疑惑:比如,到底要不要覆盖EEPROM?我应该坚持禁用视频、声音等吗?为什么 UART4 的配置引脚不起作用? 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

这是我的 /boot/uEnv.txt 文件:


#Docs: http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0

uname_r=4.19.94-ti-r71
#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=BONE-SPI1_0.dtbo
uboot_overlay_addr1=BONE-SPI0_0.dtbo
#uboot_overlay_addr2=<file2>.dtbo
#uboot_overlay_addr3=<file3>.dtbo

我没有在 uboot-overlays 部分应用 /lib/firmware 部分。

这是ls -l /dev/spidev*


crw------- 1 root root 153, 0 Feb 10 00:39 /dev/spidev1.0
crw------- 1 root root 153, 1 Feb 10 00:39 /dev/spidev2.0

我认为不是 root 对我来说可能是个问题。

无论如何...符号链接现在在源代码中使用,我想,还有一个 up-to-date 回购协议。来自 BeagleBoard.org fellows/gals 帮助人们将他们的 .dts 文件生成为 .dtb/o 文件。它对我很有用 b/c 然后我可以改变事情或者看看 beagleboard.org 的人在用 DT 做什么。

最后,我为解决这个问题所做的是:

  • RS-485 使用 ttyS4;
  • 使用 can1 进行 CANbus 通信。

然后/boot/uEnv.txt就很简单了,干脆不设置任何UART,保持默认即可。这是:

$ cat /boot/uEnv.txt

#Docs: http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0

uname_r=4.19.94-ti-r71
#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/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=0
###
###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