Linux kernel cross compile arm64 on x86_64 machine

Overview

x86_64 λ¨Έμ‹ μ—μ„œ arm64 λ¦¬λˆ…μŠ€ 컀널을 λΉŒλ“œν•©λ‹ˆλ‹€.

User mode Linux

λ¦¬λˆ…μŠ€ 컀널 μ†ŒμŠ€ μ½”λ“œλ₯Ό ν΄λ‘ ν•©λ‹ˆλ‹€.

버전 선택은 λ§ˆμŒλŒ€λ‘œ ν•˜μ‹œλ©΄ λ©λ‹ˆλ‹€.

μ €λŠ” LTS λ˜λŠ” SLTS λ₯Ό 더 μ„ ν˜Έν•©λ‹ˆλ‹€.

Github λ ˆν¬μ§€ν† λ¦¬κ°€ μ•„λ‹ˆλΌ

kernel.org Git μ—μ„œ ν΄λ‘ ν•˜λŠ” μ΄μœ λŠ” λ§ˆμ΄λ„ˆ λ¦΄λ¦¬μ¦ˆμ— λŒ€ν•œ 컀밋도 λ“€μ–΄κ°€κΈ° λ•Œλ¬Έμ—,

ν•΄λ‹Ή λ¦΄λ¦¬μ¦ˆμ— μ΅œμ‹  λ³€κ²½ 사항을 확인할 수 μžˆμŠ΅λ‹ˆλ‹€.

Linux kernel source clone

1
2
3
4
5
git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git

# 5.10.x latest (SLTS)
git tag | grep "5.10."
git checkout 5.10.19

Ubuntu

1
2
3
4
5
# arch setup & debug symbol
sudo apt -y install gcc-aarch64-linux-gnu cscope libssl-dev \
autoconf automake autotools-dev curl libmpc-dev libmpfr-dev \
libgmp-dev gawk build-essential bison flex texinfo \
gperf libtool patchutils bc zlib1g-dev libexpat-dev

μ΅œμ‹  λ²„μ „μ˜ arm64 크둜슀 컴파일러λ₯Ό λ°›κ³  μ‹ΆμœΌμ‹œλ©΄

aarch64-linux-gnu-gcc λ§ν¬μ—μ„œ 받을 수 μžˆμŠ΅λ‹ˆλ‹€.

arm64 에 λ§žμΆ°μ„œ λΉŒλ“œ ν”Œλž˜κ·Έλ₯Ό μ„€μ •ν•©λ‹ˆλ‹€.

setup.sh

1
2
3
4
5
6
7
8
9
cat > setup.sh

export ARCH=arm64
# export CROSS_COMPILE=μž…λ§›λŒ€λ‘œ..
export CROSS_COMPILE=aarch64-linux-gnu-

# ctrl + d

source setup.sh

그럼 이제 λΉŒλ“œλ₯Ό ν•©λ‹ˆλ‹€.

make

1
2
3
4
5
6
7
# defulat configuration file create
make defconfig

make -j8

# source tagging
make -j8 cscope tags

이제 arm64 컀널 μ†ŒμŠ€ 뢄석을 ν•  μ€€λΉ„κ°€ μ™„λ£Œλ˜μ—ˆμŠ΅λ‹ˆλ‹€.