Alpine on ARM: Difference between revisions

From Alpine Linux
(→‎Get latest Alpine image: mention tarball extraction)
m (→‎See also: Remove dead link.)
 
(25 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{TOC right}}
{{TOC right}}
{{Style}}
{{Move|ARM SoCs}}
{{Move|ARM SOCs}}
 
== Preparing installation media ==
 
There are no installation images for ARM, since different boards require slightly different builds of u-boot. Hence, preparation steps are a bit more involved than x86_64.
 
The latest images are available [https://alpinelinux.org/downloads/ on the Alpine Linux downloads page].
 
In case the download page provides no specific image for your particular board, download the "Generic ARM" image. armv7 is the most compatible and aarch64 is the best choice for modern ARM SoCs.
 
=== Formating the sd card ===
 
To install Alpine, an SD card is required, and it will be completely wiped while preparing it for use as installation media.
 
Insert the SD card onto the host where you've downloaded the Alpine tarball and find out its devices name with <code>dmesg</code> or <code>fdisk -l</code>.
 
{{Tip|Useful hints about basic identification of and access to your SD card or USB target device, may also be found in the general instructions at [[Installation]].}}
 
Create a partition in the SD card. The usual choice is to use <code>doas fdisk /dev/sdX</code>. Care must be taken when creating the partition; it should never overlap with the u-boot (which will be set up in the following step). It is recommended to use <code>start: 32768</code> as a safe choice when creating the partition. Make sure that the partition is also marked as bootable.
 
It is also recommended to use FAT32, since ext4 is sometimes problematic with GRUB2, so set the partition type to <code>W95 FAT32 (LBA)</code>.
 
Once the partition has been created, it needs to be formatted. Use, for example: <code>mkfs.vfat /dev/sdX1</code>
 
=== Copying installation files onto the sd card ===


(Parts of this page are still incomplete and might even need corrections.)
Now extract the downloaded tarball into the SD card:


doas mount /dev/sdX1 /mnt
cd /mnt
doas tar -xf $HOME/downloads/alpine-uboot-3.18.2-aarch64.tar.gz


==Supported SoCs==
=== Installing u-boot onto the SD card ===


Beyond the Raspberry Pi images, Alpine gets compiled with support files for so many and even formidable ARM SoCs, that it can be useful to find out about a particular chipset's support by refining (i.e. filtering for for "*<some-board-or-SoC-identifying-string>*.dtb" file), starting from the results of searching for all "*.dtb" files in the package database.
Finally, u-boot needs to be installed into the SD card. The exact steps vary per board. The following example installs u-boot for a pinebook-pro:


For example, by refining the following search in the current "edge" release:
# Copy the U-Boot TPL/SPL
doas dd if=u-boot/pinebook-pro-rk3399/idbloader.img of=/dev/sdb bs=512 seek=64 conv=notrunc
# Copy u-boot.itb itself
doas dd if=u-boot/pinebook-pro-rk3399/u-boot.itb of=/dev/sdb bs=512 seek=16384 conv=notrunc


DTB-files in the current edge branch:
For rk3399-based boards, these steps should be quite similar. Other boards are an exercise left to the reader.
https://pkgs.alpinelinux.org/contents?repo=main&file=*.dtb&branch=edge


==Installing Alpine on supported Boards==
=== Installing Alpine ===


===== Get latest Alpine image =====
Insert the SD card into the ARM board, and turn it on. At this point, you should continue the general installation process as described in the [[Installation#Installation Step Details]].
The latest images are available at: https://alpinelinux.org/downloads/


In case the download page provides no specific image for your particular board, download the "Generic ARM" image.
{{Note|Installing packages with `apk` fails with a certificate warning if the system time is too far off, i.e. by default on boards without an internal real time clock (RTC). So make sure to first adjust the clock properly.}}


The *.tar.gz files ("tarballs") need to be extracted to some boot media device.
== Supported SoCs ==


(Useful hints about basic identification of and access to your sdcard or usb target device, may also be found in the general instructions at https://wiki.alpinelinux.org/wiki/Installation.)
Alpine is compiled with support files for so many formidable SoCs — besides the Raspberry Pi — that to find out about a particular chipset's support it can be useful to refine the search for all <code>*.dtb</code> files in the package database (i.e. filter for "<code>*<some-board-or-SoC-identifying-string>*.dtb</code>" file).


After copying the files onto an usb-stick or sdcard, some devices, typically those featuring an internal flash chip with a modern bootloader and boot menu, or basic boot selection jumpers, may allow to boot the media right away.
For example, by refining the following search in the current "edge" release:


However, if your device (even with its internal bootloader firmware, if any, updated to the latest version) is not able to boot the media as is, then some further preparation of the boot media (according to the requirements of your device) is needed to allow booting.
DTB-files in the current edge branch:
https://pkgs.alpinelinux.org/contents?repo=main&file=*.dtb&branch=edge


===== Preparation of adjusted boot media in general =====
Fully supported boards are those for which there is a working bootloader shipped in the download.


Here we are using an sdcard and the "Wandboard" as a rather genric example. If your particular board happens to require something to boot Alpine not mentioned here in any more specific documents link below, please consider adding the missing info, e.g. by adding to the links below.
== Board-specific notes for supported boards==


Start by extracting the archive somewhere.
=== Wandboard ===


Then install the SoCs particular boot loader(s) to the places on the sdcard where the device expects them, e.g. the SPL and u-boot.img (this differs between boards):
Follow the steps above on [[Alpine_on_ARM#Preparing installation media|Preparing installation media]]. To install u-boot into the SD card, use:


As user root, and from the location of the extracted image files, do a direct disk write using as input file the SPL from the extracted Alpine image, and the sdcard (here /dev/sdX) as output file node (the target device):
  dd if=u-boot/wandboard/SPL of=/dev/sdX seek=1 bs=1k
  dd if=u-boot/wandboard/SPL of=/dev/sdX seek=1 bs=1k
Similarly, for the u-boot.img:
  dd if=u-boot/wandboard/u-boot.img of=/dev/sdX seek=69 bs=1k
  dd if=u-boot/wandboard/u-boot.img of=/dev/sdX seek=69 bs=1k


After creating a partition on the sd-card, behind the boot loaders (e.g. with fdisk) and mounting it, copy the folders apks/, boot/, efi/, extlinux/, and u-boot/ to the sd-card partition. (I'm not sure if all folders are needed).
Finally, put the SD card in the Wandboard and boot it with a serial console connected. The board should now boot from the SD card.


Finally, put the sd-card in the Wandboard and boot it with a serial console connected.
=== Pine64 A64 LTS ===


The board should now boot from the sd-card. When the prompt asks for a login, you can follow https://wiki.alpinelinux.org/wiki/Installation to run setup-alpine as usual.
Use the "Generic ARM aarch64" image. Install u-boot using:
 
dd if=u-boot-sunxi-with-spl.bin of=/dev/SDX bs=1024 seek=8</code>
 
Decompress (<code>gunzip</code>) the kernel image (<code>boot/vmlinuz-lts</code>) as the device's u-boot can't boot from a compressed kernel


=== More specific guides ===
=== More specific guides ===


* [[DIY Fully working Alpine Linux for Allwinner and Other ARM SOCs]]
* [[DIY Fully working Alpine Linux for Allwinner and Other ARM SOCs]]
* [[Raspberry_Pi]]
* [[Raspberry Pi]]
* [[Raspberry_Pi_4_-_Persistent_system_acting_as_a_NAS_and_Time_Machine]]
* [[Raspberry Pi 4 - Persistent system acting as a NAS and Time Machine]]
* [[Odroid-C2]]
* [[Odroid-C2]]
* [https://github.com/rickyrockrat/nanopi-alpine NanoPi Neo build script]
* [https://github.com/rickyrockrat/nanopi-alpine NanoPi Neo build script]
* [[A20 OLinuXino Lime2]]
* [[A20 OLinuXino Lime2]]


==Not fully supported boards==
== Installing Alpine on boards without full support ==


If you have e.g. an armv6/armv7 board that is not fully supported, but whose SoC is already supported by the mainline kernel and uboot, then it's still possible to install Alpine. It may involve a couple more manual steps, though.
{{Style}}


If you have, for example, an armv6/armv7 board that is not fully supported, but whose SoC is already supported by the mainline kernel and uboot, then it's still possible to install Alpine. It may involve a couple more manual steps.


===Requirements===
===Requirements===
Line 76: Line 107:




====Storage====
===Storage===


One can load uboot from the following block devices if it's supported.
One can load uboot from the following block devices if it's supported.
* NAND
* NAND
* eMMC
* eMMC
Line 85: Line 117:




====Power on====
===Power on===


Some SoCs need both SPL and uboot, you need to check uboot for your board. Most (if not all) boards boots from the internal storage first (either NAND or eMMC) you will have to check documentation of your board if you wish to boot the SPL/uboot from SD/USB.
Some SoCs need both SPL and uboot, you need to check uboot for your board. Most (if not all) boards boots from the internal storage first (either NAND or eMMC) you will have to check documentation of your board if you wish to boot the SPL/uboot from SD/USB.
Line 94: Line 126:




====Partitioning====
===Booting Linux kernel===
 
Either DOS or GPT patitions should work. Start of the first partition should be on block 2048 so there is space for SPL/uboot and marked bootable (with
the MBR bootable flag, or GPT legacy_bios_bootable attribute).
* SPL starts at block 64 (please consult the docs for your board)
* uboot starts at block 256 (please consult the docs for your board)
Just dd SPL and boot with the correct offset to the media you wish to boot
 
====Booting Linux kernel====


* uboot uses extlinux.conf file to locate the kernel/initramfs/... just like syslinx, you need to put that file on the partitions which is marked bootable in the /boot directory
* uboot uses extlinux.conf file to locate the kernel/initramfs/... just like syslinx, you need to put that file on the partitions which is marked bootable in the /boot directory
Line 115: Line 139:
</pre>
</pre>


==Using QEMU==
 
== Using QEMU ==


<pre>
<pre>
Line 122: Line 147:




 
== See also ==
== References ==


* [http://www.armadeus.org/wiki/index.php?title=Kernel-with-device-tree dtb (Device Tree Binary)]
* [http://www.armadeus.org/wiki/index.php?title=Kernel-with-device-tree dtb (Device Tree Binary)]
* [https://forum.odroid.com/viewtopic.php?t=30459 Odroid-C2] 2018 ''([https://archlinuxarm.org/platforms/armv8/amlogic/odroid-c2 ARMv8, AArch64];  [https://forum.odroid.com/viewtopic.php?f=138&t=32608 Alpine Linux custom build])''
* [https://forum.odroid.com/viewtopic.php?t=30459 Odroid-C2] 2018 ''([https://archlinuxarm.org/platforms/armv8/amlogic/odroid-c2 ARMv8, AArch64];  [https://forum.odroid.com/viewtopic.php?f=138&t=32608 Alpine Linux custom build])''
* [https://cusdeb.com/ CusDeb.com] - bootstrap SD-card images for single-board computers online; ''([https://github.com/tolstoyevsky/pieman Pieman])''
* [https://github.com/tolstoyevsky/pieman Pieman]
* [https://kernelci.org/soc/ <s>Available</s> SoCs]
* [https://kernelci.org/soc/ <s>Available</s> SoCs]


[[Category:Hardware]]
[[Category:Hardware]]
[[category:ARM]]
[[category:ARM]]

Latest revision as of 20:01, 20 January 2024

This page is proposed for moving ...

It should be renamed to ARM SoCs. (Discuss)

Preparing installation media

There are no installation images for ARM, since different boards require slightly different builds of u-boot. Hence, preparation steps are a bit more involved than x86_64.

The latest images are available on the Alpine Linux downloads page.

In case the download page provides no specific image for your particular board, download the "Generic ARM" image. armv7 is the most compatible and aarch64 is the best choice for modern ARM SoCs.

Formating the sd card

To install Alpine, an SD card is required, and it will be completely wiped while preparing it for use as installation media.

Insert the SD card onto the host where you've downloaded the Alpine tarball and find out its devices name with dmesg or fdisk -l.

Tip: Useful hints about basic identification of and access to your SD card or USB target device, may also be found in the general instructions at Installation.

Create a partition in the SD card. The usual choice is to use doas fdisk /dev/sdX. Care must be taken when creating the partition; it should never overlap with the u-boot (which will be set up in the following step). It is recommended to use start: 32768 as a safe choice when creating the partition. Make sure that the partition is also marked as bootable.

It is also recommended to use FAT32, since ext4 is sometimes problematic with GRUB2, so set the partition type to W95 FAT32 (LBA).

Once the partition has been created, it needs to be formatted. Use, for example: mkfs.vfat /dev/sdX1

Copying installation files onto the sd card

Now extract the downloaded tarball into the SD card:

doas mount /dev/sdX1 /mnt
cd /mnt
doas tar -xf $HOME/downloads/alpine-uboot-3.18.2-aarch64.tar.gz

Installing u-boot onto the SD card

Finally, u-boot needs to be installed into the SD card. The exact steps vary per board. The following example installs u-boot for a pinebook-pro:

# Copy the U-Boot TPL/SPL
doas dd if=u-boot/pinebook-pro-rk3399/idbloader.img of=/dev/sdb bs=512 seek=64 conv=notrunc
# Copy u-boot.itb itself
doas dd if=u-boot/pinebook-pro-rk3399/u-boot.itb of=/dev/sdb bs=512 seek=16384 conv=notrunc

For rk3399-based boards, these steps should be quite similar. Other boards are an exercise left to the reader.

Installing Alpine

Insert the SD card into the ARM board, and turn it on. At this point, you should continue the general installation process as described in the Installation#Installation Step Details.

Note: Installing packages with `apk` fails with a certificate warning if the system time is too far off, i.e. by default on boards without an internal real time clock (RTC). So make sure to first adjust the clock properly.

Supported SoCs

Alpine is compiled with support files for so many formidable SoCs — besides the Raspberry Pi — that to find out about a particular chipset's support it can be useful to refine the search for all *.dtb files in the package database (i.e. filter for "*<some-board-or-SoC-identifying-string>*.dtb" file).

For example, by refining the following search in the current "edge" release:

DTB-files in the current edge branch: https://pkgs.alpinelinux.org/contents?repo=main&file=*.dtb&branch=edge

Fully supported boards are those for which there is a working bootloader shipped in the download.

Board-specific notes for supported boards

Wandboard

Follow the steps above on Preparing installation media. To install u-boot into the SD card, use:

dd if=u-boot/wandboard/SPL of=/dev/sdX seek=1 bs=1k
dd if=u-boot/wandboard/u-boot.img of=/dev/sdX seek=69 bs=1k

Finally, put the SD card in the Wandboard and boot it with a serial console connected. The board should now boot from the SD card.

Pine64 A64 LTS

Use the "Generic ARM aarch64" image. Install u-boot using:

dd if=u-boot-sunxi-with-spl.bin of=/dev/SDX bs=1024 seek=8

Decompress (gunzip) the kernel image (boot/vmlinuz-lts) as the device's u-boot can't boot from a compressed kernel

More specific guides

Installing Alpine on boards without full support

This material needs wiki syntax or style improvements ...

Please feel free to help us clean it up.

If you have, for example, an armv6/armv7 board that is not fully supported, but whose SoC is already supported by the mainline kernel and uboot, then it's still possible to install Alpine. It may involve a couple more manual steps.

Requirements

  • Alpine's forked uboot to support tarballs (fabled?)
  • serial console
  • crosscompiler/toolchain if you can not compile natively


The embedded world

A lot of the SoCs have their own way of doing things, although they use uboot and Linux kernel but often they are heavily modified to suit easy flashing of "ROMs" or other unknown reasons, e.g. Rockchip's notion "partition" are neither DOS nor GPT partitions. Here, we will try to install Alpine in a more standard way, like on the x86 platform, with either DOS or GPT partitions. To boot this, you will most likely have to install/flash the mainline uboot, which can be non-destructive if you can load it from external storage.


Storage

One can load uboot from the following block devices if it's supported.

  • NAND
  • eMMC
  • SD card
  • USB


Power on

Some SoCs need both SPL and uboot, you need to check uboot for your board. Most (if not all) boards boots from the internal storage first (either NAND or eMMC) you will have to check documentation of your board if you wish to boot the SPL/uboot from SD/USB.

One can view SPL+uboot as BIOS and boot-loader on PC. Think that you could put the BIOS on an external storage :D

Once you have loaded the "standard" uboot, things are more or less like on x86.


Booting Linux kernel

  • uboot uses extlinux.conf file to locate the kernel/initramfs/... just like syslinx, you need to put that file on the partitions which is marked bootable in the /boot directory
  • there should be an extra line "FDTDIR" which points to the DTBs

e.g.

label Fedora (3.17.0-0.rc4.git2.1.fc22.armv7hl) 22 (Rawhide)
	kernel /boot/vmlinuz-3.17.0-0.rc4.git2.1.fc22.armv7hl
	append ro root=UUID=8eac677f-8ea8-4270-8479-d5ddbb797450 console=ttyS0,115200n8 LANG=en_US.UTF-8 drm.debug=0xf
	fdtdir /boot/dtb-3.17.0-0.rc4.git2.1.fc22.armv7hl
	initrd /boot/initramfs-3.17.0-0.rc4.git2.1.fc22.armv7hl.img


Using QEMU

qemu-system-arm -M vexpress-a9 -kernel zImage -initrd initramfs-grsec -dtb vexpress-v2p-ca9.dtb -hda hda.img -serial stdio


See also