zl程序教程

您现在的位置是:首页 >  系统

当前栏目

Linux·内核编译错误

2023-09-27 14:26:30 时间

1、编译内核出现:cc1: error: code model kernel does not support PIC mode

解决办法:
(1)删除该模块目录下的.cache.mk文件就好了,重新make即可  make -j2

(2)对于4.0版本以上的,查找MAKEFILE里面的KBUILD_CFLAGS   

   KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
           -fno-strict-aliasing -fno-common \
           -Werror-implicit-function-declaration \
           -Wno-format-security \
           -std=gnu89 -fno-pie 

CC_USING_FENTRY    := $(call cc-option, -mfentry -fno-pie -DCC_USING_FENTRY)

//加上红色字体两处后在make
 

2、Can't use 'defined(@array)' (Maybe you should just omit the defined()?) at kernel/timeconst.pl line 373.

编译64位内核kernel/timeconst.pl问题解决 
Can't use 'defined( @array )' (Maybe you should just omit the defined()?) at kernel/timeconst.pl line 373.  

其实,提示的错误信息已经明确告诉你了,你应该省略defined(). 

这里,我们打开 kernel/timeconst.pl 

@val  = @{$canned_values{$hz}};  
if (!defined( @val )) {  
@val  = compute_values($hz);  
}  
output($hz,  @val );  

解决办法:

将if (!defined( @val )) 改为if (! @val ),再次编译就可以通过了。


3、drivers/gpio/janz-ttl.c: 在函数‘ttl_set_value’中:
drivers/gpio/janz-ttl.c:107:2: 错误: 隐式声明函数‘iowrite16be’ [-Werror=implicit-function-declaration]
  iowrite16be(*shadow, port);
  ^
cc1:有些警告被当作是错误

drivers/gpio/janz-ttl.c: In function 'ttl_set_value': drivers/gpio/janz-ttl.c:107:2: error: implicit declaration of function 'iowrite16be' [-Werror=implicit-function-declaration] cc1: some warnings being treated as errors scripts/Makefile.build:311: recipe for target 'drivers/gpio/janz-ttl.o' failed make[2]: *** [drivers/gpio/janz-ttl.o] Error 1 scripts/Makefile.build:441: recipe for target 'drivers/gpio' failed make[1]: *** [drivers/gpio] Error 2 Makefile:945: recipe for target 'drivers' failed make: *** [drivers] Error 2

 

解决方法:

gedit drivers/gpio/janz-ttl.c
在前面加上下述定义

#define iowrite16be(v, addr) iowrite16(be16_to_cpu(v), (addr))

4、drivers/input/touchscreen/eeti_ts.c: 在函数‘eeti_ts_irq_active’中:
drivers/input/touchscreen/eeti_ts.c:65:24: 错误: 隐式声明函数‘irq_to_gpio’ [-Werror=implicit-function-declaration]
  return gpio_get_value(irq_to_gpio(priv->irq)) == priv->irq_active_high;

 解决办法:

第一种方法:

文件1(drivers/mfd/Kconfig)中

删除depends on GENERIC_HARDIRQS && SPI_MASTER 
添加depends on GENERIC_HARDIRQS && SPI_MASTER && ARCH_PXA


文件2(/drivers/mfd/ezx-pcap.c)中
添加头文件#include <linux/gpio-pxa.h>
删除} while (gpio_get_value(irq_to_gpio(pcap->spi->irq)));
添加} while (gpio_get_value(pxa_irq_to_gpio(pcap->spi->irq)));


3:#include <linux/gpio-pxa.h>  可能需要自行复制gpio-pxa.h到内核源码 相应目录。例如:我的是复制到 /include/linux目录下。


第二种 方法:

先编译看下内核有没有问题,运行make命令出现下面的错误:
      重新make menuconfig

将driver中的输入设备->触摸设备中,将EETI选项不选,保存退出后,重新make
 

 

 

 

 

 5、drivers/scsi/advansys.c:72:2: warning: #warning this driver is still not properly converted to the DMA API
drivers/scsi/advansys.c: In function 'advansys_get_sense_buffer_dma':
drivers/scsi/advansys.c:8376:2: error: implicit declaration of function 'dma_cache_sync'
make[2]: *** [drivers/scsi/advansys.o] 错误 1
make[1]: *** [drivers/scsi] 错误 2
make: *** [drivers] 错误 2

解决办法:

