树莓派 Zero w入手六小时

0.交叉编译

1. 官方 https://www.cnblogs.com/cursorhu/p/5760415.html

https://www.cnblogs.com/xieyajie/p/4699724.html

https://m.linuxidc.com/Linux/2010-03/25002.htm

https://www.cnblogs.com/ningci/p/10033940.html

2. 三方1https://github.com/abhiTronix/raspberry-pi-cross-compilers/wik

https://github.com/abhiTronix/raspberry-pi-cross-compilers/blob/master/docs/cross-gcc-buster.md#optimization-flags-involved

http://blog.chinaunix.net/uid-105044-id-2952235.html【echo "CFLAGS += -march=i486 -mtune=native" > configparms】

3. crosstool-ng

1. 调试

Raspberry Pi Zero W  调试有几个方式可选,usb接口、串口、wifi,因为开始调wifi不太顺利,所以最后选择了用usb。

这里文章推荐 一根数据线玩转树莓派Zero



1.1 烧录镜像

烧录这里推荐官方的烧录工具 Raspberry Pi Imager,去官方下载 ,镜像有三个版本,选择lite版本,听说zero烧普通版会比较卡。

1.2 修改调试设置

烧好镜像以后会出现一个boot分区,很多配置可以直接在这里改

step 1.

# 修改boot分区里的config.txt文件,在新一行增加如下内容dtoverlay=dwc2

# 修改boot分区里的cmdline.txt文件,在rootwait后面增加如下内容,注意每个参数之间空格分开,且都是在同一行modules-load=dwc2,g_ether

step 2.

在boot下建立ssh的空文件,开启ssh

然后开机上电

1.3 树莓派开机后

window 7 篇

windows会有等灯的声音,我的win7没有直接加载,需要加载驱动,驱动是win7自带的,需要通过设备管理器->更新驱动软件->网络适配器->在网络适配器窗口的制造商列表中选择微软公司(Microsoft Corporation),右侧列表中选择远端NDIS兼容设备。

可以看这篇文章,或者百度win7 RNDIS Gadget。

网卡有了以后推荐用putty连接raspberrypi.local,看之前文章既可以了,但是win7 要安装bonjour软件。

Ubuntu 16.04 篇

树莓派连上以后需要设置一下网卡,可以参考这篇,或者下图。

1.4 安装摄像头

1. 树莓派启动后,先运行"sudo raspi-config" 然后选择"Interfacing Options",在里面enable camera.

2.在/etc/modules文件最后加入一行"bcm2835-v4l2",保存退出,重启。

3. 重启后,可以用"vcgencmd get_camera"查看是不是识别到了摄像头。识别到的话,结果如下:

supported=1 detected=1。

1.5 推流

因为项目需要使用rtmp,发现基本绕不开ffmpeg,树莓派Zero编译是很慢的,网上要编译4个小时,而官方也对此进行了吐槽,并给出了详细的交叉编译文档。但是这里建议使用这个编译好的项目,直接安装(实际操作的时候其实按照这个文章先安装了x264,有没有用就不知道了),或者找个做好的docker,或者这两个项目0,1,2。

现成的还有这个,也就是这里和这里。

如果是摄像,参考这个文档 https://www.raspberrypi.org/documentation/usage/camera/raspicam/raspivid.md

1.6 配置wifi

写不动了,看这吧。

1.7 UART

uart还是要折腾一下的,先上两篇文档:

1. 官方说明

2. 针脚定义

2. 树莓派有两个串口,据说性能有差别,有需要可以交换串口

==>可以通过raspi-config(强烈建议)命令配置,或者手动配置

1. 串口的console禁用掉,在/boot/cmdline.txt,删掉删除线的部分:

dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1

root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes

rootwait

2. 在/boot/config.txt 中加入 enable_uart=1

==>编程推荐wiring pi :sudo apt-get install wiringpi 即可

1.8 ffmpeg

https://yq.aliyun.com/articles/367741

https://blog.csdn.net/zz531987464/article/details/100087755

udp  https://blog.csdn.net/big_wong/article/details/79240087

最后的命令

//raspivid -t 0 -w 1280 -h 720 -fps 20 -o - | nc -k -l 8090
raspivid -o - -t 0 -vf -hf -w 640 -h 480 -fps 25 -b 500000 | nc -k -l 8090

ffmpeg  -i tcp://127.0.0.1:8090 -vcodec copy -f h264 udp://127.0.0.1:8091 -vcodec copy -f h264 udp://127.0.0.1:8092

ffmpeg -re -i udp://127.0.0.1:8092 -vcodec copy -strict experimental -f flv rtmp://192.168.31.150:1935/live/10056496867160040390829

ffmpeg -re -i udp://127.0.0.1:8091 -vcodec copy -f segment -segment_time 5 -segment_format flv "/home/pi/file/%03d.flv"

试试用服务器

https://blog.csdn.net/luotong86/article/details/79113047

https://www.cnblogs.com/qiantuo1234/p/6611845.html

最新 apt 安装libnginx-mod-rtmp

https://aaronparecki.com/2020/09/07/7/raspberry-pi-streaming-server#:~:text=%20How%20to%20make%20an%20RTMP%20Streaming%20Server,boot%20it%20up%20it%20will%20take...%20More%20

踩坑:编译安装pcre ,编译安装openssl 1.1.0,apt 安装zlib


1.9 内核编译

https://blog.csdn.net/Groot_Lee/article/details/105333542

http://www.shumeipai.net/thread-20933-1-1.html

https://blog.csdn.net/wxh0000mm/article/details/88567468

加速

https://hub.fastgit.org/raspberrypi/linux

使用make bcm2709_defconfig 生成 .config 

部分编译 https://blog.csdn.net/liuxiao19890212/article/details/98766917?utm_medium=distribute.pc_relevant_bbs_down.none-task-blog-baidujs-1.nonecase&depth_1-utm_source=distribute.pc_relevant_bbs_down.none-task-blog-baidujs-1.nonecase

你可能感兴趣的:(树莓派 Zero w入手六小时)