初始配置RaspberryPi Zero W(macOS Sierra 10.12.6环境下)

来源:互联网 发布:孔子学院的数据 编辑:程序博客网 时间:2024/05/29 18:08

修改boot盘下文件

使用USB Gadget驱动将USB-OTG模拟为有线网卡:
1. 修改boot分区里的config.txt文件,在新一行添加:

dtoverlay=dwc2

2. 修改boot分区里的cmdline.txt文件,在rootwait后添加:

modules-load=dwc2,g_ether

注意添加内容前后需要有空格。

连接电脑

先接通电源,然后使用USB连接电脑,利用SSH登录树莓派,初始密码为raspberry:

ssh pi@raspberrypi.local

如果出现Host key verification failed. 的错误,只要清除已存的公钥信息就可以:

ssh-keygen -R raspberrypi.local

配置网络连接文件

1. 更改interfaces文件:

sudo nano /etc/network/interfaces

在文件中更改:

auto loiface lo inet loopbackiface eth0 inet manualauto wlan0iface wlan0 inet dhcp    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

2. 更改wpa_supplicant.conf文件:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

在文件最后添加:

network={    ssid="YourAP"    key_mgmt=WPA-PSK    psk="YourPassword"    priority=5}network={    ssid="YourAP"    key_mgmt=NONE    priority=4}

其中priority为优先级,数字大的优先级较高

连接无线网络

1. 输入以下命令(用于连接无密码的Wi-Fi网络):

sudo iwconfig wlan0 essid "YourAP"

使用iwconfig wlan0命令查看连接状态。

2. 完成后重启网络:

sudo /etc/init.d/networking restart

重启网络后可以ping下其他网络看是否连接成功。

更换源

1. 打开sources.list文件:

sudo nano /etc/apt/sources.list

2. 加入阿里源(可选择其他国内源):

deb http://mirrors.aliyun.com/raspbian/raspbian/ wheezy main non-free contribdeb-src http://mirrors.aliyun.com/raspbian/raspbian/ wheezy main non-free contribdeb http://mirrors.aliyun.com/raspbian/raspbian/ jessie main non-free contribdeb-src http://mirrors.aliyun.com/raspbian/raspbian/ jessie main non-free contrib

3. 更新:

sudo apt-get update && apt-get upgrade -y
原创粉丝点击