--- title: Raspberry Pi date: 2024-01-27T11:01:31+0000 #lastmod: #showDate: false showReadingTime: false showWordCount: false showPagination: false #showAuthor: false showBreadcrumbs: true feed_exclude: true # site_exclude: true --- Some basic info about Raspberry Pi of any version. ## Activity LED codes ### Up to Raspberry Pi 3 models #### Actual models | LED Activity | Description | | :---------------- | :----------------------------------------------------------------------------------------------- | | 3 flashes | start.elf not found | | 4 flashes | start.elf not launch-able (corrupt) | | 7 flashes | kernel.img not found | | 8 flashes | SDRAM not recognized. You need a newer bootcode.bin/start.elf firmware, or your SDRAM is damaged | #### Older models up to Raspberry Pi 3 | LED Activity | Description | | :---------------- | :----------------------------------- | | 3 flashes | loader.bin not found | | 4 flashes | loader.bin not launch-able (corrupt) | | 5 flashes | start.elf not found | | 6 flashes | start.elf not launch-able | | 7 flashes | kernel.img not found | ### Raspberry Pi 4 | Long flashes | Short flashes | Description | | :----------- | :------------ | :---------------------------------- | | 0 | 3 | Generic failure to boot | | 0 | 4 | start\*.elf not found | | 0 | 7 | Kernel image not found | | 0 | 8 | SDRAM failure | | 0 | 9 | Insufficient SDRAM | | 0 | 10 | In HALT state | | 2 | 1 | Partition not FAT | | 2 | 2 | Failed to read from partition | | 2 | 3 | Extended partition not FAT | | 2 | 4 | File signature/hash mismatch - Pi 4 | | 4 | 4 | Unsupported board type | | 4 | 5 | Fatal firmware error | | 4 | 6 | Power failure type A | | 4 | 7 | Power failure type B | ## Freeze a package with apt/apt-get ## Raspberry Pi 4 4GB version, if that information is of any use. #### WiFi setup Run `wifi-menu`. It does not survive a reboot though! I prefer `iwctl` or NetworkManager, so what I do: ```console # pacman -S networkmanager ``` ### No network after boot Sometimes I make mistakes in my initial `wpa_supplicant.conf` file (that I'd place on the boot partition of the new Raspberry Pi SDcard). Recently my `wpa_supplicant.conf` file was totally messed up (a bracket too much I think). So there is a quick way to connect to a WiFi network with the use of `nmcli` (NetworkManager). ```console $ sudo nmcli device wifi connect [ssid] password [password] ``` You can view networks with (no need for _sudo_): ```console $ nmcli device wifi list ``` ### Moving to testing (from bookworm) Why would you want to do that in the first place? Well, most packages on debian _stable_ are quite old -- hence the name _stable_. If you need newer packages, you should consider moving to the _testing_ branch. I moved my Raspberry Pi 4 to _testing_ because of the starship prompt that I use on my computers -- it needed a newer version of the `rustc` package. First of all, upgrade to the latest packages. ```console $ sudo apt update && sudo apt upgrade ``` Now change the release name (e.g. `bookworm`) to `testing` in `/etc/apt/sources.list`: ``` deb http://deb.debian.org/debian testing main contrib non-free non-free-firmware deb http://deb.debian.org/debian-security/ testing-security main contrib non-free non-free-firmware deb http://deb.debian.org/debian testing-updates main contrib non-free non-free-firmware ``` Then update step by step. ```console $ sudo apt update $ sudo apt upgrade ``` > Restart services during package upgrades without asking? Answer with Yes. Finish the update: ```console $ sudo apt full-upgrade $ sudo reboot ``` ### Python 3 #### Installing non-packaged modules I could not find `aprslib` as a package, so I had to install this myself. Debian did not allow the installation as it did before, so I had to create a virtual environment. And it went like this: ```console $ python -m venv ~/.env $ source ~/.env/bin/activate $ pip install aprslib $ deactivate ``` I now have a similar line in my crontab: ```crontab 3 * * * * /home/dominic/.env/bin/python /home/dominic/bin/aprs_sendstatus.py ``` We could also create virtual environments per application, module, package etc. ## Raspberry Pi 3 ### UPS Plus An **uninterruptible power supply** (UPS) is very useful if you have your own servers at home. I've been using one with my old DiskStation (NAS[^1]) but I got rid of the DiskStation at the end of 2023. I got the UPS Plus for the Raspberry Pi now for a while but never tested all its features yet (well, I haven't used it much to be honest). Though, I have some quick notes to remember: Some software is needed to get status information about the batteries (which are of type 18650). ```console $ python3 -m venv . $ curl -LsO https://raw.githubusercontent.com/geeekpi/upsplus/main/install.sh $ bash install.sh ``` Any errors can be resolved by installing by hand. In my notes I thought that info is enough, so here we are :wink: We may have to edit our crontab: ```cron * * * * * /home/dr/bin/python3 /home/dr/bin/upsPlus.py > /tmp/upsPlus.log * * * * * /home/dr/bin/python3 /home/dr/bin/upsPlus_iot.py > /tmp/upsPlus_iot.log ``` Getting information: ```console $ python3 bin/upsPlus.py ------------------------------------------------------------ ------Current information of the detected Raspberry Pi------ ------------------------------------------------------------ Raspberry Pi Supply Voltage: 5.028 V Raspberry Pi Current Current Consumption: 571.068 mA Raspberry Pi Current Power Consumption: 2570.227 mW ------------------------------------------------------------ -------------------Batteries information------------------- ------------------------------------------------------------ Voltage of Batteries: 4.208 V Battery Current (Charging) Rate: 30.000 mA Current Battery Power Supplement: 263.415 mW Successfully set the protection voltage to: 3700 mV ------------------------------------------------------------ Currently charging via Type C Port. ``` The Raspberry Pi will continue to work if you remove the power cable. [^1]: [Network Attached Storage](https://en.wikipedia.org/wiki/Network-attached_storage) ## Raspberry Pi 2 ### WiFi adapter The Raspberry Pi 2 does not have any WiFi capabilities so an adapter is needed to make use of your local WiFi network. I found [this small adapter](https://www.amazon.de/gp/product/B003MTTJOY/) and can confirm it as a working unit. ![picture of the small Edimax EW-7811UN wireless adapter](edimax_wifi.jpg "It is not available on Amazon any more, but they suggest another device as its successor. I can only speak for the one that I own: **Edimax EW-7811Un**") ## Raspberry Pi Pico W ### Using MicroPython I did the dumb thing and made the `boot.py` file break which led to an endless loop showing me only the Error code and restarting... I was able to stop the script by quickly pressing CTRL+D, CTRL+C on the serial console but never was able to update the broken file without it doing a soft-reboot which loads `boot.py` again instantly... After some research I was glad I found [pico-nuke](https://github.com/polhenarejos/pico-nuke/releases). Boot into uf2 loading (pressing BOOTSEL while power on) and place the correct .uf file (`pico_nuke_pico_w-1.1.uf2`) on the mounted device. On OpenBSD there is no response but you can see the filesystem unmounted/removed. Unplug the USB and plug it in again booting into uf2 loading, copying over the MicroPython uf2 file again.