0

I am working on a device driver for a sensor in Raspberry Pi 4. In the program of a kernel device driver for a sensor, I used the following code to print the resulting distance

pr_info( "Distance (cm) : %.2f \n", cm );

where cm was declared as, float cm = 0.0;

On making the file, I get the following errors

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

When I comment off the above mentioned line of code pr_info( "Distance (cm) : %.2f \n", cm ); the make of driver is successful

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'

The contents of 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

I couldn't find the solution for this. Are we not able to print floating values? Above the mentioned code I used pr_info() to print an integer which did not give any errors.

vrk2412
  • 23
  • 5
  • 1
    Does this answer your question? [Use of floating point in the Linux kernel](https://stackoverflow.com/questions/13886338/use-of-floating-point-in-the-linux-kernel) It describes usage of floating point in the Linux kernel. – Tsyvarev Mar 10 '21 at 08:29
  • @Tsyvarev It gives idea on some modes, but I was not still able to understand what went wrong with the program. – vrk2412 Mar 10 '21 at 08:40
  • 2
    "I was not still able to understand what went wrong with the program" - Eh? The Linux kernel has **no support** for floating point and correct code, which is run in the kernel space, **should not** use floating point. This is what wrong with your program. – Tsyvarev Mar 10 '21 at 08:44
  • @Tsyvarev That solves the problem. – vrk2412 Mar 10 '21 at 10:07

1 Answers1

1

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

That solves the problem.

vrk2412
  • 23
  • 5