通過串列埠UART登入樹莓派
阿新 • • 發佈:2019-01-06
背景
很多朋友因為了解到樹莓派的強大,所以都很快入手了一個準備把玩,可是通常買回後,發現自己沒有HDMI顯示器,即使有一個顯示器,也通常是VGA介面的,缺個VGA轉HDMI接頭。其實,沒有顯示器也還有辦法可以通過一臺主機(安裝有ssh或串列埠通訊的軟體)的命令列遠端登入到樹莓派,通常有兩種方式:
我們主要講解通過串列埠登入,因為這方面的資料介紹比較少。實際中又通常有很多人要通過串列埠登入。因為他們更加令人受不了的是,自己居然沒有路由器 -_-#, 即使有,也不會尋找DHCP分配給派的ip地址,也就無法通過puTTY這類軟體遠端登入了。
進入正題
要進行串列埠通訊,首先要有一條USB-TTL轉換線和三根杜邦線,杜邦線用來連線USB串列埠轉換器和樹莓派GPIO的UART針腳(6、8、10號)。連線方式:
raspberry pi GPIO pin | USB-TTL Pin |
---|---|
6 | GND |
8 | RXD |
10 | TXD |
首次給樹莓派燒完官方系統後是無法通過串列埠登入的,因為官方預設沒有開啟串列埠用來輸出啟動資訊。
開啟UART串列埠除錯
只需要在燒完官方系統的TF卡上找到config.txt
檔案,然後再最後面新增一句:
enable_uart=1
儲存後,首先開啟自己PC端的串列埠通訊軟體(如puTTY),設定串列埠波特率為115200
[ 0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Initializing cgroup subsys cpuset
[ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Initializing cgroup subsys cpuacct
[ 0.000000] Linux version 4.4.9-v7+ ([email protected]9333) (gcc version 4.9 .3 6
[ 0.000000] CPU: ARMv7 Processor [410fd034] revision 4 (ARMv7), cr=10c5383d
[ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instructie
[ 0.000000] Machine model: Raspberry Pi 3 Model B Rev 1.2
[ 0.000000] cma: Reserved 8 MiB at 0x3a800000
[ 0.000000] Memory policy: Data cache writealloc
[ 0.000000] [bcm2709_smp_init_cpus] enter (9520->f3003010)
[ 0.000000] [bcm2709_smp_init_cpus] ncores=4
[ 0.000000] PERCPU: Embedded 13 pages/cpu @b9f63000 s22592 r8192 d22464 u5328
[ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pa0
[ 0.000000] Kernel command line: 8250.nr_uarts=1 dma.dmachans=0x7f35 bcm2708t
[ 0.000000] PID hash table entries: 4096 (order: 2, 16384 bytes)
[ 0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
[ 0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
[ 0.000000] Memory: 939088K/966656K available (6340K kernel code, 432K rwdat)
[ 0.000000] Virtual kernel memory layout:
[ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)
[ 0.000000] fixmap : 0xffc00000 - 0xfff00000 (3072 kB)
[ 0.000000] vmalloc : 0xbb800000 - 0xff800000 (1088 MB)
[ 0.000000] lowmem : 0x80000000 - 0xbb000000 ( 944 MB)
[ 0.000000] modules : 0x7f000000 - 0x80000000 ( 16 MB)
[ 0.000000] .text : 0x80008000 - 0x807e5330 (8053 kB)
[ 0.000000] .init : 0x807e6000 - 0x8085e000 ( 480 kB)
[ 0.000000] .data : 0x8085e000 - 0x808ca088 ( 433 kB)
[ 0.000000] .bss : 0x808cd000 - 0x8098c1ac ( 765 kB)
[ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
[ 0.000000] Hierarchical RCU implementation.
[ 0.000000] Build-time adjustment of leaf fanout to 32.
[ 0.000000] NR_IRQS:16 nr_irqs:16 16
[ 0.000000] Architected cp15 timer(s) running at 19.20MHz (phys).
[ 0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycless
[ 0.000010] sched_clock: 56 bits at 19MHz, resolution 52ns, wraps every 4398s
[ 0.000027] Switching to timer-based delay loop, resolution 52ns
[ 0.000293] Console: colour dummy device 80x30
[ 0.001344] console [tty1] enabled
[ 0.001398] Calibrating delay loop (skipped), value calculated using timer f)
[ 0.001466] pid_max: default: 32768 minimum: 301
[ 0.001799] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
[ 0.001842] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
[ 0.002800] Disabling cpuset control group subsystem
[ 0.002858] Initializing cgroup subsys io
[ 0.002909] Initializing cgroup subsys memory
[ 0.002972] Initializing cgroup subsys devices
[ 0.003014] Initializing cgroup subsys freezer
[ 0.003056] Initializing cgroup subsys net_cls
[ 0.003128] CPU: Testing write buffer coherency: ok
[ 0.003216] ftrace: allocating 21193 entries in 63 pages
[ 0.052352] CPU0: update cpu_capacity 1024
[ 0.052416] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[ 0.052449] [bcm2709_smp_prepare_cpus] enter
[ 0.052598] Setting up static identity map for 0x8240 - 0x8274
[ 0.054273] [bcm2709_boot_secondary] cpu:1 started (0) 17
[ 0.054600] [bcm2709_secondary_init] enter cpu:1
[ 0.054643] CPU1: update cpu_capacity 1024
[ 0.054649] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
[ 0.055024] [bcm2709_boot_secondary] cpu:2 started (0) 16
[ 0.055285] [bcm2709_secondary_init] enter cpu:2
[ 0.055306] CPU2: update cpu_capacity 1024
[ 0.055312] CPU2: thread -1, cpu 2, socket 0, mpidr 80000002
[ 0.055669] [bcm2709_boot_secondary] cpu:3 started (0) 17
[ 0.055851] [bcm2709_secondary_init] enter cpu:3
[ 0.055871] CPU3: update cpu_capacity 1024
[ 0.055877] CPU3: thread -1, cpu 3, socket 0, mpidr 80000003
[ 0.055936] Brought up 4 CPUs
[ 0.056034] SMP: Total of 4 processors activated (153.60 BogoMIPS).
[ 0.056064] CPU: All CPU(s) started in HYP mode.
[ 0.056089] CPU: Virtualization extensions available.
[ 0.056728] devtmpfs: initialized
[ 0.066460] VFP support v0.3: implementor 41 architecture 3 part 40 variant 4
[ 0.066819] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, ms
[ 0.067534] pinctrl core: initialized pinctrl subsystem
[ 0.068084] NET: Registered protocol family 16
[ 0.073270] DMA: preallocated 4096 KiB pool for atomic coherent allocations
[ 0.080087] bcm2709: Mini UART enabled
[ 0.080146] hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint.
[ 0.080193] hw-breakpoint: maximum watchpoint size is 8 bytes.
[ 0.080370] Serial: AMBA PL011 UART driver
[ 0.080523] uart-pl011 3f201000.uart: could not find pctldev for node /soc/ge
[ 0.080725] bcm2835-mbox 3f00b880.mailbox: mailbox enabled
[ 0.143041] bcm2835-dma 3f007000.dma: DMA legacy API manager at f3007000, dm1
[ 0.144709] SCSI subsystem initialized
[ 0.144902] usbcore: registered new interface driver usbfs
[ 0.145012] usbcore: registered new interface driver hub
[ 0.145130] usbcore: registered new device driver usb
[ 0.151913] raspberrypi-firmware soc:firmware: Attached to firmware from 2013
[ 0.179166] clocksource: Switched to clocksource arch_sys_counter
[ 0.224478] FS-Cache: Loaded
[ 0.224798] CacheFiles: Loaded
[ 0.236962] NET: Registered protocol family 2
[ 0.237837] TCP established hash table entries: 8192 (order: 3, 32768 bytes)
[ 0.237975] TCP bind hash table entries: 8192 (order: 4, 65536 bytes)
[ 0.238186] TCP: Hash tables configured (established 8192 bind 8192)
[ 0.238299] UDP hash table entries: 512 (order: 2, 16384 bytes)
[ 0.238367] UDP-Lite hash table entries: 512 (order: 2, 16384 bytes)
[ 0.238628] NET: Registered protocol family 1
[ 0.238960] RPC: Registered named UNIX socket transport module.
[ 0.238992] RPC: Registered udp transport module.
[ 0.239020] RPC: Registered tcp transport module.
[ 0.239048] RPC: Registered tcp NFSv4.1 backchannel transport module.
[ 0.240107] hw perfevents: enabled with armv7_cortex_a7 PMU driver, 7 countee
[ 0.241544] futex hash table entries: 1024 (order: 4, 65536 bytes)
[ 0.254738] VFS: Disk quotas dquot_6.6.0
[ 0.255058] VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[ 0.257470] FS-Cache: Netfs 'nfs' registered for caching
[ 0.258365] NFS: Registering the id_resolver key type
[ 0.258446] Key type id_resolver registered
[ 0.258475] Key type id_legacy registered
[ 0.260778] Block layer SCSI generic (bsg) driver version 0.4 loaded (major )
[ 0.260944] io scheduler noop registered
[ 0.260982] io scheduler deadline registered (default)
[ 0.261062] io scheduler cfq registered
[ 0.263572] BCM2708FB: allocated DMA memory fac00000
[ 0.263619] BCM2708FB: allocated DMA channel 0 @ f3007000
[ 0.269285] Console: switching to colour frame buffer device 80x30
[ 0.274366] Serial: 8250/16550 driver, 1 ports, IRQ sharing disabled
[ 0.276956] console [ttyS0] disabled
[ 0.278606] 3f215040.uart: ttyS0 at MMIO 0x3f215040 (irq = 59, base_baud = 30
[ 1.012510] console [ttyS0] enabled
[ 1.865544] bcm2835-rng 3f104000.rng: hwrng registered
[ 1.872649] vc-cma: Videocore CMA driver
[ 1.878337] vc-cma: vc_cma_base = 0x00000000
[ 1.884802] vc-cma: vc_cma_size = 0x00000000 (0 MiB)
[ 1.891910] vc-cma: vc_cma_initial = 0x00000000 (0 MiB)
[ 1.899211] vc-mem: phys_addr:0x00000000 mem_base=0x3dc00000 mem_size:0x3f00)
[ 1.925286] brd: module loaded
[ 1.938451] loop: module loaded
[ 1.944029] vchiq: vchiq_init_state: slot_zero = 0xbac80000, is_master = 0
[ 1.954020] Loading iSCSI transport class v2.0-870.
[ 1.961191] usbcore: registered new interface driver smsc95xx
[ 1.968619] dwc_otg: version 3.00a 10-AUG-2012 (platform bus)
[ 2.176252] Core Release: 2.80a
[ 2.180978] Setting default values for core params
[ 2.187409] Finished setting default values for core params
[ 2.395014] Using Buffer DMA mode
[ 2.399954] Periodic Transfer Interrupt Enhancement - disabled
[ 2.407498] Multiprocessor Interrupt Enhancement - disabled
[ 2.414785] OTG VER PARAM: 0, OTG VER FLAG: 0
[ 2.420818] Dedicated Tx FIFOs mode
[ 2.426212] WARN::dwc_otg_hcd_init:1047: FIQ DMA bounce buffers: virt = 0xba4
[ 2.439377] FIQ FSM acceleration enabled for :
[ 2.439377] Non-periodic Split Transactions
[ 2.439377] Periodic Split Transactions
[ 2.439377] High-Speed Isochronous Endpoints
[ 2.439377] Interrupt/Control Split Transaction hack enabled
[ 2.469909] WARN::hcd_init_fiq:413: FIQ on core 1 at 0x804459c4
[ 2.477566] WARN::hcd_init_fiq:414: FIQ ASM at 0x80445d34 length 36
[ 2.485546] WARN::hcd_init_fiq:439: MPHI regs_base at 0xbb932000
[ 2.493272] dwc_otg 3f980000.usb: DWC OTG Controller
[ 2.499937] dwc_otg 3f980000.usb: new USB bus registered, assigned bus numbe1
[ 2.510586] dwc_otg 3f980000.usb: irq 62, io mem 0x00000000
[ 2.517903] Init: Port Power? op_state=1
[ 2.523494] Init: Power Port (0)
[ 2.528515] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[ 2.537043] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber1
[ 2.547560] usb usb1: Product: DWC OTG Controller
[ 2.553963] usb usb1: Manufacturer: Linux 4.4.9-v7+ dwc_otg_hcd
[ 2.561609] usb usb1: SerialNumber: 3f980000.usb
[ 2.568657] hub 1-0:1.0: USB hub found
[ 2.574085] hub 1-0:1.0: 1 port detected
[ 2.580519] usbcore: registered new interface driver usb-storage
[ 2.588417] mousedev: PS/2 mouse device common for all mice
[ 2.596331] bcm2835-cpufreq: min=600000 max=1200000
[ 2.603109] sdhci: Secure Digital Host Controller Interface driver
[ 2.610979] sdhci: Copyright(c) Pierre Ossman
[ 2.617277] sdhost: log_buf @ bac13000 (fac13000)
[ 2.699193] mmc0: sdhost-bcm2835 loaded - DMA enabled (>1)
[ 2.708607] mmc-bcm2835 3f300000.mmc: mmc_debug:0 mmc_debug2:0
[ 2.716152] mmc-bcm2835 3f300000.mmc: DMA channel allocated
[ 2.756235] mmc0: host does not support reading read-only switch, assuming we
[ 2.759278] sdhci-pltfm: SDHCI platform and OF driver helper
[ 2.759675] ledtrig-cpu: registered to indicate activity on CPUs
[ 2.759788] hidraw: raw HID events driver (C) Jiri Kosina
[ 2.759981] usbcore: registered new interface driver usbhid
[ 2.759983] usbhid: USB HID core driver
[ 2.760535] Initializing XFRM netlink socket
[ 2.760558] NET: Registered protocol family 17
[ 2.760674] Key type dns_resolver registered
[ 2.761168] Registering SWP/SWPB emulation handler
[ 2.761941] registered taskstats version 1
[ 2.762136] vc-sm: Videocore shared memory driver
[ 2.762145] [vc_sm_connected_init]: start
[ 2.767935] [vc_sm_connected_init]: end - returning 0
[ 2.769323] 3f201000.uart: ttyAMA0 at MMIO 0x3f201000 (irq = 87, base_baud =2
[ 2.769695] of_cfs_init
[ 2.769770] of_cfs_init: OK
[ 2.779276] Indeed it is in host mode hprt0 = 00021501
[ 2.878496] Waiting for root device /dev/mmcblk0p2...
[ 2.880327] mmc0: new high speed SDHC card at address 0007
[ 2.880931] mmcblk0: mmc0:0007 SD32G 29.0 GiB
[ 2.890352] mmcblk0: p1 p2
[ 2.905435] EXT4-fs (mmcblk0p2): INFO: recovery required on readonly filesysm
[ 2.909269] mmc1: queuing unknown CIS tuple 0x80 (2 bytes)
[ 2.910816] mmc1: queuing unknown CIS tuple 0x80 (3 bytes)
[ 2.912361] mmc1: queuing unknown CIS tuple 0x80 (3 bytes)
[ 2.915156] mmc1: queuing unknown CIS tuple 0x80 (7 bytes)
[ 2.943856] EXT4-fs (mmcblk0p2): write access will be enabled during recovery
[ 2.959202] usb 1-1: new high-speed USB device number 2 using dwc_otg
[ 2.967349] Indeed it is in host mode hprt0 = 00001101
[ 2.975113] EXT4-fs (mmcblk0p2): recovery complete
[ 3.008351] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. )
[ 3.019558] VFS: Mounted root (ext4 filesystem) readonly on device 179:2.
[ 3.029005] devtmpfs: mounted
[ 3.034767] Freeing unused kernel memory: 480K (807e6000 - 8085e000)
[ 3.045289] mmc1: new high speed SDIO card at address 0001
[ 3.169469] usb 1-1: New USB device found, idVendor=0424, idProduct=9514
[ 3.177952] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 3.187663] hub 1-1:1.0: USB hub found
[ 3.193275] hub 1-1:1.0: 5 ports detected
[ 3.311752] random: systemd urandom read with 55 bits of entropy available
[ 3.324555] systemd[1]: systemd 215 running in system mode. (+PAM +AUDIT +SE)
[ 3.341939] systemd[1]: Detected architecture 'arm'.
[ 3.479253] usb 1-1.1: new high-speed USB device number 3 using dwc_otg
[ 3.479431] NET: Registered protocol family 10
[ 3.480778] systemd[1]: Inserted module 'ipv6'
[ 3.484035] systemd[1]: Set hostname to <raspberrypi>.
[ 3.619538] usb 1-1.1: New USB device found, idVendor=0424, idProduct=ec00
[ 3.628441] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumbe0
[ 3.642514] smsc95xx v1.0.4
[ 3.713078] smsc95xx 1-1.1:1.0 eth0: register 'smsc95xx' at usb-3f980000.usbf
[ 3.819225] usb 1-1.5: new full-speed USB device number 4 using dwc_otg
[ 3.937391] systemd[1]: Expecting device dev-ttyS0.device...
[ 3.947641] systemd[1]: Starting Forward Password Requests to Wall Directory.
[ 3.959468] systemd[1]: Started Forward Password Requests to Wall Directory .
[ 3.971020] systemd[1]: Starting Remote File Systems (Pre).
[ 3.981043] systemd[1]: Reached target Remote File Systems (Pre).
[ 3.989317] systemd[1]: Starting Encrypted Volumes.
[ 3.998473] systemd[1]: Reached target Encrypted Volumes.
[ 4.006104] systemd[1]: Starting Arbitrary Executable File Formats File Syst.
[ 4.021712] systemd[1]: Set up automount Arbitrary Executable File Formats F.
[ 4.035350] usb 1-1.5: New USB device found, idVendor=248a, idProduct=8566
[ 4.035407] systemd[1]: Starting Swap.
[ 4.050304] usb 1-1.5: New USB device strings: Mfr=1, Product=2, SerialNumbe0
[ 4.050314] usb 1-1.5: Product: Wireless Receiver
[ 4.050320] usb 1-1.5: Manufacturer: Telink
[ 4.077599] systemd[1]: Reached target Swap.
[ 4.084071] systemd[1]: Expecting device dev-mmcblk0p1.device...
[ 4.094640] systemd[1]: Starting Root Slice.
[ 4.103335] systemd[1]: Created slice Root Slice.
[ 4.110175] systemd[1]: Starting User and Session Slice.
[ 4.110607] input: Telink Wireless Receiver as /devices/platform/soc/3f980000
[ 4.136483] systemd[1]: Created slice User and Session Slice.
[ 4.144354] systemd[1]: Starting /dev/initctl Compatibility Named Pipe.
[ 4.155413] systemd[1]: Listening on /dev/initctl Compatibility Named Pipe.
[ 4.164518] systemd[1]: Starting Delayed Shutdown Socket.
[ 4.172018] hid-generic 0003:248A:8566.0001: input,hidraw0: USB HID v1.11 Ke0
[ 4.190913] systemd[1]: Listening on Delayed Shutdown Socket.
[ 4.198668] systemd[1]: Starting Journal Socket (/dev/log).
[ 4.208574] systemd[1]: Listening on Journal Socket (/dev/log).
[ 4.216559] systemd[1]: Starting udev Control Socket.
[ 4.225900] systemd[1]: Listening on udev Control Socket.
[ 4.233386] systemd[1]: Starting udev Kernel Socket.
[ 4.242559] systemd[1]: Listening on udev Kernel Socket.
[ 4.249979] systemd[1]: Starting Journal Socket.
[ 4.258856] systemd[1]: Listening on Journal Socket.
[ 4.265988] systemd[1]: Starting System Slice.
[ 4.274775] systemd[1]: Created slice System Slice.
[ 4.277133] input: Telink Wireless Receiver as /devices/platform/soc/3f980001
[ 4.298107] systemd[1]: Starting File System Check on Root Device...
[ 4.329662] hid-generic 0003:248A:8566.0002: input,hidraw1: USB HID v1.11 Mo1
[ 4.359781] systemd[1]: Starting system-systemd\x2dfsck.slice.
[ 4.370389] systemd[1]: Created slice system-systemd\x2dfsck.slice.
[ 4.378809] systemd[1]: Starting system-autologin.slice.
[ 4.389362] systemd[1]: Created slice system-autologin.slice.
[ 4.397243] systemd[1]: Starting system-serial\x2dgetty.slice.
[ 4.407784] systemd[1]: Created slice system-serial\x2dgetty.slice.
[ 4.416334] systemd[1]: Starting Increase datagram queue length...
[ 4.429429] systemd[1]: Starting Restore / save the current clock...
[ 4.471153] systemd[1]: Starting Load Kernel Modules...
[ 4.483448] systemd[1]: Starting udev Coldplug all Devices...
[ 4.497008] systemd[1]: Mounted Huge Pages File System.
[ 4.505295] systemd[1]: Starting Create list of required static device nodes.
[ 4.572731] systemd[1]: Started Set Up Additional Binary Formats.
[ 4.581676] systemd[1]: Mounting POSIX Message Queue File System...
[ 4.621927] fuse init (API version 7.23)
[ 4.660016] systemd[1]: Mounting Debug File System...
[ 4.670488] i2c /dev entries driver
[ 4.672420] systemd[1]: Starting Slices.
[ 4.684393] systemd[1]: Reached target Slices.
[ 4.697543] systemd[1]: Started Increase datagram queue length.
[ 4.724812] systemd[1]: Started Restore / save the current clock.
[ 4.736083] systemd[1]: Started Load Kernel Modules.
[ 4.783579] systemd[1]: Started Create list of required static device nodes .
[ 4.799779] systemd[1]: Mounted POSIX Message Queue File System.
[ 4.810645] systemd[1]: Mounted Debug File System.
[ 4.821645] systemd[1]: Time has been changed
[ 4.831061] systemd[1]: Started udev Coldplug all Devices.
[ 4.962840] systemd[1]: Starting Create Static Device Nodes in /dev...
[ 5.009803] systemd[1]: Starting Apply Kernel Variables...
[ 5.021963] systemd[1]: Mounting FUSE Control File System...
[ 5.034783] systemd[1]: Mounting Configuration File System...
[ 5.047794] systemd[1]: Starting Syslog Socket.
[ 5.057180] systemd[1]: Listening on Syslog Socket.
[ 5.064278] systemd[1]: Starting Journal Service...
[ 5.078057] systemd[1]: Started Journal Service.
Raspbian GNU/Linux 8 raspberrypi ttyS0
raspberrypi login: