Raspberry
(→Reference) |
(→Kernel 编译) |
||
| (未显示1个用户的38个中间版本) | |||
| 第2行: | 第2行: | ||
最大 TF 卡: https://elinux.org/RPi_SD_cards | 最大 TF 卡: https://elinux.org/RPi_SD_cards | ||
| + | |||
| + | http://www.waveshare.net/wiki/1.54inch_e-Paper_Module | ||
| + | |||
| + | http://www.waveshare.net/wiki/1.54inch_e-Paper_Module_(C) | ||
<br><br> | <br><br> | ||
| 第11行: | 第15行: | ||
Password: raspberry | Password: raspberry | ||
</source> | </source> | ||
| + | |||
| + | |||
| + | ;;开启 root 登录: | ||
| + | |||
| + | <source lang=bash> | ||
| + | sudo passwd root | ||
| + | sudo passwd --unlock root | ||
| + | </source> | ||
| + | |||
| + | 设置SSH: | ||
| + | |||
| + | sudo vi /etc/ssh/sshd_config | ||
| + | |||
| + | 将其中的PermitRootLogin without-password改为PermitRootLogin yes,然后重启ssh服务sudo service ssh restart | ||
| + | |||
| + | <br> | ||
| + | |||
| + | == 大端 or 小端 == | ||
| + | |||
| + | <source lang=python> | ||
| + | root@tesla:~# python3 | ||
| + | Python 3.4.2 (default, Oct 19 2014, 13:31:11) | ||
| + | [GCC 4.9.1] on linux | ||
| + | Type "help", "copyright", "credits" or "license" for more information. | ||
| + | >>> import sys | ||
| + | >>> print(sys.byteorder) | ||
| + | little | ||
| + | </source> | ||
| + | |||
| + | <source lang=bash> | ||
| + | $ echo -n I | od -to2 | head -n1 | awk '{print $2}' | cut -c6 | ||
| + | # 1 则表示小端,0 表示大端 | ||
| + | </source> | ||
| + | |||
| + | <br> | ||
| + | |||
| + | == Kernel 编译 == | ||
| + | |||
| + | 获取 kernel code: https://github.com/raspberrypi/linux | ||
| + | |||
| + | 根据您当前系统的内核版本选 branch,比如此 Raspberry 3 model B 的内核版本为 linux 4.4.13,则选 rpi-4.4.y,然后点 code -> Local -> HTTPS -> Download ZIP: | ||
| + | <source lang=bash> | ||
| + | $ cat /proc/version | ||
| + | Linux version 4.4.13-v7+ (dc4@dc4-XPS13-9333) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611) ) #894 SMP Mon Jun 13 13:13:27 BST 2016 | ||
| + | $ cat /proc/cpuinfo | ||
| + | processor : 0 | ||
| + | model name : ARMv7 Processor rev 4 (v7l) | ||
| + | BogoMIPS : 38.40 | ||
| + | Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 | ||
| + | CPU implementer : 0x41 | ||
| + | CPU architecture: 7 | ||
| + | CPU variant : 0x0 | ||
| + | CPU part : 0xd03 | ||
| + | CPU revision : 4 | ||
| + | |||
| + | processor : 1 | ||
| + | model name : ARMv7 Processor rev 4 (v7l) | ||
| + | BogoMIPS : 38.40 | ||
| + | Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 | ||
| + | CPU implementer : 0x41 | ||
| + | CPU architecture: 7 | ||
| + | CPU variant : 0x0 | ||
| + | CPU part : 0xd03 | ||
| + | CPU revision : 4 | ||
| + | |||
| + | processor : 2 | ||
| + | model name : ARMv7 Processor rev 4 (v7l) | ||
| + | BogoMIPS : 38.40 | ||
| + | Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 | ||
| + | CPU implementer : 0x41 | ||
| + | CPU architecture: 7 | ||
| + | CPU variant : 0x0 | ||
| + | CPU part : 0xd03 | ||
| + | CPU revision : 4 | ||
| + | |||
| + | processor : 3 | ||
| + | model name : ARMv7 Processor rev 4 (v7l) | ||
| + | BogoMIPS : 38.40 | ||
| + | Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 | ||
| + | CPU implementer : 0x41 | ||
| + | CPU architecture: 7 | ||
| + | CPU variant : 0x0 | ||
| + | CPU part : 0xd03 | ||
| + | CPU revision : 4 | ||
| + | |||
| + | Hardware : BCM2709 | ||
| + | Revision : a22082 | ||
| + | Serial : 0000000036ac63be | ||
| + | |||
| + | # Raspberry 3 model B 主 SoC 为 BCM2837 芯片,支持硬浮点 (vfp) | ||
| + | </source> | ||
| + | |||
| + | 解压后,为目录 linux-rpi-4.4.y | ||
| + | |||
| + | ;;Toolchain: | ||
| + | https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads 选 AArch32 GNU/Linux target with hard float (arm-none-linux-gnueabihf) | ||
| + | |||
| + | |||
| + | ;; Build: | ||
| + | |||
| + | <source lang=bash> | ||
| + | $ cd linux-rpi-4.4.y/ | ||
| + | $ export PATH=$PATH:/path/to/toolchain/bin | ||
| + | $ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- bcm2709_defconfig # 生成 .config | ||
| + | $ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- zImage -j8 | ||
| + | |||
| + | $ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- dtbs | ||
| + | $ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- M=drivers/your/drv/ modules | ||
| + | </source> | ||
| + | |||
| + | gcc 版本过高可能出错: | ||
| + | <source lang=bash> | ||
| + | HOSTLD scripts/dtc/dtc | ||
| + | /usr/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x10): multiple definition of `yylloc'; scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here | ||
| + | collect2: error: ld returned 1 exit status | ||
| + | </source> | ||
| + | |||
| + | 编辑 vim scripts/dtc/dtc-lexer.lex.c,找到 ”YYLTYPE yylloc;“ 加上 extern:"extern YYLTYPE yylloc;" 即可 | ||
| + | |||
| + | |||
| + | ;; 部署 | ||
| + | |||
| + | bootloader 加载内核优先顺序: | ||
| + | * config.txt 中的 kernel = xxxx | ||
| + | * kernel8.img kernel8-32.img (armv8-aarch64, armv8-aarch32) | ||
| + | * kernel7.img (armv7) | ||
| + | * kernel.img (old version) | ||
<br> | <br> | ||
| 第30行: | 第161行: | ||
=== Models A+, B+, PI 2 B, PI 3 B === | === Models A+, B+, PI 2 B, PI 3 B === | ||
| − | [[文件:Gpio- | + | [[文件:Gpio-readall.JPG]] |
| − | |||
| − | [[文件: | + | [[文件:Raspberry-pi-pinout.png | 900px]] |
| + | [[文件:Rp23 pinout.png]] | ||
| − | [[文件: | + | |
| + | [[文件:Gpio-pins-pi2.jpg | 800px]] | ||
| + | |||
| + | [[文件:Gpio-numbers-pi2.png | 800px]] | ||
| + | |||
| + | [[文件:Physical-pin-numbers.png | 800px]] | ||
<br><br> | <br><br> | ||
| 第81行: | 第217行: | ||
* https://makezine.com/projects/tutorial-raspberry-pi-gpio-pins-and-python/ | * https://makezine.com/projects/tutorial-raspberry-pi-gpio-pins-and-python/ | ||
| + | |||
| + | * [https://zhuanlan.zhihu.com/p/40594358 树莓派的GPIO控制] | ||
| + | |||
| + | * [http://webiopi.trouch.com/ WebIOPi] [[WebIOPi]] | ||
| + | |||
| + | * [https://www.cnblogs.com/wangkangluo1/archive/2013/03/17/2964080.html 树莓派实现web控制GPIO教程] | ||
<br><br> | <br><br> | ||
| 第134行: | 第276行: | ||
$ sudo apt-get install hostapd dnsmasq | $ sudo apt-get install hostapd dnsmasq | ||
| + | |||
| + | <br> | ||
| + | |||
| + | == WiFi == | ||
| + | |||
| + | “Wlan0: Not associated”报错解决: | ||
| + | |||
| + | 如下命令 OK,则网卡驱动 OK: | ||
| + | |||
| + | <source lang=bash> | ||
| + | $ ifconfig wlan0 | ||
| + | $ ifconfig wlan0 up | ||
| + | $ iwlist wlan0 scan | grep SSID | ||
| + | </source> | ||
| + | |||
| + | 只需修改网络配置即可,增加一条网络凭条: | ||
| + | |||
| + | <source lang=bash> | ||
| + | $ wpa_passphrase YOUR_ssid YOUR_password >> /etc/wpa_supplicant/wpa_supplicant.conf | ||
| + | |||
| + | network={ | ||
| + | ssid="ssid" | ||
| + | #psk="password" | ||
| + | psk=44116ea881531996d8a23af58b376d70f196057429c258f529577a26e727ec1b | ||
| + | } | ||
| + | |||
| + | 要使配置生效,则需要重启 wpa_supplicant: | ||
| + | |||
| + | <source lang=bash> | ||
| + | $ killall wpa_supplicant | ||
| + | $ wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf | ||
| + | |||
| + | 或者: | ||
| + | |||
| + | $ sudo ifup wlan0 | ||
| + | </source> | ||
| + | |||
| + | 开机无法自动连 WiFi 则确认 /etc/network/interfaces 和 /etc/dhcpcd.conf: | ||
| + | |||
| + | <source lang=bash> | ||
| + | allow-hotplug wlan0 | ||
| + | iface wlan0 inet dhcp | ||
| + | wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf | ||
| + | </source> | ||
| + | |||
| + | 和 /etc/dhcpcd.conf: | ||
| + | |||
| + | <source lang=bash> | ||
| + | interface wlan0 | ||
| + | static routers=192.168.1.1 255.255.255.0 | ||
| + | static domain_name_servers=192.168.1.1 | ||
| + | </source> | ||
| + | |||
| + | * https://shumeipai.nxez.com/2016/09/17/raspberry-pi-set-up-a-wireless-internet-access.html | ||
| + | * https://www.cnblogs.com/lfri/p/11875527.html | ||
<br> | <br> | ||
| 第232行: | 第429行: | ||
=== Notes === | === Notes === | ||
| − | |||
;;Write image into SD card: | ;;Write image into SD card: | ||
| 第263行: | 第459行: | ||
sudo losetup -d /dev/loop0 | sudo losetup -d /dev/loop0 | ||
</source> | </source> | ||
| − | |||
| − | |||
<br> | <br> | ||
| 第324行: | 第518行: | ||
<br><br> | <br><br> | ||
| + | |||
| + | == config.txt == | ||
| + | |||
| + | * https://www.raspberrypi.org/documentation/configuration/config-txt/README.md | ||
| + | * https://www.raspberrypi.org/documentation/configuration/config-txt/video.md | ||
| + | |||
| + | <br> | ||
| + | |||
| + | == Offical 7' touchscreen == | ||
| + | |||
| + | * https://maker-tutorials.com/en/official-raspberry-pi-7-touch-screen-lcd-display-assembly-guide-install-and-tips/ | ||
| + | |||
| + | <br> | ||
| + | |||
| + | == Chromium Fullscreen == | ||
| + | |||
| + | /usr/bin/chromium-browser --profile-directory=Default --app-id=dbnedbfkgoaehilakknipiknpolnbapd --start-fullscreen | ||
| + | |||
| + | <br> | ||
| + | |||
| + | == Preempt-RT == | ||
| + | |||
| + | * [http://www.frank-durr.de/?p=203 Raspberry Pi Going Realtime with RT Preempt] | ||
| + | * [http://www.machinekit.io/docs/getting-started/install-rt-kernel-RPi2/ RT-PREEMPT realtime kernel (Raspberry Pi)] | ||
| + | * [https://www.raspberrypi.org/forums/viewtopic.php?t=39951 CONFIG_PREEMPT_RT on Raspberry Pi] | ||
| + | |||
| + | <br> | ||
== Reference == | == Reference == | ||
| 第333行: | 第554行: | ||
* [https://blog.csdn.net/robertsong2004/article/details/38532069 用QEMU模拟树莓派的方法] | * [https://blog.csdn.net/robertsong2004/article/details/38532069 用QEMU模拟树莓派的方法] | ||
| − | + | <br><br> | |
| − | + | ||
2025年12月12日 (五) 15:35的最后版本
目录 |
[编辑] 1 Overview
最大 TF 卡: https://elinux.org/RPi_SD_cards
http://www.waveshare.net/wiki/1.54inch_e-Paper_Module
http://www.waveshare.net/wiki/1.54inch_e-Paper_Module_(C)
[编辑] 2 Login
Username: pi Password: raspberry
- 开启 root 登录:
sudo passwd root sudo passwd --unlock root
设置SSH:
sudo vi /etc/ssh/sshd_config
将其中的PermitRootLogin without-password改为PermitRootLogin yes,然后重启ssh服务sudo service ssh restart
[编辑] 3 大端 or 小端
root@tesla:~# python3 Python 3.4.2 (default, Oct 19 2014, 13:31:11) [GCC 4.9.1] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> print(sys.byteorder) little
$ echo -n I | od -to2 | head -n1 | awk '{print $2}' | cut -c6
# 1 则表示小端,0 表示大端
[编辑] 4 Kernel 编译
获取 kernel code: https://github.com/raspberrypi/linux
根据您当前系统的内核版本选 branch,比如此 Raspberry 3 model B 的内核版本为 linux 4.4.13,则选 rpi-4.4.y,然后点 code -> Local -> HTTPS -> Download ZIP:
$ cat /proc/version Linux version 4.4.13-v7+ (dc4@dc4-XPS13-9333) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611) ) #894 SMP Mon Jun 13 13:13:27 BST 2016 $ cat /proc/cpuinfo processor : 0 model name : ARMv7 Processor rev 4 (v7l) BogoMIPS : 38.40 Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x0 CPU part : 0xd03 CPU revision : 4 processor : 1 model name : ARMv7 Processor rev 4 (v7l) BogoMIPS : 38.40 Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x0 CPU part : 0xd03 CPU revision : 4 processor : 2 model name : ARMv7 Processor rev 4 (v7l) BogoMIPS : 38.40 Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x0 CPU part : 0xd03 CPU revision : 4 processor : 3 model name : ARMv7 Processor rev 4 (v7l) BogoMIPS : 38.40 Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x0 CPU part : 0xd03 CPU revision : 4 Hardware : BCM2709 Revision : a22082 Serial : 0000000036ac63be # Raspberry 3 model B 主 SoC 为 BCM2837 芯片,支持硬浮点 (vfp)
解压后,为目录 linux-rpi-4.4.y
- Toolchain
https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads 选 AArch32 GNU/Linux target with hard float (arm-none-linux-gnueabihf)
- Build
$ cd linux-rpi-4.4.y/ $ export PATH=$PATH:/path/to/toolchain/bin $ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- bcm2709_defconfig # 生成 .config $ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- zImage -j8 $ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- dtbs $ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- M=drivers/your/drv/ modules
gcc 版本过高可能出错:
HOSTLD scripts/dtc/dtc /usr/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x10): multiple definition of `yylloc'; scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here collect2: error: ld returned 1 exit status
编辑 vim scripts/dtc/dtc-lexer.lex.c,找到 ”YYLTYPE yylloc;“ 加上 extern:"extern YYLTYPE yylloc;" 即可
- 部署
bootloader 加载内核优先顺序:
- config.txt 中的 kernel = xxxx
- kernel8.img kernel8-32.img (armv8-aarch64, armv8-aarch32)
- kernel7.img (armv7)
- kernel.img (old version)
[编辑] 5 Pinout
[编辑] 5.1 Model A and B
[编辑] 5.2 Models A+, B+, PI 2 B, PI 3 B
[编辑] 6 Serial
[编辑] 6.1 Enable
/boot/cmdline.txt "console=serial0,115200" /boot/config.txt enable_uart=1
[编辑] 6.2 Disable
Remove "console=serial0,115200" from /boot/cmdline.txt
If you want to use the uart as IO device, add "enable_uart=1" into /boot/config.txt
Or you can do it by run "sudo raspi-config" , enter "Advanced Options" and then enter "Serial" ....
[编辑] 6.3 Connections
- RASP_TXD --- HEX_TX
- RASP_RXD --- HEX_RX
[编辑] 7 GPIO Control
- https://github.com/joan2937/pigpio
- raspi-gpio
- RAW: http://www.pieter-jan.com/node/15
[编辑] 8 Timezone
$ cat /etc/timezone Etc/UTC $ sudo echo "Asia/Shanghai" > /etc/timezone
add following into /etc/profile:
TZ=Asia/Shanghai export TZ
$ sudo reboot
[编辑] 9 Static IP
add following into /etc/dhcpcd.conf:
interface eth0 static ip_address=192.168.1.45/24 static routers=192.168.1.1 static domain_name_servers=192.168.1.1
[编辑] 10 ESP8266/ESP8089
Note that the CH_PD signal is connected to the ID_SD signal. This must be mapped as a GPIO (GPIO0) and switched to an output and driven low then switched to an input again before the driver is loaded in order to reset the module. This will be added in the near future in the driver.
https://github.com/al177/esp8089
https://hackaday.io/project/8678/instructions?page=1
[编辑] 11 WiFi access-point
$ sudo apt-get install hostapd dnsmasq
[编辑] 12 WiFi
“Wlan0: Not associated”报错解决:
如下命令 OK,则网卡驱动 OK:
$ ifconfig wlan0 $ ifconfig wlan0 up $ iwlist wlan0 scan | grep SSID
只需修改网络配置即可,增加一条网络凭条:
$ wpa_passphrase YOUR_ssid YOUR_password >> /etc/wpa_supplicant/wpa_supplicant.conf
network={
ssid="ssid"
#psk="password"
psk=44116ea881531996d8a23af58b376d70f196057429c258f529577a26e727ec1b
}
要使配置生效,则需要重启 wpa_supplicant:
<source lang=bash>
$ killall wpa_supplicant
$ wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
或者:
$ sudo ifup wlan0
开机无法自动连 WiFi 则确认 /etc/network/interfaces 和 /etc/dhcpcd.conf:
allow-hotplug wlan0 iface wlan0 inet dhcp wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
和 /etc/dhcpcd.conf:
interface wlan0 static routers=192.168.1.1 255.255.255.0 static domain_name_servers=192.168.1.1
- https://shumeipai.nxez.com/2016/09/17/raspberry-pi-set-up-a-wireless-internet-access.html
- https://www.cnblogs.com/lfri/p/11875527.html
[编辑] 13 Bluetooth
$ sudo apt-get install bluetooth bluez $ sudo apt-get install python-bluez
[编辑] 14 2G/3G/4G
$ sudo apt-get install python-gammu gammu wvdial
[编辑] 15 GPS
$ sudo apt-get install gpsd gpsd-clients
[编辑] 16 Qemu
$ sudo apt install qemu qemu-system-arm $
- Using Qemu to custom system
- Fetch disk image from: http://www.raspberrypi.org/downloads
- Get kernel img and versatile-pb.dtb from: https://github.com/dhruvvyas90/qemu-rpi-kernel
- Run the Qemu 1st:
$ sudo apt-get install qemu $ qemu-system-arm -cpu'?' | grep arm1176 $ qemu-system-arm -cpu arm1176 -m 256 -M versatilepb \ -kernel ./kernel-qemu-4.14.79-stretch \ -dtb ./versatile-pb.dtb \ -hda ./2018-11-13-raspbian-stretch-lite.img \ -append 'root=/dev/sda2 panic=1 init=/bin/bash' \ -no-reboot -serial stdio
-net nic \ -net user,hostfwd=tcp::5022-:22 \
Edit the /etc/ld.so.preload, remove the 1st line:
#/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so
QEMU 模拟器上磁盘是认作 /dev/sda , 但是实机上是 /dev/mmcblk0 所以要设定对应的符号链接,创建 /etc/udev/rules.d/90-qemu.rules 并追加以下记录:
KERNEL=="sda", SYMLINK+="mmcblk0" KERNEL=="sda?", SYMLINK+="mmcblk0p%n" KERNEL=="sda2", SYMLINK+="root"
Then re-run the Qemu:
$ sudo apt-get install qemu $ qemu-system-arm -cpu'?' | grep arm1176 $ qemu-system-arm -cpu arm1176 -m 256 -M versatilepb \ -kernel ./kernel-qemu-4.14.79-stretch \ -dtb ./versatile-pb.dtb \ -hda ./2018-11-13-raspbian-stretch-lite.img \ -append 'root=/dev/sda2 panic=1' \ -no-reboot -serial stdio
[编辑] 17 Image
[编辑] 17.1 Raspberry PI 3B
- Raspbian-4.1
- raspberrypi-jessie-WAZIUP-demo.dmg.zip
- 2019-04-08-raspbian-stretch-lite.zip
[编辑] 17.2 Raspberry Model A/B
- raspberrypi-jessie-WAZIUP-demo.dmg.zip (HomeAssist)
[编辑] 17.3 Notes
- Write image into SD card
$ sudo dd bs=1m if=2019-04-08-raspbian-stretch-lite.img of=/dev/rdisk2 conv=sync
- Make SD card into a img file
$ dd if=/dev/mmc0 | gzip -9 > sd-all.img.gz $ gzip -dc /tmp/sd-all.img.gz | sudo dd of=/dev/mmc0
- Mount the img
sudo apt-get install dosfstools dump parted kpartx sudo losetup /dev/loop0 2019-04-08-raspbian-stretch-lite.img mkdir -p /mnt/a/boot/ mkdir -p /mnt/a/root/ sudo kpartx -av /dev/loop0 boot="/dev/mapper/loop0p6" root="/dev/mapper/loop0p7" sudo mount $boot /mnt/a/boot/ sudo mount $root /mnt/a/root/ sudo kpartx -d /dev/loop0 sudo losetup -d /dev/loop0
[编辑] 17.4 Backup the System into img
#!/bin/sh
sudo apt-get install -y dosfstools parted kpartx rsync
df=`df -P | grep /dev/root | awk '{print $3}'`
dr=`df -P | grep /dev/mmcblk0p1 | awk '{print $2}'`
df=`echo $df $dr |awk '{print int(($1+$2)*1.2)}'`
sudo dd if=/dev/zero of=raspberrypi.img bs=1K count=$df
sudo parted raspberrypi.img --script -- mklabel msdos
start=`sudo fdisk -l /dev/mmcblk0| awk 'NR==10 {print $2}'`
start=`echo $start's'`
end=`sudo fdisk -l /dev/mmcblk0| awk 'NR==10 {print $3}'`
end2=$[end+1]
end=`echo $end's'`
end2=`echo $end2's'`
sudo parted raspberrypi.img --script -- mkpart primary fat32 $start $end
sudo parted raspberrypi.img --script -- mkpart primary ext4 $end2 -1
loopdevice=`sudo losetup -f --show raspberrypi.img`
device=`sudo kpartx -va $loopdevice | sed -E 's/.*(loop[0-9])p.*/\1/g' | head -1`
device="/dev/mapper/${device}"
partBoot="${device}p1"
partRoot="${device}p2"
sudo mkfs.vfat $partBoot
sudo mkfs.ext4 $partRoot
sudo mount -t vfat $partBoot /media
sudo cp -rfp /boot/* /media/
sudo umount /media
sudo mount -t ext4 $partRoot /media/
cd /media
sudo rsync -aP --exclude="raspberrypi.img" --exclude=/media/* --exclude=/sys/* --exclude=/proc/* --exclude=/tmp/* / ./
# replace PARTUUID
opartuuidb=`blkid -o export /dev/mmcblk0p1 | grep PARTUUID`
opartuuidr=`blkid -o export /dev/mmcblk0p2 | grep PARTUUID`
npartuuidb=`blkid -o export ${device}p1 | grep PARTUUID`
npartuuidr=`blkid -o export ${device}p2 | grep PARTUUID`
echo "BOOT uuid old=$opartuuidb -> new=$npartuuidb"
echo "ROOT uuid old=$opartuuidr -> new=$npartuuidr"
sudo sed -i "s/$opartuuidr/$npartuuidr/g" $dst_boot_path/cmdline.txt
sudo sed -i "s/$opartuuidb/$npartuuidb/g" $dst_root_path/etc/fstab
sudo sed -i "s/$opartuuidr/$npartuuidr/g" $dst_root_path/etc/fstab
cd
sudo umount /media
sudo kpartx -d $loopdevice
sudo losetup -d $loopdevice
[编辑] 18 config.txt
- https://www.raspberrypi.org/documentation/configuration/config-txt/README.md
- https://www.raspberrypi.org/documentation/configuration/config-txt/video.md
[编辑] 19 Offical 7' touchscreen
[编辑] 20 Chromium Fullscreen
/usr/bin/chromium-browser --profile-directory=Default --app-id=dbnedbfkgoaehilakknipiknpolnbapd --start-fullscreen
[编辑] 21 Preempt-RT
- Raspberry Pi Going Realtime with RT Preempt
- RT-PREEMPT realtime kernel (Raspberry Pi)
- CONFIG_PREEMPT_RT on Raspberry Pi
[编辑] 22 Reference


