我正在尝试将linux内核驱动程序添加到android源中。
我将其添加到要构建的配置文件中(内核/msm-4.9/arch/arm64/config/sdm845_defconfig)。
CONFIG_LEDS_QPNP_WLED=y
# CONFIG_LEDS_QPNP_HAPTICS is not set
CONFIG_HAPTICS_MISC=y
kernel / msm-4.9 / drivers / misc /中的makefile和Kconfig文件也已更新为包含驱动程序。
Makefile:
haptics-misc-objs := haptics-misc.o hatpics-misc-tables.o
obj-$(CONFIG_HAPTICS_MISC) += haptics-misc.o
Kconfig:
config HAPTICS_MISC
tristate "Haptics driver"
depends on I2C && SYSFS && NEW_LEDS
help
Boosted Haptics Driver
我尝试通过以下步骤构建内核:
$ source build/envsetup.sh
$ lunch 41
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=8.1.0
TARGET_PRODUCT=sdm845
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_PLATFORM_VERSION=OPM1
TARGET_BUILD_APPS=
TARGET_ARCH=arm64
TARGET_ARCH_VARIANT=armv8-a
TARGET_CPU_VARIANT=kryo300
TARGET_2ND_ARCH=arm
TARGET_2ND_ARCH_VARIANT=armv7-a-neon
TARGET_2ND_CPU_VARIANT=cortex-a9
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-4.15.0-24-generic-x86_64-with-Ubuntu-16.04-xenial
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=OPM1.171019.026
OUT_DIR=out
AUX_OS_VARIANT_LIST=
$ make -j12
构建因以下错误而失败:
Haptics driver (HAPTICS_MISC) [N/m/y/?] (NEW) aborted!
Console input/output is redirected. Run 'make oldconfig' to update configuration.
/media/ftreven/quarter-b/Open-Q_845_Android-O_v1.0/Source_Package/SDA845_Open-Q_845_Android-O_v1.0/kernel/msm-4.9/scripts/kconfig/Makefile:37: recipe for target 'silentoldconfig' failed
make[3]: *** [silentoldconfig] Error 1
/media/ftreven/quarter-b/Open-Q_845_Android-O_v1.0/Source_Package/SDA845_Open-Q_845_Android-O_v1.0/kernel/msm-4.9/Makefile:550: recipe for target 'silentoldconfig' failed
make[2]: *** [silentoldconfig] Error 2
make[1]: *** No rule to make target 'include/config/auto.conf', needed by 'include/config/kernel.release'. Stop.
make[1]: Leaving directory '/media/ftreven/quarter-b/Open-Q_845_Android-O_v1.0/Source_Package/SDA845_Open-Q_845_Android-O_v1.0/out/target/product/sdm845/obj/kernel/msm-4.9'
Makefile:150: recipe for target 'sub-make' failed
make: *** [sub-make] Error 2
从错误消息看来,命令失败仅是因为符号是新的。它建议制作oldconfig,但这也会失败:
$ make oldconfig
ninja: error: unknown target 'oldconfig', did you mean 'fmconfig'?
13:08:18 ninja failed with: exit status 1
#### failed to build some targets (38 seconds) ####
我不确定“ fmconfig”是什么,但是我尝试按照建议的方法构建它并成功。但是,由于与上述相同的原因,尝试构建整个内核失败。知道是什么原因造成的吗?它是在添加新符号之前成功构建的。
答案 0 :(得分:0)
我发现发布Linux内核版本4.9之后,android框架停止允许内置驱动程序。为了解决这个问题,我不得不将驱动程序构建为可动态加载的内核模块。为此,我在vendor /下创建了一个名为dlkm /的目录,在其中放置了所有源代码和configs / Makefile。
完成此操作后,我可以成功构建源代码。
$ source build/envsetup.sh
$ lunch 41
$ make -j12
#### build completed successfully (03:38 (mm:ss)) ###
在android框架的实际内核部分中无法引用驱动程序,否则构建将失败。设备树(.dtsi,.dts文件)的例外情况仍然是在内核中构建的。