在使用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

#include

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

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然后在make的时候竟然出错,

/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)));好奇怪, 最后发现出错的都是在x86文件夹下, 解决办法:

make ARCH=arm CORSS_COMPILE=arm-linux-gnueabihf-这样就不会报错了, 但是还不清楚为啥会这个样子,难道源码的顶层Makefile有问题, 可是sdk的make all之后生成的文件确实是arm平台的, 有高手看到本文的话望指点一下.

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