technexion-android / cookers

Please select your target branch first, then the detail instruction is inside the README.md
8 stars 9 forks source link

Kernel print logs - Issue #25

Closed toni1727 closed 3 years ago

toni1727 commented 3 years ago

Merry Christmas!

I am trying to integrate an acceleration sensor and I have problems. The point is that I try to put records to debug but they don't appear! printk does not work for kernel debugging. Do I have to do something special for the logs to appear?

Thanks a lot.

wigcheng commented 3 years ago

That's Impossible I think, how do you put your printk? I think a possible is your driver could not running correct.

toni1727 commented 3 years ago

Hello and Happy new year!,

I'm using the LSM9DS1 sensor and i added the st_imu68 IIO driver into my kernel.

https://github.com/STMicroelectronics/STMems_Linux_IIO_drivers/tree/linux-4.14.y-gh/drivers/iio/imu/st_imu68

Inside /sys/bus/iio/devices i can read raw devices. So the driver is working fine.

But the app still cannot read the data.

This is the DTS File:

Dts file:

lsm9ds1_ag@6b { compatible = "st,lsm9ds1"; reg = <0x6B>; status = "okay"; interrupt-parent = <&intc>; interrupts = <0 89 IRQ_TYPE_LEVEL_HIGH>; interrupt-names = "ag_irq"; };

lsm9ds1_m@1e{ compatible = "st,lsm9ds1_magn"; reg = <0x1E>; status = "okay"; interrupt-parent = <&intc>; interrupts = <0 90 IRQ_TYPE_LEVEL_HIGH>; interrupt-names = "m_irq"; };

I have no idea how to configure interrupts. I have copied them from another site. it's okay?

interrupt-parent = <& intc>; interrupts = <0 90 IRQ_TYPE_LEVEL_HIGH>; interrupt-names = "m_irq";

Thank you!!

wigcheng commented 3 years ago

What is your irq pin? connect to CPU? You need to define irq pinmux in dts first.

toni1727 commented 3 years ago

I don't have an IRQ pin physically connected.

How would software interrupts be configured?

Best regards.

wigcheng commented 3 years ago

I have no touch this sensor before, and I think soft irq could be works, but you should confirm dts configuration is right (refer other board first?).

In addition,issue 'cat /proc/interrupts' command can observe your irq is working or not, try it, please. Thanks a lot!

Happy new year!

toni1727 commented 3 years ago

I have no idea if that interrupt is okay. I copied it. How do you configure a software interrupt? I thought it depended on each CPU, not the sensor.

The driver of the component is this:

https://github.com/STMicroelectronics/STMems_Linux_IIO_drivers/tree/linux-4.14.y-gh/drivers/iio/imu/st_imu68

I'm sure it's because of the interruptions, everything is configured well, the only thing that the component doesn't launch the events.

image

This is the Logs: image

wigcheng commented 3 years ago

Just checked your log, I have some comment as following:

I recommend separated two part to debug: kernel layer and framework layer, and you need to confirm kernel layer has no problems first:

I saw the STMicro has example, and you should be refer it, but you have no connect physical irq, their example is connect real irq, so I think it's wrong: https://github.com/STMicroelectronics/STMems_Linux_IIO_drivers

And about this example, it has read sensor data command, do you try it before? you see device node was generated not means driver is correct, you have to find some command/tools to verify your driver's 'read' function is works: https://github.com/jsagfr/lsm9ds1

If read function works but app still faied, that should be permission/selinux problem, or missing some HIDL driver definition.

Good luck!

toni1727 commented 3 years ago

Thank you very much!

If I execute this command:

cat / sys / bus / iio / devices / iio \: device0 / in_accel_x_raw

Device or resource busy

I get that, but before I read it without problems. I think I get that because the HAL II layer is using it now.

App still failed

wigcheng commented 3 years ago

you can take out HAL layer from HIDL definition first, it's in device/fsl/imx7d/pico-imx7d/manifest.xml, should be has sensor relate tag, remove them first.

You need confirm for command executing works first.

toni1727 commented 3 years ago

I added SELinux policy (I hadn't done it before):

############################################################
STSensors.te

type STSensors, domain, mlstrustedsubject, coredomain;
type STSensors_exec, exec_type, file_type;

# Started by init
init_daemon_domain(STSensors)

# Access to /persist/STSensors
allow STSensors persist_file:dir r_dir_perms;
allow STSensors persist_STSensors_file:dir rw_dir_perms;
allow STSensors persist_STSensors_file:file create_file_perms;

# Access to /data/STSensorHAL
allow STSensors system_data_file:dir  { create_dir_perms getattr };
allow STSensors system_data_file:file create_file_perms;

# This part is to be used if APK is used to get calibration data
allow STSensors app_data_file:dir  { rw_dir_perms getattr };
allow STSensors app_data_file:file rw_file_perms;

############################################################

But I received two errors when I compile:

STSensors.te:8:ERROR 'unknown type persist_file' at token ';'

"ERROR: permissive domains not allowed in user builds\" violated by allow STSensors system_data_file:file { write create setattr append unlink rename }

toni1727 commented 3 years ago

By the way, If I take out HAL layer from HIDL definition:

pico_imx7:/ # cat /sys/bus/iio/devices/iio:device0/in_accel_x_raw
-51
pico_imx7:/ # cat /sys/bus/iio/devices/iio:device0/in_accel_x_raw                                                                                                                                                 
-50
pico_imx7:/ # cat /sys/bus/iio/devices/iio:device0/in_accel_x_raw                                                                                                                                                 
-595
pico_imx7:/ # cat /sys/bus/iio/devices/iio:device0/in_accel_x_raw                                                                                                                                                 
-1240
wigcheng commented 3 years ago
  1. Are those sensor's output match your requirement??
  2. If yes, it means kernel driver/dts has no problem, please disable selinux before test your app as following command:

    setenforce 0

Also remember check your device node permission (0666 is recommended).

toni1727 commented 3 years ago
  1. Yes
  2. With setenforce 0 it doesn't work either. I think it has to be something related to software readings.
wigcheng commented 3 years ago

That's a bit complicated!! I suggest you can recover your manifest file first, because you're confirm your kernel layer has no problems, and add debug messages on HAL layer (confirm HAL driver already occupy device node first), observe HAL driver still get right output.

If no problem, keep trace JNI layer, but I think the root cause should be in HAL or permission as my experience.

Welcome to post your HAL debug message here, thanks.

wigcheng commented 3 years ago

May I close this issue ticket if no any update?

toni1727 commented 3 years ago

I haven't gotten it to work. I have contacted the developer of STMems_Android_Sensor_HAL_IIO Let's see if we are lucky.

Thanks a lot!

wigcheng commented 3 years ago

Good luck, hope have good news soon, keep updated here if possible, and welcome to ask question if you have concern on BSP part, thanks!