implicit declaration of function `dma_cache_sync'表示隐式声明错误,可能有几个原因:
1   没有把函数所在的c文件生成.o目标文件
2   在函数所在的c文件中定义了,但是没有在与之相关联的.h文件中声明
查找arch\arm\include\asm\dma-mapping.h下没有这个函数声明,但有如下注释:

/*
* Dummy noncoherent implementation.  We don't provide a dma_cache_sync
* function so drivers using this API are highlighted with build warnings.
*/

晕了,不用为什么还在程序里有这个函数?直接在advansys.c中把
dma_cache_sync(board->dev, scp->sense_buffer,
               SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
注释掉,编译就OK了

编译内核 出现过的其他错误:


问题1:
drivers/gpio/janz-ttl.c
implicit declaration of function 'iowrite16be'
解决方案:
添加宏定义:#define iowrite16be(v, addr) iowrite16(be16_to_cpu(v), (addr))

问题2:
drivers/char/s3c_mem.c中没有mach/map.h
解决方案:
去掉该文件中#include <mach/map.h>

问题3:
drivers/input/touchscreen/eeti_ts.c:65: error: implicit declaration of function 'irq_to_gpio'
解决方案:
a、raumfeld.c
static struct eeti_ts_platform_data eeti_ts_pdata = {
.irq_active_high = 1,
.gpio = GPIO_TOUCH_IRQ,//添加
};
b、/drivers/input/touchscreen/eeti_ts.c
struct eeti_ts_priv {
struct input_dev *input;
struct work_struct work;
struct mutex mutex;
int irq, irq_active_high;//删除
int irq, gpio, irq_active_high;//添加
};
static inline int eeti_ts_irq_active(struct eeti_ts_priv *priv)
{
return gpio_get_value(irq_to_gpio(priv->irq)) == priv->irq_active_high;//删除
return gpio_get_value(priv->gpio) == priv->irq_active_high;//添加
}

if (pdata)
priv->irq_active_high = pdata->irq_active_high;
替换为
if (pdata) {
priv->gpio = pdata->gpio;
priv->irq_active_high = pdata->irq_active_high;
}

c、/include/linux/input/eeti_ts.h 
struct eeti_ts_platform_data {
unsigned int irq_active_high;
unsigned int gpio;//添加
};

问题4:
drivers/mfd/ezx-pcap.c:205: error: implicit declaration of function 'irq_to_gpio'
解决方案:

进入ezx-pcap.c,到第205行:

将} while (gpio_get_value(irq_to_gpio(pcap->spi->irq)));改为} while (gpio_get_value(pdata->gpio));

并找ezx-pcap.h,在struct pcap_platform_data加上int gpio;

问题5:
drivers/mmc/core/mmc_ops.c:20:22: error: plat/cpu.h: No such file or directory
解决方案:
将头文件去掉

问题6:
drivers/mmc/host/sdhci.c中:S3C64XX_SDHCI_CONTROL4,S3C64XX_SDHCI_CONTROL4_BUSY未定义
解决方案:
头文件所在arch/arm/plat-samsung/include/plat/regs-sdhci.h中
实在不行就将定义拷过去

问题7:
drivers/scsi/osd/osd_initiator.c:67: error: size of array 'type name' is negative
解决方案:
注释掉报错的行,该内容定义以后并未被使用

问题8:
drivers/scsi/advansys.c:8376: error: implicit declaration of function 'dma_cache_sync'
解决方案:
该函数已经被放弃了,直接注释

问题9:
EABI版本不一致,链接失败
解决方案:
这个是由编译器版本过高导致的,在内核编译选项中选择Kernel Features中的Use the ARM EABI to compile the kernel

问题10:
drivers/staging/dt3155v4l/dt3155v4l.c:434: error: implicit declaration of function 'kzalloc'
解决方案:
添加头文件<linux/slab.h>

问题11:
drivers/staging/iio/accel/lis3l02dq_core.c:708: error: implicit declaration of function 'irq_to_gpio'
drivers/staging/iio/accel/lis3l02dq_ring.c:297: error: implicit declaration of function 'irq_to_gpio'
drivers/staging/iio/accel/sca3000_core.c:1169: error: implicit declaration of function 'irq_to_gpio'
drivers/staging/iio/imu/adis16400_core.c:822: error: implicit declaration of function 'irq_to_gpio'
解决方案:
这几个文件中的引用头文件中<linux/gpio.h>包含了该函数的定义

问题12:
drivers/staging/solo6x10/core.c:140: error: implicit declaration of function 'kzalloc'
drivers/staging/solo6x10/p2m.c:52: error: implicit declaration of function 'kzalloc'
drivers/staging/solo6x10/enc.c:101: error: implicit declaration of function 'kzalloc'
drivers/staging/solo6x10/g723.c:139: error: implicit declaration of function 'kzalloc'
解决方案:
添加头文件#include <linux/slab.h>

问题13:
drivers/staging/vme/bridges/vme_tsi148.c:130: error: implicit declaration of function 'ioread32be'
drivers/staging/vme/bridges/vme_tsi148.c:133: error: implicit declaration of function 'ioread32be'
drivers/tty/serial/uartlite.c:79: error: implicit declaration of function 'ioread32be'
drivers/tty/serial/uartlite.c:125: error: implicit declaration of function 'iowrite32be'
解决方案:
#define iowrite32be(v, addr) iowrite32(be32_to_cpu(v), (addr))
#define ioread32be(addr) be32_to_cpu(ioread32(addr))