通过串口UART登录树莓派

背景

很多朋友因为了解到树莓派的强大,所以都很快入手了一个准备把玩,可是通常买回后,发现自己没有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+ (dc4@dc4-XPS13-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 
  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值