您的位置:首页 > 编程语言 > ASP

Raspberry Pi B+ 实验

2015-12-01 10:43 621 查看
使用Raspberry Pi B+进行实验。

实验环境:

硬件:Raspberry Pi B+, Micro SD卡, 5V移动电源及其USB线, 网线

软件:Windows 10, Win32DiskImager, (Nmap)

1. 把镜像写入SD卡中

方法:https://www.raspberrypi.org/documentation/installation/installing-images/

下载系统镜像( https://www.raspberrypi.org/downloads/ ),并解压得到img镜像文件。

将SD卡连入电脑。

使用Win32DiskImager工具( http://sourceforge.net/projects/win32diskimager/ )把镜像写入SD卡中:

3.1 运行工具。

3.2 选择相应的img文件,在“Device”下选择SD的盘符。

3.3 选择“Write”,等待写入。完成后点确认即可。

2. 使用网线连接,并通过SSH访问Raspberry Pi

方法:https://www.raspberrypi.org/documentation/remote-access/ssh/README.md

由于没有额外显示器,而Raspberry Pi默认是启动SSH的,所以使用网线把Raspberry Pi连入电脑,再用PuTTY或VNC控制。

使用网线把Raspberry Pi和电脑连接起来。

获取Raspberry Pi的IP地址。

在命令行中输入
arp -a
,找到相应interface的相应IP地址(Raspberry Pi的物理地址一般都是“b8-”开头)。

官方方法:https://www.raspberrypi.org/documentation/troubleshooting/hardware/networking/ip-address.md

2.1 下载Nmap( https://nmap.org/download.html )并安装。

2.2 在命令行中输入
ipconfig /all
找到本机的IP地址。

2.3 假设本机的IP地址是
192.168.1.5
,那么在命令行中输入
nmap -sn 192.168.1.0/24
搜索Raspberry Pi的IP地址。

2.4 找到类似
Nmap scan report for raspberrypi (192.168.1.8)
的输出,其中的IP地址即为Raspberry Pi的IP地址。

打开PuTTY并输入Raspberry Pi的IP地址,连接。

输入Raspberry Pi中OS的用户名(默认为
pi
)和密码(默认为
raspberry
)。

3. raspi-config

在SSH下需要手动输入
sudo raspi-config
来进行设置。

可以选择第1项“Expand Filesystem”。

4. 使用网线连接,并通过VNC访问Raspberry Pi

方法:https://www.raspberrypi.org/documentation/remote-access/vnc/README.md

注意:Raspbian Jessie Lite没有X,需要自行安装。

sudo apt-get install lightdm
#sudo apt-get install xorg lxde
sudo apt-get install xfce


部份软件:

http://blog.kurrunk.com/post/401.html

https://wiki.archlinux.org/index.php/List_of_applications

使用SSH或显示器连接Raspberry Pi,并在终端中输入:
sudo apt-get install tightvncserver
。(记得把网络共享给以太网连接,以保证可以上网下载apt。)

运行tightvncserver,它会让你输入密码。

You will require a password to access your desktops.

Would you like to enter a view-only password (y/n)? n
xauth:  file /home/pi/.Xauthority does not exist

New 'X' desktop is raspberrypi:1

Creating default startup script /home/pi/.vnc/xstartup
Starting applications specified in /home/pi/.vnc/xstartup
Log file is /home/pi/.vnc/raspberrypi:1.log


启动vncserver,并指定分辨率:
vncserver :1 -geometry 1366x768 -depth 24


在PC机上启动VNC软件,如RealVNC, tightvnc view,输入密码即可。

5. 使用网线连接,并通过xrdp访问Raspberry Pi

如果要使用Microsoft Remote Desktop,则需要在Raspberry Pi上安装xrdp:
sudo apt-get install xrdp
,再启动Microsoft Remote Desktop,输入用户名及密码即可。

6. 使用无线网卡连接

确认无线网卡芯片是否在支持列表里( http://elinux.org/RPi_USB_Wi-Fi_Adapters )。

插入无线网卡,输入
sudo lsusb
即可看到所有挂载的USB设备,查看无线网卡是否检测成功。

输入
sudo iwlist wlan0 scan
获取周围的无线网络信息。

编辑网络配置文件,输入
sudo nano /etc/network/interfaces
,把

allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf


改成

allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-ssid 你要连接的wifi的ESSID
wpa-psk 你要连接的wifi的密码


输入
sudo reboot
重启。

之后参考上文用网线连接的方法连接Raspberry Pi即可。输入
iwconfig
可以看到wlan0中的AP信息,若无AP信息即说明没有连接上AP。

7. 固定IP

有线IP固定

编辑网络配置文件,输入
sudo nano /etc/network/interfaces
,把

auto eth0
allow-hotplug eth0
iface eth0 inet dhcp


改成

auto eth0
allow-hotplug eth0
iface eth0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8
dns-search 8.8.4.4


其中的IP,网关等按实际情况修改。

无线IP固定

编辑网络配置文件,输入
sudo nano /etc/network/interfaces
,把

auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-ssid TP-LINK_123456
wpa-psk 1234567890


改成

auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.137.2
netmask 255.255.255.0
gateway 192.168.137.1
wpa-ssid TP-LINK_123456
wpa-psk 1234567890


其中的IP,网关等按实际情况修改。

为了使Raspberry Pi不会自动装无线关掉,可在
/etc/network/interfaces


加上一行

wireless-power off


并修改
/etc/kbd/config
,将
BLANK_TIME=
改成
BLANK_TIME=0
POWERDOWN_TIME=
改成
POWERDOWN_TIME=0


8. 无线上网卡配置

安装usb_modeswitch。

sudo apt-get install usb-modeswitch usb-modeswitch-data


不同的无线上网卡配置的内容不一样。对于华为E3372,配置
/etc/usb_modeswitch.conf
,在最后加上

EnableLogging=0
DefaultVendor=0x12d1
DefaultProduct=0x1f01

TargetVendor=0x12d1
TargetProduct=0x14dc

MessageContent="55534243123456780000000000000a11062000000000000100000000000000"
NoDriverLoading=1


然后输入命令
sudo usb_modeswitch -W -c /etc/usb_modeswitch.conf -I


将无线上网卡拔下,重启Raspberry Pi,再将无线上网卡插上。

修改
/etc/network/interfaces
,加入

auto eht1
allow-hotplug eth1
iface eth1 inet dhcp


输入
sudo reboot
重启。

参考

https://www.raspberrypi.org

http://my.oschina.net/quanpower/blog/221920?fromerr=UueIXg7F

https://wiki.archlinux.org/index.php/List_of_applications

http://blog.kurrunk.com/post/401.html

https://sites.google.com/site/raspberypishare0918/home/di-yi-ci-qi-dong/1-6-you-xian-huo-wu-xian-dedhcp
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: