结论
Linux内核空间无法调用C库函数并且禁用FPU,可以放弃
了。
- 原因:内核这么设计有利于上下文切换和调度。
解决方法
尝试过手动实现某些三角函数到我的文件中。发现只要涉及浮点数,虽然编译时不会error,但有一些warning如下:
MODPOST 1 modules
WARNING: "__aeabi_f2d" [/work/coding/1_diy/22_dts_i2c_mpu6050/mpu6050.ko] undefined!
WARNING: "__aeabi_fcmplt" [/work/coding/1_diy/22_dts_i2c_mpu6050/mpu6050.ko] undefined!
WARNING: "__aeabi_fmul" [/work/coding/1_diy/22_dts_i2c_mpu6050/mpu6050.ko] undefined!
WARNING: "__aeabi_fdiv" [/work/coding/1_diy/22_dts_i2c_mpu6050/mpu6050.ko] undefined!
WARNING: "__aeabi_f2iz" [/work/coding/1_diy/22_dts_i2c_mpu6050/mpu6050.ko] undefined!
WARNING: "__aeabi_fcmple" [/work/coding/1_diy/22_dts_i2c_mpu6050/mpu6050.ko] undefined!
WARNING: "__aeabi_fcmpge" [/work/coding/1_diy/22_dts_i2c_mpu6050/mpu6050.ko] undefined!
WARNING: "__aeabi_fsub" [/work/coding/1_diy/22_dts_i2c_mpu6050/mpu6050.ko] undefined!
WARNING: "__aeabi_d2f" [/work/coding/1_diy/22_dts_i2c_mpu6050/mpu6050.ko] undefined!
WARNING: "__aeabi_dmul" [/work/coding/1_diy/22_dts_i2c_mpu6050/mpu6050.ko] undefined!
WARNING: "__aeabi_i2f" [/work/coding/1_diy/22_dts_i2c_mpu6050/mpu6050.ko] undefined!
WARNING: "__aeabi_fcmpgt" [/work/coding/1_diy/22_dts_i2c_mpu6050/mpu6050.ko] undefined!
WARNING: "__aeabi_fadd" [/work/coding/1_diy/22_dts_i2c_mpu6050/mpu6050.ko] undefined!
最终加载驱动时会报错如下:
root@ATK-IMX6U:/work# insmod mpu6050.ko
mpu6050: Unknown symbol __aeabi_fadd (err 0)
mpu6050: Unknown symbol __aeabi_fcmpgt (err 0)
mpu6050: Unknown symbol __aeabi_i2f (err 0)
mpu6050: Unknown symbol __aeabi_dmul (err 0)
mpu6050: Unknown symbol __aeabi_d2f (err 0)
mpu6050: Unknown symbol __aeabi_fsub (err 0)
mpu6050: Unknown symbol __aeabi_fcmpge (err 0)
mpu6050: Unknown symbol __aeabi_fcmple (err 0)
mpu6050: Unknown symbol __aeabi_f2iz (err 0)
mpu6050: Unknown symbol __aeabi_fdiv (err 0)
mpu6050: Unknown symbol __aeabi_fmul (err 0)
mpu6050: Unknown symbol __aeabi_fcmplt (err 0)
mpu6050: Unknown symbol __aeabi_f2d (err 0)
原因是:
当前使用Linux内核版本不支持ARM平台的相关运算,相同的内核代码在X86平台是没有问题的。