树莓派4B Centos8 打开软串口UART

硬件环境:树莓派4B 2G
软件环境:Centos8 64位
镜像:CentOS-Userland-8-aarch64-RaspberryPI-Minimal-4-sda.raw.xz
几天来的折腾为了做一个Mdbus Rtu的树莓派模拟器,然而ttyAMA0这个串口python不能用系统又发现不了ttyS0,一时头疼,各种百度,360参考各路大神方法,终于搞定,方法附上,备查:
未发现ttyS0时
解决方法编辑/boot/config.txt
镜像目录下没有这个文件,新建就可以。编辑保存后重启即可。
我把代码贴在第一行,其他过程可不看

enable_uart=1
dtoverlay=pi3-miniuart-bt-overlay
force_turbo=1

以下为过程,编辑前观察路径

[root@bogon driver]# dir /proc/tty/driver
ttyAMA
[root@bogon driver]# dir /dev
autofs           cuse       gpiomem  loop1         mapper     mqueue  ram1   ram3    raw             stderr  tty12  tty2   tty27  tty34  tty41  tty49  tty56  tty63      urandom  vcs3   vcsa4     vcsu4        video12
block            disk       hwrng    loop2         media0     net     ram10  ram4    rfkill          stdin   tty13  tty20  tty28  tty35  tty42  tty5   tty57  tty7       v4l      vcs4   vcsa5     vcsu5        video13
btrfs-control    dma_heap   initctl  loop3         media1     null    ram11  ram5    rpivid-h264mem  stdout  tty14  tty21  tty29  tty36  tty43  tty50  tty58  tty8       vchiq    vcs5   vcsa6     vcsu6        video14
bus              fd         input    loop4         mem        port    ram12  ram6    rpivid-hevcmem  tty     tty15  tty22  tty3   tty37  tty44  tty51  tty59  tty9       vcio     vcs6   vcsm-cma  vga_arbiter  video15
cachefiles       full       kmsg     loop5         mmcblk0    ppp     ram13  ram7    rpivid-intcmem  tty0    tty16  tty23  tty30  tty38  tty45  tty52  tty6   ttyAMA0    vc-mem   vcsa   vcsu      vhci         video16
char             fuse       kvm      loop6         mmcblk0p1  ptmx    ram14  ram8    rpivid-vp9mem   tty1    tty17  tty24  tty31  tty39  tty46  tty53  tty60  ttyprintk  vcs      vcsa1  vcsu1     vhost-net    watchdog
console          gpiochip0  log      loop7         mmcblk0p2  pts     ram15  ram9    shm             tty10   tty18  tty25  tty32  tty4   tty47  tty54  tty61  uhid       vcs1     vcsa2  vcsu2     video10      watchdog0
cpu_dma_latency  gpiochip1  loop0    loop-control  mmcblk0p3  ram0    ram2   random  snd             tty11   tty19  tty26  tty33  tty40  tty48  tty55  tty62  uinput     vcs2     vcsa3  vcsu3     video11      zero
[root@bogon driver]# 
[root@bogon driver]# cd /boot
[root@bogon boot]# dir
bcm2710-rpi-2-b.dtb       bcm2710-rpi-cm3.dtb       bcm2837-rpi-3-b.dtb       bootcode.bin       fixup4cd.dat  fixup4x.dat   fixup_db.dat  kernel-5.4.65-v8.2.el8.img  overlays      start4.elf    start_db.elf
bcm2710-rpi-3-b.dtb       bcm2711-rpi-4-b.dtb       bcm2837-rpi-3-b-plus.dtb  cmdline.txt        fixup4.dat    fixup_cd.dat  fixup_x.dat   kernel8.img                 start4cd.elf  start4x.elf   start.elf
bcm2710-rpi-3-b-plus.dtb  bcm2837-rpi-3-a-plus.dtb  bcm2837-rpi-cm3-io3.dtb   COPYING.linux-5.4  fixup4db.dat  fixup.dat     grub          LICENCE.broadcom            start4db.elf  start_cd.elf  start_x.elf
[root@bogon boot]# 

编辑文件

vi /boot/config.txt
enable_uart=1
dtoverlay=pi3-miniuart-bt-overlay
force_turbo=1

重启后

[root@bogon driver]# dir
serial  ttyAMA
[root@bogon driver]# dir /dev
autofs           cuse       gpiomem  loop1         mapper     mqueue  ram1   ram3    raw             stderr  tty12  tty2   tty27  tty34  tty41  tty49  tty56  tty63      uinput   vcs2   vcsa3     vcsu3        video11    zero
block            disk       hwrng    loop2         media0     net     ram10  ram4    rfkill          stdin   tty13  tty20  tty28  tty35  tty42  tty5   tty57  tty7       urandom  vcs3   vcsa4     vcsu4        video12
btrfs-control    dma_heap   initctl  loop3         media1     null    ram11  ram5    rpivid-h264mem  stdout  tty14  tty21  tty29  tty36  tty43  tty50  tty58  tty8       v4l      vcs4   vcsa5     vcsu5        video13
bus              fd         input    loop4         mem        port    ram12  ram6    rpivid-hevcmem  tty     tty15  tty22  tty3   tty37  tty44  tty51  tty59  tty9       vchiq    vcs5   vcsa6     vcsu6        video14
cachefiles       full       kmsg     loop5         mmcblk0    ppp     ram13  ram7    rpivid-intcmem  tty0    tty16  tty23  tty30  tty38  tty45  tty52  tty6   ttyAMA0    vcio     vcs6   vcsm-cma  vga_arbiter  video15
char             fuse       kvm      loop6         mmcblk0p1  ptmx    ram14  ram8    rpivid-vp9mem   tty1    tty17  tty24  tty31  tty39  tty46  tty53  tty60  ttyprintk  vc-mem   vcsa   vcsu      vhci         video16
console          gpiochip0  log      loop7         mmcblk0p2  pts     ram15  ram9    shm             tty10   tty18  tty25  tty32  tty4   tty47  tty54  tty61  ttyS0      vcs      vcsa1  vcsu1     vhost-net    watchdog
cpu_dma_latency  gpiochip1  loop0    loop-control  mmcblk0p3  ram0    ram2   random  snd             tty11   tty19  tty26  tty33  tty40  tty48  tty55  tty62  uhid       vcs1     vcsa2  vcsu2     video10      watchdog0
[root@bogon driver]# 

注意:此时ttyS0已经出现了,经测试此时Python Modbus RTU打开ttyS0已经能够正常运行了

猜你喜欢

转载自blog.csdn.net/taogunet/article/details/111823863