RPi4:设备驱动程序 - pr_info 带有浮动导致构建错误
RPi4 : Device Driver - pr_info with float causing build error
我正在为 Raspberry Pi 4 中的传感器开发设备驱动程序。在传感器的 内核设备驱动程序 的程序中,我使用以下代码打印结果距离
pr_info( "Distance (cm) : %.2f \n", cm );
其中 cm
声明为 float cm = 0.0;
制作文件时,出现以下错误
pi@raspberrypi:~/TestCodes/3_10MAR21 $ make
make -C /lib/modules/5.10.20-v7l+/build M=/home/pi/TestCodes/3_10MAR21 modules
make[1]: Entering directory '/home/pi/kernel/linux'
CC [M] /home/pi/TestCodes/3_10MAR21/driver_ultraS_2.o
MODPOST /home/pi/TestCodes/3_10MAR21/Module.symvers
ERROR: modpost: "__aeabi_f2iz" [/home/pi/TestCodes/3_10MAR21/driver_ultraS_2.ko] undefined!
ERROR: modpost: "__aeabi_ddiv" [/home/pi/TestCodes/3_10MAR21/driver_ultraS_2.ko] undefined!
ERROR: modpost: "__aeabi_f2d" [/home/pi/TestCodes/3_10MAR21/driver_ultraS_2.ko] undefined!
ERROR: modpost: "__aeabi_d2f" [/home/pi/3_10MAR21/driver_ultraS_2.ko] undefined!
ERROR: modpost: "__aeabi_dadd" [/home/pi/TestCodes/3_10MAR21/driver_ultraS_2.ko] undefined!
ERROR: modpost: "__aeabi_dmul" [/home/pi/TestCodes/3_10MAR21/driver_ultraS_2.ko] undefined!
ERROR: modpost: "__aeabi_ui2d" [/home/pi/TestCodes/3_10MAR21/driver_ultraS_2.ko] undefined!
make[2]: *** [scripts/Makefile.modpost:111: /home/pi/TestCodes/3_10MAR21/Module.symvers] Error 1
make[2]: *** Deleting file '/home/pi/TestCodes/3_10MAR21/Module.symvers'
make[1]: *** [Makefile:1708: modules] Error 2
make[1]: Leaving directory '/home/pi/kernel/linux'
make: *** [Makefile:7: all] Error 2
当我注释掉上面提到的那行代码时pr_info( "Distance (cm) : %.2f \n", cm );
驱动制作成功
pi@raspberrypi:~/TestCodes/3_10MAR21 $ make
make -C /lib/modules/5.10.20-v7l+/build M=/home/pi/TestCodes/3_10MAR21 modules
make[1]: Entering directory '/home/pi/kernel/linux'
CC [M] /home/pi/TestCodes/3_10MAR21/driver_ultraS_2.o
MODPOST /home/pi/TestCodes/3_10MAR21/Module.symvers
CC [M] /home/pi/TestCodes/3_10MAR21/driver_ultraS_2.mod.o
LD [M] /home/pi/TestCodes/3_10MAR21/driver_ultraS_2.ko
make[1]: Leaving directory '/home/pi/kernel/linux'
Makefile 的内容
obj-m += driver_ultraS_2.o
KDIR = /lib/modules/$(shell uname -r)/build
all:
make -C $(KDIR) M=$(shell pwd) modules
clean:
make -C $(KDIR) M=$(shell pwd) clean
我找不到解决这个问题的方法。 我们不能打印浮点值吗?
在上面提到的代码中,我使用 pr_info()
打印了一个没有给出任何错误的整数。
The Linux kernel has no support for floating point and correct code,
which is run in the kernel space, should not use floating point
-Tsyvarev
问题解决了。
我正在为 Raspberry Pi 4 中的传感器开发设备驱动程序。在传感器的 内核设备驱动程序 的程序中,我使用以下代码打印结果距离
pr_info( "Distance (cm) : %.2f \n", cm );
其中 cm
声明为 float cm = 0.0;
制作文件时,出现以下错误
pi@raspberrypi:~/TestCodes/3_10MAR21 $ make
make -C /lib/modules/5.10.20-v7l+/build M=/home/pi/TestCodes/3_10MAR21 modules
make[1]: Entering directory '/home/pi/kernel/linux'
CC [M] /home/pi/TestCodes/3_10MAR21/driver_ultraS_2.o
MODPOST /home/pi/TestCodes/3_10MAR21/Module.symvers
ERROR: modpost: "__aeabi_f2iz" [/home/pi/TestCodes/3_10MAR21/driver_ultraS_2.ko] undefined!
ERROR: modpost: "__aeabi_ddiv" [/home/pi/TestCodes/3_10MAR21/driver_ultraS_2.ko] undefined!
ERROR: modpost: "__aeabi_f2d" [/home/pi/TestCodes/3_10MAR21/driver_ultraS_2.ko] undefined!
ERROR: modpost: "__aeabi_d2f" [/home/pi/3_10MAR21/driver_ultraS_2.ko] undefined!
ERROR: modpost: "__aeabi_dadd" [/home/pi/TestCodes/3_10MAR21/driver_ultraS_2.ko] undefined!
ERROR: modpost: "__aeabi_dmul" [/home/pi/TestCodes/3_10MAR21/driver_ultraS_2.ko] undefined!
ERROR: modpost: "__aeabi_ui2d" [/home/pi/TestCodes/3_10MAR21/driver_ultraS_2.ko] undefined!
make[2]: *** [scripts/Makefile.modpost:111: /home/pi/TestCodes/3_10MAR21/Module.symvers] Error 1
make[2]: *** Deleting file '/home/pi/TestCodes/3_10MAR21/Module.symvers'
make[1]: *** [Makefile:1708: modules] Error 2
make[1]: Leaving directory '/home/pi/kernel/linux'
make: *** [Makefile:7: all] Error 2
当我注释掉上面提到的那行代码时pr_info( "Distance (cm) : %.2f \n", cm );
驱动制作成功
pi@raspberrypi:~/TestCodes/3_10MAR21 $ make
make -C /lib/modules/5.10.20-v7l+/build M=/home/pi/TestCodes/3_10MAR21 modules
make[1]: Entering directory '/home/pi/kernel/linux'
CC [M] /home/pi/TestCodes/3_10MAR21/driver_ultraS_2.o
MODPOST /home/pi/TestCodes/3_10MAR21/Module.symvers
CC [M] /home/pi/TestCodes/3_10MAR21/driver_ultraS_2.mod.o
LD [M] /home/pi/TestCodes/3_10MAR21/driver_ultraS_2.ko
make[1]: Leaving directory '/home/pi/kernel/linux'
Makefile 的内容
obj-m += driver_ultraS_2.o
KDIR = /lib/modules/$(shell uname -r)/build
all:
make -C $(KDIR) M=$(shell pwd) modules
clean:
make -C $(KDIR) M=$(shell pwd) clean
我找不到解决这个问题的方法。 我们不能打印浮点值吗?
在上面提到的代码中,我使用 pr_info()
打印了一个没有给出任何错误的整数。
The Linux kernel has no support for floating point and correct code, which is run in the kernel space, should not use floating point
-Tsyvarev
问题解决了。