/************************************************************************************** * RPi 2B UART作为调试口或者普通串口 * 声明: * 本文主要记录RPi 2B UART如何设置为调试口或者普通串口,本来早就做出来了,由于接错 * 了线,GND和TXD接反了,导致SecureCRT发不出信号,但能接收到。 * * 2016-2-24 深圳 南山平山村 曾剑锋 ************************************************************************************/ 一、参考文档: RPi Serial Connection http://elinux.org/RPi_Serial_Connection 二、uart serial: 1. cat /boot/cmdline.txt dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait 2. cat /etc/inittab #Spawn a getty on Raspberry Pi serial line #T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100 3. 串口获取的dmesg信息: lo[ 655.631165] reboot: Restarting system Uncompressing Linux... done, booting the kernel. 三、debug console: 1. cat /boot/cmdline.txt dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait 2. cat /etc/inittab #Spawn a getty on Raspberry Pi serial line T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100 3. 串口获取的dmesg信息: Uncompressing Linux... done, booting the kernel. [ 0.000000] Booting Linux on physical CPU 0xf00 [ 0.000000] Initializing cgroup subsys cpuset [ 0.000000] Initializing cgroup subsys cpu [ 0.000000] Initializing cgroup subsys cpuacct [ 0.000000] Linux version 4.1.13-v7+ (dc4@dc4-XPS13-9333) (gcc version 4.8.3 20140303 (prerelease) (crosstool-NG linaro-1.13.1+bzr2650 - Linaro GCC 2014.03) ) #826 SMP PREEMPT Fri Nov 13 20:19:03 GMT 2015 [ 0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d [ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache [ 0.000000] Machine model: Raspberry Pi 2 Model B Rev 1.1 [ 0.000000] cma: Reserved 8 MiB at 0x3a800000 [ 0.000000] Memory policy: Data cache writealloc [ 0.000000] [bcm2709_smp_init_cpus] enter (9420->f3003010) [ 0.000000] [bcm2709_smp_init_cpus] ncores=4 [ 0.000000] PERCPU: Embedded 13 pages/cpu @b9f64000 s20608 r8192 d24448 u53248 [ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 239540 [ 0.000000] Kernel command line: dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2709.boardrev=0xa21041 bcm2709.serial=0xc33be36b smsc95xx.macaddr=B8:27:EB:3B:E3:6B bcm2708_fb.fbswap=1 bcm2709.disk_led_gpio=47 bcm2709.disk_led_active_low=0 sdhci-bcm2708.emmc_clock_freq=250000000 vc_mem.mem_base=0x3dc00000 vc_mem.mem_size=0x3f000000 dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait [ 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: 939496K/966656K available (5967K kernel code, 534K rwdata, 1652K rodata, 420K init, 757K bss, 18968K reserved, 8192K cma-reserved) [ 0.000000] Virtual kernel memory layout: [ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB) [ 0.000000] fixmap : 0xffc00000 - 0xfff00000 (3072 kB) [ 0.000000] vmalloc : 0xbb800000 - 0xff000000 (1080 MB) [ 0.000000] lowmem : 0x80000000 - 0xbb000000 ( 944 MB) [ 0.000000] modules : 0x7f000000 - 0x80000000 ( 16 MB) [ 0.000000] .text : 0x80008000 - 0x80778f64 (7620 kB) [ 0.000000] .init : 0x80779000 - 0x807e2000 ( 420 kB) [ 0.000000] .data : 0x807e2000 - 0x80867b6c ( 535 kB) [ 0.000000] .bss : 0x8086a000 - 0x8092779c ( 758 kB) [ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1 [ 0.000000] Preemptible hierarchical RCU implementation. [ 0.000000] Additional per-CPU info printed with stalls. [ 0.000000] NR_IRQS:608 [ 0.000000] Architected cp15 timer(s) running at 19.20MHz (phys). [ 0.000000] clocksource arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x46d987e47, max_idle_ns: 440795202767 ns [ 0.000010] sched_clock: 56 bits at 19MHz, resolution 52ns, wraps every 4398046511078ns [ 0.000032] Switching to timer-based delay loop, resolution 52ns [ 0.000322] Console: colour dummy device 80x30 [ 0.002090] console [tty1] enabled [ 0.002156] Calibrating delay loop (skipped), value calculated using timer frequency.. 38.40 BogoMIPS (lpj=192000) [ 0.002256] pid_max: default: 32768 minimum: 301 [ 0.002633] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes) [ 0.002698] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes) [ 0.004012] Initializing cgroup subsys blkio [ 0.004090] Initializing cgroup subsys memory [ 0.004160] Initializing cgroup subsys devices [ 0.004221] Initializing cgroup subsys freezer [ 0.004296] Initializing cgroup subsys net_cls [ 0.004403] CPU: Testing write buffer coherency: ok [ 0.004523] ftrace: allocating 20235 entries in 60 pages [ 0.053972] CPU0: update cpu_capacity 1024 [ 0.054052] CPU0: thread -1, cpu 0, socket 15, mpidr 80000f00 [ 0.054098] [bcm2709_smp_prepare_cpus] enter [ 0.054264] Setting up static identity map for 0x8240 - 0x8274 [ 0.113839] [bcm2709_boot_secondary] cpu:1 started (0) 18 [ 0.114275] [bcm2709_secondary_init] enter cpu:1 [ 0.114331] CPU1: update cpu_capacity 1024 [ 0.114340] CPU1: thread -1, cpu 1, socket 15, mpidr 80000f01 [ 0.133826] [bcm2709_boot_secondary] cpu:2 started (0) 17 [ 0.134183] [bcm2709_secondary_init] enter cpu:2 [ 0.134215] CPU2: update cpu_capacity 1024 [ 0.134224] CPU2: thread -1, cpu 2, socket 15, mpidr 80000f02 [ 0.153868] [bcm2709_boot_secondary] cpu:3 started (0) 18 [ 0.154124] [bcm2709_secondary_init] enter cpu:3 [ 0.154153] CPU3: update cpu_capacity 1024 [ 0.154161] CPU3: thread -1, cpu 3, socket 15, mpidr 80000f03 [ 0.154255] Brought up 4 CPUs [ 0.154389] SMP: Total of 4 processors activated (153.60 BogoMIPS). [ 0.154431] CPU: All CPU(s) started in HYP mode. [ 0.154467] CPU: Virtualization extensions available. [ 0.155468] devtmpfs: initialized [ 0.179850] VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5 [ 0.180241] clocksource jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns [ 0.181380] pinctrl core: initialized pinctrl subsystem [ 0.182218] NET: Registered protocol family 16 [ 0.188015] DMA: preallocated 4096 KiB pool for atomic coherent allocations [ 0.189281] bcm2709.uart_clock = 3000000 [ 0.194111] hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers. [ 0.194182] hw-breakpoint: maximum watchpoint size is 8 bytes. [ 0.194403] Serial: AMBA PL011 UART driver [ 0.194618] 3f201000.uart: ttyAMA0 at MMIO 0x3f201000 (irq = 83, base_baud = 0) is a PL011 rev2 [ 0.701674] console [ttyAMA0] enabled [ 0.705954] bcm2835-mbox 3f00b880.mailbox: mailbox enabled [ 0.786324] bcm2708-dmaengine 3f007000.dma: DMA legacy API manager at f3007000, dmachans=0xf35 [ 0.795082] bcm2708-dmaengine 3f007000.dma: Initialized 7 DMA channels (+ 1 legacy) [ 0.803498] bcm2708-dmaengine 3f007000.dma: Load BCM2835 DMA engine driver [ 0.810427] bcm2708-dmaengine 3f007000.dma: dma_debug:0 [ 0.816395] SCSI subsystem initialized [ 0.820412] usbcore: registered new interface driver usbfs [ 0.826051] usbcore: registered new interface driver hub [ 0.831537] usbcore: registered new device driver usb [ 0.837319] raspberrypi-firmware soc:firmware: Attached to firmware from 2015-11-18 15:43 [ 0.872892] Switched to clocksource arch_sys_counter [ 0.927061] FS-Cache: Loaded [ 0.930345] CacheFiles: Loaded [ 0.945109] NET: Registered protocol family 2 [ 0.950796] TCP established hash table entries: 8192 (order: 3, 32768 bytes) [ 0.958063] TCP bind hash table entries: 8192 (order: 4, 65536 bytes) [ 0.964794] TCP: Hash tables configured (established 8192 bind 8192) [ 0.971327] UDP hash table entries: 512 (order: 2, 16384 bytes) [ 0.977365] UDP-Lite hash table entries: 512 (order: 2, 16384 bytes) [ 0.984201] NET: Registered protocol family 1 [ 0.989133] RPC: Registered named UNIX socket transport module. [ 0.995125] RPC: Registered udp transport module. [ 0.999848] RPC: Registered tcp transport module. [ 1.004619] RPC: Registered tcp NFSv4.1 backchannel transport module. [ 1.012286] hw perfevents: enabled with armv7_cortex_a7 PMU driver, 5 counters available [ 1.021871] futex hash table entries: 1024 (order: 4, 65536 bytes) [ 1.043896] VFS: Disk quotas dquot_6.6.0 [ 1.048228] VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes) [ 1.057888] FS-Cache: Netfs 'nfs' registered for caching [ 1.064441] NFS: Registering the id_resolver key type [ 1.069577] Key type id_resolver registered [ 1.073817] Key type id_legacy registered [ 1.080614] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252) [ 1.088335] io scheduler noop registered [ 1.092293] io scheduler deadline registered (default) [ 1.097800] io scheduler cfq registered [ 1.104251] BCM2708FB: allocated DMA memory fac00000 [ 1.109274] BCM2708FB: allocated DMA channel 0 @ f3007000 [ 1.120375] Console: switching to colour frame buffer device 82x26 [ 1.131852] Serial: 8250/16550 driver, 0 ports, IRQ sharing disabled [ 1.140469] KGDB: Registered I/O driver kgdboc [ 1.183661] vc-cma: Videocore CMA driver [ 1.189264] vc-cma: vc_cma_base = 0x00000000 [ 1.195623] vc-cma: vc_cma_size = 0x00000000 (0 MiB) [ 1.202580] vc-cma: vc_cma_initial = 0x00000000 (0 MiB) [ 1.209723] vc-mem: phys_addr:0x00000000 mem_base=0x3dc00000 mem_size:0x3f000000(1008 MiB) [ 1.236745] brd: module loaded [ 1.250281] loop: module loaded [ 1.255997] vchiq: vchiq_init_state: slot_zero = 0xbac80000, is_master = 0 [ 1.266297] Loading iSCSI transport class v2.0-870. [ 1.273751] usbcore: registered new interface driver smsc95xx [ 1.281082] dwc_otg: version 3.00a 10-AUG-2012 (platform bus) [ 1.488693] Core Release: 2.80a [ 1.493335] Setting default values for core params [ 1.499647] Finished setting default values for core params [ 1.707160] Using Buffer DMA mode [ 1.711972] Periodic Transfer Interrupt Enhancement - disabled [ 1.719431] Multiprocessor Interrupt Enhancement - disabled [ 1.726588] OTG VER PARAM: 0, OTG VER FLAG: 0 [ 1.732474] Dedicated Tx FIFOs mode [ 1.737794] WARN::dwc_otg_hcd_init:1047: FIQ DMA bounce buffers: virt = 0xbac14000 dma = 0xfac14000 len=9024 [ 1.750833] FIQ FSM acceleration enabled for : [ 1.750833] Non-periodic Split Transactions [ 1.750833] Periodic Split Transactions [ 1.750833] High-Speed Isochronous Endpoints [ 1.774070] WARN::hcd_init_fiq:412: FIQ on core 1 at 0x80402c54 [ 1.781613] WARN::hcd_init_fiq:413: FIQ ASM at 0x80402fb0 length 36 [ 1.789513] WARN::hcd_init_fiq:438: MPHI regs_base at 0xbb89a000 [ 1.797136] dwc_otg 3f980000.usb: DWC OTG Controller [ 1.803750] dwc_otg 3f980000.usb: new USB bus registered, assigned bus number 1 [ 1.812686] dwc_otg 3f980000.usb: irq 32, io mem 0x00000000 [ 1.819890] Init: Port Power? op_state=1 [ 1.825366] Init: Power Port (0) [ 1.830390] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002 [ 1.838788] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1 [ 1.847606] usb usb1: Product: DWC OTG Controller [ 1.853872] usb usb1: Manufacturer: Linux 4.1.13-v7+ dwc_otg_hcd [ 1.861426] usb usb1: SerialNumber: 3f980000.usb [ 1.868462] hub 1-0:1.0: USB hub found [ 1.873871] hub 1-0:1.0: 1 port detected [ 1.880153] usbcore: registered new interface driver usb-storage [ 1.887946] mousedev: PS/2 mouse device common for all mice [ 1.895869] bcm2835-cpufreq: min=600000 max=900000 [ 1.902495] sdhci: Secure Digital Host Controller Interface driver [ 1.910227] sdhci: Copyright(c) Pierre Ossman [ 1.916640] mmc-bcm2835 3f300000.mmc: mmc_debug:0 mmc_debug2:0 [ 1.924050] mmc-bcm2835 3f300000.mmc: DMA channels allocated [ 1.963260] sdhci-pltfm: SDHCI platform and OF driver helper [ 1.977560] ledtrig-cpu: registered to indicate activity on CPUs [ 1.985434] hidraw: raw HID events driver (C) Jiri Kosina [ 1.992691] usbcore: registered new interface driver usbhid [ 2.000928] usbhid: USB HID core driver [ 2.007827] Initializing XFRM netlink socket [ 2.013792] NET: Registered protocol family 17 [ 2.023001] Key type dns_resolver registered [ 2.029254] Registering SWP/SWPB emulation handler [ 2.036451] registered taskstats version 1 [ 2.042269] vc-sm: Videocore shared memory driver [ 2.048495] [vc_sm_connected_init]: start [ 2.052577] mmc0: host does not support reading read-only switch, assuming write-enable [ 2.056256] mmc0: new high speed SDHC card at address aaaa [ 2.056866] mmcblk0: mmc0:aaaa SS08G 7.40 GiB [ 2.066398] mmcblk0: p1 p2 [ 2.082648] Indeed it is in host mode hprt0 = 00021501 [ 2.083600] [vc_sm_connected_init]: end - returning 0 [ 2.109834] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null) [ 2.121267] VFS: Mounted root (ext4 filesystem) readonly on device 179:2. [ 2.130804] devtmpfs: mounted [ 2.136162] Freeing unused kernel memory: 420K (80779000 - 807e2000) [ 2.272989] usb 1-1: new high-speed USB device number 2 using dwc_otg [ 2.281567] Indeed it is in host mode hprt0 = 00001101 [ 2.441901] random: systemd urandom read with 35 bits of entropy available [ 2.456018] systemd[1]: systemd 215 running in system mode. (+PAM +AUDIT +SELINUX +IMA +SYSVINIT +LIBCRYPTSETUP +GCRYPT +ACL +XZ -SECCOMP -APPARMOR) [ 2.473913] systemd[1]: Detected architecture 'arm'. [ 2.493434] usb 1-1: New USB device found, idVendor=0424, idProduct=9514 [ 2.502086] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0 [ 2.512140] hub 1-1:1.0: USB hub found [ 2.518056] hub 1-1:1.0: 5 ports detected [ 2.617947] NET: Registered protocol family 10 [ 2.626739] systemd[1]: Inserted module 'ipv6' [ 2.635313] systemd[1]: Set hostname to <raspberrypi>. [ 2.725272] uart-pl011 3f201000.uart: no DMA platform data [ 2.802987] usb 1-1.1: new high-speed USB device number 3 using dwc_otg [ 2.924064] usb 1-1.1: New USB device found, idVendor=0424, idProduct=ec00 [ 2.933304] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0 [ 2.950115] smsc95xx v1.0.4 [ 3.017276] smsc95xx 1-1.1:1.0 eth0: register 'smsc95xx' at usb-3f980000.usb-1.1, smsc95xx USB 2.0 Ethernet, b8:27:eb:3b:e3:6b [ 3.123001] usb 1-1.3: new high-speed USB device number 4 using dwc_otg [ 3.137859] systemd[1]: Starting Forward Password Requests to Wall Directory Watch. [ 3.149619] systemd[1]: Started Forward Password Requests to Wall Directory Watch. [ 3.160914] systemd[1]: Expecting device dev-ttyAMA0.device... [ 3.171313] systemd[1]: Starting Remote File Systems (Pre). [ 3.181189] systemd[1]: Reached target Remote File Systems (Pre). [ 3.189375] systemd[1]: Starting Encrypted Volumes. [ 3.198602] systemd[1]: Reached target Encrypted Volumes. [ 3.206226] systemd[1]: Starting Arbitrary Executable File Formats File System Automount Point. [ 3.222072] systemd[1]: Set up automount Arbitrary Executable File Formats File System Automount Point. [ 3.235832] systemd[1]: Starting Swap. [ 3.244177] systemd[1]: Reached target Swap. [ 3.250486] systemd[1]: Expecting device dev-mmcblk0p1.device... [ 3.261239] systemd[1]: Starting Root Slice. [ 3.269793] systemd[1]: Created slice Root Slice. [ 3.276410] systemd[1]: Starting User and Session Slice. [ 3.285991] systemd[1]: Created slice User and Session Slice. [ 3.293635] systemd[1]: Starting /dev/initctl Compatibility Named Pipe. [ 3.304744] systemd[1]: Listening on /dev/initctl Compatibility Named Pipe. [ 3.313717] systemd[1]: Starting Delayed Shutdown Socket. [ 3.323392] systemd[1]: Listening on Delayed Shutdown Socket. [ 3.331017] systemd[1]: Starting Journal Socket (/dev/log). [ 3.340717] systemd[1]: Listening on Journal Socket (/dev/log). [ 3.348582] systemd[1]: Starting udev Control Socket. [ 3.357670] systemd[1]: Listening on udev Control Socket. [ 3.364937] systemd[1]: Starting udev Kernel Socket. [ 3.373913] systemd[1]: Listening on udev Kernel Socket. [ 3.381067] systemd[1]: Starting Journal Socket. [ 3.389987] systemd[1]: Listening on Journal Socket. [ 3.396974] systemd[1]: Starting System Slice. [ 3.405556] systemd[1]: Created slice System Slice. [ 3.412279] systemd[1]: Starting File System Check on Root Device... [ 3.425817] systemd[1]: Starting system-systemd\x2dfsck.slice. [ 3.436737] systemd[1]: Created slice system-systemd\x2dfsck.slice. [ 3.444983] systemd[1]: Starting system-autologin.slice. [ 3.455282] systemd[1]: Created slice system-autologin.slice. [ 3.463207] systemd[1]: Starting system-serial\x2dgetty.slice. [ 3.473706] systemd[1]: Created slice system-serial\x2dgetty.slice. [ 3.482186] systemd[1]: Starting Increase datagram queue length... [ 3.495995] systemd[1]: Starting Restore / save the current clock... [ 3.544175] systemd[1]: Starting Load Kernel Modules... [ 3.576265] systemd[1]: Started Set Up Additional Binary Formats. [ 3.592664] systemd[1]: Starting Create list of required static device nodes for the current kernel... [ 3.616267] systemd[1]: Mounting Debug File System... [ 3.630391] systemd[1]: Mounting POSIX Message Queue File System... [ 3.645149] systemd[1]: Mounted Huge Pages File System. [ 3.653252] systemd[1]: Starting udev Coldplug all Devices... [ 3.664271] usb 1-1.3: New USB device found, idVendor=148f, idProduct=7601 [ 3.664287] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 3.675337] fuse init (API version 7.23) [ 3.693816] systemd[1]: Starting Slices. [ 3.703250] systemd[1]: Reached target Slices. [ 3.711825] i2c /dev entries driver [ 3.719708] systemd[1]: Mounted POSIX Message Queue File System. [ 3.730629] systemd[1]: Mounted Debug File System. [ 3.742275] systemd[1]: Started Increase datagram queue length. [ 3.766497] systemd[1]: Started Restore / save the current clock. [ 3.778666] systemd[1]: Started Load Kernel Modules. [ 3.789610] systemd[1]: Started Create list of required static device nodes for the current kernel. [ 3.808259] systemd[1]: Started File System Check on Root Device. [ 3.843156] systemd[1]: Time has been changed [ 3.902051] systemd[1]: Started udev Coldplug all Devices. [ 4.050303] systemd[1]: Starting Create Static Device Nodes in /dev... [ 4.065244] systemd[1]: Mounting FUSE Control File System... [ 4.079358] systemd[1]: Starting Apply Kernel Variables... [ 4.094942] systemd[1]: Mounting Configuration File System... [ 4.108786] systemd[1]: Starting Syslog Socket. [ 4.118425] systemd[1]: Listening on Syslog Socket. [ 4.125514] systemd[1]: Starting Journal Service... Raspbian GNU/Linux 8 raspberrypi ttyAMA0 raspberrypi login: pi Password: Last login: Wed Feb 24 11:34:12 UTC 2016 on tty1 Linux raspberrypi 4.1.13-v7+ #826 SMP PREEMPT Fri Nov 13 20:19:03 GMT 2015 armv7l The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. pi@raspberrypi:~$ ls Desktop Downloads Pictures Public show Videos Documents Music programe python_games Templates pi@raspberrypi:~$