Raspberry Pi 4B experience

System selection and installation

The awesome rapberry pi github project introduces almost all Raspberry Pi systems for reference. Here I only discuss the Raspberry Pi systems I have tried:

  • The official 32-bit system is officially recommended, but I don't recommend it too much. The advantage of the 32-bit system may be stability. If it is used for long-term web browsing/writing documents/swiping dramas, it may be fine, but it is not suitable for development. The built-in Python version is relatively old, and the latest support of conda dates back to 2015. armv7 is almost an obsolete architecture, so many packages and software do not support it well.

  • Official 64-bit system, recommended for development. The 64-bit system is a customized system based on debian. The system architecture of aarch64 has better support for software, and its performance is higher than that of 32-bit. At the same time, because it is an official system, resources on the hardware can be used without too much trouble. I think it is a more convenient choice. The environment configuration and other issues mentioned later in this article are aimed at this system.

  • Kali linux is beautiful and cool, and it is very suitable for network security. For this system, I just tried it briefly, and I feel that it is very suitable for the daily use of programmers. If it is not necessary to complete the design and hope to be more stable, I think this may be a better choice. It should be noted that after the new system is installed, it must be installed first apt dist-upgrade, and then it can be normal apt upgrade, otherwise an error that the software package version is not supported will be reported.

  • OPENFANS, the base system for Raspberry Pi enthusiasts, is suitable for daily use without peripherals such as monitors and keyboards. It can be said that this system has configured most of the environments for users, and can directly access ssh and vnc on the webpage, and can also directly open docker, etc., which can be said to be very considerate. But what makes people uncomfortable is that it is a Chinese system, and it is a bit too bloated, and it is not very friendly to programmers.

  • Ubuntu, no feature is the biggest feature. It can be said that this is the most commonly used Linux system. If you are more used to this system, you can use it. I have only used this system for a short time, and I always feel that it is a bit too high to be too low, maybe this is the price that is suitable for the public.

Of course, you can even customize your own raspberry pi operating system, raspberry pi os is a good learning material.

The installation of the system is very simple, just download the Raspberry Pi Imager, and burn it like a fool. If there is no peripheral, it is recommended to use the official system, which can configure WiFi and ssh directly during burning. Otherwise, you need to connect the sd card to another Linux system through a card reader after burning, and modify some configuration files before it can be used.

Environment configuration

conda installation

Although the official 64-bit system of Raspberry Pi is aarch64 system architecture, theoretically speaking, it can be installed directly by directly downloading the latest miniconda, but this is not the case. During installation or use, an error will be reported, indicating that a certain command cannot be executed. I didn't find a good solution to this, so I gave up miniconda and switched to Miniforge . This conda can be used directly by installing it, but it should be noted that the conda source cannot be modified, otherwise it will not work normally. The speed of using the original source is not bad, and it is available for personal testing.

pytorch installation

The pytorch official does not provide a direct installation method for the aarch64 version. If you want to use pytorch, one way is to build from the source code yourself, and the other is to directly use the wheel built by others.The pytorch aarch64 project is a pytorch wheel built for aarch64, and it is easy to install and is still being updated.

The installation of pytorch is not a big problem, but it is not recommended to deploy these applications on the Raspberry Pi, because the Raspberry Pi does not have GPU acceleration, and it is a bit of a stretch to perform artificial intelligence calculations.

problems encountered

VNC can't connect, it prompts an error such as unable to authenticate

One method is to install the supporting VNC Viewer, which can be used to connect to the Raspberry Pi normally.

Another way is to modify the VNC settings on the Raspberry Pi side. The premise is that you have peripherals. After connecting the Raspberry Pi, change the Authentication from UNIX password to VNC password, and then you can use Mobaxterm and other software to connect to VNC normally.

So it is more convenient to install VNC Viewer directly, and the interface is quite beautiful.

VNC shows 'Cannot Currently Show the Desktop'

This situation occurred after I raspi-configturned on the camera function. I think this kind of linkage is outrageous. The general impact process seems to be that after turning on the camera, the boot will not enter the desktop, so VNC cannot connect to it. If the Raspberry Pi is connected to the screen during boot, then using VNC works fine afterwards (but what's the use of that anyway).

Many domestic articles say that this situation needs to modify the VNC resolution or reinstall lxsession. I don't know if this can be solved in the old system, but it doesn't work here.

The solution is found on foreign Raspberry Pi forums:

  1. Enable video without HDMI connected (aka headless), by adding video=HDMI-A-1:1920x1080@60Dto /boot/cmdline.txt (hdmi_force_hotplug=1 in /boot/config.txt is no longer sufficient)

  2. Disable Mutter, otherwise your system will crawl to a halt. In /usr/bin/startlxde-pi , edit $TOTAL_MEM -ge 2048to $TOTAL_MEM -ge 20480and reboot.

  3. Disable the KMS Overlay in /boot/config.txt, to further increase performance.#dtoverlay=vc4-kms-v3d

hdmi_force_hotplug=1Although it was not enough in the first step to say uncomment, I used this method to solve the problem and did not modify the content in cmdline.txt.

The Raspberry Pi cannot be used after connecting to the camera

I installed the official camera module v2 on the Raspberry Pi, but I couldn't access the camera on the Raspberry Pi at the beginning.

Most of the tutorials circulating on the Internet now use the raspistill command, but on the aarch64 system, this method has been abandoned and needs to be replaced by libcamera-related commands. For details, see libcamera official documentation

My attempts are:

  1. Add in /etc/modules-load.d/modules.confbcm2835-v4l2

  2. sudo modprobe bcm2835-v4l2

  3. Execute after connecting to the external networksudo rpi-update

The first two methods didn't solve my problem, but I don't know if they did. I actually managed to access the camera after the last step, and the most difficult part of this step is connecting to the external network. Here I need to thank my good roommate, who has configured circumvention rules on the router, so after connecting to his WiFi, he can directly access the external network. Although I have software available on Windows and Android, it is still difficult to circumvent the firewall on Linux. I installed and configured V2RayA, but I did not access the external network smoothly.

I also found a way to update locally, but I didn’t try it. I put it here for your reference: those pitfalls of Raspberry Pi firmware update (rpi-update)

OpenCV cannot access the camera

My OpenCV version is 4.5.5. After the raspberry pie is connected to the camera and can be accessed normally using libcamera, I declare it in the python code. In theory, it cap = cv2.VideoCapture(0)can be used normally cap.read()to read frames, but in my code it always returns false.

The solution is to enable the camera function in raspi-config, which also causes problems with the above VNC. Fortunately, both of these can be repaired.

In addition, I also saw on the forum that OpenCV can be installed through source code, but since my OpenCV is installed using conda, I don't want to toss OpenCV, so I didn't try this method.