본문 바로가기

리눅스 커널의 구조와 원리/2. 라즈베리 파이 설정

[라즈베리 파이 4B] 라즈비안 커널 빌드 (크로스 컴파일러 - cross compile)

32비트 라즈비안 커널

커널 빌드 (arm32_rpi_kernel_build.sh)

#!/bin/bash

KERNEL=kernel8

echo "configure build output path"
TOP_PATH=$( cd "$(dirname "$0")" ; pwd )
OUTPUT="$TOP_PATH/out32"

BUILD_LOG="$TOP_PATH/rpi_build_log.txt"

rpi_build_start_time=`date +%s`

pushd linux > /dev/null

make ARCH=arm O=$OUTPUT CROSS_COMPILE=arm-linux-gnueabihf- bcm2711_defconfig -j16 2>&1
make ARCH=arm O=$OUTPUT CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs  -j16 2>&1 | tee $BUILD_LOG

popd > /dev/null

커널 설치 (arm32_rpi_kernel_install.sh)

#!/bin/bash

echo "configure build output path"
TOP_PATH=$( cd "$(dirname "$0")" ; pwd )
OUTPUT="$TOP_PATH/out32"

sudo make modules_install

sudo cp $OUTPUT/arch/arm/boot/dts/*.dtb /boot/
sudo cp $OUTPUT/arch/arm/boot/dts/overlays/*.dtb* /boot/overlays/
sudo cp $OUTPUT/arch/arm/boot/zImage /boot/kernel7l.img

64비트 라즈비안 커널

커널 빌드 (arm64_rpi_kernel_build.sh)

#!/bin/bash

KERNEL=kernel8

echo "configure build output path"
TOP_PATH=$( cd "$(dirname "$0")" ; pwd )
OUTPUT="$TOP_PATH/out64"

BUILD_LOG="$TOP_PATH/rpi_build_log.txt"

rpi_build_start_time=`date +%s`

pushd linux > /dev/null

make ARCH=arm64 O=$OUTPUT CROSS_COMPILE=aarch64-linux-gnu- bcm2711_defconfig -j16 2>&1
make ARCH=arm64 O=$OUTPUT CROSS_COMPILE=aarch64-linux-gnu- Image modules dtbs  -j16 2>&1 | tee $BUILD_LOG

popd > /dev/null

커널 설치 (arm64_rpi_kernel_install.sh)

#!/bin/bash

echo "configure build output path"
TOP_PATH=$( cd "$(dirname "$0")" ; pwd )
OUTPUT="$TOP_PATH/out64"

BUILD_LOG="$TOP_PATH/rpi_build_log.txt"

rpi_build_start_time=`date +%s`

sudo make modules_install

sudo cp $OUTPUT/arch/arm64/boot/dts/broadcom/*.dtb /boot/
sudo cp $OUTPUT/arch/arm64/boot/dts/overlays/*.dtb* /boot/overlays/
sudo cp arch/arm64/boot/Image.gz /boot/kernel8.img

<From:>
https://www.raspberrypi.com/documentation/computers/linux_kernel.html
#!/bin/bash

echo "configure build output path"
TOP_PATH=$( cd "$(dirname "$0")" ; pwd )
OUTPUT="$TOP_PATH/out64"

BUILD_LOG="$TOP_PATH/rpi_build_log.txt"

rpi_build_start_time=`date +%s`

sudo make modules_install

sudo cp $OUTPUT/arch/arm64/boot/dts/broadcom/*.dtb /boot/
sudo cp $OUTPUT/arch/arm64/boot/dts/overlays/*.dtb* /boot/overlays/
sudo cp arch/arm64/boot/Image.gz /boot/kernel8.img

<From:>
https://www.raspberrypi.com/documentation/computers/linux_kernel.html