Compiling a custom kernel module for the SC200E platform using the QCM2290 Android 12.0 build environment

Below is the command and error I encountered:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -C /path/to/kernel/msm-4.19 M=$PWD modules

Error:
make: Entering directory '/home/sc200/share/QCM2290_Android12.0_R02_r004-SC200E_rl/UM.9.15/kernel/msm-4.19'
Makefile:617: include/config/auto.conf: No such file or directory

  ERROR: Kernel configuration is invalid.
         include/generated/autoconf.h or include/config/auto.conf are missing.
         Run 'make oldconfig && make prepare' on kernel src to fix it.

Makefile:678: recipe for target 'include/config/auto.conf' failed
make: *** [include/config/auto.conf] Error 1
make: Leaving directory '/home/sc200/share/QCM2290_Android12.0_R02_r004-SC200E_rl/UM.9.15/kernel/msm-4.19'
-------------------------------
root@74428c8f849d:/home/sc200/share/QCM2290_Android12.0_R02_r004-SC200E_rl/UM.9.15/custom_module# make aboot -j
make: *** No rule to make target 'aboot'. Stop.

--------------------------------

Could you please provide guidance on how to resolve this and successfully compile the kernel module?

Dear customer:
You need to use the following command to compile kernel in UM folder
cd UM.9.15
source build/envsetup.sh && lunch bengal-user
make bootimage

Hi @Great.Zheng-Q,

I am unable to excute make menuconfig.
Can you help me to fix this.

root@74428c8f849d:/home/sc200/share/QCM2290_Android12.0_R02_r004-SC200E_rl/UM.9.15# make menuconfig
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=11
TARGET_PRODUCT=aosp_arm
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
TARGET_CPU_VARIANT=generic
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-6.8.0-40-generic-x86_64-Ubuntu-16.04.7-LTS
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=RKQ1.220116.001
OUT_DIR=out
PRODUCT_SOONG_NAMESPACES=device/generic/goldfish device/generic/goldfish-opengl hardware/google/camera hardware/google
/camera/devices/EmulatedCamera device/generic/goldfish device/generic/goldfish-opengl packages/apps/Bluetooth
============================================
[ 74% 134/180] test android/soong/cc/config
Clang SA is not enabled
PASS
[ 94% 170/180] test android/soong/cc
Clang SA is not enabled
PASS
[ 95% 171/180] test android/soong/sh
Clang SA is not enabled
PASS
[ 95% 172/180] test android/soong/bpf
Clang SA is not enabled
PASS
[ 96% 173/180] test android/soong/rust
Clang SA is not enabled
PASS
[ 96% 174/180] test android/soong/java
Clang SA is not enabled
[ 97% 175/180] test android/soong/sysprop
Clang SA is not enabled
PASS
[ 97% 176/180] test android/soong/aidl
Clang SA is not enabled
PASS
[ 98% 177/180] test android/soong/apex
Clang SA is not enabled
PASS
[ 98% 178/180] test android/soong/sdk
Clang SA is not enabled
PASS
[100% 180/180] out/soong/.bootstrap/bin/soong_build out/soong/build.ninja
Clang SA is not enabled
[100% 181/181] initializing build system ...
build/make/core/main.mk:368: warning: "Compile using modified AOSP tree supporting full vendor value-adds"
[ 43% 237/545] including disregard/Android.mk ...
Skipping Android.mk under disregard
[ 55% 303/545] including kernel/Android.mk ...
Skipping Android.mk under kernel
[ 73% 399/545] including vendor/qcom/opensource/dataservices/rmnetctl/Android.mk ...
FAILED: 
In file included from build/make/core/executable.mk:97:
In file included from vendor/qcom/opensource/dataservices/rmnetctl/Android.mk:1:
vendor/qcom/opensource/dataservices/rmnetctl/src/Android.mk:10: error: BUILD_COPY_HEADERS is obsolete. See https://and
roid.googlesource.com/platform/build/+/master/Changes.md#copy_headers.
07:15:41 ckati failed with: exit status 1

