Raspberry Pi: Difference between revisions
(Remove link to outdated Pi ZeroW specific page which candidate for removal) Tag: Manual revert |
Prabuanand (talk | contribs) (added camera_auto_detect=1 option) |
||
(18 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{TOC right}} | {{TOC right}} | ||
This | This page explains how to install and use Alpine Linux on Raspberry Pi. | ||
For scenarios where there is not expected to be significant changes to disk after setup (like running a static HTTP server), | For scenarios where there is not expected to be significant changes to disk after setup (like running a static HTTP server), [[Diskless Mode|diskless mode]] is preferable, as running the entire system from memory will improve performance (by avoiding the slow SD card) and improve the SD card life (by reducing the writes to the card, as all logging will happen in RAM). Use [[Alpine local backup|Alpine Local Backup (lbu)]] utility to install packages, save local files, and tune the system. | ||
[[Classic install or sys mode on Raspberry Pi|sys-mode installation]] is more appropriate for the following use cases: | |||
* There will be constant changes to the disk after initial setup (for example, if you expect people to login and save files to their home directories) | * There will be constant changes to the disk after initial setup (for example, if you expect people to login and save files to their home directories) | ||
Line 14: | Line 12: | ||
* Plan to install kernel modules (such as ZFS) | * Plan to install kernel modules (such as ZFS) | ||
== | == Compatibility list == | ||
Refer to the information regarding Raspberry Pi models in the below table when choosing image/file to download from [https://alpinelinux.org/downloads/ Downloads] page for your device. [[Installation#Verifying_downloaded_image|Verify]] the downloaded image before proceeding further. | |||
{{:Include:Architecture support matrix}} | |||
== Preparing for the installation== | |||
SD card based install media can easily be generated with few clicks using [https://www.raspberrypi.com/news/raspberry-pi-imager-imaging-utility/ Raspberry Pi Imager tool] on Linux/macOS/Windows. In Alpine linux, install the {{pkg|rpi-imager}} package and launch the tool: {{Cmd|rpi-imager}} | |||
Follow the prompts to create install media on sd-card. When using this tool, there is no need to partition and format as the tool does everything and creates the sd card based install media. Proceed to [[#Installation|Installation]], if no further customization is required. | |||
It is recommended to create a '''usercfg.txt''' file on boot partition to configure low-level system settings, as '''config.txt''' may be replaced during bootloader/system upgrades: details can be found [https://www.raspberrypi.com/documentation/computers/config_txt.html here]. | === Manual method === | ||
However, | |||
Alternatively, image may be downloaded, and media formatted and prepared as per below: | |||
* [https://alpinelinux.org/downloads/ Download] the Alpine for Raspberry Pi tarball. Use the compability list above when choosing image/file to download. | |||
* [[Create_a_Bootable_Device#Manually_copying_Alpine_files|Create a bootable FAT32 partition on your SD card.]] The partitioning and formatting part of the instructions on the linked page could be done using a graphical partitioning tool such as [https://en.wikipedia.org/wiki/GNOME_Disks gnome-disks], just make sure the partition type is <code>W95 FAT32 (LBA)</code>. (The current type can be found in the "Type" column in the output of <code>fdisk -l</code>.) | |||
*: {{warning |Due to an upstream [https://github.com/raspberrypi/firmware/issues/1529 bug], kernel/initramfs cannot be loaded from subdirectory with same name as volume label. Since kernel is installed to <code>boot/</code> folder in Alpine Linux, do not use label <code>boot</code> for the fat32 partition.}} | |||
* Extract the tarball to the root of the bootable FAT32 partition. | |||
* It is recommended to create a '''usercfg.txt''' file on boot partition to configure low-level system settings, as '''config.txt''' may be replaced during bootloader/system upgrades: details can be found [https://www.raspberrypi.com/documentation/computers/config_txt.html here]. However, some [https://www.raspberrypi.com/documentation/computers/config_txt.html#include settings] can only be set in '''config.txt''', and will have no effect when specified in '''usercfg.txt''' (e.g. <code>gpu_mem</code>). Some interesting values include:{{Cat|usercfg.txt|<nowiki> | |||
enable_uart=1 # To enable the UART console: | |||
dtparam=audio=on # To enable audio </nowiki>}} | |||
* By default system will use legacy video driver: some [https://www.raspberrypi.com/documentation/computers/legacy_config_txt.html#legacy-video-options options] may be used to adjust displays modes (e.g. if you see black edges around your screen after booting the Pi, you can add <code>disable_overscan=1</code>). Alternatively Linux DRM-KMS driver may be used (see below). | * By default system will use legacy video driver: some [https://www.raspberrypi.com/documentation/computers/legacy_config_txt.html#legacy-video-options options] may be used to adjust displays modes (e.g. if you see black edges around your screen after booting the Pi, you can add <code>disable_overscan=1</code>). Alternatively Linux DRM-KMS driver may be used (see below). | ||
* If you plan to install on a Pi | * If you plan to install on a Pi Computer Module 4 with I/O board, you may need to add: <code>otg_mode=1</code> | ||
* Pi Zero may be configured as simple USB serial-gadget or ethernet-gadget networking with another computer sharing its internet connection. | |||
* For headless use, use the following parameters to maximize available memory (32 megs is required for the rpi bootloader):<code>gpu_mem=32</code> | |||
=== Headless pi === | |||
== | To setup a headless system, a bootstrapping configuration overlay file [https://github.com/macmpi/alpine-linux-headless-bootstrap headless.apkovl.tar.gz] may be added to the sd card based Install media. To enable wifi, create a file {{Path|wpa_supplicant.conf}} in the install media as follows:{{Cat|wpa_supplicant.conf|<nowiki>country=FR | ||
network={ | |||
key_mgmt=WPA-PSK | |||
ssid="mySSID" | |||
psk="myPassPhrase" | |||
} | |||
</nowiki>}} | |||
Alternately, use <code>wpa_passphrase</code> utility from {{pkg|wpa_supplicant}} package to create the encrypted version of the above file {{Path|wpa_supplicant.conf}} as follows: {{Cmd| wpa_passphrase 'mySSID' 'myPassPhrase' > wpa_supplicant.conf}} and place it on the install media. | |||
With the above setup, following Installation steps can be performed remotely using <code>ssh</code>. | |||
* Use {{Codeline|nmap -v -sn 192.168.1.0/24}} to find the ip of your pi. | |||
* Refer [https://github.com/macmpi/alpine-linux-headless-bootstrap author's website] for other options. | |||
== Installation == | |||
{{Seealso|Classic install or sys mode on Raspberry Pi}} | |||
Follow these steps to install Alpine Linux in [[Diskless Mode]]: | |||
# Insert the SD card into the Raspberry Pi and power it on | # Insert the SD card into the Raspberry Pi and power it on | ||
# Login into the Alpine system as root. Leave the password empty. | # Login into the Alpine system as root. Leave the password empty. | ||
# Check the current date and time by issuing <code>date</code>. Correct if necessary by issuing <code>date -s YYYYMMDDhhmm</code>. | |||
# Type <code>setup-alpine</code> | # Type <code>setup-alpine</code> | ||
# Once the installation is complete, commit the changes by typing <code>lbu commit -d</code> | # Once the installation is complete, commit the changes by typing <code>lbu commit -d</code> | ||
Line 64: | Line 82: | ||
=== Linux Kernel Graphics Modes === | === Linux Kernel Graphics Modes === | ||
By default system configuration will use legacy video driver: this driver has some limitations and is lacking support.<br> | By default system configuration will use legacy video driver: this driver has some limitations and is lacking support.<br> | ||
It is recommended to enable Linux DRM-KMS driver by adding the following to '''usercfg.txt''': | It is recommended to enable Linux DRM-KMS driver by adding the following to '''usercfg.txt''': | ||
Line 84: | Line 103: | ||
=== Wireless drivers === | === Wireless drivers === | ||
As of Alpine 3.17, Wifi and Bluetooth drivers are available within install image: they are part of <code>linux-firmware-brcm</code> (and linked dependencies). Since kernel 6.1.25 (i.e. Alpine 3.18), onboard bluetooth is enabled & autoprobed by default. This may be disabled by setting [https://github.com/raspberrypi/rpi-firmware/tree/master/overlays krnbt] off). | |||
=== Picam === | |||
The working of picam has been tested in [[Classic install or sys mode on Raspberry Pi|sys mode]] only with Pi Zero 2 W model. | |||
# Upgrade to [[Repositories#Upgrading_to_edge|edge]] version as {{pkg|rpicam-apps}} package is not yet supported in v3.21. | |||
# Setup eudev as device manager:{{Cmd|# setup-devd udev}} | |||
# Add <Code>camera_auto_detect=1</Code> option to the user config file {{Path|/boot/usercfg.txt}} | |||
# Install the package {{pkg|rpicam-apps}} available in the [[Repositories#Testing|testing]] repository. | |||
# Due to bug {{Issue|16911}}, change the permission after every reboot as follows:{{Cmd|$doas chmod 666 /dev/dma_heap/*}} | |||
# Test the picam by the command {{Cmd|$libcamera-hello --list-cameras}} | |||
== Loopback image with overlayfs == | |||
When you install Alpine in diskless mode, the entire system is loaded into memory at boot. If you want additional storage (for example, if you need more space than offered by your RAM) we need to create loop-back storage onto the SD card mounted with overlayfs. | When you install Alpine in diskless mode, the entire system is loaded into memory at boot. If you want additional storage (for example, if you need more space than offered by your RAM) we need to create loop-back storage onto the SD card mounted with overlayfs. | ||
Line 168: | Line 142: | ||
mkdir /media/persist | mkdir /media/persist | ||
mount -a}} | mount -a}} | ||
{{Note|Overlay workdir needs to be an empty directory on the same filesystem mount as the upper directory. So each overlay must use its own workdir.}} | |||
Make the overlay folders, we are using the /usr directory here, but you can use /home or anything else. | Make the overlay folders, we are using the /usr directory here, but you can use /home or anything else. | ||
{{cmd|mkdir /media/persist/usr | {{cmd|mkdir /media/persist/usr | ||
mkdir /media/persist/.work_usr | mkdir /media/persist/.work_usr | ||
Line 195: | Line 168: | ||
== Netboot == | == Netboot == | ||
The Raspberry Pi 4 bootloader can be configured to boot from the network [https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#raspberry-pi-4-bootloader-configuration]. Configure the bootloader with at least | The Raspberry Pi 4 bootloader can be configured to boot from the network [https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#raspberry-pi-4-bootloader-configuration]. Configure the bootloader with at least | ||
Line 233: | Line 204: | ||
With the above configured the Raspberry Pi 4 should be able to boot from the network without an SD card. | With the above configured the Raspberry Pi 4 should be able to boot from the network without an SD card. | ||
== Enable the Serial Console == | |||
Besides having <code>enable_uart=1</code> in ''usercfg.txt'', the kernel command-line option <var>console</var> needs to be changed to <code>console=serial0,115200</code> in ''cmdline.txt''. | |||
From a Linux desktop, connect to it with something like this: | |||
{{cmd|cu -l /dev/ttyUSB0 -s 115200}} | |||
== Troubleshooting == | |||
<code>raspinfo</code> utility from the {{Pkg|raspberrypi-utils-raspinfo}} package can be used as a first step to diagnose issues: it will make a log report of essential Pi system configuration, and is often used as a reference to submit questions or bug reports within Raspberry Pi community (Forums, Github, etc). | |||
After booting, you may find less system memory available than you expect. Currently the Pi requires a minimum of 32 megs of memory for the gpu, to boot unless you have the cut down boot loader installed, in which case you can use 16. However, you may find more gpu memory is still being used, even if you configure it for less, if you enable audio or camera support. To find out how your system is actually split, use <Code>vcgencmd</Code> utility from the {{pkg|raspberrypi-utils-vcgencmd}} package as follows:{{Cmd|<nowiki># vcgencmd get_mem gpu | |||
# vcgencmd get_mem arm</nowiki>}} | |||
=== Long boot time when running headless === | |||
If no peripherals are connected, the system might hang for an exceptionally long period of time while it attempts to accumulate entropy. | |||
If this is the case, simply plugging in any USB device should work around this issue, since it increases the amount of entropy available to the kernel via interrupts. | |||
=== apk indicating 'No space left on device' === | |||
Note some models of the Raspberry Pi such as the 3A+ only have 512M of RAM, which on fresh Alpine deployment will only leave around 200M for tmpfs root. It's important to keep this limitation in mind when using these boards. | |||
=== Clock-related error messages === | |||
During the booting time, you might notice errors related to the hardware clock. Many Raspberry Pi do not have a hardware clock, or may have one without battery, in which case the behaviour depends on whether you physically cut power or not. | |||
Also, <code>setup-alpine</code> will adapt the installation to the type of Raspberry Pi you use, which means for example that on a RPI5, you will see <code>hwclock></code> service, whereas on a RPI4 it will use <code>swclock</code>. In doubt, make sure to do the installation on the target hardware. | |||
If you still experience clock errors, add the following line to '''/etc/chrony/chrony.conf''': | |||
<code>makestep 0.1 3</code> | |||
=== Wireless support with older Alpine images === | === Wireless support with older Alpine images === | ||
Line 249: | Line 255: | ||
cp firmware-nonfree/brcm/* /mnt/sdcard/firmware/brcm | cp firmware-nonfree/brcm/* /mnt/sdcard/firmware/brcm | ||
== | === Fileystem for boot partition === | ||
If you are trapped at the dreaded rainbow screen, with the green led blinking a few times in a row, repeatedly, check the boot partition type. | |||
The rpi2 require '''fat32''' for the boot partition, NOT '''fat16'''. Use linux fdisk to set the boot partition type as "c" (for fat32/lba) and set the '''lba''' and '''boot''' flags for the partition as suggested. Create the boot partition filesystem as fat32 with:{{Cmd|mkdosfs -F 32 /dev/sdX1}} | |||
== See also == | |||
* [[Classic install or sys mode on Raspberry Pi]] - a variant. | * [[Classic install or sys mode on Raspberry Pi]] - a variant. | ||
* [[Raspberry Pi 3 - Setting Up Bluetooth]] | * [[Raspberry Pi 3 - Setting Up Bluetooth]] |
Latest revision as of 13:14, 14 February 2025
This page explains how to install and use Alpine Linux on Raspberry Pi.
For scenarios where there is not expected to be significant changes to disk after setup (like running a static HTTP server), diskless mode is preferable, as running the entire system from memory will improve performance (by avoiding the slow SD card) and improve the SD card life (by reducing the writes to the card, as all logging will happen in RAM). Use Alpine Local Backup (lbu) utility to install packages, save local files, and tune the system.
sys-mode installation is more appropriate for the following use cases:
- There will be constant changes to the disk after initial setup (for example, if you expect people to login and save files to their home directories)
- Logs should persists across reboots
- Plan to install packages which consume more space than can be loaded into RAM
- Plan to install kernel modules (such as ZFS)
Compatibility list
Refer to the information regarding Raspberry Pi models in the below table when choosing image/file to download from Downloads page for your device. Verify the downloaded image before proceeding further.
Alpine Linux Hardware Support Matrix | |||
Architecture | Port | Description | Since |
---|---|---|---|
x86 | x86 | 32 bit i686 compatible (or later) CPUs with at least CMOV and SSE2 | All |
x86_64 | AMD64 compatible 64-bit x86 instruction set | All | |
ARM | armhf | 32 bit ARM with hard-float ABI - for ARMv6 devices- Raspberry Pi 1, Zero, ZeroW, cm1 (defconfig bcmrpi) | v3.0 |
armv7 | 32 bit ARM - for ARMv7 devices - Raspberry Pi 2, 3, 3+, Zero2W, cm3, cm3+ (defconfig bcm2709) | v3.9 | |
aarch64 | 64 bit ARM - for ARMv8+ devices - Raspberry Pi 3, 3+, 4, 400, Zero2W, cm3, cm3+, cm4, 5 (defconfig bcm2711) | v3.5 | |
PowerPC | ppc64le | 64 bit PowerPC (little-endian) mostly for POWER8 and POWER9 | v3.6 |
IBM System Z | s390x | IBM Z mainframes, especially IBM Z and IBM LinuxONE (z196 minimum) | v3.6 |
RISC V | riscv64 | 64 bit RISC V | v3.20 |
LoongArch | loongarch64 | 64 bit LoongArch | v3.21 |
Preparing for the installation
SD card based install media can easily be generated with few clicks using Raspberry Pi Imager tool on Linux/macOS/Windows. In Alpine linux, install the rpi-imager package and launch the tool:
rpi-imager
Follow the prompts to create install media on sd-card. When using this tool, there is no need to partition and format as the tool does everything and creates the sd card based install media. Proceed to Installation, if no further customization is required.
Manual method
Alternatively, image may be downloaded, and media formatted and prepared as per below:
- Download the Alpine for Raspberry Pi tarball. Use the compability list above when choosing image/file to download.
- Create a bootable FAT32 partition on your SD card. The partitioning and formatting part of the instructions on the linked page could be done using a graphical partitioning tool such as gnome-disks, just make sure the partition type is
W95 FAT32 (LBA)
. (The current type can be found in the "Type" column in the output offdisk -l
.)- Warning: Due to an upstream bug, kernel/initramfs cannot be loaded from subdirectory with same name as volume label. Since kernel is installed to
boot/
folder in Alpine Linux, do not use labelboot
for the fat32 partition.
- Extract the tarball to the root of the bootable FAT32 partition.
- It is recommended to create a usercfg.txt file on boot partition to configure low-level system settings, as config.txt may be replaced during bootloader/system upgrades: details can be found here. However, some settings can only be set in config.txt, and will have no effect when specified in usercfg.txt (e.g.
gpu_mem
). Some interesting values include:Contents of usercfg.txt
enable_uart=1 # To enable the UART console: dtparam=audio=on # To enable audio - By default system will use legacy video driver: some options may be used to adjust displays modes (e.g. if you see black edges around your screen after booting the Pi, you can add
disable_overscan=1
). Alternatively Linux DRM-KMS driver may be used (see below). - If you plan to install on a Pi Computer Module 4 with I/O board, you may need to add:
otg_mode=1
- Pi Zero may be configured as simple USB serial-gadget or ethernet-gadget networking with another computer sharing its internet connection.
- For headless use, use the following parameters to maximize available memory (32 megs is required for the rpi bootloader):
gpu_mem=32
Headless pi
To setup a headless system, a bootstrapping configuration overlay file headless.apkovl.tar.gz may be added to the sd card based Install media. To enable wifi, create a file wpa_supplicant.conf in the install media as follows:
Contents of wpa_supplicant.conf
Alternately, use wpa_passphrase
utility from wpa_supplicant package to create the encrypted version of the above file wpa_supplicant.conf as follows:
wpa_passphrase 'mySSID' 'myPassPhrase' > wpa_supplicant.conf
and place it on the install media.
With the above setup, following Installation steps can be performed remotely using ssh
.
- Use nmap -v -sn 192.168.1.0/24 to find the ip of your pi.
- Refer author's website for other options.
Installation
Follow these steps to install Alpine Linux in Diskless Mode:
- Insert the SD card into the Raspberry Pi and power it on
- Login into the Alpine system as root. Leave the password empty.
- Check the current date and time by issuing
date
. Correct if necessary by issuingdate -s YYYYMMDDhhmm
. - Type
setup-alpine
- Once the installation is complete, commit the changes by typing
lbu commit -d
Type reboot
to verify that the installation was indeed successful.
Post Installation
Update the System
After installation, make sure your system is up-to-date:
apk update apk upgrade
Don't forget to save the changes:
lbu commit -d
Note: this does not upgrade the kernel. In order to upgrade the kernel, a full upgrade of the Alpine Linux version must be performed as described in upgrading Alpine Linux for removable media.
Linux Kernel Graphics Modes
By default system configuration will use legacy video driver: this driver has some limitations and is lacking support.
It is recommended to enable Linux DRM-KMS driver by adding the following to usercfg.txt:
# Enable DRM VC4 V3D driver dtoverlay=vc4-kms-v3d max_framebuffers=2 # Don't have the firmware create an initial video= setting in cmdline.txt. # Use the kernel's default instead. disable_fw_kms_setup=1
Note: This overlay disables legacy video options.
Install the Mesa drivers (Pi4 and Pi5):
apk add mesa-dri-gallium
Then reboot:
lbu_commit -d; reboot
Wireless drivers
As of Alpine 3.17, Wifi and Bluetooth drivers are available within install image: they are part of linux-firmware-brcm
(and linked dependencies). Since kernel 6.1.25 (i.e. Alpine 3.18), onboard bluetooth is enabled & autoprobed by default. This may be disabled by setting krnbt off).
Picam
The working of picam has been tested in sys mode only with Pi Zero 2 W model.
- Upgrade to edge version as rpicam-apps package is not yet supported in v3.21.
- Setup eudev as device manager:
# setup-devd udev
- Add
camera_auto_detect=1
option to the user config file /boot/usercfg.txt - Install the package rpicam-apps available in the testing repository.
- Due to bug #16911, change the permission after every reboot as follows:
$doas chmod 666 /dev/dma_heap/*
- Test the picam by the command
$libcamera-hello --list-cameras
Loopback image with overlayfs
When you install Alpine in diskless mode, the entire system is loaded into memory at boot. If you want additional storage (for example, if you need more space than offered by your RAM) we need to create loop-back storage onto the SD card mounted with overlayfs.
First, make the SD card writable again and change fstab to always do so:
mount /media/mmcblk0p1 -o rw,remount sed -i 's/vfat\ ro,/vfat\ rw,/' /etc/fstab
Create the loop-back file, this example is 1 GB:
dd if=/dev/zero of=/media/mmcblk0p1/persist.img bs=1024 count=0 seek=1048576
Install the ext utilities:
apk add e2fsprogs
Format the loop-back file:
mkfs.ext4 /media/mmcblk0p1/persist.img
Mount the storage:
echo "/media/mmcblk0p1/persist.img /media/persist ext4 rw,relatime,errors=remount-ro 0 0" >> /etc/fstab mkdir /media/persist mount -a
Make the overlay folders, we are using the /usr directory here, but you can use /home or anything else.
mkdir /media/persist/usr mkdir /media/persist/.work_usr echo "overlay /usr overlay lowerdir=/usr,upperdir=/media/persist/usr,workdir=/media/persist/.work_usr 0 0" >> /etc/fstab mount -a
Your /etc/fstab should look something like this:
/dev/cdrom /media/cdrom iso9660 noauto,ro 0 0 /dev/usbdisk /media/usb vfat noauto,ro 0 0 /dev/mmcblk0p1 /media/mmcblk0p1 vfat rw,relatime,fmask=0022,dmask=0022,errors=remount-ro 0 0 /media/mmcblk0p1/persist.img /media/persist ext4 rw,relatime,errors=remount-ro 0 0 overlay /usr overlay lowerdir=/usr,upperdir=/media/persist/usr,workdir=/media/persist/.work_usr 0 0
Now commit the changes: (optionally remove the e2fsprogs, but it does contain repair tools)
lbu_commit -d
Remember, with this setup if you install things and you have done this overlay for /usr, you must not commit the 'apk add', otherwise, while it boots it will try and install it to memory, not to the persistent storage.
If you do want to install something small at boot, you can use apk add
and lbu commit -d
.
If it is something a bit bigger, then you can use apk add
but then not commit it. It will be persistent (in /user
), but be sure to check everything you need is in that directory and not in folders you have not made persistent.
Netboot
The Raspberry Pi 4 bootloader can be configured to boot from the network [1]. Configure the bootloader with at least
BOOT_ORDER=0xf142 TFTP_PREFIX=1
and optionally also
TFTP_IP=x.x.x.x
where x.x.x.x
is the IP address of your TFTP server.
If not configuring TFTP_IP
in the bootloader, you'll need to configure your DHCP server to advertise the TFTP server IP address. This varies depending on your DHCP server; use the following details if applicable:
- Vendor class:
PXEClient:Arch:00000:UNDI:002001
- Filename:
/
The minimal set of files that your TFTP server needs to host are:
bcm2711-rpi-4-b.dtb
(from raspberrypi/firmware/master/boot/bcm2711-rpi-4-b.dtb)cmdline.txt
(see below)config.txt
(see below)fixup4.dat
(from raspberrypi/firmware/master/boot/fixup4.dat, alternativelyfixup4cd.dat
for the cut down version)initramfs-rpi4
(from alpine/edge/releases/aarch64/netboot/initramfs-rpi4)start4.elf
(from raspberrypi/firmware/master/boot/start4.elf, alternativelystart4cd.elf
for the cut down version)vmlinuz-rpi4
(from alpine/edge/releases/aarch64/netboot/vmlinuz-rpi4)
config.txt
:
[pi4] kernel=vmlinuz-rpi4 initramfs initramfs-rpi4 arm_64bit=1
cmdline.txt
:
modules=loop,squashfs console=ttyAMA0,115200 ip=dhcp alpine_repo=http://dl-cdn.alpinelinux.org/alpine/edge/main modloop=http://dl-cdn.alpinelinux.org/alpine/edge/releases/aarch64/netboot/modloop-rpi4
Instead of using the http://dl-cdn.alpinelinux.org/alpine/edge/releases/aarch64/netboot/ base URL above, pinning to a specific point in time is preferred. Raspberry Pi 4 netboot files are available from https://dl-cdn.alpinelinux.org/alpine/edge/releases/aarch64/netboot-20230329/ onward.
With the above configured the Raspberry Pi 4 should be able to boot from the network without an SD card.
Enable the Serial Console
Besides having enable_uart=1
in usercfg.txt, the kernel command-line option console needs to be changed to console=serial0,115200
in cmdline.txt.
From a Linux desktop, connect to it with something like this:
cu -l /dev/ttyUSB0 -s 115200
Troubleshooting
raspinfo
utility from the raspberrypi-utils-raspinfo package can be used as a first step to diagnose issues: it will make a log report of essential Pi system configuration, and is often used as a reference to submit questions or bug reports within Raspberry Pi community (Forums, Github, etc).
After booting, you may find less system memory available than you expect. Currently the Pi requires a minimum of 32 megs of memory for the gpu, to boot unless you have the cut down boot loader installed, in which case you can use 16. However, you may find more gpu memory is still being used, even if you configure it for less, if you enable audio or camera support. To find out how your system is actually split, use vcgencmd
utility from the raspberrypi-utils-vcgencmd package as follows:
# vcgencmd get_mem gpu # vcgencmd get_mem arm
Long boot time when running headless
If no peripherals are connected, the system might hang for an exceptionally long period of time while it attempts to accumulate entropy.
If this is the case, simply plugging in any USB device should work around this issue, since it increases the amount of entropy available to the kernel via interrupts.
apk indicating 'No space left on device'
Note some models of the Raspberry Pi such as the 3A+ only have 512M of RAM, which on fresh Alpine deployment will only leave around 200M for tmpfs root. It's important to keep this limitation in mind when using these boards.
During the booting time, you might notice errors related to the hardware clock. Many Raspberry Pi do not have a hardware clock, or may have one without battery, in which case the behaviour depends on whether you physically cut power or not.
Also, setup-alpine
will adapt the installation to the type of Raspberry Pi you use, which means for example that on a RPI5, you will see hwclock>
service, whereas on a RPI4 it will use swclock
. In doubt, make sure to do the installation on the target hardware.
If you still experience clock errors, add the following line to /etc/chrony/chrony.conf:
makestep 0.1 3
Wireless support with older Alpine images
In Alpine 3.14, the WiFi drivers for the Raspberry Pi were moved from linux-firmware-brcm
to the linux-firmware-cypress
package (source?). Since the images seem to be an outdated version of the former, Wi-Fi will work during installation, but after the first update it will break.
Use the ethernet interface to download the required packages:
apk add linux-firmware-cypress
And reboot.
If you need Wi-Fi, you'll need to download the latest Broadcom drivers to your SD card. (Replace /mnt/sdcard with the correct mount point.)
git clone --depth 1 https://github.com/RPi-Distro/firmware-nonfree.git cp firmware-nonfree/brcm/* /mnt/sdcard/firmware/brcm
Fileystem for boot partition
If you are trapped at the dreaded rainbow screen, with the green led blinking a few times in a row, repeatedly, check the boot partition type.
The rpi2 require fat32 for the boot partition, NOT fat16. Use linux fdisk to set the boot partition type as "c" (for fat32/lba) and set the lba and boot flags for the partition as suggested. Create the boot partition filesystem as fat32 with:
mkdosfs -F 32 /dev/sdX1
See also
- Classic install or sys mode on Raspberry Pi - a variant.
- Raspberry Pi 3 - Setting Up Bluetooth
- Raspberry Pi 3 - Configuring it as wireless access point -AP Mode
- Raspberry Pi 3 - Browser Client
- Linux Router with VPN on a Raspberry Pi
- Create a bootable SDHC from a Mac
- Build custom Raspberry Pi images based on Alpine via Pieman
- Tutorials and Howtos#Raspberry Pi