Raspberry Pi: Difference between revisions
m (→Installation) |
|||
(161 intermediate revisions by 56 users not shown) | |||
Line 1: | Line 1: | ||
[[ | {{TOC right}} | ||
This | |||
Raspberry Pi devices are well supported on Alpine Linux by default: users can follow generic [[Installation| standard procedures]] for install and setup. However this page enlightens few specific information like [[#Preparing_for_the_installation| install media creation]], [[#Post_Installation| post-install]] customization and [[#Troubleshooting| troubleshooting]]. | |||
== Considerations for choosing install modes [[Installation#Installation_Overview|(diskless/data disk/system disk)]] == | |||
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]] may be 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). [[Alpine local backup|Alpine Local Backup (lbu)]] utility is used to save limited amount of local files, and system settings. | |||
System disk mode installation may be 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) | |||
System disk mode with [[OverlayFS#Immutable_root_with_tmpfs_overlay|Immutable root option]] can also be a solution to keep whole system on read-only media (lower RAM requirement than diskless mode which loads whole system in RAM) while avoiding SD wear as runtime files are mapped to ''tmpfs'' in RAM (check limitations). | |||
== 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== | |||
=== Raspberry Pi Imager === | |||
[https://www.raspberrypi.com/news/raspberry-pi-imager-imaging-utility Raspberry Pi Imager] is a GUI utility for creating distributions install media for Pi devices in few clicks: it takes care of downloading, partitioning and formatting. Pre-built binaries are available for [https://github.com/raspberrypi/rpi-imager/releases Linux/macOS/Windows].<br> | |||
Alpine Linux is listed under '''Other general-purpose OS''' section from '''Choose OS''' tab. | |||
This utility can also be used from an Alpine linux system: install the {{pkg|rpi-imager}} package from <code>edge/testing</code> repository. To launch the utility in graphical mode issue the command: {{Cmd|rpi-imager}} | |||
'''--cli''' option is also available. For complete usage guide, check out the <code>rpi-imager(1)</code> manpages, which you can [[install]] with the {{Pkg|rpi-imager-doc}} package. | |||
{{Note|Raspberry Pi Imager will only create a minimum-sized FAT32 partition of about 100MB. If you need a bigger partition (i.e. with more room for diskless packages and cache), you may want to grow that partition afterwards, or follow the [[#Manual method|Manual method]] below.}} | |||
=== Manual method === | |||
Alternatively, image or tarball may be downloaded, and SD card media formatted and prepared as per below: | |||
* [https://alpinelinux.org/downloads/ Download] the Alpine Linux image or tarball for Raspberry Pi . Use the compability list above when choosing image/tarball 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] or [https://gparted.org gparted]: 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>.) | |||
*: {{Tip|to reduce SD wear risk, it is advised to keep at least 10% of capacity as unallocated space. If media was previously partitioned at full capacity, running <code>blkdiscard /dev/mmcblk0</code> makes sure to [https://man7.org/linux/man-pages/man8/blkdiscard.8.html discard device sectors] before re-partitioning.}} | |||
*: {{warning|Do not use the volume label <code>boot</code> for the fat32 partition. 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 the volume label <code>boot</code> for the fat32 partition.}} | |||
* Extract the tarball to the root of the bootable FAT32 partition. | |||
Once install media is prepared, proceed to [[Installation#Base_configuration| standard procedures]] for install and initial base setup. | |||
{{Tip|To install Alpine Linux on a pi without keyboard, mouse & display, additional preparatory steps are available at [[Installation on a headless host|headless Installation]] page.}} | |||
After install and reboot, check notes below for further customization and [[#Troubleshooting| troubleshooting]]. | |||
== Post Installation == | |||
=== Customize ''config.txt'' and ''usercfg.txt'' === | |||
Instead of the BIOS found on a conventional PC, Raspberry Pi devices use a configuration file called '''config.txt'''. The GPU reads '''config.txt''' before the Arm CPU and Linux initialise. | |||
It is recommended to create a custom '''usercfg.txt''' file on boot partition to configure low-level system settings, as '''config.txt''' may be replaced during bootloader/system upgrades. Available settings information can be found [https://www.raspberrypi.com/documentation/computers/config_txt.html here]. However, few [https://www.raspberrypi.com/documentation/computers/config_txt.html#include settings] can only be set within '''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, better supported ''Linux DRM-KMS driver'' may be used (see setup[[#Linux_Kernel_Graphics_Modes| below]]). | |||
* 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 Zeros/A/A+/3A+/4B/400/5/500/CMs may be configured as USB serial-gadget (i.e. console access for setup) or ethernet-gadget networking: add <code>dtoverlay=dwc2,dr_mode=peripheral</code> in '''usercfg.txt''' and <code>modules=g_cdc</code> in '''cmdline.txt''' | |||
* To maximize available CPU memory if not requiring extra GPU features (i.e. headless/CLI use-cases), cut-down bootloader may be installed with {{Pkg|raspberrypi-bootloader-cutdown|arch=}} package, and activated by adding <code>gpu_mem=16</code> in '''config.txt''' (setting may be wiped after bootloader package update). | |||
=== Update the System === | |||
After installation, make sure your system is up-to-date: | |||
{{cmd|apk update | |||
apk upgrade}} | |||
{{Note| If on diskless mode: | |||
* don't forget to save changes after any system or configuration files update with <code>lbu commit -d</code> | |||
* in order to upgrade the kernel, follow [[Diskless_Mode#Upgrading_a_diskless_system| update-kernel]] script procedure.}} | |||
=== Linux Kernel Graphics Modes === | |||
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''': | |||
# 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 [https://www.raspberrypi.com/documentation/computers/legacy_config_txt.html#legacy-video-options options]. | |||
Install the Mesa drivers (Pi4 and Pi5):{{cmd|apk add {{pkg|mesa-dri-gallium|arch=a*}}}} | |||
=== 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 === | |||
{{Note|The below instructions to get picam to work with Pi Zero 2 W model has been tested in [[Classic install or sys mode on Raspberry Pi|sys mode]] only.}} | |||
# Upgrade to [[Repositories#Upgrading_to_edge|edge]] version as {{pkg|rpicam-apps|arch=}} 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|arch=}} 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}} | |||
== Custom installation instructions == | |||
* To switch a Diskless installation to a fully disk-based installation refer [[Classic_install_or_sys_mode_on_Raspberry_Pi#Convert diskless to sys mode|Convert diskless to sys mode]]. | |||
* An alternate approach [[OverlayFS#Loopback image with overlayfs|using loopback image with overlayfs]] for memory constrained Raspberry Pi models (3A+,Pi0) with only 512M of RAM running Diskless mode. | |||
=== Netboot === | |||
The Raspberry Pi 4 bootloader can be configured to [https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#raspberry-pi-4-bootloader-configuration boot from the network]. Configure the bootloader with at least | |||
{{cmd|<nowiki>BOOT_ORDER=0xf142 | |||
TFTP_PREFIX=1</nowiki>}} | |||
and optionally also {{cmd|<nowiki>TFTP_IP=x.x.x.x</nowiki>}} where <code>x.x.x.x</code> is the IP address of your TFTP server. | |||
If not configuring <code>TFTP_IP</code> 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: <code>PXEClient:Arch:00000:UNDI:002001</code> | |||
# Filename: <code>/</code> | |||
The minimal set of files that your TFTP server needs to host are: | |||
# <code>bcm2711-rpi-4-b.dtb</code> (from [https://raw.githubusercontent.com/raspberrypi/firmware/master/boot/bcm2711-rpi-4-b.dtb raspberrypi/firmware/master/boot/bcm2711-rpi-4-b.dtb]) | |||
# <code>cmdline.txt</code> (see below) | |||
# <code>config.txt</code> (see below) | |||
# <code>fixup4.dat</code> (from [https://raw.githubusercontent.com/raspberrypi/firmware/master/boot/fixup4.dat raspberrypi/firmware/master/boot/fixup4.dat], alternatively <code>fixup4cd.dat</code> for the cut down version) | |||
# <code>initramfs-rpi4</code> (from [https://dl-cdn.alpinelinux.org/alpine/edge/releases/aarch64/netboot/initramfs-rpi4 alpine/edge/releases/aarch64/netboot/initramfs-rpi4]) | |||
# <code>start4.elf</code> (from [https://raw.githubusercontent.com/raspberrypi/firmware/master/boot/start4.elf raspberrypi/firmware/master/boot/start4.elf], alternatively <code>start4cd.elf</code> for the cut down version) | |||
# <code>vmlinuz-rpi4</code> (from [https://dl-cdn.alpinelinux.org/alpine/edge/releases/aarch64/netboot/vmlinuz-rpi4 alpine/edge/releases/aarch64/netboot/vmlinuz-rpi4]) | |||
<code>config.txt</code>: | |||
{{cmd|<nowiki>[pi4] | |||
kernel=vmlinuz-rpi4 | |||
initramfs initramfs-rpi4 | |||
arm_64bit=1 | |||
</nowiki>}} | |||
<code>cmdline.txt</code>: | |||
{{cmd|<nowiki>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</nowiki>}} | |||
Instead of using the <nowiki>http://dl-cdn.alpinelinux.org/alpine/edge/releases/aarch64/netboot/</nowiki> 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 <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|arch=}} 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, as default CPU/GPU RAM split depends on Pi models and activated settings (audio, camera, video drivers, etc). To find out how your system is actually split, use <Code>vcgencmd</Code> utility from the {{pkg|raspberrypi-utils-vcgencmd|arch=}} package as follows:{{Cmd|<nowiki># vcgencmd get_mem gpu | |||
# vcgencmd get_mem arm</nowiki>}} | |||
To modify the memory allocation refer to [[#Customize config.txt|Customize config.txt]] section. | |||
=== 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' === | |||
While running Raspberry Pi models(3A+,Pi0) with only 512M of RAM, a fresh Alpine Linux installation in Diskless mode will only leave around 200M for tmpfs root. Allocation may be [[Diskless_Mode| tuned]] or alternative install modes shall be [[#Considerations_for_choosing_install_modes_(diskless/data_disk/system_disk)| considered]]. | |||
=== 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 === | |||
In Alpine 3.14, the WiFi drivers for the Raspberry Pi were moved from <code>linux-firmware-brcm</code> to the <code>linux-firmware-cypress</code> 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: | |||
{{cmd|apk add {{pkg|linux-firmware-cypress|arch=a*}}}} | |||
And reboot. | |||
If you need Wi-Fi, you'll need to [https://github.com/RPi-Distro/firmware-nonfree/tree/master/brcm 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 | |||
=== Filesystem 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]] | |||
* [[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]] | |||
* [[OverlayFS]] | |||
* Build custom Raspberry Pi images based on Alpine via [https://github.com/tolstoyevsky/pieman Pieman] | |||
* [[Tutorials and Howtos#Raspberry Pi]] | |||
[[Category:Installation]] | |||
[[Category: Raspberry]] |
Latest revision as of 06:50, 20 April 2025
Raspberry Pi devices are well supported on Alpine Linux by default: users can follow generic standard procedures for install and setup. However this page enlightens few specific information like install media creation, post-install customization and troubleshooting.
Considerations for choosing install modes (diskless/data disk/system disk)
For scenarios where there is not expected to be significant changes to disk after setup (like running a static HTTP server), diskless mode may be 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). Alpine Local Backup (lbu) utility is used to save limited amount of local files, and system settings.
System disk mode installation may be 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)
System disk mode with Immutable root option can also be a solution to keep whole system on read-only media (lower RAM requirement than diskless mode which loads whole system in RAM) while avoiding SD wear as runtime files are mapped to tmpfs in RAM (check limitations).
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
Raspberry Pi Imager
Raspberry Pi Imager is a GUI utility for creating distributions install media for Pi devices in few clicks: it takes care of downloading, partitioning and formatting. Pre-built binaries are available for Linux/macOS/Windows.
Alpine Linux is listed under Other general-purpose OS section from Choose OS tab.
This utility can also be used from an Alpine linux system: install the rpi-imager package from edge/testing
repository. To launch the utility in graphical mode issue the command:
rpi-imager
--cli option is also available. For complete usage guide, check out the rpi-imager(1)
manpages, which you can install with the rpi-imager-doc package.
Manual method
Alternatively, image or tarball may be downloaded, and SD card media formatted and prepared as per below:
- Download the Alpine Linux image or tarball for Raspberry Pi . Use the compability list above when choosing image/tarball 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 or gparted: 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
.)- Tip: to reduce SD wear risk, it is advised to keep at least 10% of capacity as unallocated space. If media was previously partitioned at full capacity, running
blkdiscard /dev/mmcblk0
makes sure to discard device sectors before re-partitioning. - Warning: Do not use the volume label
boot
for the fat32 partition. Due to an upstream bug, kernel/initramfs cannot be loaded from subdirectory with same name as volume label. Since kernel is installed toboot/
folder in Alpine Linux, do not use the volume labelboot
for the fat32 partition.
- Extract the tarball to the root of the bootable FAT32 partition.
Once install media is prepared, proceed to standard procedures for install and initial base setup.
After install and reboot, check notes below for further customization and troubleshooting.
Post Installation
Customize config.txt and usercfg.txt
Instead of the BIOS found on a conventional PC, Raspberry Pi devices use a configuration file called config.txt. The GPU reads config.txt before the Arm CPU and Linux initialise.
It is recommended to create a custom usercfg.txt file on boot partition to configure low-level system settings, as config.txt may be replaced during bootloader/system upgrades. Available settings information can be found here. However, few settings can only be set within config.txt, and will have no effect when specified in usercfg.txt (e.g. gpu_mem
).
Some interesting values include:
Contents of usercfg.txt
- 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, better supported Linux DRM-KMS driver may be used (see setup 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 Zeros/A/A+/3A+/4B/400/5/500/CMs may be configured as USB serial-gadget (i.e. console access for setup) or ethernet-gadget networking: add
dtoverlay=dwc2,dr_mode=peripheral
in usercfg.txt andmodules=g_cdc
in cmdline.txt - To maximize available CPU memory if not requiring extra GPU features (i.e. headless/CLI use-cases), cut-down bootloader may be installed with raspberrypi-bootloader-cutdown package, and activated by adding
gpu_mem=16
in config.txt (setting may be wiped after bootloader package update).
Update the System
After installation, make sure your system is up-to-date:
apk update apk upgrade
- don't forget to save changes after any system or configuration files update with
lbu commit -d
- in order to upgrade the kernel, follow update-kernel script procedure.
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
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
- 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
Custom installation instructions
- To switch a Diskless installation to a fully disk-based installation refer Convert diskless to sys mode.
- An alternate approach using loopback image with overlayfs for memory constrained Raspberry Pi models (3A+,Pi0) with only 512M of RAM running Diskless mode.
Netboot
The Raspberry Pi 4 bootloader can be configured to boot from the network. 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, as default CPU/GPU RAM split depends on Pi models and activated settings (audio, camera, video drivers, etc). 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
To modify the memory allocation refer to Customize config.txt section.
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'
While running Raspberry Pi models(3A+,Pi0) with only 512M of RAM, a fresh Alpine Linux installation in Diskless mode will only leave around 200M for tmpfs root. Allocation may be tuned or alternative install modes shall be considered.
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
Filesystem 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
- 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
- OverlayFS
- Build custom Raspberry Pi images based on Alpine via Pieman
- Tutorials and Howtos#Raspberry Pi