User:Zulu Foxtrott/ARM64/Blocks/Host

From Gentoo Wiki
Jump to:navigation Jump to:search

Setting up a cross build environment

Depending on the operating system providing the current command-line environment, instructions on how to install the toolchain for cross compilation differ. Consult the specific operating system's documentation. On debian and the likes gcc-aarch64-linux-gnu and binutils-aarch64-linux-gnu would need to be installed.

In case the host system runs Gentoo, set up sys-devel/crossdev:

Installing crossdev

First create an overlay that crossdev can use:

root #mkdir -p /var/db/repos/localrepo-crossdev/{profiles,metadata}
root #echo 'crossdev' > /var/db/repos/localrepo-crossdev/profiles/repo_name
root #echo 'masters = gentoo' > /var/db/repos/localrepo-crossdev/metadata/layout.conf
root #chown -R portage:portage /var/db/repos/localrepo-crossdev
Note
If the main Portage tree is synchronized by using Git, or any other method with Manifest files that do not include checksums for ebuilds, prevent masked by: corruption errors by appending thin-manifests = true at the bottom of /var/db/repos/localrepo-crossdev/metadata/layout.conf

Then instruct Portage and crossdev to use this overlay create:

FILE /etc/portage/repos.conf/crossdev.conf
[crossdev]
location = /var/db/repos/localrepo-crossdev
priority = 10
masters = gentoo
auto-sync = no

Now install crossdev:

root #emerge --ask sys-devel/crossdev

Installing the cross build toolchain

Install the cross toolchain:

root #crossdev --stable --target aarch64-linux-gnu

Setting environment variables

Finally set the necessary environment variables:

root #export ARCH=arm64

Do not omit the trailing "-":

root #export CROSS_COMPILE=aarch64-linux-gnu-
Important
If the installation to the storage device is interrupted anywhere after this point, it is necessary to set these environment variables again on resume.

Installing required tools

Install GNU Parted and the Device Tree Compiler (dtc). The easiest way to do that depends on the host system's operating system. On debian and descendants one would usually use apt install followed by the package name.

On Gentoo the respective packages - sys-block/parted and sys-apps/dtc - can be installed with:

root #emerge --ask sys-block/parted sys-apps/dtc

Optional: Installing cryptsetup for device encryption

In case the new installation is to be encrypted install cryptsetup version 2.0.0 or newer.

On a Gentoo host system this can be accomplished by installing sys-fs/cryptsetup:

root #emerge --ask sys-fs/cryptsetup

If unsure, verify the version with:

root #cryptsetup --version