login RPi via serial port

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

你可能感兴趣的:(login RPi via serial port)