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

本文详述了在macOS Sierra 10.12.6环境下配置Raspberry Pi Zero W的步骤,包括修改boot分区文件、通过USB连接电脑、配置网络连接文件以连接无线网络,并指导更换软件源以加速下载。

修改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 lo
iface lo inet loopback

iface eth0 inet manual

auto wlan0
iface 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 contrib
deb-src http://mirrors.aliyun.com/raspbian/raspbian/ wheezy main non-free contrib

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

3. 更新:

sudo apt-get update && apt-get upgrade -y
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值