树莓派版本:2018-04-18-raspbian-stretch-lite
1、安装vim
sudo apt-get install vim
2、更换软件源:
sudo vim /etc/apt/sources.list
全部替换成:
deb https://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi
注意版本,2017年9月以后的使用stretch
之前的请使用jessie
更新软件源
sudo apt-get update
sudo apt-get upgrade
3、添加wifi和固定IP
sudo vim /etc/wpa_supplicant/wpa_supplicant.conf
在尾部添加wifi账号和密码
network={
ssid="zhongyi"
psk="63120760"
}
sudo vim /etc/dhcpcd.conf
修改:
#interface eth0
#static ip_address=192.168.1.23/24
#static routers=192.168.1.1
#static domain_name_servers=192.168.1.1
变为
interface eth0
static ip_address=192.168.137.90/24
static routers=192.168.137.1
static domain_name_servers=202.96.209.133
开启路由器转发
sudo vim /etc/sysctl.d/40-ip-forward.conf
net.ipv4.ip_forward=1
echo 1 > /proc/sys/net/ipv4/ip_forward
4、修改时区
sudo raspi-config
选择Localisation Options -> Change Timezone -> Asia -> Shanghai
5、PIP安装,升级
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
python -m pip install --upgrade pip
6、开启SPI
sudo raspi-config
Interfacing Opetions -> SPI
顺便把python 的spi驱动还有GPS解析库也装上
sudo apt-get install python-dev
sudo pip install spidev
sudo pip install pynmea2
7、关闭蓝牙,打开TTL串口:
安装minicom
sudo apt-get install minicom
sudo pip install pyserial
sudo pip install pycrypto
关闭板载蓝牙
sudo systemctl disable hciuart
编辑config.txt
sudo vim /boot/config.txt
添加下两行
dtoverlay=pi3-miniuart-bt
force_turbo=1
修改cmdline.txt
sudo vim /boot/cmdline.txt
将:
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
修改成:
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
8、移除USBMODESELCET(使设备可以识别ME909S)
sudo apt-get remove usb-modeswitch usb-modeswitch-data
9、安装teamviewer
sudo raspi-config
->Boot Options
–> Desktop / CLI
–> Console AutoLogin
teamviewer连接后全屏:
sudo vim /boot/config.txt
hdmi_group=2
hdmi_mode=82
hdmi_ignore_edid=0xa5000080
hdmi_mode=82
指1080P的分辨率,重启树莓派,teamviewer连接生效。
下载,安装,配置teamview:
wget http://download.teamviewer.com/download/linux/version_13x/teamviewer-host_armhf.deb
sudo apt-get install gdebi
sudo dpkg -i teamviewer-host_armhf.deb
sudo apt-get -f install
sudo dpkg -i teamviewer-host_armhf.deb
sudo teamviewer license accept
sudo teamviewer setup
如果需要登录,直接Ctrl+c掉
10、安装django
sudo pip install django==1.11.13
sudo pip install django-bootstrap3
11、安装AES库
sudo pip install Crypto
12、安装 requests
sudo pip install requests
13、开启看门狗
sudo modprobe bcm2835_wdt
sudo apt-get install watchdog
sudo update-rc.d watchdog defaults
编辑看门狗配置
sudo vim /etc/watchdog.conf
去掉watchdog-device = /dev/watchdog前面的#号
watchdog-device = /dev/watchdog
14、开启DHCP
sudo apt-get install isc-dhcp-server
修改/etc/default/isc-dhcp-server
sudo vim /etc/default/isc-dhcp-server
INTERFACESv4="eth0"
保存并退出
sudo vim /etc/dhcp/dhcpd.conf
在最后添加
subnet 192.168.137.0 netmask 255.255.255.0 {
range 192.168.137.100 192.168.137.255;
option domain-name-servers 202.96.209.133;
option domain-name "pi4G";
option routers 192.168.137.1;
option broadcast-address 192.168.137.255;
default-lease-time 600;
max-lease-time 7200;
}
参照第三条,再把本机地址改为192.168.137.1
sudo service isc-dhcp-server start
15、将树莓派本身wifi作为无线热点
#将代码copy到本地,安装
git clone https://github.com/oblique/create_ap
cd create_ap
make install
#安装依赖的库
apt-get install util-linux procps hostapd iproute2 iw haveged dnsmasq
#创建WiFi热点(GitHub上有多种方式创建,可以查找自己需要的那种)
此时需要让wifi处于无连接的状态,创建热点
sudo create_ap wlan0 eth0 zhongyi_pi 63120760
编辑配置文件:
sudo vim /etc/create_ap.conf
将GATEWAY=XXX改成,WIFI名和密码也在这个文件里面,自己调节:
GATEWAY=192.168.12.1
开机自启动
sudo systemctl enable create_ap
16、 绑定设备串口
dmesg
sudo vim /etc/udev/rules.d/60-USBSerial.rules
写入:
ACTION=="add",SUBSYSTEMS=="usb",DRIVERS=="cp210x",SYMLINK+="bluetooth"
ACTION=="add",SUBSYSTEMS=="usb",ATTRS{interface}=="Huawei Mobile Connect - Modem",SYMLINK+="modem"
17、备份系统方便批量生产
安装必要备份工具
sudo apt-get install dosfstools
sudo apt-get install dump
sudo apt-get install parted
sudo apt-get install kpartx
sudo apt-get install exfat-fuse
插上U盘,执行脚本
sudo mount -o uid=pi,gid=pi /dev/sda1 /mnt
cd /mnt
chmod 777 pack_dev.sh
sudo nohup ./pack_dev.sh &
备份脚本私信问我