当前位置: 首页 > news >正文

20250711荣品RD-RK3588开发板在Android13下的开机自启动的配置步骤

20250711荣品RD-RK3588开发板在Android13下的开机自启动的配置步骤
2025/7/11 9:06


1、
Z:\Android13.0\device\rockchip\common\sepolicy\vendor\file_contexts
# rpdzkj mem_test
/vendor/bin/rp_stress_test/cpu_ddr_stress_test.sh   u:object_r:mem_test_exec:s0

#for_forlinx
/vendor/bin/autostart_test.sh u:object_r:autostart_test_exec:s0


2、
Z:\Android13.0\device\rockchip\common\sepolicy\vendor\system_server.te
#allow system_server sysfs:file { read open getattr };
# for gpu
allow system_server abc:dir { read open getattr };
allow system_server serial_device:chr_file rw_file_perms;
allow system_server sysfs_extcon:file r_file_perms;


# for forlinx
allow system_server debug_prop:property_service set;

type autostart_test, domain;
type autostart_test_exec, exec_type,vendor_file_type,file_type;

init_daemon_domain(autostart_test)

allow autostart_test vendor_shell_exec:file rx_file_perms;
allow autostart_test vendor_toolbox_exec:file rx_file_perms;
allow autostart_test console_device:chr_file { open write };
allow autostart_test autostart_test:capability { sys_module };
allow autostart_test vendor_file:system { module_load };


# for storage
allow system_server storage_stub_file:dir getattr;

allow system_server zygote:process getpgid;

allow system_server sysfs_net:file r_file_perms;
r_dir_file(system_server, metadata_file)


# for forlinx
allow autostart_test serial_device:chr_file { ioctl open read write };


#rk_output_hal
allow system_server rk_output_hal_service:hwservice_manager find;
allow system_server zygote:process { getsched setsched };
allow system_server sysfs_hdmi:file { read open getattr };

add_service(system_server,drm_device_management_service)

binder_call(system_server, rk_output_hal)
binder_call(system_server, zygote)

rw_rockchip_graphic_device(system_server)

get_prop(system_server, vendor_base_prop)


3、新增:【开机自启动脚本文件】
Z:\Android13.0\device\rockchip\rk3588\rk3588_t\autostart_test.sh
#!/vendor/bin/sh
echo "Forlinx:: 2025/4/17 11:39 ::GNSS_CONFIG start!" > /dev/ttyFIQ0
echo "This is a test" > /dev/ttyFIQ0
#echo $(date) > /data/date.txt
#/system/bin/rk3566_android_serial
sleep 30
/system/bin/iptables -t filter -F tetherctrl_FORWARD
#/vendor/bin/clear_drop
echo "Forlinx:: 2025/4/17 11:49 ::GNSS_CONFIG end!" > /dev/ttyFIQ0
/system/bin/uart2tcp


4、
Z:\Android13.0\device\rockchip\rk3588\rk3588_t\rk3588_t.mk
#
# Copyright 2014 The Android Open-Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# First lunching is T, api_level is 33
PRODUCT_SHIPPING_API_LEVEL := 33
PRODUCT_DTBO_TEMPLATE := $(LOCAL_PATH)/dt-overlay.in

include device/rockchip/common/build/rockchip/DynamicPartitions.mk
include device/rockchip/rk3588/rk3588_t/BoardConfig.mk
include device/rockchip/common/BoardConfig.mk
$(call inherit-product, device/rockchip/rk3588/device.mk)
$(call inherit-product, device/rockchip/common/device.mk)
$(call inherit-product, frameworks/native/build/tablet-10in-xhdpi-2048-dalvik-heap.mk)

DEVICE_PACKAGE_OVERLAYS += $(LOCAL_PATH)/../overlay

PRODUCT_CHARACTERISTICS := tablet

