login RPi via serial port

本文介绍如何通过串口连接并登录 Raspberry Pi。默认情况下,Raspberry Pi 在启动时会运行 getty 服务,允许用户通过串口进行登录。文章还详细介绍了如何禁用启动时的串口输出,并提供了测试串口连接的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Since I have bought a product from adafruit, I need to know how to connect my RPi from PC via serial port.

Login via Serial port

By default, RPi can be login via serial port due to program getty is running configured in /etc/inittab

Bootup info

When RPi boots up, it would send boot info to serial port since the file /boot/cmdline.txt.

Disable serial port when boots up

  • add # character to the begining in file /etc/inittab
    #T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
  • remove all reference to ttyAMA0 in file /boot/cmdline.txt
    From
    dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
    To dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

Reboot

sudo reboot

Test the serial port

  • stty -F /dev/ttyAMA0 9600
  • minicom -b 9600 -o -D /dev/ttyAMA0
  • python serial
    ser = serial.Serial("/dev/ttyAMA0",9600)
    ser.open()

Reference:

Raspberry Pi and the Serial Port
get terminal access to Pi over USB/serial cable
RPi_Serial_Connection
raspberry-pi-and-arduino-connected-serial-gpio
Raspberry Pi Serial Console With MAX3232CPE

转载于:https://my.oschina.net/l1z2g9/blog/162505

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值