由于树莓派官方推荐的版本仍是32位,本博客探索64位版本。

https://www.codenong.com/37790029/

Raspberry Pi Type 3具有64位CPU,但其体系结构不是arm64,而是armhf。armhf代表” arm hard float”,是为具有硬件浮点支持的arm处理器(armv7 +)的debian端口指定的名称。
arm64和armhf有什么区别?

armhf代表” arm hard float”,是为具有硬件浮点支持的arm处理器(armv7 +)的debian端口指定的名称。

:~$ dpkg --print-architecture
armhf

在树莓派官方推荐的32位系统中将返回armhf,在官方推荐的32位系统升级64位后的系统也返回armhf,只有按下文下载的系统才会返回arm64。

如何安装64位树莓派系统

https://raspberrytips.com/raspberry-pi-os-64-bits-vs-32-bits/

Raspberry Pi OS is available only in a 32-bit version. There is a 64-bit version in development, but it’s not stable yet.
When the CPU is compatible, a 64-bit operating system improves the program performances.

You can expect an overall boost of about 25% in performance with a 64-bit operating system on a compatible device. And some apps will benefit even more from it.

On the official website and in the Raspberry Pi Imager, you’ll only find the 32-bit version. You need to go directly to this link to find the latest versions available.

image-20210530152132577

可能出现某个版本系统无法安装的情况,换一个即可。

但是存在一些问题。Another thing you will notice is that a few apps are missing in the “Recommended Software” tool.For example, there is no Minecraft Pi or Mathematica that you can install directly from there.
These software packages don’t have a build available for the 64-bit operating system.

上一篇博客可看到系统的架构是v7l,为32位系统。

下面显示安装的树莓派64位系统的信息。

pi@pi:~ $ pi@pi:~ $ uname -a
Linux pi 5.4.51-v8+ #1333 SMP PREEMPT Mon Aug 10 16:58:35 BST 2020 aarch64 GNU/Linux
pi@pi:~ $ cat /proc/cpuinfo
processor : 0
BogoMIPS : 108.00
Features : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3

processor : 1
BogoMIPS : 108.00
Features : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part : 0xd08
-bash: pi@pi:~:未找到命令
CPU revision : 3

processor : 2
BogoMIPS : 108.00
Features : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3

processor : 3
BogoMIPS : 108.00
Features : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3

Hardware : BCM2835
Revision : c03112
Serial : 1000000060357d6d
Model : Raspberry Pi 4 Model B Rev 1.2

芯片版本BCM2711 or BCM2835

查看当前芯片版本,显示为4核心,但是芯片名字却是BCM2835,这是一个很老的芯片。在树莓派zero和1上使用的,新的树莓派4B是BCM2711,拿起板子我能明显看到 芯片上的丝印字,为什么cpuinfo命令查出来的是错误的呢?因为内核只许设置1个值,如果设置不同的值就要改代码,这会导致上游集成更加麻烦。建议查版本用cat /proc/device-tree/model来看。

版本参考这里就是准确的 https://shumeipai.nxez.com/raspberry-pi-revision-codeshttps://www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md 。从 4.9 版的内核开始,所有的树莓派都显示为 BCM2835,即便实际上是 BCM2836 和 BCM2837 或2837和2711 处理器。因此仅用这串字符来作为判断依据是不够的。

cat /proc/cpuinfo 打印的信息里面,包含 Hardware: BCM2835 硬件架构码,但这并不是 CPU 型号,而是 Linux 内核内置的,代表树莓派系列的硬件架构码。

这个官方也解释过了:
Why does cpuinfo report I have a BCM2835? The upstream Linux kernel developers had decided that all models of Raspberry Pi return bcm2835 as the SoC name. At Raspberry Pi we like to use as much upstream kernel code as possible, as it makes software maintenance much easier, so we use this code. Unfortunately it means that cat /proc/cpuinfo is inaccurate for the Raspberry Pi 2, Raspberry Pi 3 and Raspberry Pi 4, which use the bcm2836/bcm2837, bcm2837 and bcm2711 respectively. You can use cat /proc/device-tree/model to get an accurate description of the SoC on your Raspberry Pi model.