PRODUCT_NAME := rk3588_t
PRODUCT_DEVICE := rk3588_t
PRODUCT_BRAND := rockchip
PRODUCT_MODEL := rk3588_t
PRODUCT_MANUFACTURER := rockchip
PRODUCT_AAPT_PREF_CONFIG := mdpi
#
## add Rockchip properties
#
#PRODUCT_PROPERTY_OVERRIDES += ro.sf.lcd_density=320
PRODUCT_PROPERTY_OVERRIDES += ro.wifi.sleep.power.down=true
PRODUCT_PROPERTY_OVERRIDES += persist.wifi.sleep.delay.ms=0
PRODUCT_PROPERTY_OVERRIDES += persist.bt.power.down=true
#PRODUCT_PROPERTY_OVERRIDES += vendor.hwc.device.primary=DSI
#PRODUCT_PROPERTY_OVERRIDES += vendor.hwc.device.extend=HDMI-A,eDP

# copy test.sh to dir vendor/bin/test.sh
#PRODUCT_COPY_FILES +=device/rockchip/rk356x/rk3566_t/myapp.sh:vendor/bin/myapp.sh
PRODUCT_COPY_FILES +=device/rockchip/rk3588/rk3588_t/uart2tcp:/system/bin/uart2tcp
PRODUCT_COPY_FILES +=device/rockchip/rk3588/rk3588_t/autostart_test.sh:vendor/bin/autostart_test.sh


5、新增。【你需要开机自启动的Native C语言程序,编译之后的二进制文件。】
Z:\Android13.0\device\rockchip\rk3588\rk3588_t\uart2tcp


6、
Z:\Android13.0\system\core\rootdir\init.rc

    # Define default initial receive window size in segments.
setprop net.tcp_def_init_rwnd 60

    # Update dm-verity state and set partition.*.verified properties.
verity_update_state

    # Start standard binderized HAL daemons
class_start hal

    class_start core


service autostart_test /vendor/bin/autostart_test.sh
class main
user root
group root
disabled
oneshot


on nonencrypted
class_start main
class_start late_start

on property:sys.init_log_level=*
loglevel ${sys.init_log_level}

on charger
class_start charger

on property:sys.boot_completed=1
bootchart stop
# Setup per_boot directory so other .rc could start to use it on boot_completed
exec - system system -- /bin/rm -rf /data/per_boot
mkdir /data/per_boot 0700 system system encryption=Require key=per_boot_ref
    start autostart_test

# system server cannot write to /proc/sys files,
# and chown/chmod does not work for /proc/sys/ entries.
# So proxy writes through init.
on property:sys.sysctl.extra_free_kbytes=*
exec -- /system/bin/extra_free_kbytes.sh ${sys.sysctl.extra_free_kbytes}

开机自启动的脚本:OK3588_android_autostart.patch

diff --git a/device/rockchip/common/sepolicy/vendor/file_contexts b/device/rockchip/common/sepolicy/vendor/file_contexts
index 148f9f94f2..69f6c03620 100644
--- a/device/rockchip/common/sepolicy/vendor/file_contexts
+++ b/device/rockchip/common/sepolicy/vendor/file_contexts
@@ -235,6 +235,9 @@
#flash_img
/vendor/bin/flash_img.sh u:object_r:vendor_install_recovery_exec:s0

+#for_forlinx
+/vendor/bin/autostart_test.sh u:object_r:autostart_test_exec:s0
+
# rk dma_buf heaps
/dev/dma_heap/cma            u:object_r:dmabuf_system_heap_device:s0
/dev/dma_heap/system-dma32        u:object_r:dmabuf_system_heap_device:s0
diff --git a/device/rockchip/common/sepolicy/vendor/system_server.te b/device/rockchip/common/sepolicy/vendor/system_server.te
index ddce9e9832..2ee867babe 100644
--- a/device/rockchip/common/sepolicy/vendor/system_server.te
+++ b/device/rockchip/common/sepolicy/vendor/system_server.te
@@ -4,6 +4,20 @@ allow system_server abc:dir { read open getattr };
allow system_server serial_device:chr_file rw_file_perms;
allow system_server sysfs_extcon:file r_file_perms;

