RPi 2B UART作为调试口或者普通串口

时间:2024-01-19 18:47:50
/**************************************************************************************
* RPi 2B UART作为调试口或者普通串口
* 声明:
* 本文主要记录RPi 2B UART如何设置为调试口或者普通串口,本来早就做出来了,由于接错
* 了线,GND和TXD接反了,导致SecureCRT发不出信号,但能接收到。
*
* 2016-2-24 深圳 南山平山村 曾剑锋
************************************************************************************/ 一、参考文档:
RPi Serial Connection
http://elinux.org/RPi_Serial_Connection 二、uart serial:
. cat /boot/cmdline.txt
dwc_otg.lpm_enable= console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
. cat /etc/inittab
#Spawn a getty on Raspberry Pi serial line
#T0::respawn:/sbin/getty -L ttyAMA0 vt100
. 串口获取的dmesg信息:
lo[ 655.631165] reboot: Restarting system
Uncompressing Linux... done, booting the kernel. 三、debug console:
. cat /boot/cmdline.txt
dwc_otg.lpm_enable= console=ttyAMA0, kgdboc=ttyAMA0, console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
. cat /etc/inittab
#Spawn a getty on Raspberry Pi serial line
T0::respawn:/sbin/getty -L ttyAMA0 vt100
. 串口获取的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.-v7+ (dc4@dc4-XPS13-) (gcc version 4.8. (prerelease) (crosstool-NG linaro-1.13.+bzr2650 - Linaro GCC 2014.03) ) # SMP PREEMPT Fri Nov :: GMT
[ 0.000000] CPU: ARMv7 Processor [410fc075] revision (ARMv7), cr=10c5387d
[ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[ 0.000000] Machine model: Raspberry Pi Model B Rev 1.1
[ 0.000000] cma: Reserved MiB at 0x3a800000
[ 0.000000] Memory policy: Data cache writealloc
[ 0.000000] [bcm2709_smp_init_cpus] enter (->f3003010)
[ 0.000000] [bcm2709_smp_init_cpus] ncores=
[ 0.000000] PERCPU: Embedded pages/cpu @b9f64000 s20608 r8192 d24448 u53248
[ 0.000000] Built zonelists in Zone order, mobility grouping on. Total pages:
[ 0.000000] Kernel command line: dma.dmachans=0x7f35 bcm2708_fb.fbwidth= bcm2708_fb.fbheight= bcm2709.boardrev=0xa21041 bcm2709.serial=0xc33be36b smsc95xx.macaddr=B8::EB:3B:E3:6B bcm2708_fb.fbswap= bcm2709.disk_led_gpio= bcm2709.disk_led_active_low= sdhci-bcm2708.emmc_clock_freq= vc_mem.mem_base=0x3dc00000 vc_mem.mem_size=0x3f000000 dwc_otg.lpm_enable= console=ttyAMA0, kgdboc=ttyAMA0, console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
[ 0.000000] PID hash table entries: (order: , bytes)
[ 0.000000] Dentry cache hash table entries: (order: , bytes)
[ 0.000000] Inode-cache hash table entries: (order: , 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 ( kB)
[ 0.000000] fixmap : 0xffc00000 - 0xfff00000 ( kB)
[ 0.000000] vmalloc : 0xbb800000 - 0xff000000 ( MB)
[ 0.000000] lowmem : 0x80000000 - 0xbb000000 ( MB)
[ 0.000000] modules : 0x7f000000 - 0x80000000 ( MB)
[ 0.000000] .text : 0x80008000 - 0x80778f64 ( kB)
[ 0.000000] .init : 0x80779000 - 0x807e2000 ( kB)
[ 0.000000] .data : 0x807e2000 - 0x80867b6c ( kB)
[ 0.000000] .bss : 0x8086a000 - 0x8092779c ( kB)
[ 0.000000] SLUB: HWalign=, Order=-, MinObjects=, CPUs=, Nodes=
[ 0.000000] Preemptible hierarchical RCU implementation.
[ 0.000000] Additional per-CPU info printed with stalls.
[ 0.000000] NR_IRQS:
[ 0.000000] Architected cp15 timer(s) running at .20MHz (phys).
[ 0.000000] clocksource arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x46d987e47, max_idle_ns: ns
[ 0.000010] sched_clock: 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=)
[ 0.002256] pid_max: default: minimum:
[ 0.002633] Mount-cache hash table entries: (order: , bytes)
[ 0.002698] Mountpoint-cache hash table entries: (order: , 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 entries in pages
[ 0.053972] CPU0: update cpu_capacity
[ 0.054052] CPU0: thread -, cpu , socket , 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: started ()
[ 0.114275] [bcm2709_secondary_init] enter cpu:
[ 0.114331] CPU1: update cpu_capacity
[ 0.114340] CPU1: thread -, cpu , socket , mpidr 80000f01
[ 0.133826] [bcm2709_boot_secondary] cpu: started ()
[ 0.134183] [bcm2709_secondary_init] enter cpu:
[ 0.134215] CPU2: update cpu_capacity
[ 0.134224] CPU2: thread -, cpu , socket , mpidr 80000f02
[ 0.153868] [bcm2709_boot_secondary] cpu: started ()
[ 0.154124] [bcm2709_secondary_init] enter cpu:
[ 0.154153] CPU3: update cpu_capacity
[ 0.154161] CPU3: thread -, cpu , socket , mpidr 80000f03
[ 0.154255] Brought up CPUs
[ 0.154389] SMP: Total of 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.: implementor architecture part variant rev
[ 0.180241] clocksource jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: ns
[ 0.181380] pinctrl core: initialized pinctrl subsystem
[ 0.182218] NET: Registered protocol family
[ 0.188015] DMA: preallocated KiB pool for atomic coherent allocations
[ 0.189281] bcm2709.uart_clock =
[ 0.194111] hw-breakpoint: found (+ reserved) breakpoint and watchpoint registers.
[ 0.194182] hw-breakpoint: maximum watchpoint size is bytes.
[ 0.194403] Serial: AMBA PL011 UART driver
[ 0.194618] 3f201000.uart: ttyAMA0 at MMIO 0x3f201000 (irq = , base_baud = ) 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 DMA channels (+ legacy)
[ 0.803498] bcm2708-dmaengine 3f007000.dma: Load BCM2835 DMA engine driver
[ 0.810427] bcm2708-dmaengine 3f007000.dma: dma_debug:
[ 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 -- :
[ 0.872892] Switched to clocksource arch_sys_counter
[ 0.927061] FS-Cache: Loaded
[ 0.930345] CacheFiles: Loaded
[ 0.945109] NET: Registered protocol family
[ 0.950796] TCP established hash table entries: (order: , bytes)
[ 0.958063] TCP bind hash table entries: (order: , bytes)
[ 0.964794] TCP: Hash tables configured (established bind )
[ 0.971327] UDP hash table entries: (order: , bytes)
[ 0.977365] UDP-Lite hash table entries: (order: , bytes)
[ 0.984201] NET: Registered protocol family
[ 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. backchannel transport module.
[ 1.012286] hw perfevents: enabled with armv7_cortex_a7 PMU driver, counters available
[ 1.021871] futex hash table entries: (order: , bytes)
[ 1.043896] VFS: Disk quotas dquot_6.6.0
[ 1.048228] VFS: Dquot-cache hash table entries: (order , 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 )
[ 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 @ f3007000
[ 1.120375] Console: switching to colour frame buffer device 82x26
[ 1.131852] Serial: / driver, 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 ( MiB)
[ 1.202580] vc-cma: vc_cma_initial = 0x00000000 ( MiB)
[ 1.209723] vc-mem: phys_addr:0x00000000 mem_base=0x3dc00000 mem_size:0x3f000000( MiB)
[ 1.236745] brd: module loaded
[ 1.250281] loop: module loaded
[ 1.255997] vchiq: vchiq_init_state: slot_zero = 0xbac80000, is_master =
[ 1.266297] Loading iSCSI transport class v2.-.
[ 1.273751] usbcore: registered new interface driver smsc95xx
[ 1.281082] dwc_otg: version .00a -AUG- (platform bus)
[ 1.488693] Core Release: .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: , OTG VER FLAG:
[ 1.732474] Dedicated Tx FIFOs mode
[ 1.737794] WARN::dwc_otg_hcd_init:: FIQ DMA bounce buffers: virt = 0xbac14000 dma = 0xfac14000 len=
[ 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:: FIQ on core at 0x80402c54
[ 1.781613] WARN::hcd_init_fiq:: FIQ ASM at 0x80402fb0 length
[ 1.789513] WARN::hcd_init_fiq:: 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.812686] dwc_otg 3f980000.usb: irq , io mem 0x00000000
[ 1.819890] Init: Port Power? op_state=
[ 1.825366] Init: Power Port ()
[ 1.830390] usb usb1: New USB device found, idVendor=1d6b, idProduct=
[ 1.838788] usb usb1: New USB device strings: Mfr=, Product=, SerialNumber=
[ 1.847606] usb usb1: Product: DWC OTG Controller
[ 1.853872] usb usb1: Manufacturer: Linux 4.1.-v7+ dwc_otg_hcd
[ 1.861426] usb usb1: SerialNumber: 3f980000.usb
[ 1.868462] hub -:1.0: USB hub found
[ 1.873871] hub -:1.0: port detected
[ 1.880153] usbcore: registered new interface driver usb-storage
[ 1.887946] mousedev: PS/ mouse device common for all mice
[ 1.895869] bcm2835-cpufreq: min= max=
[ 1.902495] sdhci: Secure Digital Host Controller Interface driver
[ 1.910227] sdhci: Copyright(c) Pierre Ossman
[ 1.916640] mmc-bcm2835 3f300000.mmc: mmc_debug: mmc_debug2:
[ 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
[ 2.023001] Key type dns_resolver registered
[ 2.029254] Registering SWP/SWPB emulation handler
[ 2.036451] registered taskstats version
[ 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 =
[ 2.083600] [vc_sm_connected_init]: end - returning
[ 2.109834] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[ 2.121267] VFS: Mounted root (ext4 filesystem) readonly on device :.
[ 2.130804] devtmpfs: mounted
[ 2.136162] Freeing unused kernel memory: 420K ( - 807e2000)
[ 2.272989] usb -: new high-speed USB device number using dwc_otg
[ 2.281567] Indeed it is in host mode hprt0 =
[ 2.441901] random: systemd urandom read with bits of entropy available
[ 2.456018] systemd[]: systemd running in system mode. (+PAM +AUDIT +SELINUX +IMA +SYSVINIT +LIBCRYPTSETUP +GCRYPT +ACL +XZ -SECCOMP -APPARMOR)
[ 2.473913] systemd[]: Detected architecture 'arm'.
[ 2.493434] usb -: New USB device found, idVendor=, idProduct=
[ 2.502086] usb -: New USB device strings: Mfr=, Product=, SerialNumber=
[ 2.512140] hub -:1.0: USB hub found
[ 2.518056] hub -:1.0: ports detected
[ 2.617947] NET: Registered protocol family
[ 2.626739] systemd[]: Inserted module 'ipv6'
[ 2.635313] systemd[]: Set hostname to <raspberrypi>.
[ 2.725272] uart-pl011 3f201000.uart: no DMA platform data
[ 2.802987] usb -1.1: new high-speed USB device number using dwc_otg
[ 2.924064] usb -1.1: New USB device found, idVendor=, idProduct=ec00
[ 2.933304] usb -1.1: New USB device strings: Mfr=, Product=, SerialNumber=
[ 2.950115] smsc95xx v1.0.4
[ 3.017276] smsc95xx -1.1:1.0 eth0: register 'smsc95xx' at usb-3f980000.usb-1.1, smsc95xx USB 2.0 Ethernet, b8::eb:3b:e3:6b
[ 3.123001] usb -1.3: new high-speed USB device number using dwc_otg
[ 3.137859] systemd[]: Starting Forward Password Requests to Wall Directory Watch.
[ 3.149619] systemd[]: Started Forward Password Requests to Wall Directory Watch.
[ 3.160914] systemd[]: Expecting device dev-ttyAMA0.device...
[ 3.171313] systemd[]: Starting Remote File Systems (Pre).
[ 3.181189] systemd[]: Reached target Remote File Systems (Pre).
[ 3.189375] systemd[]: Starting Encrypted Volumes.
[ 3.198602] systemd[]: Reached target Encrypted Volumes.
[ 3.206226] systemd[]: Starting Arbitrary Executable File Formats File System Automount Point.
[ 3.222072] systemd[]: Set up automount Arbitrary Executable File Formats File System Automount Point.
[ 3.235832] systemd[]: Starting Swap.
[ 3.244177] systemd[]: Reached target Swap.
[ 3.250486] systemd[]: Expecting device dev-mmcblk0p1.device...
[ 3.261239] systemd[]: Starting Root Slice.
[ 3.269793] systemd[]: Created slice Root Slice.
[ 3.276410] systemd[]: Starting User and Session Slice.
[ 3.285991] systemd[]: Created slice User and Session Slice.
[ 3.293635] systemd[]: Starting /dev/initctl Compatibility Named Pipe.
[ 3.304744] systemd[]: Listening on /dev/initctl Compatibility Named Pipe.
[ 3.313717] systemd[]: Starting Delayed Shutdown Socket.
[ 3.323392] systemd[]: Listening on Delayed Shutdown Socket.
[ 3.331017] systemd[]: Starting Journal Socket (/dev/log).
[ 3.340717] systemd[]: Listening on Journal Socket (/dev/log).
[ 3.348582] systemd[]: Starting udev Control Socket.
[ 3.357670] systemd[]: Listening on udev Control Socket.
[ 3.364937] systemd[]: Starting udev Kernel Socket.
[ 3.373913] systemd[]: Listening on udev Kernel Socket.
[ 3.381067] systemd[]: Starting Journal Socket.
[ 3.389987] systemd[]: Listening on Journal Socket.
[ 3.396974] systemd[]: Starting System Slice.
[ 3.405556] systemd[]: Created slice System Slice.
[ 3.412279] systemd[]: Starting File System Check on Root Device...
[ 3.425817] systemd[]: Starting system-systemd\x2dfsck.slice.
[ 3.436737] systemd[]: Created slice system-systemd\x2dfsck.slice.
[ 3.444983] systemd[]: Starting system-autologin.slice.
[ 3.455282] systemd[]: Created slice system-autologin.slice.
[ 3.463207] systemd[]: Starting system-serial\x2dgetty.slice.
[ 3.473706] systemd[]: Created slice system-serial\x2dgetty.slice.
[ 3.482186] systemd[]: Starting Increase datagram queue length...
[ 3.495995] systemd[]: Starting Restore / save the current clock...
[ 3.544175] systemd[]: Starting Load Kernel Modules...
[ 3.576265] systemd[]: Started Set Up Additional Binary Formats.
[ 3.592664] systemd[]: Starting Create list of required static device nodes for the current kernel...
[ 3.616267] systemd[]: Mounting Debug File System...
[ 3.630391] systemd[]: Mounting POSIX Message Queue File System...
[ 3.645149] systemd[]: Mounted Huge Pages File System.
[ 3.653252] systemd[]: Starting udev Coldplug all Devices...
[ 3.664271] usb -1.3: New USB device found, idVendor=148f, idProduct=
[ 3.664287] usb -1.3: New USB device strings: Mfr=, Product=, SerialNumber=
[ 3.675337] fuse init (API version 7.23)
[ 3.693816] systemd[]: Starting Slices.
[ 3.703250] systemd[]: Reached target Slices.
[ 3.711825] i2c /dev entries driver
[ 3.719708] systemd[]: Mounted POSIX Message Queue File System.
[ 3.730629] systemd[]: Mounted Debug File System.
[ 3.742275] systemd[]: Started Increase datagram queue length.
[ 3.766497] systemd[]: Started Restore / save the current clock.
[ 3.778666] systemd[]: Started Load Kernel Modules.
[ 3.789610] systemd[]: Started Create list of required static device nodes for the current kernel.
[ 3.808259] systemd[]: Started File System Check on Root Device.
[ 3.843156] systemd[]: Time has been changed
[ 3.902051] systemd[]: Started udev Coldplug all Devices.
[ 4.050303] systemd[]: Starting Create Static Device Nodes in /dev...
[ 4.065244] systemd[]: Mounting FUSE Control File System...
[ 4.079358] systemd[]: Starting Apply Kernel Variables...
[ 4.094942] systemd[]: Mounting Configuration File System...
[ 4.108786] systemd[]: Starting Syslog Socket.
[ 4.118425] systemd[]: Listening on Syslog Socket.
[ 4.125514] systemd[]: Starting Journal Service... Raspbian GNU/Linux raspberrypi ttyAMA0 raspberrypi login: pi
Password:
Last login: Wed Feb :: UTC on tty1
Linux raspberrypi 4.1.-v7+ # SMP PREEMPT Fri Nov :: GMT 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:~$