为 Android 设备编译内核时出错

为 Android 设备编译内核时出错

我希望你有个美好的一天,

我是新手,刚刚搜索了我的情况,但没有答案,这里和这里大约有 40 个帖子,没有人帮助我,所以我不好意思问你这个问题,但我不得不问,

我正在尝试为我的 android 设备编译一个内核,我编译了我的链工具并修改了我的内核,但是当我编译它时,它显示了 112 个错误,如下所示:

CC      arch/arm/mm/alignment.o
CC      fs/open.o
CC      kernel/fork.o
CC      fs/read_write.o
In file included from include/linux/printk.h:6:0,
             from include/linux/kernel.h:13,
             from arch/arm/mm/rodata.c:15:
  arch/arm/mm/rodata.c: In function 'set_page_attributes':
include/linux/kern_levels.h:4:18: warning: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type 'pmd_t {aka unsigned int}' [-Wformat=]
#define KERN_SOH "\001"  /* ASCII Start Of Header */
              ^
include/linux/kern_levels.h:10:18: note: in expansion of macro 'KERN_SOH'
#define KERN_ERR KERN_SOH "3" /* error conditions */
              ^
include/linux/printk.h:216:9: note: in expansion of macro 'KERN_ERR'
printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
     ^
arch/arm/mm/rodata.c:91:4: note: in expansion of macro 'pr_err'
pr_err("%s: pmd %p=%08lx for %08lx not page table\n",
^
CC      mm/filemap.o
CC      mm/mempool.o
CC      mm/oom_kill.o
AS      arch/arm/mm/abort-ev7.o
AS      arch/arm/mm/pabort-v7.o
In file included from arch/arm/mm/dma-mapping.c:20:0:
include/linux/dma-contiguous.h: In function 'dev_get_cma_area':
include/linux/dma-contiguous.h:72:16: error: 'struct device' has no member named 'cma_area'
if (dev && dev->cma_area)
            ^
include/linux/dma-contiguous.h:73:13: error: 'struct device' has no member named 'cma_area'
return dev->cma_area;
         ^
include/linux/dma-contiguous.h: In function 'dev_set_cma_area':
include/linux/dma-contiguous.h:80:6: error: 'struct device' has no member named 'cma_area'
dev->cma_area = cma;
  ^
AS      arch/arm/mm/cache-v7.o
CC      arch/arm/mm/copypage-v6.o
CC      kernel/exec_domain.o
CC      arch/arm/mm/context.o
In file included from /home/tareq/Kernel/arch/arm/include/asm/sec/sec_debug.h:21:0,
             from include/asm-generic/emergency-restart.h:4,
             from arch/arm/include/generated/asm/emergency-restart.h:1,
             from include/linux/reboot.h:56,
             from arch/arm/kernel/process.c:21:
include/soc/sprd/hardware.h:40:2: error: #error "Unknown architecture specification"
#error "Unknown architecture specification"
^
CC      security/apparmor/apparmorfs.o
CC      ipc/util.o
CC      crypto/api.o
arch/arm/mm/dma-mapping.c: At top level:
include/linux/dma-contiguous.h:66:28: error: 'CONFIG_CMA_AREAS' undeclared here (not in a function)
#define MAX_CMA_AREAS (1 + CONFIG_CMA_AREAS)
                        ^
arch/arm/mm/dma-mapping.c:396:54: note: in expansion of macro 'MAX_CMA_AREAS'
static struct dma_contig_early_reserve dma_mmu_remap[MAX_CMA_AREAS] __initdata;
                                                  ^
AS      arch/arm/mm/tlb-v7.o
CC      fs/file_table.o
AS      arch/arm/mm/proc-v7.o
arch/arm/mm/dma-mapping.c:396:40: warning: 'dma_mmu_remap' defined but not used [-Wunused-variable]
static struct dma_contig_early_reserve dma_mmu_remap[MAX_CMA_AREAS] __initdata;
                                    ^
In file included from /home/tareq/Kernel/arch/arm/include/asm/sec/sec_debug.h:21:0,
             from include/asm-generic/emergency-restart.h:4,
             from arch/arm/include/generated/asm/emergency-restart.h:1,
             from include/linux/reboot.h:56,
             from arch/arm/kernel/machine_kexec.c:8:
include/soc/sprd/hardware.h:40:2: error: #error "Unknown architecture specification"
#error "Unknown architecture specification"
^
CC      fs/super.o
CC      mm/fadvise.o
scripts/Makefile.build:308: recipe for target 'arch/arm/mm/dma-mapping.o' failed
make[1]: *** [arch/arm/mm/dma-mapping.o] Error 1
make[1]: *** Waiting for unfinished jobs....
CC      fs/char_dev.o
CC      ipc/msgutil.o
CC      mm/maccess.o
In file included from /home/tareq/Kernel/arch/arm/include/asm/sec/sec_debug.h:21:0,
             from arch/arm/kernel/traps.c:39:
include/soc/sprd/hardware.h:40:2: error: #error "Unknown architecture specification"
#error "Unknown architecture specification"
^
In file included from arch/arm/kernel/process.c:44:0:
/home/tareq/Kernel/arch/arm/include/asm/sec/sec_log.h:24:20: warning: function declaration isn't a prototype [-Wstrict-prototypes]
static inline void sec_debug_panic_message(en) { }
                ^
/home/tareq/Kernel/arch/arm/include/asm/sec/sec_log.h: In function 'sec_debug_panic_message':
/home/tareq/Kernel/arch/arm/include/asm/sec/sec_log.h:24:20: warning: type of 'en' defaults to 'int' [-Wimplicit-int]
CC      ipc/msg.o
In file included from arch/arm/mm/init.c:23:0:
include/linux/dma-contiguous.h: In function 'dev_get_cma_area':
include/linux/dma-contiguous.h:72:16: error: 'struct device' has no member named 'cma_area'
if (dev && dev->cma_area)
            ^
include/linux/dma-contiguous.h:73:13: error: 'struct device' has no member named 'cma_area'
return dev->cma_area;
         ^
include/linux/dma-contiguous.h: In function 'dev_set_cma_area':
include/linux/dma-contiguous.h:80:6: error: 'struct device' has no member named 'cma_area'
dev->cma_area = cma;
  ^
CC      kernel/panic.o
CC      ipc/sem.o
In file included from /home/tareq/Kernel/arch/arm/include/asm/sec/sec_debug.h:21:0,
             from arch/arm/mm/fault.c:34:
include/soc/sprd/hardware.h:40:2: error: #error "Unknown architecture specification"
#error "Unknown architecture specification"
^
CC      kernel/printk.o
CC      ipc/shm.o
arch/arm/kernel/traps.c: In function 'cp_abort':
arch/arm/kernel/traps.c:829:8: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'void *' [-Wformat=]
panic("CP Crash : %s", debug_info);
    ^
scripts/Makefile.build:308: recipe for target 'arch/arm/kern /machine_kexec.o' failed
make[1]: *** [arch/arm/kernel/machine_kexec.o] Error 1
make[1]: *** Waiting for unfinished jobs....
CC      kernel/cpu.o
scripts/Makefile.build:308: recipe for target 'arch/arm/kernel/process.o' failed
make[1]: *** [arch/arm/kernel/process.o] Error 1
CC      ipc/ipcns_notifier.o
scripts/Makefile.build:308: recipe for target 'arch/arm/mm/fault.o' failed
make[1]: *** [arch/arm/mm/fault.o] Error 1
CC      kernel/exit.o
scripts/Makefile.build:308: recipe for target 'arch/arm/kernel/traps.o' failed
make[1]: *** [arch/arm/kernel/traps.o] Error 1
CC      security/apparmor/audit.o
GEN     security/apparmor/capability_names.h
CC      security/apparmor/context.o
CC      kernel/itimer.o
LD      arch/arm/common/built-in.o
HZFILE  kernel/hz.bc
scripts/Makefile.build:308: recipe for target 'arch/arm/mm/init.o' failed
make[1]: *** [arch/arm/mm/init.o] Error 1
CC      kernel/softirq.o
CC      ipc/syscall.o
CC      kernel/resource.o 

编译结束时:

CC [M]  fs/ocfs2/dlm/dlmdomain.o
CC [M]  fs/ocfs2/cluster/tcp.o
In file included from /home/tareq/Kernel/arch/arm/include/asm/sec/sec_debug.h:21:0,
             from include/asm-generic/emergency-restart.h:4,
             from arch/arm/include/generated/asm/emergency-restart.h:1,
             from include/linux/reboot.h:56,
             from fs/ocfs2/cluster/quorum.c:48:
include/soc/sprd/hardware.h:40:2: error: #error "Unknown architecture specification"
#error "Unknown architecture specification"
^
scripts/Makefile.build:308: recipe for target 'fs/ocfs2/cluster/quorum.o' failed
make[3]: *** [fs/ocfs2/cluster/quorum.o] Error 1
make[3]: *** Waiting for unfinished jobs....
CC [M]  fs/xfs/xfs_ialloc_btree.o
CC [M]  fs/ocfs2/dlm/dlmdebug.o
CC [M]  fs/xfs/xfs_inode.o
CC [M]  fs/ocfs2/dlm/dlmthread.o
CC [M]  fs/xfs/xfs_log_recover.o
In file included from /home/tareq/Kernel/arch/arm/include/asm/sec/sec_debug.h:21:0,
             from include/asm-generic/emergency-restart.h:4,
             from arch/arm/include/generated/asm/emergency-restart.h:1,
             from include/linux/reboot.h:56,
             from fs/ocfs2/stack_user.c:25:
include/soc/sprd/hardware.h:40:2: error: #error "Unknown architecture specification"
#error "Unknown architecture specification"
^
scripts/Makefile.build:308: recipe for target 'fs/ocfs2/stack_user.o' failed
make[2]: *** [fs/ocfs2/stack_user.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CC [M]  fs/xfs/xfs_mount.o
CC [M]  fs/xfs/xfs_symlink.o
CC [M]  fs/ocfs2/dlm/dlmrecovery.o
CC [M]  fs/ocfs2/dlm/dlmmaster.o
CC [M]  fs/xfs/xfs_trans.o
CC [M]  fs/ocfs2/dlm/dlmast.o
CC [M]  fs/xfs/xfs_log.o
CC [M]  fs/xfs/xfs_log_cil.o
CC [M]  fs/xfs/xfs_buf_item.o
CC [M]  fs/xfs/xfs_extfree_item.o
CC [M]  fs/xfs/xfs_inode_item.o
CC [M]  fs/xfs/xfs_trans_ail.o
CC [M]  fs/ocfs2/dlm/dlmconvert.o
CC [M]  fs/xfs/xfs_trans_buf.o
CC [M]  fs/ocfs2/dlm/dlmlock.o
CC [M]  fs/xfs/xfs_trans_extfree.o
CC [M]  fs/ocfs2/dlm/dlmunlock.o
CC [M]  fs/xfs/xfs_trans_inode.o
CC [M]  fs/xfs/xfs_dquot.o
CC [M]  fs/xfs/xfs_dquot_item.o
CC [M]  fs/xfs/xfs_trans_dquot.o
CC [M]  fs/ocfs2/dlm/dlmver.o
CC [M]  fs/xfs/xfs_qm_syscalls.o
CC [M]  fs/xfs/xfs_qm_bhv.o
CC [M]  fs/xfs/xfs_qm.o
CC [M]  fs/xfs/xfs_quotaops.o
LD [M]  fs/nfs/blocklayout/blocklayoutdriver.o
CC [M]  fs/xfs/xfs_rtalloc.o
CC [M]  fs/xfs/xfs_acl.o
CC [M]  fs/xfs/xfs_stats.o
CC [M]  fs/xfs/xfs_sysctl.o
LD [M]  fs/nfs/objlayout/objlayoutdriver.o
LD [M]  fs/cifs/cifs.o
LD      fs/ext4/ext4.o
LD      fs/ext4/built-in.o
scripts/Makefile.build:455: recipe for target 'fs/ocfs2/cluster' failed
make[2]: *** [fs/ocfs2/cluster] Error 2
LD [M]  fs/nfs/nfs_layout_nfsv41_files.o
LD [M]  fs/nfs/nfsv4.o
LD [M]  fs/nfs/nfsv2.o
LD [M]  fs/nfs/nfsv3.o
LD [M]  fs/nfs/nfs.o
LD [M]  fs/xfs/xfs.o
LD [M]  fs/ocfs2/dlm/ocfs2_dlm.o
scripts/Makefile.build:455: recipe for target 'fs/ocfs2' failed
make[1]: *** [fs/ocfs2] Error 2
Makefile:798: recipe for target 'fs' failed
make: *** [fs] Error 2
ERROR: An error occured. Kernel was not compiled. 

这是不可能的,

很难相信所有这些错误都出在一个内核中。

所以请问有人能帮我解释一下为什么会出现这些错误吗?我该怎么做才能让它正常工作而不出现错误?

答案1

抱歉,大家好,我确实找到了问题所在,是 defconfig 文件的名称,我所做的就是例如:我最初有这个:anyname_defconfig,我将其重命名为:bravo_defconfig。然后错误消失了。但仍然存在一个问题 [错误爱我哈哈:(] 这是我遇到的:

include/linux/kern_levels.h:10:18: note: in expansion of macro 'KERN_SOH'
#define KERN_ERR KERN_SOH "3" /* error conditions */

include/linux/kern_levels.h:10:18: note: in expansion of macro 'KERN_SOH'
#define KERN_ERR KERN_SOH "3" /* error conditions */

include/linux/kern_levels.h:10:18: note: in expansion of macro 'KERN_SOH'
#define KERN_ERR KERN_SOH "3" /* error conditions */

scripts/Makefile.build:441: recipe for target 'drivers/misc/mdbg/mdbgdrv.o' failed
make[3]: *** [drivers/misc/mdbg/mdbgdrv.o] Error 1
scripts/Makefile.build:455: recipe for target 'drivers/misc/mdbg'failed
make[2]: *** [drivers/misc/mdbg] Error 2
make[2]: *** Waiting for unfinished jobs....

drivers/media/sprd_scale/common/img_scale.c: In function 'scale_k_read':
drivers/media/sprd_scale/common/img_scale.c:110:10: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'size_t {aka unsigned int}' [-Wformat=]
printk("scale_k_read error: wrong size of u_data: %ld \n", cnt);

scripts/Makefile.build:455: recipe for target 'drivers/misc' failed
make[1]: *** [drivers/misc] Error 2
make[1]: *** Waiting for unfinished jobs....

scripts/Makefile.build:387: recipe for target 'kernel/trace/built-in.o' failed
make[2]: *** [kernel/trace/built-in.o] Error 1
scripts/Makefile.build:455: recipe for target 'kernel/trace' failed
make[1]: *** [kernel/trace] Error 2
Makefile:798: recipe for target 'kernel' failed
make: *** [kernel] Error 2

drivers/input/keyboard/tc350k.c: In function 'tc300k_power':
drivers/input/keyboard/tc350k.c:367:27: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
dev_err(&client->dev, "%s regulator_get error \n");

Makefile:798: recipe for target 'drivers' failed
make: *** [drivers] Error 2

scripts/Makefile.build:387: recipe for target 'fs/built-in.o' failed
make[1]: *** [fs/built-in.o] Error 1
Makefile:798: recipe for target 'fs' failed
make: *** [fs] Error 2
ERROR: An error occured. Kernel was not compiled.

如果有人能帮助我解决这些错误,我恳求你。

如何修复此错误?

相关内容