===================================================================
驱动代码
===================================================================
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("Dual BSD/GPL");
MODULE_AUTHOR("YU");
static int hello_init(void)
{
printk(KERN_EMERG "HELLO WORLD enter!\n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_EMERG "HELLO WORLD exit!\n");
}
module_init(hello_init);
module_exit(hello_exit);
=====================================================================
Makefile文件
=====================================================================
obj-m += module_test.o
KDIR := /home/orangepi/Android_5.1/Android/lichee/linux-3.10
#当前目录变量
PWD ?= $(shell pwd)
all:
make -C $(KDIR) M=$(PWD) modules
clean:
rm -rf *.o
=============================== ====================================
编译提示出错
====================================================================
topeet@ubuntu:/home/orangepi/Android_5.1/orangepi_kernel_code$ ls
Makefile OrangePi_misc.c
topeet@ubuntu:/home/orangepi/Android_5.1/orangepi_kernel_code$ make
make -C /home/orangepi/Android_5.1/Android/lichee/linux-3.10 M=/home/orangepi/Android_5.1/orangepi_kernel_code modules
make[1]: 正在进入目录 `/home/orangepi/Android_5.1/Android/lichee/linux-3.10'
CC [M] /home/orangepi/Android_5.1/orangepi_kernel_code/OrangePi_misc.o
In file included from include/linux/types.h:5,
from include/linux/init.h:5,
from /home/orangepi/Android_5.1/orangepi_kernel_code/OrangePi_misc.c:1:
include/uapi/linux/types.h:4: fatal error: asm/types.h: No such file or directory
compilation terminated.
make[2]: *** [/home/orangepi/Android_5.1/orangepi_kernel_code/OrangePi_misc.o] 错误 1
make[1]: *** [_module_/home/orangepi/Android_5.1/orangepi_kernel_code] 错误 2
make[1]:正在离开目录 `/home/orangepi/Android_5.1/Android/lichee/linux-3.10'
make: *** [all] 错误 2
离线
是内核根目录的Makefile文件吗
ARCH ?= arm
CROSS_COMPILE ?=/usr/local/arm/4.4.1/bin/arm-none-linux-gnueabi-
离线
emmmmmm 还是提示include/uapi/linux/types.h:4:23: fatal error: asm/types.h:没有那个文件或目录
#include <asm/types.h>
离线
编译LINUX内核源码没问题,下面是给的提示。
sun50iw2p1 compile Kernel successful
INFO:build Kernel OK.
INFO:build rootfs ...
INFO:skip make rootfs for android
INFO:build rootfs OK.
-------------------------------------------
build sun50iw2p1 android lichee OK
--------------------------------------------
离线
root@ubuntu:/home/orangepi/Android_5.1/orangepi_kernel_code# ARCH=arm CROSS_COMPILE=/usr/local/arm/4.4.1/bin/arm-none-linux-gnueabi- make modules
make: *** 没有规则可以创建目标“modules”。 停止。
root@ubuntu:/home/orangepi/Android_5.1/orangepi_kernel_code# ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- make modules
make: *** 没有规则可以创建目标“modules”。 停止。
root@ubuntu:/home/orangepi/Android_5.1/orangepi_kernel_code# su topeet
topeet@ubuntu:/home/orangepi/Android_5.1/orangepi_kernel_code$ ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- make modules
离线
离线
还是不行。我看了一下官方给的源码文件里面,存在一个编译器。我编译的时候直接调用官方给的脚本 .build.sh config进行编译。
是不是我得装上它给的的编译器才能行?
root@ubuntu:/home/orangepi/Android_5.1/orangepi_kernel_code# ls
Makefile OrangePi_misc.c
root@ubuntu:/home/orangepi/Android_5.1/orangepi_kernel_code# ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- M=${PWD} make -C /home/orangepi/Android_5.1/Android/lichee/linux-3.10 modules
make:进入目录'/home/orangepi/Android_5.1/Android/lichee/linux-3.10'
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
make[1]: “include/generated/mach-types.h”是最新的。
CALL scripts/checksyscalls.sh
CC scripts/mod/devicetable-offsets.s
GEN scripts/mod/devicetable-offsets.h
HOSTCC scripts/mod/file2alias.o
HOSTLD scripts/mod/modpost
CC [M] security/fivm/fivm_crypto.o
/tmp/ccWnMY01.s: Assembler messages:
/tmp/ccWnMY01.s:234: Error: garbage following instruction -- `dmb ish'
/tmp/ccWnMY01.s:248: Error: garbage following instruction -- `dmb ish'
make[2]: *** [security/fivm/fivm_crypto.o] 错误 1
make[1]: *** [security/fivm] 错误 2
make: *** [security] 错误 2
make:离开目录“/home/orangepi/Android_5.1/Android/lichee/linux-3.10”
最近编辑记录 yugezaizheli (2020-05-04 18:25:53)
离线
心态崩了,换了编译器出现了不同的错误- -|||
topeet@ubuntu:/home/orangepi/Android_5.1/orangepi_kernel_code$ sudo ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- M=${PWD}
make -C /home/orangepi/Android_5.1/Android/lichee/linux-3.10 modules
make:进入目录'/home/orangepi/Android_5.1/Android/lichee/linux-3.10'
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
make[1]: “include/generated/mach-types.h”是最新的。
CALL scripts/checksyscalls.sh
CC scripts/mod/devicetable-offsets.s
GEN scripts/mod/devicetable-offsets.h
HOSTCC scripts/mod/file2alias.o
HOSTLD scripts/mod/modpost
CC [M] drivers/crypto/sunxi/sunxi_ss.o
drivers/crypto/sunxi/sunxi_ss.c: 在函数‘sunxi_ss_res_request’中:
drivers/crypto/sunxi/sunxi_ss.c:715:2: 错误: 隐式声明函数‘irq_of_parse_and_map’ [-Werror=implicit-function-declaration]
drivers/crypto/sunxi/sunxi_ss.c: 在函数‘sunxi_ss_hw_init’中:
drivers/crypto/sunxi/sunxi_ss.c:767:2: 错误: 隐式声明函数‘of_property_read_u32_array’ [-Werror=implicit-function-declaration]
drivers/crypto/sunxi/sunxi_ss.c: 在文件作用域:
drivers/crypto/sunxi/sunxi_ss.c:1041:21: 错误: ‘sunxi_ss_of_match’未声明(不在函数内)
drivers/crypto/sunxi/sunxi_ss.c:912:12: 警告: ‘sunxi_ss_dma_mask’定义后未使用 [-Wunused-variable]
cc1: some warnings being treated as errors
make[3]: *** [drivers/crypto/sunxi/sunxi_ss.o] 错误 1
make[2]: *** [drivers/crypto/sunxi] 错误 2
make[1]: *** [drivers/crypto] 错误 2
make: *** [drivers] 错误 2
make:离开目录“/home/orangepi/Android_5.1/Android/lichee/linux-3.10”
离线
确认过了。
1、上午用的官方脚本编译的LINUX内核,那个脚本交叉编译器用的是/home/orangepi/Android_5.1/Android/lichee/brandy/gcc-linaro/bin
2、我在内核目录中用ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make 不能通过
In file included from kernel/power/scenelock.c:14:0:
kernel/power/scenelock_data.h:22:34: 错误: ‘sizeof’不能用于不完全的类型‘struct scene_extended_standby_t[]’
kernel/power/scenelock.c: 在函数‘scenelocks_init’中:
kernel/power/scenelock.c:352:24: 错误: ‘sizeof’不能用于不完全的类型‘struct scene_extended_standby_t[]’
make[2]: *** [kernel/power/scenelock.o] 错误 1
make[1]: *** [kernel/power] 错误 2
make: *** [kernel] 错误 2
root@ubuntu:/home/orangepi/Android_5.1/Android/lichee/linux-3.10#
离线
是的 明天再研究研究 感谢晕哥 耽误了你不少时间 谢谢~
离线