初级会员
- 积分
- 57
- 金钱
- 57
- 注册时间
- 2015-4-13
- 在线时间
- 11 小时
|
5金钱
Deal all,字符设备驱动make -j32出现 error:code model kernel does not support PIC mode.
环境:Ubuntu 18.04
arm-linux-guneabihf-gcc: version 4.9.4(Linaro GCC 4.9-2017.01)
内核源码:正点原子修改后的:linux-imx-4.1.15-2.1.0-g49efdaa-v1.0.tar.bz2
前提:内核源码编译内核成功:Kernel: arch/arm/boot/zImage is ready
字符设备驱动源码:拷贝例程源码\2、Linux驱动例程\1_chrdevbase,
并修改VScode工程中自己的源码路径和Makefile路径
"includePath": [
"${workspaceFolder}/**",
"/home/wjj/Documents/opendev/linux-imx-4.1.15-alpha/include",
"/home/wjj/Documents/opendev/linux-imx-4.1.15-alpha/arch/arm/include",
"/home/wjj/Documents/opendev/linux-imx-4.1.15-alpha/arch/arm/include/generated/"
KERNELDIR := /home/wjj/Documents/opendev/linux-imx-4.1.15-alpha
在1_chrdevbase目录下make -j32,出现下述错误。
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
make -C /home/wjj/Documents/opendev/linux-imx-4.1.15-alpha M=/home/wjj/Documents/opendev/LinuxDrivers/1_chrdevbase modules
make[1]: Entering directory '/home/wjj/Documents/opendev/linux-imx-4.1.15-alpha'
CC [M] /home/wjj/Documents/opendev/LinuxDrivers/1_chrdevbase/chrdevbase.o
cc1: error: code model kernel does not support PIC mode
scripts/Makefile.build:264: recipe for target '/home/wjj/Documents/opendev/LinuxDrivers/1_chrdevbase/chrdevbase.o' failed
make[2]: *** [/home/wjj/Documents/opendev/LinuxDrivers/1_chrdevbase/chrdevbase.o] Error 1
Makefile:1384: recipe for target '_module_/home/wjj/Documents/opendev/LinuxDrivers/1_chrdevbase' failed
make[1]: *** [_module_/home/wjj/Documents/opendev/LinuxDrivers/1_chrdevbase] Error 2
make[1]: Leaving directory '/home/wjj/Documents/opendev/linux-imx-4.1.15-alpha'
Makefile:9: recipe for target 'kernel_modules' failed
make: *** [kernel_modules] Error 2
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
尝试解决:参考https://blog.csdn.net/jasonLee_lijiaqi/article/details/84651138中在内核源码的顶层Makefile做如下修改:在KBUILD_CFLAGS尾部添加 -fno-pie
添加后出现了更多的error:
evbase.c:2:
./arch/x86/include/asm/arch_hweight.h: In function ‘__arch_hweight64’:
./arch/x86/include/asm/arch_hweight.h:53:42: error: expected ‘:’ or ‘)’ before ‘POPCNT64’
asm (ALTERNATIVE("call __sw_hweight64", POPCNT64, X86_FEATURE_POPCNT)
........
error: unknown type name ‘atomic64_t’; did you mean ‘atomic_t’?
static inline void atomic64_set(atomic64_t *v, long i)
-----------------------------------------------------------------------------
请教论坛大神,这类问题接下来要如何解决?
Linux源码Makefile添加-fno-pie后再重新编译内核吗?
|
最佳答案
查看完整内容[请看2#楼]
问题解决:https://e2e.ti.com/support/processors/f/791/t/737467
需要使用make ARCH=arm CROSS_COMPILE = arm-linux-gnueabihf-gcc
按照手册中直接输入make -j32编译可能有问题。
|