#### failed to build some targets (01:14 (mm:ss)) ####

Second :

source build/envsetup.sh && lunch bengal-user

make menuconfig

device/qcom/kernelscripts/kernel_definitions.mk:172: warning: overriding commands for target `out/target/
product/bengal/obj/KERNEL_OBJ/usr'
device/qcom/kernelscripts/kernel_definitions.mk:172: warning: ignoring old commands for target `out/targe
t/product/bengal/obj/KERNEL_OBJ/usr'
device/qcom/kernelscripts/kernel_definitions.mk:176: warning: overriding commands for target `out/target/
product/bengal/obj/kernel/msm-4.19/arch/arm64/boot/Image.gz'
device/qcom/kernelscripts/kernel_definitions.mk:176: warning: ignoring old commands for target `out/targe
t/product/bengal/obj/kernel/msm-4.19/arch/arm64/boot/Image.gz'
device/qcom/kernelscripts/kernel_definitions.mk:192: warning: overriding commands for target `out/target/
product/bengal/kernel'
device/qcom/kernelscripts/kernel_definitions.mk:192: warning: ignoring old commands for target `out/targe
t/product/bengal/kernel'
device/qcom/kernelscripts/kernel_definitions.mk:197: warning: overriding commands for target `out/target/
product/bengal/obj/KERNEL_OBJ/rtic_mp.dtb'
device/qcom/kernelscripts/kernel_definitions.mk:197: warning: ignoring old commands for target `out/targe
t/product/bengal/obj/KERNEL_OBJ/rtic_mp.dtb'
device/qcom/kernelscripts/kernel_definitions.mk:203: warning: overriding commands for target `out/target/
product/bengal/dtb.img'
device/qcom/kernelscripts/kernel_definitions.mk:203: warning: ignoring old commands for target `out/targe
t/product/bengal/dtb.img'
build/make/core/base_rules.mk:506: warning: overriding commands for target `out/target/product/bengal/ven
dor/etc/init/android.hardware.camera.provider@2.4-service_64.rc'
build/make/core/base_rules.mk:521: warning: ignoring old commands for target `out/target/product/bengal/v
endor/etc/init/android.hardware.camera.provider@2.4-service_64.rc'
build/make/core/Makefile:892: warning: overriding commands for target `out/target/product/bengal/vendor/l
ib/modules/qca_cld3_wlan.ko'
build/make/core/Makefile:892: warning: ignoring old commands for target `out/target/product/bengal/vendor
/lib/modules/qca_cld3_wlan.ko'
FAILED: ninja: unknown target 'menuconfig'
07:31:28 ninja failed with: exit status 1

#### failed to build some targets (02:14 (mm:ss)) ####

I am trying to create a local Makefile to compile my custom module to run on the SC200E board.

I would like to know if this is the right approach to do it?

Hi
we don’t use menuconfig
For debug version, you can add macro in UM.9.15/kernel/msm-4.19/arch/arm64/configs/vendor/bengal_defconfig
For user version, you can add macro in UM.9.15/kernel/msm-4.19/arch/arm64/configs/vendor/bengal-perf_defconfig.

Thanks.

Thanks for the quick response @Great.Zheng-Q,

Can you also guide how can I build a custom kernel Module for the same?

For kernel, we need to build a boot.img and flash into the device.
Thanks.

Hi @Great.Zheng-Q ,

I want modify the kernel config file.
Can you help me which file need to be edit?
and also show one example while add/remove from the kernel module from the config file?

saurabh@quantum:~/quantum/sc200/QCM2290_Android12.0_R02_r004-SC200E_rl/UM.9.15/kernel/msm-4.19/arch/arm64/configs/vendor$ ls
bengal_defconfig       kona_defconfig           kona-perf_defconfig  msm8937_defconfig       sdm660-perf_defconfig
bengal-perf_defconfig  kona-iot_defconfig       lito_defconfig       msm8937-perf_defconfig
debugfs.config         kona-iot-perf_defconfig  lito-perf_defconfig  sdm660_defconfig