Linux kernel: Difference between revisions
imported>Khoi Fixed ordering of section |
imported>Khoi No edit summary |
||
Line 135: | Line 135: | ||
by opening {{ic|/tmp/nix-build-linux-config-4.19.0-mptcp_v0.94.1.drv-0/.attr-0}}. | by opening {{ic|/tmp/nix-build-linux-config-4.19.0-mptcp_v0.94.1.drv-0/.attr-0}}. | ||
== Cross-compile xconfig and menuconfig == | == Embedded Linux Cross-compile xconfig and menuconfig == | ||
This section details the on how to get an environment that can be used to configure and cross-compile the kernel for embedded Linux development. The kernel source won't come from nix unpack phase but rather gotten externally(such as from the chip vendor github). So first clone the kernel source, then use the shell.nix below will to set up the dev environment(example below is for aarch64): | |||
<syntaxHighlight lang=nix> | <syntaxHighlight lang=nix> | ||
let | let | ||
pkgs = import <nixpkgs> { }; | |||
aarch64Pkgs = import <nixpkgs> { | |||
crossSystem = | crossSystem = { | ||
config = "aarch64-unknown-linux-gnu"; | |||
}; | |||
}; | }; | ||
in | in | ||
pkgs. | (pkgs.buildFHSUserEnv { | ||
name = "kernel-build-env"; | |||
targetPkgs = pkgs: (with pkgs; | |||
[ | |||
pkgconfig | |||
ncurses | |||
qt5.qtbase | |||
pkgsCross.aarch64-multiplatform.stdenv.cc | |||
] | |||
++ pkgs.linux.nativeBuildInputs); | |||
runScript = pkgs.writeScript "init.sh" '' | |||
export ARCH=arm64 | export ARCH=arm64 | ||
export | export CROSS_COMPILE=aarch64-unknown-linux-gnu- | ||
export PKG_CONFIG_PATH="${ | export PKG_CONFIG_PATH="${pkgs.ncurses.dev}/lib/pkgconfig:${pkgs.qt5.qtbase.dev}/lib/pkgconfig" | ||
export QT_QPA_PLATFORM_PLUGIN_PATH="${ | export QT_QPA_PLATFORM_PLUGIN_PATH="${pkgs.qt5.qtbase.bin}/lib/qt-${pkgs.qt5.qtbase.version}/plugins" | ||
export QT_QPA_PLATFORMTHEME=qt5ct | export QT_QPA_PLATFORMTHEME=qt5ct | ||
exec bash | |||
''; | ''; | ||
} | }).env | ||
</syntaxHighlight> | </syntaxHighlight> | ||
Finally, cd to the kernel source dir and do development normally. | |||
== make menuconfig == | == make menuconfig == |