From ae2c4d38f713535ece896a422131ed9252d90fa1 Mon Sep 17 00:00:00 2001 From: Alex Williams Date: Wed, 2 Jan 2019 10:06:59 +0000 Subject: [PATCH 1/2] Add instructions for compiling a kernel module --- recipes/kernel-module-compilation.md | 41 ++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 recipes/kernel-module-compilation.md diff --git a/recipes/kernel-module-compilation.md b/recipes/kernel-module-compilation.md new file mode 100644 index 0000000..8aac2a7 --- /dev/null +++ b/recipes/kernel-module-compilation.md @@ -0,0 +1,41 @@ +# Kernel module compilation + +Follow these instructions to compile an additional kernel module. + +In this example, we'll compile the `ds1307 RTC` kernel module for version `4.4.154-1124`: + +1. Obtain your kernel version: `uname -r` + (ex: `4.4.154-1124-rockchip-ayufan-ged3ce4d15ec1`) +2. Download the kernel source code which matches your kernel version from [https://github.com/ayufan-rock64/linux-kernel/releases](github.com/ayufan-rock64/linux-kernel/releases) +3. Extract the kernel: `tar -zxvf 4.4.154-1124-rockchip-ayufan.tar.gz` +4. Copy the old kernel config: + ```bash + cd linux-kernel-4.4.154-1124-rockchip-ayufan + cp /usr/src/linux-headers-4.4.154-1124-rockchip-ayufan-ged3ce4d15ec1/.config . + make oldconfig + ``` +5. Install required build packages: `apt-get install bc python libncurses5-dev` +6. Configure the kernel with the additional modules you want: `make menuconfig` + (ex: `Device Drivers --> [*] Real Time Clock --> Dallas/Maxim DS1307..`) +7. Exit and save the config +8. Prepare the modules: + ```bash + make EXTRAVERSION=-1124-rockchip-ayufan-ged3ce4d15ec1 modules_prepare + ```` +9. Build the module: `make M=drivers/rtc` + (note: specify the correct directory containing the module you added) +10. Copy the module to the modules directory: + ```bash + mkdir -p /lib/modules/4.4.154-1124-rockchip-ayufan-ged3ce4d15ec1/kernel/drivers/rtc/ + cp drivers/rtc/rtc-ds1307.ko /lib/modules/4.4.154-1124-rockchip-ayufan-ged3ce4d15ec1/kernel/drivers/rtc/ + ``` +11. Ensure module is added to dep file: + ```bash + echo 'kernel/drivers/rtc/rtc-ds1307.ko:' >> /lib/modules/4.4.154-1124-rockchip-ayufan-ged3ce4d15ec1/modules.dep + ``` +12. Load the module: + ```bash + depmod -a + modprobe rtc-ds1307 + ``` +13. Ensure module is loaded on boot: `echo "rtc-ds1307" >> /etc/modules` From f5fd5f899e94164dd082771b2c6f19ea3ebf50d7 Mon Sep 17 00:00:00 2001 From: Alex Williams Date: Wed, 2 Jan 2019 12:40:34 +0000 Subject: [PATCH 2/2] Fix URL for kernel releases --- recipes/kernel-module-compilation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/kernel-module-compilation.md b/recipes/kernel-module-compilation.md index 8aac2a7..fb33c57 100644 --- a/recipes/kernel-module-compilation.md +++ b/recipes/kernel-module-compilation.md @@ -6,7 +6,7 @@ In this example, we'll compile the `ds1307 RTC` kernel module for version `4.4.1 1. Obtain your kernel version: `uname -r` (ex: `4.4.154-1124-rockchip-ayufan-ged3ce4d15ec1`) -2. Download the kernel source code which matches your kernel version from [https://github.com/ayufan-rock64/linux-kernel/releases](github.com/ayufan-rock64/linux-kernel/releases) +2. Download the kernel source code which matches your kernel version from [github.com/ayufan-rock64/linux-kernel/releases](https://github.com/ayufan-rock64/linux-kernel/releases) 3. Extract the kernel: `tar -zxvf 4.4.154-1124-rockchip-ayufan.tar.gz` 4. Copy the old kernel config: ```bash