系统安装
下载系统zip:https://downloads.raspberrypi.org/raspbian_lite_latest
使用Etcher (https://resin-production-downloads.s3.amazonaws.com/etcher/1.0.0/Etcher-1.0.0-darwin-x64.dmg)将下载的系统zip写进TF卡中,写入完成后,重新将TF卡插入Mac,Mac会装载一个boot目录
此时,系统安装完成
如果要启动树莓派之前连接Wifi:
【连接Wifi】在boot目录下新建名为wpa_supplicant.conf的文件,并在其中添加如下代码
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB
network={
ssid="[wifi name]"
psk="[password]"
key_mgmt=WPA-PSK
priority=4
}
使用ssh登录树莓派:
【ssh登录】在boot目录下新建名为ssh的空文件
将TF卡插入树莓派,上电启动,等待2分钟之后,即可使用ssh登录系统
系统设置
修改原有密码
使用原有密码(raspberry)登录系统
passwd 命令修改为新登录密码
更新系统
使用 sudo apt update && sudo apt upgrade -y
安装Vim
sudo apt install vim
修改 /etc/vim/vimrc ,在最后添加一行 set nu! ,这样使用Vim时就会显示出行号
修改时区
使用 sudo tzselect 命令,按照向导选择时区
在 .profile 中新增 TZ='Asia/Shanghai'; export TZ 指定时区
安装一些必要的软件
sudo apt-get install pkg-config libpng12-0 libpng12-dev libpng++-dev libpng3 libpnglite-dev zlib1g-dbg zlib1g zlib1g-dev build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev python-dev python-numpy libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev libv4l-dev v4l2ucp v4l-utils
安装java-jdk8
sudo apt-get install oracle-java8-jdk
设置JAVA_HOME环境变量,在 .profile 中新增:
JAVA_HOME='/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt'
export JAVA_HOME
安装OpenCV
安装运行时库
sudo apt-get install pkg-config libpng12-0 libpng12-dev libpng++-dev libpng3 libpnglite-dev zlib1g-dbg zlib1g zlib1g-dev build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev python-dev python-numpy libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev libv4l-dev v4l2ucp v4l-utils
下载源码并编译
git clonehttps://github.com/opencv/opencv.git
cd opencv
git checkout -b 2.4.13.2 2.4.13.2
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON -D WITH_FFMPEG=OFF ..
make
sudo make install
在 .profile 中新增:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
sudo ldconfig /usr/local/lib
安装wiringPi
git clonegit://git.drogon.net/wiringPi
cd wiringPi
./build
test: gpio readall
打开通讯接口
sudo raspi-config
选择Interfaceing Options
设置自动挂载swapfile
sudo dd if=/dev/zero of=.swapfile bs=10240 count=100000
sudo mkswap .swapfile
在/etc/init.d下新建swapfile文件:
#! /bin/sh
### BEGIN INIT INFO
# Provides: swapfile
# Required-Start: $local_fs $remote_fs
# Required-Stop:
# X-Start-Before: rmnologin
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Provide limited super user privileges to specific users
# Description: Provide limited super user privileges to specific users.
### END INIT INFO
swapon /home/pi/.swapfile
sudo chmod 755 /etc/init.d/swapfile
cd /etc/rc3.d
sudo ln -s ../init.d/swapfile S01swapfile
安装TensorFlow
sudo apt-get install python-pip python-dev python-virtualenv
virtualenv --system-site-packages ~/tensorflow
source ~/tensorflow/bin/activate
export TF_BINARY_URL=https://github.com/samjabrahams/tensorflow-on-raspberry-pi/releases/download/v1.0.0/tensorflow-1.0.0-cp27-none-linux_armv7l.whl
pip install --upgrade $TF_BINARY_URL