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 ==
Use this shell.nix(example below is for aarch64):
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
   hostPkgs = import <nixpkgs> { };
   pkgs = import <nixpkgs> { };
   pkgs = import <nixpkgs> {
   aarch64Pkgs = import <nixpkgs> {
     crossSystem = (import <nixpkgs/lib>).systems.examples.aarch64-multiplatform;
     crossSystem = {
      config = "aarch64-unknown-linux-gnu";
    };
   };
   };
in
in
pkgs.mkShell rec {
(pkgs.buildFHSUserEnv {
   depsBuildBuild = [ hostPkgs.buildPackages.stdenv.cc ];
   name = "kernel-build-env";
   nativeBuildInputs = with hostPkgs.buildPackages; [
   targetPkgs = pkgs: (with pkgs;
     bison
     [
    flex
      pkgconfig
    lzop
      ncurses
    pkgconfig
      qt5.qtbase
    ncurses
      pkgsCross.aarch64-multiplatform.stdenv.cc
    qt5.qtbase
     ]
     openssl
    ++ pkgs.linux.nativeBuildInputs);
  ];
   runScript = pkgs.writeScript "init.sh" ''
   shellHook = ''
     export ARCH=arm64
     export ARCH=arm64
     export CC=aarch64-unknown-linux-gnu-
     export CROSS_COMPILE=aarch64-unknown-linux-gnu-
     export PKG_CONFIG_PATH="${hostPkgs.ncurses.dev}/lib/pkgconfig:${hostPkgs.qt5.qtbase.dev}/lib/pkgconfig"
     export PKG_CONFIG_PATH="${pkgs.ncurses.dev}/lib/pkgconfig:${pkgs.qt5.qtbase.dev}/lib/pkgconfig"
     export QT_QPA_PLATFORM_PLUGIN_PATH="${hostPkgs.qt5.qtbase.bin}/lib/qt-${hostPkgs.qt5.qtbase.version}/plugins"
     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 ==