【android12-linux-5.1】【ST芯片】HAL移植后开机卡死

按照ST的官方readme移植HAL后开机一直卡在android界面,看logcat提示写文件时errorcode:-13。查下资料大致明白13错误码是权限不足,浏览代码在写文件的接口加日志后,发现是需要写iio:device*/buffer/enable这类文件的时候报错的。千万不要傻傻的手动去修改这一个文件的权限(我就是那个傻子),修改完编译好刷机后,你会发现又有别的文件没权限依旧报-13,。而且,每次开机手动加权限实在太恶心。仔细看文档后,发现还有个文件:

/hardware/STMicroelectronics/SensorHAL_IIO/Documentation/ueventd.example.rc

这个文件里面给出了需要加权限的文件路径,如下图:

【android12-linux-5.1】【ST芯片】HAL移植后开机卡死_第1张图片

 理论上是把这个文件的内容拷贝到如下路径文件添加到末尾就行:

/device/rockchip/common/rootdir/ueventd.rockchip.rc

但是系统原因,iio:device所在路径可能有变化,我的路径在:/sys/bus/iio/devices/iio:device,与文档就不一致。所以要根据自身系统情况修改前缀。

除了文档列出的,还有一个路径需要加:/sys/bus/iio/devices/iio:device* current_timestamp_clock 0666 system system

增加内容:

#common iio char devices
/dev/iio:device* 0666 system system
/sys/bus/iio/devices/iio:device* current_timestamp_clock 0666 system system

#common sensors files
/sys/bus/iio/devices/iio:device* buffer/enable 0666 system system
/sys/bus/iio/devices/iio:device* buffer/length 0666 system system
/sys/bus/iio/devices/iio:device* sampling_frequency 0666 system system
/sys/bus/iio/devices/iio:device* scan_elements/in_timestamp_en 0666 system system
/sys/bus/iio/devices/iio:device* hwfifo_flush 0666 system system
/sys/bus/iio/devices/iio:device* hwfifo_enabled 0666 system system
/sys/bus/iio/devices/iio:device* hwfifo_watermark 0666 system system
/sys/bus/iio/devices/iio:device* injection_mode 0666 system system

#accelerometer sensor
/sys/bus/iio/devices/iio:device* scan_elements/in_accel_x_en 0666 system system
/sys/bus/iio/devices/iio:device* scan_elements/in_accel_y_en 0666 system system
/sys/bus/iio/devices/iio:device* scan_elements/in_accel_z_en 0666 system system
/sys/bus/iio/devices/iio:device* in_accel_x_scale 0666 system system
/sys/bus/iio/devices/iio:device* in_accel_y_scale 0666 system system
/sys/bus/iio/devices/iio:device* in_accel_z_scale 0666 system system
/sys/bus/iio/devices/iio:device* in_accel_injection_raw 0666 system system

#magnetometer sensor
/sys/bus/iio/devices/iio:device* scan_elements/in_magn_x_en 0666 system system
/sys/bus/iio/devices/iio:device* scan_elements/in_magn_y_en 0666 system system
/sys/bus/iio/devices/iio:device* scan_elements/in_magn_z_en 0666 system system
/sys/bus/iio/devices/iio:device* in_magn_x_scale 0666 system system
/sys/bus/iio/devices/iio:device* in_magn_y_scale 0666 system system
/sys/bus/iio/devices/iio:device* in_magn_z_scale 0666 system system

#gyroscope sensor
/sys/bus/iio/devices/iio:device* scan_elements/in_anglvel_x_en 0666 system system
/sys/bus/iio/devices/iio:device* scan_elements/in_anglvel_y_en 0666 system system
/sys/bus/iio/devices/iio:device* scan_elements/in_anglvel_z_en 0666 system system
/sys/bus/iio/devices/iio:device* in_anglvel_x_scale 0666 system system
/sys/bus/iio/devices/iio:device* in_anglvel_y_scale 0666 system system
/sys/bus/iio/devices/iio:device* in_anglvel_z_scale 0666 system system

#pressure sensor
/sys/bus/iio/devices/iio:device* scan_elements/in_pressure_en 0666 system system
/sys/bus/iio/devices/iio:device* scan_elements/in_temp_en 0666 system system
/sys/bus/iio/devices/iio:device* in_pressure_scale 0666 system system

#step counter sensor
/sys/bus/iio/devices/iio:device* max_delivery_rate 0666 system system
/sys/bus/iio/devices/iio:device* reset_counter 0666 system system
/sys/bus/iio/devices/iio:device* scan_elements/in_step_counter_en 0666 system system


#significant motion sensor
/sys/bus/iio/devices/iio:device* scan_elements/in_sign_motion_en 0666 system system

#step detector sensor
/sys/bus/iio/devices/iio:device* scan_elements/in_step_detector_en 0666 system system

#tilt sensor
/sys/bus/iio/devices/iio:device* scan_elements/in_tilt_en 0666 system system

添加好后,还有个坑,文件前面可能有同路径的配置,可能会有影响,需要自己排查处理。

修改好后,就可以实现开机顺利启动不需要手动添加权限了。

新人入行,经验分享,如有所误,欢迎指出~

 版权归属:深圳市琪智科技有限公司-花花

你可能感兴趣的:(Android,android,linux)