§2023-06-12

This is to compile a Build odroid-hc4 kernel

試作機器:hc4Jammy.yushei.net

  1. reqirements
$ sudo apt update
$ sudo apt install git lzop build-essential gcc bc libncurses5-dev 
  1. Do native compile
alexlai@hc4Jammy:~/build$ git clone --depth 1 https://github.com/hardkernel/linux.git -b odroidg12-4.9.y
alexlai@hc4Jammy:~/build$ cd linux/
alexlai@hc4Jammy:~/build/linux$ make odroidg12_defconfig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  SHIPPED scripts/kconfig/zconf.tab.c
  SHIPPED scripts/kconfig/zconf.lex.c
  SHIPPED scripts/kconfig/zconf.hash.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
#
# configuration written to .config
#
alexlai@hc4Jammy:~/build/linux$ time make -j 4
scripts/kconfig/conf  --silentoldconfig Kconfig
  CHK     include/config/kernel.release
  WRAP    arch/arm64/include/generated/asm/bugs.h
 ....
real    78m13.663s
user    272m14.733s
sys     26m57.680s
  1. mount the microSD
$ pwd
~/build/src
$ sudo mount /dev/sdb1 boot
$ sudo mount /dev/sdb2 root
  1. Copy files
$ pwd
/home/alexlai/build/linux

$ sudo cp -v arch/arm64/boot/Image arch/arm64/boot/Image.gz arch/arm64/boot/dts/amlogic/meson64_odroidhc4.dtb ~/build/src/boot && sync 

$ file /boot/Image
/boot/Image: Linux kernel ARM64 boot executable Image, little-endian, 4K pages
  1. make modules_install

When compiling a kernel, the make modules_install command is used to install the kernel modules into the appropriate directory. Kernel modules are separate pieces of code that can be dynamically loaded into the kernel to provide additional functionality or support for specific hardware or features.

The make modules_install command installs these kernel modules into the directory specified by the INSTALL_MOD_PATH variable or, if not set, the default location on the system. By default, the modules are installed in the /lib/modules/<kernel-version>/ directory.

For example, if you compile a kernel with the version 5.10.0, the modules will be installed in the /lib/modules/5.10.0/ directory.

$ sudo make modules_install ARCH=arm64 INSTALL_MOD_PATH=~/build/src/root && sync 
alexlai@hc4Jammy:~/build/linux$ ls -l ../src/root/
total 20
drwxr-xr-x 4 root root  4096 Jun 13 13:09 lib
drwx------ 2 root root 16384 Jun 13 13:08 lost+found
alexlai@hc4Jammy:~/build/linux$ ls -l ../src/root/lib/
total 8
drwxr-xr-x 6 root root 4096 Jun 13 13:09 firmware
drwxr-xr-x 3 root root 4096 Jun 13 13:09 modules
alexlai@hc4Jammy:~/build/linux$ ls -l ../src/root/lib/modules/
total 4
drwxr-xr-x 3 root root 4096 Jun 13 13:09 4.9.337+
alexlai@hc4Jammy:~/build/linux$ ls -l ../src/root/lib/modules/4.9.337+/
total 1652
lrwxrwxrwx 1 root root     25 Jun 13 13:09 build -> /home/alexlai/build/linux
drwxr-xr-x 8 root root   4096 Jun 13 13:09 kernel
-rw-r--r-- 1 root root 463185 Jun 13 13:09 modules.alias
-rw-r--r-- 1 root root 473868 Jun 13 13:09 modules.alias.bin
-rw-r--r-- 1 root root  19825 Jun 13 13:09 modules.builtin
-rw-r--r-- 1 root root      0 Jun 13 13:09 modules.builtin.alias.bin
-rw-r--r-- 1 root root  20949 Jun 13 13:09 modules.builtin.bin
-rw-r--r-- 1 root root 105237 Jun 13 13:09 modules.dep
-rw-r--r-- 1 root root 163193 Jun 13 13:09 modules.dep.bin
-rw-r--r-- 1 root root    211 Jun 13 13:09 modules.devname
-rw-r--r-- 1 root root  52873 Jun 13 13:09 modules.order
-rw-r--r-- 1 root root     82 Jun 13 13:09 modules.softdep
-rw-r--r-- 1 root root 160795 Jun 13 13:09 modules.symbols
-rw-r--r-- 1 root root 202160 Jun 13 13:09 modules.symbols.bin
lrwxrwxrwx 1 root root     25 Jun 13 13:09 source -> /home/alexlai/build/linux