北镇做网站,网络营销媒体有哪些,wordpress footer错位,wordpress标签加icon前言
开发板型号#xff1a;RK_EVB7_RK3588_LP4…_V11目标#xff1a;在开发板上随开机自启动脚本#xff0c;带起二进制程序#xff0c;并完备一些其他系统功能。简介#xff1a;本文自启动脚本run.sh唯一的作用就是拉起二进制程序demo#xff1b;demo是简单的hello_wo…前言
开发板型号RK_EVB7_RK3588_LP4…_V11目标在开发板上随开机自启动脚本带起二进制程序并完备一些其他系统功能。简介本文自启动脚本run.sh唯一的作用就是拉起二进制程序demodemo是简单的hello_world程序使用android-ndk-r18 toolchain编译而成。
开启ADB功能
默认的evb7_dtsi关闭了USB 3.0 host因此无法通过Type-C接口连接到本地设备设备。通过修改kernel-5.10/arch/arm64/boot/dts/rockchip/rk3588-evb7-v11.dtsi文件使能adb。usbhost3_0 {
- status disabled; status okay;
};usbhost_dwc3_0 {
- status disabled; status okay;
};添加Android native层服务
在系统添加执行目录
在device/rockchip/common/添加your/bin/将可执行程序demo和对应的启动脚本run.sh放在下面。run.sh代码如下。#! /system/bin/sh/vendor/app/your/bin/demo修改device/rockchip/common/device.mk。添加如下代码。Andorid 8.0以上新建应用须放在/vendor目录。PRODUCT_COPY_FILES \device/rockchip/common/your/bin/demo:vendor/app/your/bin/demo:mode755 \device/rockchip/common/your/bin/run.sh:vendor/app/your/bin/run.sh:mode755烧录系统后将出现/vendor/app/your目录以及目录下bin/的可执行文件。
在只读分区修改文件属性
vondor分区为只读分区修改文件属性只能通过修改config.fs方式达成。添加device/rockchip/common/config.fs文件。文件内容如下。[vendor/app/your/bin/run.sh]
mode: 0755
user: AID_SYSTEM
group: AID_SYSTEM
caps: WAKE_ALARM[vendor/app/your/bin/demo]
mode: 0755
user: AID_SYSTEM
group: AID_SYSTEM
caps: WAKE_ALARM在device/rockchip/common/BoardConfig.mk添加如下代码。TARGET_FS_CONFIG_GEN : device/rockchip/common/config.fs添加Native层服务并随开机自启动 修改device/rockchip/common/rootdir/init.rockchip.rc在文件末尾添加如下代码。 service demo /vendor/app/your/bin/run.shclass mainuser rootgroup rootoneshoton property:sys.boot_completed1start demo配置SELinux权限 修改device/rockchip/common/sepolicy/vendor/file_contexts在末尾添加下面的代码。注意file_contexts最后一行一定是空行否则编译不过/vendor/app/your/bin/run.sh u:object_r:demo_exec:s0
/vendor/app/your/bin/demo u:object_r:demo_exec:s0 新建device/rockchip/common/sepolicy/vendor/demo.te添加代码。type demo_domain, domain;
type demo_exec, exec_type, vendor_file_type, file_type;
type demo_domain_exec, exec_type, vendor_file_type, file_type;init_daemon_domain(demo_domain)allow demo_domain demo_exec:file { getattr open read execute map execute_no_trans };
allow demo_domain demo_domain_exec:file { entrypoint open read execute getattr map };
allow demo_domain postinstall_mnt_dir:dir { getattr };
allow demo_domain system_data_root_file:dir { read };allow init demo_domain_exec:file { getattr open read execute map };
allow init demo_domain:process transition;allow shell demo_exec:file { execute read open execute_no_trans map getattr };
allow shell postinstall_mnt_dir:dir { getattr };allow init-insmod-sh demo_exec:file { execute_no_trans };在device/rockchip/common/sepolicy/vendor/init-insmod-sh.te添加如下代码。allow init-insmod-sh postinstall_mnt_dir:dir { getattr };
allow init-insmod-sh system_data_root_file:dir { read };验证服务是否开启 烧录后通过pgrep demo查看进程PID。进一步的可以通过ps -ef | grep demo查看进程细节内容。如果没有通过logcat | grep -E run.sh|demo查看日志如出现avc denied字样需根据对应日志修改demo.te。
通过audit2allow工具自动生成政策文件
audit2allow是一个非常有用的工具可以帮助你自动生成SELinux策略语句。安装audit2allow。 sudo apt install policycoreutils抓取和权限相关的log指令并重定向保存至文件例如avcTest.txtadb logcat -b all | grep avc ./avcTest.txt将保存相关的log的文件复制到ubuntu里面使用命令audit2allow -i avcTest.txt -o avc.te