+# for forlinx
+allow system_server debug_prop:property_service set;
+
+type autostart_test, domain;
+type autostart_test_exec, exec_type,vendor_file_type,file_type;
+
+init_daemon_domain(autostart_test)
+
+allow autostart_test vendor_shell_exec:file rx_file_perms;
+allow autostart_test vendor_toolbox_exec:file rx_file_perms;
+allow autostart_test console_device:chr_file { open write };
+allow autostart_test autostart_test:capability { sys_module };
+allow autostart_test vendor_file:system { module_load };
+
# for storage
allow system_server storage_stub_file:dir getattr;

@@ -12,6 +26,9 @@ allow system_server zygote:process getpgid;
allow system_server sysfs_net:file r_file_perms;
r_dir_file(system_server, metadata_file)

+# for forlinx
+allow autostart_test serial_device:chr_file { ioctl open read write };
+
#rk_output_hal
allow system_server rk_output_hal_service:hwservice_manager find;
allow system_server zygote:process { getsched setsched };
diff --git a/device/rockchip/rk3588/ok3588_c/autostart_test.sh b/device/rockchip/rk3588/ok3588_c/autostart_test.sh
new file mode 100644
index 0000000000..8d38856413
--- /dev/null
+++ b/device/rockchip/rk3588/ok3588_c/autostart_test.sh
@@ -0,0 +1,4 @@
+#!/vendor/bin/sh
+echo "Forlinx::::::::::::::::::GNSS_CONFIG start!" > /dev/ttyFIQ0
+echo "This is a test" > /dev/ttyFIQ0
+echo "Forlinx::::::::::::::::::GNSS_CONFIG end!" > /dev/ttyFIQ0
diff --git a/device/rockchip/rk3588/ok3588_c/ok3588_c.mk b/device/rockchip/rk3588/ok3588_c/ok3588_c.mk
index 10a61ab86e..cd639f9cc4 100644
--- a/device/rockchip/rk3588/ok3588_c/ok3588_c.mk
+++ b/device/rockchip/rk3588/ok3588_c/ok3588_c.mk
@@ -76,5 +76,6 @@ PRODUCT_PACKAGES += \

BOARD_HDMI_IN_SUPPORT := true
PRODUCT_COPY_FILES += \
-       $(LOCAL_PATH)/bootanimation.zip:/system/media/bootanimation.zip
+       $(LOCAL_PATH)/bootanimation.zip:/system/media/bootanimation.zip \
+       $(LOCAL_PATH)/autostart_test.sh:$(TARGET_COPY_OUT_VENDOR)/bin/autostart_test.sh

diff --git a/system/core/rootdir/init.rc b/system/core/rootdir/init.rc
index 993c8b11fe..1043adff1b 100644
--- a/system/core/rootdir/init.rc
+++ b/system/core/rootdir/init.rc
@@ -1145,11 +1145,19 @@ on property:vold.decrypt=trigger_shutdown_framework
class_reset_post_data core
class_reset_post_data hal

+service autostart_test /vendor/bin/autostart_test.sh
+    class main
+    user root
+    group root
+    disabled
+    oneshot
+
on property:sys.boot_completed=1
bootchart stop
# Setup per_boot directory so other .rc could start to use it on boot_completed
exec - system system -- /bin/rm -rf /data/per_boot
mkdir /data/per_boot 0700 system system encryption=Require key=per_boot_ref
+    start autostart_test

# system server cannot write to /proc/sys files,
# and chown/chmod does not work for /proc/sys/ entries.

开机之后确认开机只启动成功的打印LOG:

【大概47s开机自启动脚本跑完。如果需要微调,可以适当修改sleep的时间了!】

[BEGIN] 2025/7/10 16:28:26
[2025/7/10 16:28:27] DDR V1.13 25cee80c4f cym 23/08/11-09:31:58

