认识RPi
Posted tommybjia
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了认识RPi相关的知识,希望对你有一定的参考价值。
一、 实验目的和要求
1. 了解嵌入式板卡一般情况;
2. 熟悉pdDuino的供电等接线方式;
3. 复习Linux启动过程(操作系统课);
4. 复习通过Linux获得硬件数据(操作系统课);
5. 熟练掌握串口在PC上的使用;
6. 熟练掌握Linux的以太网和WiFi配置;
7. 熟练掌握Linux的SSH配置;
8. 熟练掌握PC上的SSH软件。
9. 掌握嵌入式板卡和PC建立文件共享的方式;
10. 寻找和安装交叉编译环境,理解交叉编译;
11. 熟悉嵌入式板卡的Linux下的编程环境;
12. 了解远程访问嵌入式板卡图形桌面的方式。
二、 实验内容和原理
1. 在PC上安装好USB串口驱动和串口终端软件;
2. 按照图纸要求,将USB串口线与pcDuino连接好,并连接好以太网(如果打算采用WiFi,可不连接以太 网)。如有条件,接上HDMI线和HDMI显示器;
3. 给pcDuino上电,记录启动过程的输出;
4. 从终端登陆pcDuino的Linux,配置网络和/或WiFi,从pcDuino和PC两端证明网络已连接;
5. 配置pcDuino的SSH,可尝试采用各种不同的认证方式;
6. 从PC通过SSH登陆pcDuino;
7. 看到多个不同端口的登陆(本机键盘/屏幕、串口和SSH),并运用Linux的write来互相通信。
8. 配置嵌入式板卡上的SAMBA客户端,使它能访问PC上共享的目录;
9. 尝试各种与嵌入式板卡传递文件的方式并做比较:
10. 通过SAMBA共享;
11. 通过NFS共享(选做);
12. 通过sftp传递;
13. 通过串口XModem协议传递;
14. 通过Dropbox共享(选做)。
15. 选择和安装PC上的交叉编译环境;
16. 交叉编译C语言的浮点运算程序到pcDuino上去运行,证明所编译的程序是ARM的;
17. 尝试嵌入式板卡上的三个语言的开发环境:C/C++、Python和Java;
18. 尝试一种从PC远程访问嵌入式板卡图形桌面的方式:x-window(通过SSH)、RDP或VNC。
三、 实验过程和数据记录
1. 安装USB串口欲动和串口终端软件
a. 实验使用的USb串口线芯片为PL2303,从官网下载Mac对应的驱动。
b. 安装串口程序minicom,使用命令brew install minicom安装,minicom –s命令打开串口程序
Figure 1 minicom启动界面
2. 画出你所实际实施的连接示意图;
Figure 2 树莓派通过串口进行连接
3. 给出实际拍摄的板卡连接照片;
Figure 3 板卡连接照片
4. 给出所用的器材的列表;
a. RaspberryPi B+
b. MacOS
c. DVI显示器
d. 无线路由器一台
e. Micro-USB线
f. USB-TTL串口线
g. HDMI-DVI连接线
h. USB键盘
i. 5V电源(充电宝)
5. 给出拷贝得到的树莓派启动时的输出文字,并逐行解释;
Uncompressing Linux... done, booting the kernel. # 解压内核并且启动树莓派 [ 0.000000] Booting Linux on physical CPU 0xf00 # 树莓派启动CPU [ 0.000000] Initializing cgroup subsys cpu [ 0.000000] Initializing cgroup subsys cpuacct # 初始化cgroups子系统 [ 0.000000] Linux version 3.18.7-v7+ (dc4@dc4-XPS13-9333) (gcc version 4.8.3 20140303 (prerelease) (crosstool-NG linaro-1.13.1+bzr2650 - Linaro GCC 2014.03) ) #755 SMP PREEMPT Thu Feb 12 17:20:48 GMT 2015 # Linux内核版本号,以及交叉编译的访问,用户名和工具链等信息 [ 0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d # CPU型号:ARMv7 [ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache # 指令和cache类型 [ 0.000000] Machine model: Raspberry Pi 2 Model B # 树莓派型号:2代B [ 0.000000] cma: Reserved 8 MiB at 0x3a800000 [ 0.000000] Memory policy: Data cache writealloc # 数据cache策略为fetch on write [ 0.000000] [bcm2709_smp_init_cpus] enter (8620->f3003010) [ 0.000000] [bcm2709_smp_init_cpus] ncores=4 # CPU为4核 [ 0.000000] PERCPU: Embedded 11 pages/cpu @ba05d000 s12864 r8192 d24000 u45056 [ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 239776 [ 0.000000] Kernel command line: dma.dmachans=0x7f35 bcm2708_fb.fbwidth=592 bcm2708_fb.fbheight=448 bcm2709.boardrev=0xa21041 bcm2709.serial=0x3951248f smsc95xx.macaddr=B8:27:EB:51:24:8F 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 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait # 内核启动的某些参数,包括CPU、内存以及各个终端 [ 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: 940740K/966656K available (5785K kernel code, 377K rwdata, 1760K rodata, 396K init, 771K bss, 25916K reserved) # 占用内存报告 [ 0.000000] Virtual kernel memory layout: [ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB) [ 0.000000] fixmap : 0xffc00000 - 0xffe00000 (2048 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 - 0x80766748 (7546 kB) [ 0.000000] .init : 0x80767000 - 0x807ca000 ( 396 kB) [ 0.000000] .data : 0x807ca000 - 0x808287ec ( 378 kB) [ 0.000000] .bss : 0x808287ec - 0x808e96d4 ( 772 kB) # 内段地址分配 [ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1 [ 0.000000] Preemptible hierarchical RCU implementation. [ 0.000000] NR_IRQS:480 [ 0.000000] Architected cp15 timer(s) running at 19.20MHz (virt). # ARM的cp15处理器,管理cache等 [ 0.000015] sched_clock: 56 bits at 19MHz, resolution 52ns, wraps every 3579139424256ns [ 0.000039] Switching to timer-based delay loop, resolution 52ns [ 0.000340] Console: colour dummy device 80x30 [ 0.001767] console [tty1] enabled [ 0.001818] Calibrating delay loop (skipped), value calculated using timer frequency.. 38.40 BogoMIPS (lpj=192000) [ 0.001901] pid_max: default: 32768 minimum: 301 [ 0.002319] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes) [ 0.002380] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes) [ 0.003661] Initializing cgroup subsys memory [ 0.003747] Initializing cgroup subsys devices [ 0.003806] Initializing cgroup subsys freezer [ 0.003856] Initializing cgroup subsys net_cls [ 0.003920] Initializing cgroup subsys blkio # 初始化cgroups子系统,内存以及块设备等 [ 0.004033] CPU: Testing write buffer coherency: ok [ 0.004151] ftrace: allocating 19969 entries in 59 pages [ 0.053552] CPU0: update cpu_capacity 1024 [ 0.053633] CPU0: thread -1, cpu 0, socket 15, mpidr 80000f00 [ 0.053670] [bcm2709_smp_prepare_cpus] enter [ 0.053838] Setting up static identity map for 0x536c78 - 0x536cd0 [ 0.113528] [bcm2709_boot_secondary] cpu:1 started (0) 17 [ 0.113843] CPU1: Booted secondary processor [ 0.113851] [bcm2709_secondary_init] enter cpu:1 [ 0.113906] CPU1: update cpu_capacity 1024 [ 0.113915] CPU1: thread -1, cpu 1, socket 15, mpidr 80000f01 [ 0.133488] [bcm2709_boot_secondary] cpu:2 started (0) 18 [ 0.133738] CPU2: Booted secondary processor [ 0.133745] [bcm2709_secondary_init] enter cpu:2 [ 0.133775] CPU2: update cpu_capacity 1024 [ 0.133784] CPU2: thread -1, cpu 2, socket 15, mpidr 80000f02 [ 0.153550] [bcm2709_boot_secondary] cpu:3 started (0) 16 [ 0.153789] CPU3: Booted secondary processor [ 0.153796] [bcm2709_secondary_init] enter cpu:3 [ 0.153828] CPU3: update cpu_capacity 1024 [ 0.153837] CPU3: thread -1, cpu 3, socket 15, mpidr 80000f03 [ 0.153930] Brought up 4 CPUs [ 0.154051] SMP: Total of 4 processors activated (153.60 BogoMIPS). [ 0.154084] CPU: All CPU(s) started in SVC mode. [ 0.155091] devtmpfs: initialized [ 0.178144] VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5 [ 0.180314] pinctrl core: initialized pinctrl subsystem [ 0.183364] NET: Registered protocol family 16 [ 0.188987] DMA: preallocated 4096 KiB pool for atomic coherent allocations # DMA初始化 [ 0.213342] cpuidle: using governor ladder [ 0.243371] cpuidle: using governor menu [ 0.243767] bcm2709.uart_clock = 3000000 [ 0.246525] No ATAGs? [ 0.246588] hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers. [ 0.246643] hw-breakpoint: maximum watchpoint size is 8 bytes. [ 0.246706] mailbox: Broadcom VideoCore Mailbox driver [ 0.246836] bcm2708_vcio: mailbox at f300b880 [ 0.247217] bcm_power: Broadcom power driver [ 0.247261] bcm_power_open() -> 0 [ 0.247287] bcm_power_request(0, 8) [ 0.747990] bcm_mailbox_read -> 00000080, 0 [ 0.748022] bcm_power_request -> 0 [ 0.748178] Serial: AMBA PL011 UART driver [ 0.748340] dev:f1: ttyAMA0 at MMIO 0x3f201000 (irq = 83, base_baud = 0) is a PL011 rev3 [ 1.266655] console [ttyAMA0] enabled # 串口终端ttyAMA0 [ 1.336774] SCSI subsystem initialized # SCSI子系统 [ 1.340793] usbcore: registered new interface driver usbfs [ 1.346457] usbcore: registered new interface driver hub [ 1.351917] usbcore: registered new device driver usb [ 1.358863] Switched to clocksource arch_sys_counter [ 1.393698] FS-Cache: Loaded [ 1.396947] CacheFiles: Loaded [ 1.412382] NET: Registered protocol family 2 [ 1.418002] TCP established hash table entries: 8192 (order: 3, 32768 bytes) [ 1.425254] TCP bind hash table entries: 8192 (order: 4, 65536 bytes) [ 1.431955] TCP: Hash tables configured (established 8192 bind 8192) [ 1.438426] TCP: reno registered [ 1.441708] UDP hash table entries: 512 (order: 2, 16384 bytes) [ 1.447693] UDP-Lite hash table entries: 512 (order: 2, 16384 bytes) [ 1.454446] NET: Registered protocol family 1 [ 1.459296] RPC: Registered named UNIX socket transport module. [ 1.465237] RPC: Registered udp transport module. [ 1.470025] RPC: Registered tcp transport module. [ 1.474747] RPC: Registered tcp NFSv4.1 backchannel transport module. [ 1.482249] bcm2708_dma: DMA manager at f3007000 [ 1.487063] vc-mem: phys_addr:0x00000000 mem_base=0x3dc00000 mem_size:0x3f000000(1008 MiB) [ 1.497011] futex hash table entries: 1024 (order: 4, 65536 bytes) [ 1.503477] audit: initializing netlink subsys (disabled) [ 1.509001] audit: type=2000 audit(1.299:1): initialized [ 1.530605] VFS: Disk quotas dquot_6.5.2 [ 1.534920] Dquot-cache hash table entries: 1024 (order 0, 4096 bytes) [ 1.544594] FS-Cache: Netfs 'nfs' registered for caching [ 1.550974] NFS: Registering the id_resolver key type [ 1.556100] Key type id_resolver registered [ 1.560326] Key type id_legacy registered [ 1.565451] msgmni has been set to 1853 [ 1.571057] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252) [ 1.578672] io scheduler noop registered [ 1.582657] io scheduler deadline registered (default) [ 1.588132] io scheduler cfq registered [ 1.594657] BCM2708FB: allocated DMA memory fac00000 [ 1.599719] BCM2708FB: allocated DMA channel 0 @ f3007000 [ 1.611492] Console: switching to colour frame buffer device 74x28 [ 1.623887] bcm2708-dmaengine bcm2708-dmaengine: Load BCM2835 DMA engine driver [ 1.635022] uart-pl011 dev:f1: no DMA platform data [ 1.642231] vc-cma: Videocore CMA driver [ 1.647872] vc-cma: vc_cma_base = 0x00000000 [ 1.654274] vc-cma: vc_cma_size = 0x00000000 (0 MiB) [ 1.661320] vc-cma: vc_cma_initial = 0x00000000 (0 MiB) [ 1.680229] brd: module loaded [ 1.690979] loop: module loaded [ 1.695996] vchiq: vchiq_init_state: slot_zero = 0xba800000, is_master = 0 [ 1.706752] Loading iSCSI transport class v2.0-870. [ 1.714236] usbcore: registered new interface driver smsc95xx [ 1.721721] dwc_otg: version 3.00a 10-AUG-2012 (platform bus) [ 1.929486] Core Release: 2.80a [ 1.934234] Setting default values for core params [ 1.940697] Finished setting default values for core params [ 2.148293] Using Buffer DMA mode [ 2.153233] Periodic Transfer Interrupt Enhancement - disabled [ 2.160749] Multiprocessor Interrupt Enhancement - disabled [ 2.167992] OTG VER PARAM: 0, OTG VER FLAG: 0 [ 2.174057] Dedicated Tx FIFOs mode [ 2.179588] WARN::dwc_otg_hcd_init:1047: FIQ DMA bounce buffers: virt = 0xbac14000 dma = 0xfac14000 len=9024 [ 2.192805] FIQ FSM acceleration enabled for : [ 2.192805] Non-periodic Split Transactions [ 2.192805] Periodic Split Transactions [ 2.192805] High-Speed Isochronous Endpoints [ 2.216097] WARN::hcd_init_fiq:412: FIQ on core 1 at 0x803e4200 [ 2.223755] WARN::hcd_init_fiq:413: FIQ ASM at 0x803e455c length 36 [ 2.231744] WARN::hcd_init_fiq:438: MPHI regs_base at 0xbb806000 [ 2.239521] dwc_otg bcm2708_usb: DWC OTG Controller [ 2.246149] dwc_otg bcm2708_usb: new USB bus registered, assigned bus number 1 [ 2.256752] dwc_otg bcm2708_usb: irq 32, io mem 0x00000000 [ 2.264022] Init: Port Power? op_state=1 [ 2.269656] Init: Power Port (0) [ 2.274817] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002 [ 2.284986] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1 [ 2.295678] usb usb1: Product: DWC OTG Controller [ 2.302165] usb usb1: Manufacturer: Linux 3.18.7-v7+ dwc_otg_hcd [ 2.309968] usb usb1: SerialNumber: bcm2708_usb [ 2.317237] hub 1-0:1.0: USB hub found [ 2.322850] hub 1-0:1.0: 1 port detected [ 2.329467] usbcore: registered new interface driver usb-storage [ 2.337491] mousedev: PS/2 mouse device common for all mice [ 2.345556] bcm2835-cpufreq: min=600000 max=900000 [ 2.352514] sdhci: Secure Digital Host Controller Interface driver [ 2.360555] sdhci: Copyright(c) Pierre Ossman [ 2.366863] DMA channels allocated for the MMC driver [ 2.408901] Load BCM2835 MMC driver [ 2.416256] sdhci-pltfm: SDHCI platform and OF driver helper [ 2.424491] ledtrig-cpu: registered to indicate activity on CPUs [ 2.435913] hidraw: raw HID events driver (C) Jiri Kosina [ 2.443444] usbcore: registered new interface driver usbhid [ 2.451908] usbhid: USB HID core driver [ 2.460977] TCP: cubic registered [ 2.467145] Initializing XFRM netlink socket [ 2.473284] NET: Registered protocol family 17 [ 2.482951] Key type dns_resolver registered [ 2.489444] Registering SWP/SWPB emulation handler [ 2.496811] registered taskstats version 1 [ 2.502808] vc-sm: Videocore shared memory driver [ 2.509144] [vc_sm_connected_init]: start [ 2.515488] [vc_sm_connected_init]: end - returning 0 [ 2.518839] mmc0: host does not support reading read-only switch, assuming write-enable [ 2.523156] mmc0: new high speed SDHC card at address aaaa [ 2.523712] mmcblk0: mmc0:aaaa SU08G 7.40 GiB [ 2.534894] mmcblk0: p1 p2 [ 2.551240] Indeed it is in host mode hprt0 = 00021501 [ 2.577664] EXT4-fs (mmcblk0p2): INFO: recovery required on readonly filesystem [ 2.588922] EXT4-fs (mmcblk0p2): write access will be enabled during recovery [ 2.738998] usb 1-1: new high-speed USB device number 2 using dwc_otg [ 2.747444] Indeed it is in host mode hprt0 = 00001101 [ 2.949246] usb 1-1: New USB device found, idVendor=0424, idProduct=9514 [ 2.959557] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0 [ 2.971446] hub 1-1:1.0: USB hub found [ 2.977247] hub 1-1:1.0: 5 ports detected [ 3.258999] usb 1-1.1: new high-speed USB device number 3 using dwc_otg [ 3.379227] usb 1-1.1: New USB device found, idVendor=0424, idProduct=ec00 [ 3.390036] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0 [ 3.404349] smsc95xx v1.0.4 [ 3.472950] smsc95xx 1-1.1:1.0 eth0: register 'smsc95xx' at usb-bcm2708_usb-1.1, smsc95xx USB 2.0 Ethernet, b8:27:eb:51:24:8f [ 4.061742] EXT4-fs (mmcblk0p2): orphan cleanup on readonly fs [ 4.070169] EXT4-fs (mmcblk0p2): 5 orphan inodes deleted [ 4.077539] EXT4-fs (mmcblk0p2): recovery complete [ 4.113104] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null) [ 4.125163] VFS: Mounted root (ext4 filesystem) readonly on device 179:2. [ 4.137120] devtmpfs: mounted [ 4.142662] Freeing unused kernel memory: 396K (80767000 - 807ca000) [ 5.176112] udevd[174]: starting version 175 [ 7.436480] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null) [ 7.680789] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null) øø Raspbian GNU/Linux 7 raspberrypi ttyAMA0
raspberrypi login: pi Password: Last login: Thu Nov 26 14:27:29 UTC 2015 on tty1 Linux raspberrypi 3.18.7-v7+ #755 SMP PREEMPT Thu Feb 12 17:20:48 GMT 2015 armv7l |
6. 如何通过Linux获得硬件数据,截屏给出获得的硬件数据,如CPU型号、时钟频率、内存大小等;
可以通过cat /proc/cpinfo | grep name | cut –f2 –d: | uniq –c命令查看CPU型号
Figure 4 CPU info
可以使用cpufreq-into命令查看时钟频率
Figure 5 时钟频率信息
可以通过cat /proc/meminfo来查看树莓派内存大小
Figure 6 RAM info
7. 给出你的网络配置参数,截屏给出从pcDuino和PC两端得到的网络已连接的证明;
Figure 7 ifconfig
Figure 8 路由器客户端列表
Figure 9 PC端ping树莓派端
Figure 10 树莓派端ping PC端
8. 给出你的SSH配置文件,并解释其中内容;
以下是SSH配置文件:
# This is the ssh client system-wide configuration file. See # ssh_config(5) for more information. This file provides defaults for # users, and the values can be changed in per-user configuration files # or on the command line.
# Configuration data is parsed as follows: # 1. command line options # 2. user-specific file # 3. system-wide file # Any configuration value is only changed the first time it is set. # Thus, host-specific definitions should be at the beginning of the # configuration file, and defaults at the end.
# Site-wide defaults for some commonly used options. For a comprehensive # list of available options, their meanings and defaults, please see the # ssh_config(5) man page.
Host * # 声明只适用于与hostnames相匹配的主机。后面可以加通配符*,表示制定所有主机。 # ForwardAgent no # ForwardX11 no # 如果设置为yes,那么自动通过一条安全通道以不可信模式来转发X11连接,但是并不设置shell变量DISPLAY。如果ForwardX11Trusted也设置为yes,那么连接以可信模式转发。 # ForwardX11Trusted yes # 与前一配置一同使用时,ForwardX11必须设置为yes。 # RhostsRSAAuthentication no # RSAAuthentication yes # PasswordAuthentication yes # HostbasedAuthentication no # GSSAPIAuthentication no # GSSAPIDelegateCredentials no # GSSAPIKeyExchange no # GSSAPITrustDNS no # BatchMode no # CheckHostIP yes #设置为yes,那么出了用know_hosts文件中的主机名之外,还可以采用IP地址来识别远程系统。如果设置为no则只能使用主机名。 # AddressFamily any # ConnectTimeout 0 # StrictHostKeyChecking ask # 决定openSSH是否将主机密钥添加到用户的known_hosts文件中以及如何添加。设置为ask则表示在连接新系统时会询问是否添加主机密钥 # IdentityFile ~/.ssh/identity # IdentityFile ~/.ssh/id_rsa # IdentityFile ~/.ssh/id_dsa # Port 22 # 使openSSH通过22号端口与远程系统连接 # Protocol 2,1 # Cipher 3des # Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc # MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160 # EscapeChar ~ # Tunnel no # TunnelDevice any:any # PermitLocalCommand no # VisualHostKey no # ProxyCommand ssh -q -W %h:%p gateway.example.com SendEnv LANG LC_* HashKnownHosts yes # 当设置为yes时,OpenSSH会将文件~/.ssh/know_hosts中的主机名和地址进行散列。当设置为no时,主机名与地址将以明文形式写入。 GSSAPIAuthentication yes GSSAPIDelegateCredentials no |
9. 存在多个登陆时,如何看到不同端口的登陆,给出截屏结果;
通过三个端口登录(本机外接显示屏、串口和SSH登录),我们可以通过命令w来显示多端口登录的信息。
Figure 11 两个端口的登录信息
Figure 12 三个端口同时登录照片
我们可以使用write命令来完成不同端口之间的通信:
Figure 13 不同端口通过write命令通信
10. 给出嵌入式板卡上的SAMBA配置文件内容,并逐行解释;
以下是SAMBA配置文件内容:
# # Sample configuration file for the Samba suite for Debian GNU/Linux. # # # This is the main Samba configuration file. You should read the # smb.conf(5) manual page in order to understand the options listed # here. Samba has a huge number of configurable options most of which # are not shown in this example # # Some options that are often worth tuning have been included as # commented-out examples in this file. # - When such options are commented with ";", the proposed setting # differs from the default Samba behaviour # - When commented with "#", the proposed setting is the default # behaviour of Samba but the option is considered important # enough to be mentioned here # # NOTE: Whenever you modify this file you should run the command # "testparm" to check that you have not made any basic syntactic # errors. # A well-established practice is to name the original file # "smb.conf.master" and create the "real" config file with # testparm -s smb.conf.master >smb.conf # This minimizes the size of the really used smb.conf file # which, according to the Samba Team, impacts performance # However, use this with caution if your smb.conf file contains nested # "include" statements. See Debian bug #483187 for a case # where using a master file is not a good idea. #
#======================= Global Settings ======================= # 全局参数 [global]
## Browsing/Identification ###
# Change this to the workgroup/NT-domain name your Samba server will part of workgroup = WORKGROUP # 设定Samba Server所要加入的工作组或者域
# server string is the equivalent of the NT Description field server string = %h server # 设定Samba Server的注释,可以是任何字符串,也可以不填
# Windows Internet Name Serving Support Section: # WINS Support - Tells the NMBD component of Samba to enable its WINS Server # wins support = no
# WINS Server - Tells the NMBD components of Samba to be a WINS Client # Note: Samba can be either a WINS Server, or a WINS Client, but NOT both ; wins server = w.x.y.z
# This will prevent nmbd to search for NetBios names through DNS. dns proxy = no
# What naming service and in what order should we use to resolve host names # to IP addresses ; name resolve order = lmhosts host wins bcast
#### Networking ####
# The specific set of interfaces / networks to bind to # This can be either the interface name or an IP address/netmask; # interface names are normally preferred ; interfaces = 127.0.0.0/8 eth0 # 设置Samba Server监听哪些网卡,可以写网卡名,也可以写该网卡的IP地址
# Only bind to the named interfaces and/or networks; you must use the # 'interfaces' option above to use this. # It is recommended that you enable this feature if your Samba machine is # not protected by a firewall or is a firewall itself. However, this # option cannot handle dynamic or non-broadcast interfaces correctly. ; bind interfaces only = yes
#### Debugging/Accounting ####
# This tells Samba to use a separate log file for each machine # that connects log file = /var/log/samba/log.%m # 设置Samba Server日志文件的存储位置以及日志文件名称。在文件名后加个宏%m(主机名),表示对每台访问Samba Server的机器都单独记录一个日志文件。如果pc1、pc2访问过Samba Server,就会在/var/log/samba目录下留下log.pc1和log.pc2两个日志文件。
# Cap the size of the individual log files (in KiB). max log size = 1000 # 设置Samba Server日志文件的最大容量,单位为kB,0代表不限制。
# If you want Samba to only log through syslog then set the following # parameter to 'yes'. # syslog only = no
# We want Samba to log a minimum amount of information to syslog. Everything # should go to /var/log/samba/log.smbd,nmbd instead. If you want to log # through syslog you should set the following parameter to something higher. syslog = 0
# Do something sensible when Samba crashes: mail the admin a backtrace panic action = /usr/share/samba/panic-action %d
####### Authentication #######
# "security = user" is always a good idea. This will require a Unix account # in this server for every user accessing the server. See # /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/ServerType.html # in the samba-doc package for details. # security = user # 设置用户访问Samba Server的验证方式,user代表Samba Server共享目录只能被授权的用户访问,由Samba Server负责检查账号和密码的正确性。账号和密码要在Samba Server中建立。
# You may wish to use password encryption. See the section on # 'encrypt passwords' in the smb.conf(5) manpage before enabling. encrypt passwords = true # 是否将认证密码加密。因为现在windows操作系统都是使用加密密码,所以一般要开启此项。配置文件默认为开启。
# If you are using encrypted passwords, Samba will need to know what # password database type you are using. passdb backend = tdbsam
obey pam restrictions = yes
# This boolean parameter controls whether Samba attempts to sync the Unix # password with the SMB password when the encrypted SMB password in the # passdb is changed. unix password sync = yes
# For Unix password sync to work on a Debian GNU/Linux system, the following # parameters must be set (thanks to Ian Kahan <<kahan@informatik.tu-muenchen.de> for # sending the correct chat script for the passwd program in Debian Sarge). passwd program = /usr/bin/passwd %u passwd chat = *Enter\\snew\\s*\\spassword:* %n\\n *Retype\\snew\\s*\\spassword:* %n\\n *password\\supdated\\ssuccessfully* .
# This boolean controls whether PAM will be used for password changes # when requested by an SMB client instead of the program listed in # 'passwd program'. The default is 'no'. pam password change = yes
# This option controls how unsuccessful authentication attempts are mapped # to anonymous connections map to guest = bad user # 该选项表示不成功的验证尝试会被重定向到bad user界面
########## Domains ###########
# Is this machine able to authenticate users. Both PDC and BDC # must have this setting enabled. If you are the BDC you must # change the 'domain master' setting to no # ; domain logons = yes # # The following setting only takes effect if 'domain logons' is set # It specifies the location of the user's profile directory # from the client point of view) # The following required a [profiles] share to be setup on the # samba server (see below) ; logon path = \\\\%N\\profiles\\%U # Another common choice is storing the profile in the user's home directory # (this is Samba's default) # logon path = \\\\%N\\%U\\profile
# The following setting only takes effect if 'domain logons' is set # It specifies the location of a user's home directory (from the client # point of view) ; logon drive = H: # logon home = \\\\%N\\%U
# The following setting only takes effect if 'domain logons' is set # It specifies the script to run during logon. The script must be stored # in the [netlogon] share # NOTE: Must be store in 'DOS' file format convention ; logon script = logon.cmd
# This allows Unix users to be created on the domain controller via the SAMR # RPC pipe. The example command creates a user account with a disabled Unix # password; please adapt to your needs ; add user script = /usr/sbin/adduser --quiet --disabled-password --gecos "" %u
# This allows machine accounts to be created on the domain controller via the # SAMR RPC pipe. # The following assumes a "machines" group exists on the system ; add machine script = /usr/sbin/useradd -g machines -c "%u machine account" -d /var/lib/samba -s /bin/false %u
# This allows Unix groups to be created on the domain controller via the SAMR # RPC pipe. ; add group script = /usr/sbin/addgroup --force-badname %g
########## Printing ##########
# If you want to automatically load your printer list rather # than setting them up individually then you'll need this # load printers = yes
# lpr(ng) printing. You may wish to override the location of the # printcap file ; printing = bsd ; printcap name = /etc/printcap
# CUPS printing. See also the cupsaddsmb(8) manpage in the # cupsys-client package. ; printing = cups ; printcap name = cups
############ Misc ############
# Using the following line enables you to customise your configuration # on a per machine basis. The %m gets replaced with the netbios name # of the machine that is connecting ; include = /home/samba/etc/smb.conf.%m
# Most people will find that this option gives better performance. # See smb.conf(5) and /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/speed.html # for details # You may want to add the following on a Linux system: # SO_RCVBUF=8192 SO_SNDBUF=8192 # socket options = TCP_NODELAY
# The following parameter is useful only if you have the linpopup package # installed. The samba maintainer and the linpopup maintainer are # working to ease installation and configuration of linpopup and samba. ; message command = /bin/sh -c '/usr/bin/linpopup "%f" "%m" %s; rm %s' &
# Domain Master specifies Samba to be the Domain Master Browser. If this # machine will be configured as a BDC (a secondary logon server), you # must set this to 'no'; otherwise, the default behavior is recommended. # domain master = auto
# Some defaults for winbind (make sure you're not using the ranges # for something else.) ; idmap uid = 10000-20000 ; idmap gid = 10000-20000 ; template shell = /bin/bash
# The following was the default behaviour in sarge, # but samba upstream reverted the default because it might induce # performance issues in large organizations. # See Debian bug #368251 for some of the consequences of *not* # having this setting and smb.conf(5) for details. ; winbind enum groups = yes ; winbind enum users = yes
# Setup usershare options to enable non-root users to share folders # with the net usershare command.
# Maximum number of usershare. 0 (default) means that usershare is disabled. ; usershare max shares = 100 # 最大的分享用户的数目,0表示用户之间不能分享文件
# Allow users who've been granted usershare privileges to create # public shares, not just authenticated ones usershare allow guests = yes
#======================= Share Definitions =======================
[homes] comment = Home Directories # comment是对该共享的描述,可以是任意字符串 browseable = no
# By default, the home directories are exported read-only. Change the # next parameter to 'no' if you want to be able to write to them. read only = yes
# File creation mask is set to 0700 for security reasons. If you want to # create files with group=rw permissions, set next parameter to 0775. create mask = 0700
# Directory creation mask is set to 0700 for security reasons. If you want to # create dirs. with group=rw permissions, set next parameter to 0775. directory mask = 0700
# By default, \\\\server\\username shares can be connected to by anyone # with access to the samba server. # The following parameter makes sure that only "username" can connect # to \\\\server\\username # This might need tweaking when using external authentication schemes valid users = %S # 用来指定允许访问该共享资源的用户
# Un-comment the following and create the netlogon directory for Domain Logons # (you need to configure Samba to act as a domain controller too.) ;[netlogon] ; comment = Network Logon Service ; path = /home/samba/netlogon ; guest ok = yes ; read only = yes
# Un-comment the following and create the profiles directory to store # users profiles (see the "logon path" option above) # (you need to configure Samba to act as a domain controller too.) # The path below should be writable by all users so that their # profile directory may be created the first time they log on ;[profiles] ; comment = Users profiles ; path = /home/samba/profiles ; guest ok = no ; browseable = no ; create mask = 0600 ; directory mask = 0700
[printers] comment = All Printers browseable = no path = /var/spool/samba printable = yes guest ok = no read only = yes create mask = 0700
# Windows clients look for this share name as a source of downloadable # printer drivers [print$] comment = Printer Drivers path = /var/lib/samba/printers browseable = yes read only = yes guest ok = no # Uncomment to allow remote administration of Windows print drivers. # You may need to replace 'lpadmin' with the name of the group your # admin users are members of. # Please note that you also need to set appropriate Unix permissions # to the drivers directory for these users to have write rights in it ; write list = root, @lpadmin
# A sample share for sharing your CD-ROM with others. ;[cdrom] ; comment = Samba server's CD-ROM ; read only = yes ; locking = no ; path = /cdrom ; guest ok = yes
# The next two parameters show how to auto-mount a CD-ROM when the # cdrom share is accesed. For this to work /etc/fstab must contain # an entry like this: # # /dev/scd0 /cdrom iso9660 defaults,noauto,ro,user 0 0 # # The CD-ROM gets unmounted automatically after the connection to the # # If you don't want to use auto-mounting/unmounting make sure the CD # is mounted on /cdrom # ; preexec = /bin/mount /cdrom ; postexec = /bin/umount /cdrom
[home] comment = laowang's data # 对该共享的描述 path = /home # path用来指定共享目录的路径 valid users = pi # 有效的用户 public = no writable = yes # writable用来指定该共享路径是否可写。 printable = no create mask = 0777 |
11. 给出用各种方式传递文件的过程,并从易用性、速度、安全等方面做比较;
SAMBA方式
Mac启动Samba共享服务,需要到“系统偏好设置”中开启
Figure 14 系统设置中共享界面
在树莓派挂载后,便可正常读写,可以看到在树莓派端往Mac新建文件后,Mac就能够正常读取出来
树莓派上需要设置samba服务,编辑/etc/samba/smb.conf文件,在smbpasswd中添加用户名和密码,在Mac端输入smb://IP,即可读写树莓派的目录。
Figure15 Mac端登录树莓派目录
sFTP方式
下面演示在Mac端使用sftp方式向树莓派用户传输文件
使用命令
sftp root@192.168.1.104 root@192.168.1.104’s password Connected to 192.168.1.104 |
Figure 16 sftp传输文件
串口XModem方式
为了使用Xmodem协议,Mac上需要安装lrzxz软件包,并建立连接
brew install lrzxz |
ln –s lrx rx |
ln –s lsx sx |
在树莓派端输入sxfilename,并启用minicom菜单接受文件,即可成功传输文件。
Figure 17 使用minicom接收文件
三种传递方式的比较:
1. 就速度而言,samba最快,sftp辞职,xmodem最慢
2. 就传输介质而言,samba最便捷;sftp需要经过加密传输,速度会稍微慢一些,xmodem通过串口线传输数据,要求最高
3. 就安全性而言,通过串口直连,安全性都非常高。要是不通过串口相连,sftp安全性最高,因为通过加密传输。Samba和xmodem方式安全性能较低。
12. 给出你所选择的交叉编译环境的情况:来源、安装过程等
在Github下载编译完成的armGNU工具链,ARMx-2009q3-67.tar.bz2。
由于Mac默认的文件系统不是大小写敏感的,而源于linux的工具链大小写敏感,所以需要使用系统自带的硬盘工具建立空白映像,并将工具链解压于其中。
挂载后设置PATH变量后便可使用
export PATH=$PATH:/Volumes/arm/bin |
13. 给出交叉编译的程序的情况,并证明它是ARM/MIPS的可执行文件;
在PC端的C语言文件
经过编译之后,得到a.out文件,通过file命令检测,证明其为arm汇编可执行文件
将其通过scp命令拷贝到树莓派中
通过ssh登录树莓派,验证C语言程序交叉编译
14. 给出嵌入式板卡本机开发环境的情况,给出一或两种语言编程的例子和结果;
C在树莓派上的编译运行
Python在树莓派上的解释运行
Java在树莓派上的编译运行
15. 给出你尝试的远程图形桌面的方式:嵌入式板卡端的配置方法,PC端软件的获得,使用结果截屏等。
嵌入式板卡上直接使用sudo apt-get install tightvncserver安装VNC server。安装完成之后,使用tightvncserver启动VNC服务器,并且创建密码,如下图所示。
Figure 18 VNC server
PC端使用VNC viewer,可以在http://www.realvnc.com/download/get/1246/网址可以下载。
下载完成之后,打开如下界面
Figure 19 VNC Viewer
输入树莓派的IP地址与打开服务器的序号(默认为1),点击connect,之后输入之前在服务器端设置的密码,就可以打开图形化界面,如下图所示:
Figure 20 树莓派图形化桌面
四、 实验结果分析
实验结果即操作实现图,展示在第三部分实验过程中,故本部分内容略过。
五、 讨论与心得
本次实验难度较大。主要原因是之前对于嵌入式系统接触太少,导致对于配置文件的细节部分掌握的不够,理解出现问题。
通过本次实验,对嵌入式系统有了更深一步的了解,希望在以后的实验中能够越来越熟练的完成实验。
以上是关于认识RPi的主要内容,如果未能解决你的问题,请参考以下文章