1
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?

Linuxのリアルタイムカーネル(PREEMPT_RT)を自己ビルド

Posted at

6.12カーネルからリアルタイムカーネル(PREEMPT_RT)がサポートされるようになりました。時代はリアルタイムではないか?ということで、それ以後リアルタイムを有効にしてカーネルを自己ビルドし、動作を試していましたが、ディスプレイの輝度調節ができない、音が出ない、wifiが使えない等、クライアントとしてはうまく動作しない状態が続いていました。6.16カーネルになってようやく動作しているかな、という状態になったので、記事にします。

ビルド環境

  • OS: Ubuntu 22.04.5 LTS
  • コンパイラ: clang 19.1.3

動作環境

  • OS: Debian bookworm 12.11
  • PCハード: MSI Prestige 13Evo A12M/MS-13Q1

準備

.configの雛型などが得られるためkojiからソースを取得します。

% wget https://kojipkgs.fedoraproject.org//packages/kernel/6.16.0/200.fc42/src/kernel-6.16.0-200.fc42.src.rpm

ソース展開

作業ディレクトリを掘って作業を進めます。

% mkdir x; cd x
% rpm2cpio ../kernel-6.16.0-200.fc42.src.rpm |cpio -id
% mkdir y; cd y
% tar Jxf ../linux-6.16.tar.xz
% cd linux-6.16
% cp ../../Makefile.rhelver .
% cp ../../kernel-x86_64-rt-fedora.config .config
% patch -p1 < ../../patch-6.16-redhat.patch
% yes "" | make CC=clang oldconfig

menuconfig

ここで、自己ビルドのカーネルを実行した際、/var/log/kern.logに以下のメッセージが出てディスプレイの輝度調節ができずサウンドも出ないためmake menuconfigします。

Aug 12 12:32:12 testpc kernel: xe 0000:00:02.0: Your graphics device 46a6 is not officially supported
by xe driver in this kernel version. To force Xe probe,
use xe.force_probe='46a6' and i915.force_probe='!46a6'
module parameters or CONFIG_DRM_XE_FORCE_PROBE='46a6' and
CONFIG_DRM_I915_FORCE_PROBE='!46a6' configuration options.

メニューに入り、以下を辿ります。
Device Drivers ---> Graphics support ---> Direct Rendering Manager (XFree86 4.1.0 and higher DRI support) ---> Force probe xe for selected Intel hardware IDs
xe4.png

画像のように「46a6」を入力して.configを保存します。(tabキーでカーソルが移動します)

ビルド

% make CC=clang -j32 bindeb-pkg LOCALVERSION=-my KDEB_PKGVERSION=$(make kernelversion) > log 2>&1 &

カーネルのインストール

ビルドしたディクトリの上位のディレクトリにカーネルのdebファイルができるので(適宜実行環境にコピーして)インストールします。

# dpkg -i linux-headers-6.16.0-my_6.16.0_amd64.deb linux-image-6.16.0-my_6.16.0_amd64.deb

ファームウェア(無線LAN)

2024年のモノを使っています(2024年に作業したため)が2025年のモノでもたぶんOKです。

% wget http://ftp.jp.debian.org/debian/pool/non-free-firmware/f/firmware-nonfree/firmware-iwlwifi_20240709-2~bpo12+1_all.deb
% cp firmware-iwlwifi_20240709-2~bpo12+1_all.deb /tmp
% su
# cd /tmp
# apt install ./firmware-iwlwifi_20240709-2\~bpo12+1_all.deb

ファームウェア(サウンド)

2024年のモノを使っています(2024年に作業したため)が2025年のモノでもたぶんOKです。

% wget http://ftp.jp.debian.org/debian/pool/non-free-firmware/f/firmware-sof/firmware-sof-signed_2024.09.1-1_all.deb
% cp firmware-sof-signed_2024.09.1-1_all.deb /tmp
% su
# cd /tmp
# apt install ./firmware-sof-signed_2024.09.1-1_all.deb

ファームウェア(グラフィックス)

% wget http://ftp.jp.debian.org/debian/pool/non-free-firmware/f/firmware-nonfree/firmware-intel-graphics_20250410-2~bpo12+1_all.deb
% cp firmware-intel-graphics_20250410-2~bpo12+1_all.deb /tmp
% su
# cd /tmp
# apt install ./firmware-intel-graphics_20250410-2~bpo12+1_all.deb

再起動と確認

カーネルとファームウェアを入れたら再起動。
特殊キーで画面輝度が変化、サウンド音量などが変化することを確認。

% uname -a
Linux testpc 6.16.0-my #1 SMP PREEMPT_RT Tue Aug 12 15:54:54 JST 2025 x86_64 GNU/Linux

PREEMPT_RTが表示され、リアルタイムカーネルになっています。

1
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
1
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?