Linux内核树外驱动程序编译失败,生成错误为0

Linux内核树外驱动程序编译失败,生成错误为0,linux,linux-kernel,raspberry-pi,driver,linux-device-driver,Linux,Linux Kernel,Raspberry Pi,Driver,Linux Device Driver,在Raspberry Pi 3上,我正在编译一个自定义Linux内核,并希望包含一个开源软件PWM内核驱动程序 我为Linux源代码克隆了以下存储库: https://github.com/raspberrypi/linux.git 我为软件克隆了以下存储库: https://github.com/dagon666/rpi_SoftPwm 成功构建内核后,我按照自述文件编译软件PWM驱动程序,如下所示: pi@raspberrypi:~/Desktop/rpi_SoftPwm $ make

在Raspberry Pi 3上,我正在编译一个自定义Linux内核,并希望包含一个开源软件PWM内核驱动程序

我为Linux源代码克隆了以下存储库:

https://github.com/raspberrypi/linux.git
我为软件克隆了以下存储库:

https://github.com/dagon666/rpi_SoftPwm
成功构建内核后,我按照自述文件编译软件PWM驱动程序,如下所示:

pi@raspberrypi:~/Desktop/rpi_SoftPwm $ make M=/home/pi/Desktop/rpi_SoftPwm -C /home/pi/linux/ modules
编译失败,错误如下:

make: Entering directory '/home/pi/linux'
  CC [M]  /home/pi/Desktop/rpi_SoftPwm/pwm.o
In file included from ./include/linux/thread_info.h:11:0,
                 from ./include/asm-generic/preempt.h:4,
                 from ./arch/arm/include/generated/asm/preempt.h:1,
                 from ./include/linux/preempt.h:59,
                 from ./include/linux/spinlock.h:50,
                 from ./include/linux/seqlock.h:35,
                 from ./include/linux/time.h:5,
                 from ./include/linux/stat.h:18,
                 from ./include/linux/module.h:10,
                 from /home/pi/Desktop/rpi_SoftPwm/pwm.c:2:
./include/linux/bug.h:37:45: error: negative width in bit-field ‘<anonymous>’
 #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
                                             ^
./include/linux/kernel.h:854:3: note: in expansion of macro ‘BUILD_BUG_ON_ZERO’
   BUILD_BUG_ON_ZERO((perms) & 2) +     \
   ^
./include/linux/sysfs.h:102:12: note: in expansion of macro ‘VERIFY_OCTAL_PERMISSIONS’
    .mode = VERIFY_OCTAL_PERMISSIONS(_mode) },  \
            ^
/home/pi/Desktop/rpi_SoftPwm/pwm.c:155:2: note: in expansion of macro ‘__ATTR’
  __ATTR(export, 0222, NULL, export_store),
  ^
./include/linux/bug.h:37:45: error: negative width in bit-field ‘<anonymous>’
 #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
                                             ^
./include/linux/kernel.h:854:3: note: in expansion of macro ‘BUILD_BUG_ON_ZERO’
   BUILD_BUG_ON_ZERO((perms) & 2) +     \
   ^
./include/linux/sysfs.h:102:12: note: in expansion of macro ‘VERIFY_OCTAL_PERMISSIONS’
    .mode = VERIFY_OCTAL_PERMISSIONS(_mode) },  \
            ^
/home/pi/Desktop/rpi_SoftPwm/pwm.c:156:2: note: in expansion of macro ‘__ATTR’
  __ATTR(unexport, 0222, NULL, unexport_store),
  ^
scripts/Makefile.build:299: recipe for target '/home/pi/Desktop/rpi_SoftPwm/pwm.o' failed
make[1]: *** [/home/pi/Desktop/rpi_SoftPwm/pwm.o] Error 1
Makefile:1490: recipe for target '_module_/home/pi/Desktop/rpi_SoftPwm' failed
make: *** [_module_/home/pi/Desktop/rpi_SoftPwm] Error 2
make: Leaving directory '/home/pi/linux'
make:进入目录'/home/pi/linux'
CC[M]/home/pi/Desktop/rpi_SoftPwm/pwm.o
在包含自./include/linux/thread_info.h:11:0的文件中,
from./include/asm generic/preempt.h:4,
from./arch/arm/include/generated/asm/preempt.h:1,
from./include/linux/preempt.h:59,
from./include/linux/spinlock.h:50,
from./include/linux/seqlock.h:35,
from./include/linux/time.h:5,
from./include/linux/stat.h:18,
from./include/linux/module.h:10,
from/home/pi/Desktop/rpi_SoftPwm/pwm.c:2:
./include/linux/bug.h:37:45:错误:位字段“”中的负宽度
#在0(e)(sizeof(struct{int:-!!(e);}))上定义构建错误
^
./include/linux/kernel.h:854:3:注意:在宏“BUILD\u BUG\u ON\u ZERO”的扩展中
在零(perms)和2+\
^
./include/linux/sysfs.h:102:12:注意:在宏“VERIFY_octall_PERMISSIONS”的扩展中
.mode=验证\u八进制\u权限(\u模式)}\
^
/home/pi/Desktop/rpi_SoftPwm/pwm.c:155:2:注意:在宏“\uu ATTR”的展开中
__属性(导出,0222,空,导出存储),
^
./include/linux/bug.h:37:45:错误:位字段“”中的负宽度
#在0(e)(sizeof(struct{int:-!!(e);}))上定义构建错误
^
./include/linux/kernel.h:854:3:注意:在宏“BUILD\u BUG\u ON\u ZERO”的扩展中
在零(perms)和2+\
^
./include/linux/sysfs.h:102:12:注意:在宏“VERIFY_octall_PERMISSIONS”的扩展中
.mode=验证\u八进制\u权限(\u模式)}\
^
/home/pi/Desktop/rpi\u SoftPwm/pwm.c:156:2:注意:在宏“\uu ATTR”的展开中
__ATTR(未报告,0222,空,未报告存储),
^
scripts/Makefile.build:299:目标“/home/pi/Desktop/rpi_SoftPwm/pwm.o”的配方失败
make[1]:***[/home/pi/Desktop/rpi_SoftPwm/pwm.o]错误1
Makefile:1490:目标“\u module\u/home/pi/Desktop/rpi\u SoftPwm”的配方失败
make:**[\u模块\家庭/pi/桌面/rpi\软PWM]错误2
make:离开目录“/home/pi/linux”
我曾试图在谷歌上对此进行研究,但没有找到解决方案。失败与_ATTR宏有关。它过去是使用较旧的Linux内核3.19编译的,但是现在Raspbian使用的是Linux 4+


我怎样才能编译这个?谢谢。

Linux内核开发人员倾向于为非root用户创建不可写的属性(在
/sys
下的文件)。这是宏验证八进制权限所检查的:权限不应设置标志
S\u IWOTH
(第二位)


将权限0222替换为0220,这样编译就会成功。

Linux内核开发人员倾向于为非根用户创建不可写的属性(在
/sys
下的文件)。这是宏验证八进制权限所检查的:权限不应设置标志
S\u IWOTH
(第二位)

将权限0222替换为0220,编译将成功