1、树莓派刷机1
程序:Win32DiskImager
工具:SD储存卡转换USB插口
-
先打开程序,在把插上SD存储卡的USB插到电脑,等程序识别到了移动磁盘符后
-
选择树莓派系统固件包,等刷机完后把SD卡插到树莓派
2、树莓派登录2
- HDMI视频线 连接到显示器查看
- 串口登录查看
- 设备破解
- 默认情况,树莓派的串口和蓝牙是连接的
- 所以要想办法断开蓝牙连接,把串口用来数据通信
- 观看树莓派的启动过程,字符
- 通过串口登录树莓派
修改系统配置,启用串口登录树莓派
1.打开SD卡根目录的"config.txt"文件,将以下内容添加在最后并且保存。(文件所在位置请参考网线方案那篇文章)
dtoverlay=pi3-miniuart-bt
这样就停止了蓝牙,解除了对串口的占用。
也可以直接复制这段内容到"config.txt"文件
# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details
# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1
# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
#disable_overscan=1
# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16
# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720
# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1
# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1
# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2
# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4
# uncomment for composite PAL
#sdtv_mode=2
#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800
# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on
# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18
# Additional overlays and parameters are documented /boot/overlays/README
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2
[all]
#dtoverlay=vc4-fkms-v3d
dtoverlay=pi3-disable-bt
start_x=1
gpu_mem=128
2.然后再修改根目录的"cmdline.txt",将里面的内容全部替换成以下内容,以防万一,请先备份好这个文件的原内容。
dwc_otg.lpm_enable=0 console=tty1 console=serial0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
配置修改完成
树莓派的串口插线:
串口的T跟树莓派的R相连
R就跟树莓派的T相连
在连上GND
登录工具:SecureCRT
点击闪电图标
选Serial协议
端口要装串口驱动,然后选USB转串口通信
改波特率115200
配置好工作环境后,先插好串口USB,在插电源USB,等待开机
后输入账号密码
默认账号:pi
默认密码:raspberry
成功启动树莓派操作系统
SecureCRT报错处理3
3、通过网络登录
- 让树莓派入网4
- 修改配置文件
1、命令:
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
超级用户,用nano编辑器修改wpa_supplicant.conf网络的配置文件
在文件中添加无线网配置信息:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=CN
network={
ssid="你的无线网名字"
psk="密码"
key_mgmt=WPA-PSK #保密方式,可以不写
}
network={
ssid="你的其他无线网名字"
psk="密码"
key_mgmt=WPA-PSK
}
Nano是文档编辑器,一进入便可以编写
Ctrl+o 保存,会有提示是否写入。按回车确认。Ctrl+x退出
sudo reboot 重启串口登录的系统
ifconfig wlan0 查看网络IP
ipconfig 查看Windows的网络情况
ping IP 查看网络的连接情况
固定树莓派静态IP5
因为没有固定树莓派的IP地址,所以每次回随机分配
所以可以固定一下树莓派的IP地址
sudo nano /etc/rc.local
在退出之前写入这个
ifconfig wlan0 198.168.1.101(IP地址)
sudo reboot 重启系统 ifconfig 查看IP地址是否配置成功
4、用网络ssh方式登录树莓派
SSH服务配置方法:6
在命令行输入"sudo raspi-config",然后回车
选择"Interfacing Options",回车
选择"P2 SSH",回车
按方向键"←"键选择"YES",回车
再次回车,然后按Tab键选择"Finish"退出
可以通过"ps ax | grep sshd",查看是否有sshd进程
如果有,就说明服务已经起来,就可以连接了
用SecureCRT新建环境
协议选SSH2
配置主机IP地址
用户名
成功完成登录树莓派
5、升级VIM7
sudo apt-get install vim
当更新失败时
就是因为VI的更新源,系统配置的是国外的,所以要换成国内的
编辑sources.list
打开终端 输入
sudo nano /etc/apt/sources.list
用#注释或直接删除原有的内容,新增两条:
deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi
#deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi
ctrl+x 保存并退出
更新:
sudo apt-get update 更新源
sudo apt-get install vim 安装新版vim
6、远程图形界面登录
sudo apt-get install xrdp 下载升级xrdp
然后用windows的远程桌面连接登录
7、数据互传
FileZilla 用这个FTP来做文件互传
主机名:sftp://198.168.1.102
用户名:pi
密码:raspberry
登录成功,后面就可以互传数据