操作系统版本—指令集版本ARMv7 or ARMv8

ARMv7 是32位。

ARMv8架构引入了对ARM架构的64位支持,重点在于节能的实现,同时保持与现有32位软件的兼容性。通过采用干净的方法,ARMv8-A处理器扩展了可用的性能范围,同时保持了ARM处理器的低功耗特性,这将为未来最具创新性和效率的设备提供动力。ARM有3种不同的产品级别支持ARMv8-A架构:高性能,高效率和超高效率。

ARMv8-A为ARM体系结构引入了64位体系结构支持,其中包括:

64位通用寄存器,SP(堆栈指针)和PC(程序计数器)

64位数据处理和扩展虚拟寻址
两个主要执行状态:

AArch64 - 64位执行状态,包括异常模式,内存模式,程序员模型和指令集支持

AArch32 - 32位执行状态,包括异常模型,存储器模型,程序员模型和支持该状态的指令集

低于ARMv8(如ARMv7)是32位。

https://www.cnblogs.com/pingwen/p/13455876.html

pi@raspberrypi:~ $ uname -a
Linux raspberrypi 5.10.17-v8+ #1414 SMP PREEMPT Fri Apr 30 13:23:25 BST 2021 aarch64 GNU/Linux
pi@raspberrypi:~ $ uname -m
aarch64
pi@pi:~ $ getconf LONG_BIT
64

ARMv8指令集分为Aarch64和Aarch32指令集,而ARMv7使用的是A32和T16指令集(分别为32位和16位)。

再补充一个小知识,armv7不是arm7,做嵌入式的可能比较清楚的,但做纯PC的程序员就比较迷糊了。arm7,8, 9是芯片版本,而v7,v8是指令集版本。

查看当前操作系统版本,有的是v7l,l是小端的cpu。

架构aarch64 or armhf

uname -m 显示主机类型
dpkg --print-architecture 显示架构
armhf

linux版本buster

pi@pi:~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 10 (buster)
Release: 10
Codename: buster

https://www.debian.org/releases/index.zh-cn.html

当前 Debian 的稳定版版本号是 10,开发代号为 buster。Buster,来自皮克斯《玩具总动员》电影中狗的名字。
这个版本基于最新的 Debian 开发,甚至比 Debian 的官方版本更早发布。

发行版目录

树莓派4B使用Raspbian官方64位系统内核

https://www.mmuaa.com/post/0c9188ffde4e2cff.html

树莓派版本信息

getconf` `LONG_BIT    ``# 查看系统位数``
uname` `-a ``# kernel 版本``
/opt/vc/bin/vcgencmd` `version ``# firmware版本``
strings` `/boot/start``.elf | ``grep` `VC_BUILD_ID ``# firmware版本``
cat` `/proc/version` `# kernel``
cat` `/etc/os-release` `# OS版本资讯``
cat` `/etc/issue` `# Linux distro 版本``
cat` `/etc/debian_version` `# Debian版本编号

树莓派64位系统换源

https://blog.csdn.net/qq_51951392/article/details/113703729

https://www.codenong.com/cs109778546/

https://blog.csdn.net/baidu_26678247/article/details/108930421

SNAP安装程序

按照教程 https://snapcraft.io/install/flutter/raspbian

由于snap安装core和flutter都不成功,怀疑是64位支持的snap问题,但不成功会返回snap安装包的链接,我通过windows下科学上网下载该snap文件,然后移到树莓派中,进行本地安装。

树莓派系统linux桌面运行flutter

最终无法在桌面应用中展示,出现一点问题。

libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast

** (dummy_desktop:10814): WARNING **: Failed to start Flutter renderer: Unable to create a GL context

** (dummy_desktop:10814): WARNING **: Unable to retrieve framework response: No engine to send to

解决方案 https://github.com/flutter/flutter/issues/76178#issuecomment-832127601

对于flutter的桌面支持

https://flutter.dev/desktop

使得在win、linux、osx环境下,都有桌面应用可以展示应用。

flutter config --enable-<platform>-desktop
flutter run -d linux