[2025/7/10 16:28:27] LPDDR4X, 1800MHz
[2025/7/10 16:28:27] channel[0] BW=16 Col=10 Bk=8 CS0 Row=16 CS1 Row=16 CS=2 Die BW=16 Size=2048MB
[2025/7/10 16:28:27] channel[1] BW=16 Col=10 Bk=8 CS0 Row=16 CS1 Row=16 CS=2 Die BW=16 Size=2048MB
[2025/7/10 16:28:27] channel[2] BW=16 Col=10 Bk=8 CS0 Row=16 CS1 Row=16 CS=2 Die BW=16 Size=2048MB
[2025/7/10 16:28:27] channel[3] BW=16 Col=10 Bk=8 CS0 Row=16 CS1 Row=16 CS=2 Die BW=16 Size=2048MB
[2025/7/10 16:28:27] Manufacturer ID:0x13
[2025/7/10 16:28:27] CH0 RX Vref:29.3%, TX Vref:24.8%,26.8%
[2025/7/10 16:28:27] CH1 RX Vref:29.3%, TX Vref:24.8%,26.8%
[2025/7/10 16:28:27] CH2 RX Vref:29.7%, TX Vref:26.8%,27.8%
[2025/7/10 16:28:27] CH3 RX Vref:29.7%, TX Vref:25.8%,25.8%
[2025/7/10 16:28:27] change to F1: 528MHz
[2025/7/10 16:28:27] change to F2: 1068MHz
[2025/7/10 16:28:27] change to F3: 1560MHz
[2025/7/10 16:28:27] change to F0: 1800MHz
[2025/7/10 16:28:27] out
[2025/7/10 16:28:27] U-Boot SPL board init
[2025/7/10 16:28:27] U-Boot SPL 2017.09-g5f53abfa1e-221223 #zzz (Dec 26 2022 - 09:10:09)

[2025/7/10 16:28:44] Forlinx:: 2025/4/17 11:39 ::GNSS_CONFIG start!
[2025/7/10 16:29:14] Forlinx:: 2025/4/17 11:49 ::GNSS_CONFIG end!

http://www.lryc.cn/news/585197.html

相关文章:

  • 宝塔命令Composer 更改数据源不生效
  • 动态组件和插槽
  • 基于定制开发开源AI智能名片与S2B2C商城小程序的旅游日志创新应用研究
  • nessus最新安装
  • [Meetily后端框架] Whisper转录服务器 | 后端服务管理脚本
  • 20.缓存问题与解决方案详解教程
  • NodeJs后端常用三方库汇总
  • 录音实时上传
  • 2025河南高考生物真题及解析
  • 国际学术期刊IJCAST发布最新一期论文
  • 【达梦数据库|JPA】后端数据库国产化迁移记录
  • uniapp类似抖音视频滑动
  • [python]在drf中使用drf_spectacular
  • 持续集成 简介环境搭建
  • STM32G473串口通信-USART/UART配置和清除串口寄存器状态的注意事项
  • Rail开发日志_5
  • 基于Selenium和FFmpeg的全平台短视频自动化发布系统
  • Maven下载与配置对Java项目的理解
  • RISC-V:开源芯浪潮下的技术突围与职业新赛道 (三)RISC-V架构深度解剖(下)
  • SpringBoot 使用注解获取配置文件中的值
  • c/c++拷贝函数
  • Claude Code是什么?国内如何使用到Claude Code?附国内最新使用教程
  • FlashBots 之 MEV-boost
  • 决策树算法在医学影像诊断中的广泛应用
  • 用Python和OpenCV从零搭建一个完整的双目视觉系统(六 最终篇)
  • CentOS 安装 Redis 简明指南
  • 【Centos】Redis Cluster 集群部署图文步骤
  • VMware安装Centos 7
  • 包稳定的Docker 安装方式(CentOS)
  • 云、实时、时序数据库混合应用:医疗数据管理的革新与展望(上)