0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

RPi2Bカーネルビルド手順

Last updated at Posted at 2023-10-30

ハードウェア種別とアーキテクチャ

  • Raspberry Pi Zero(初代)
    ARMv6 である。後のビルド手順での KERNEL 環境変数には
    KERNEL=kernelを指定する。
  • Raspberry Pi2 ModelB(v1.1)
    ARMv7 である。後のビルド手順での KERNEL 環境変数には
    KERNEL=kernel7を指定する。

ビルドの準備と手順

ソースコードの取得

Raspberry Pi OS のソースコードの取得(Github上のソースをシャローコピー)

$ git clone --depth=1 https://github.com/raspberrypi/linux`

x86ホスト上でのクロスコンパイル

ARCH=arm make bcmrpi_defconfi (または bcm2709_defconfig)
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make

RPi上でのビルド手順

ARMv6の場合

KERNEL=kernel
make bcmrpi_defconfig

ARMv7の場合

KERNEL=kernel7
make bcm2709_defconfig

ファイルの導入

Bookworm リリース以降は、 /boot/firmware 配下にファイルを配置するように変更になった。以下リンクの内容を参照のこと。
https://www.raspberrypi.com/documentation/computers/linux_kernel.html
https://www.raspberrypi.com/documentation/computers/config_txt.html
よってビルド完了後のファイル類の配置は、参照先ページの通り /boot/firmware/ディレクトリの配下で合っている。

sudo cp arch/arm/boot/dts/*.dtb /boot/firmware/
sudo cp arch/arm/boot/dts/overlays/*.dtb* /boot/firmware/overlays/
sudo cp arch/arm/boot/dts/overlays/README /boot/firmware/overlays/
sudo cp arch/arm/boot/zImage /boot/firmware/$KERNEL.img

Bookworm以前のリリースでは、ファイル類を/boot/配下に配置するという手順が正しかったが、それはobsoleteになった。

クロスコンパイル用マシン(x86)でのビルド環境の準備

https://www.raspberrypi.com/documentation/computers/linux_kernel.html#cross-compiling-the-kernel
に準じる。

パッケージ導入

Raspberry Pi OS や Ubuntu には以下のパッケージが存在するので、aptで導入する。

sudo apt install git bc bison flex libssl-dev make libc6-dev libncurses5-dev
sudo apt install crossbuild-essential-armhf

古めの書籍に記載されているような、 https://github.com/raspberrypi/tools から clone するという手順は不要である。このリポジトリ上のクロスビルド用ツール(4.xといった古いバージョンのgcc)の代わりに、上記の apt で導入できる arm 用ツール(OSに準じるが、2023年だと gcc 11.x)を使用するからである。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?