TI am335x sdk 自帶linux原始碼下編譯驅動出錯解決辦法
阿新 • • 發佈:2018-12-31
在使用beaglebone black的時候從TI官網下載了最新版的sdk: ti-processor-sdk-linux-am335x-evm-01.00.00.00-Linux-x86-Install.bin
在linux下安裝之後 kernel的預設路徑是 /opt/ti-processor-sdk-linux-am335x-evm-01.00.00.00/ 然後執行make all就可以設定好所有的東西, 包括kernel也會編譯一遍
/opt/ti-processor-sdk-linux-am335x-evm-01.00.00.00/board-support/linux-3.14.26-g2489c02就是kernel的原始碼目錄
接下來我用了一個最簡單的test驅動來測試:
#include <linux/init.h>
#include <linux/module.h>
static int myspi_init(void)
{
printk ("myspi_init \n");
return 0;
}
static void myspi_exit(void)
{
printk ("myspi_exit\n");
return 0;
}
module_init(myspi_init);
module_exit(myspi_exit);
MODULE_LICENSE("GPL");
對應的Makefile
然後在make的時候竟然出錯,ifeq ($(KERNELRELEASE), ) KERNELDIR ?= /opt/ti-processor-sdk-linux-am335x-evm-01.00.00.00/board-support/linux-3.14.26-g2489c02 PWD := $(shell pwd) modules: $(MAKE) -C $(KERNELDIR) M=$(PWD) modules modules_install: $(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install clean: rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions .PHONY: moudules modules_install clean else obj-m := myspidriver.o endif
好奇怪, 最後發現出錯的都是在x86資料夾下, 解決辦法:/opt/ti-processor-sdk-linux-am335x-evm-01.00.00.00/board-support/linux-3.14.26-g2489c02/arch/x86/include/asm/arch_hweight.h: In function ‘__arch_hweight64’: /opt/ti-processor-sdk-linux-am335x-evm-01.00.00.00/board-support/linux-3.14.26-g2489c02/arch/x86/include/asm/arch_hweight.h:53:42: error: expected ‘:’ or ‘)’ before ‘POPCNT64’ asm (ALTERNATIVE("call __sw_hweight64", POPCNT64, X86_FEATURE_POPCNT) ^ /opt/ti-processor-sdk-linux-am335x-evm-01.00.00.00/board-support/linux-3.14.26-g2489c02/arch/x86/include/asm/alternative.h:98:31: note: in definition of macro ‘ALTINSTR_REPLACEMENT’ b_replacement(number)":\n\t" newinstr "\n" e_replacement(number) ":\n\t" ^ /opt/ti-processor-sdk-linux-am335x-evm-01.00.00.00/board-support/linux-3.14.26-g2489c02/arch/x86/include/asm/arch_hweight.h:53:7: note: in expansion of macro ‘ALTERNATIVE’ asm (ALTERNATIVE("call __sw_hweight64", POPCNT64, X86_FEATURE_POPCNT) ^ In file included from include/linux/cache.h:5:0, from include/linux/time.h:4, from include/linux/stat.h:18, from include/linux/module.h:10, from /home/cxh/bbb_driver/myspidriver.c:2: /opt/ti-processor-sdk-linux-am335x-evm-01.00.00.00/board-support/linux-3.14.26-g2489c02/arch/x86/include/asm/processor.h: At top level: /opt/ti-processor-sdk-linux-am335x-evm-01.00.00.00/board-support/linux-3.14.26-g2489c02/arch/x86/include/asm/cache.h:7:25: error: ‘CONFIG_X86_L1_CACHE_SHIFT’ undeclared here (not in a function) #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT) ^ /opt/ti-processor-sdk-linux-am335x-evm-01.00.00.00/board-support/linux-3.14.26-g2489c02/arch/x86/include/asm/cache.h:8:30: note: in expansion of macro ‘L1_CACHE_SHIFT’ #define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) ^ include/linux/cache.h:12:25: note: in expansion of macro ‘L1_CACHE_BYTES’ #define SMP_CACHE_BYTES L1_CACHE_BYTES ^ /opt/ti-processor-sdk-linux-am335x-evm-01.00.00.00/board-support/linux-3.14.26-g2489c02/arch/x86/include/asm/processor.h:131:30: note: in expansion of macro ‘SMP_CACHE_BYTES’ } __attribute__((__aligned__(SMP_CACHE_BYTES)));
make ARCH=arm CORSS_COMPILE=arm-linux-gnueabihf-
這樣就不會報錯了, 但是還不清楚為啥會這個樣子,難道原始碼的頂層Makefile有問題, 可是sdk的make all之後生成的檔案確實是arm平臺的, 有高手看到本文的話望指點一下.