From 89b9a50820d4d581ef9b6cacc7d19b4c04b46350 Mon Sep 17 00:00:00 2001 From: Woody Lin Date: Mon, 4 Sep 2023 09:58:01 +0800 Subject: [PATCH] init.debug.rc: enable etm/etm2dram when SJTAG is unlocked Enables the debug features required an unlocked SJTAG to the section `on property:ro.vendor.sjtag_ap_is_unlocked=true`, so they can be enabled when 1. PD is available on non-fused device on boot, or 2. PD is available after betterbug acquires it from the corp service. Bug: 298314432 Change-Id: Ie834b587c130d749a33a87801113df03d5b3d29a --- conf/init.check_ap_pd_auth.sh | 15 +++++++++++++++ conf/init.debug.rc | 10 ++++++++-- device.mk | 3 ++- 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 conf/init.check_ap_pd_auth.sh diff --git a/conf/init.check_ap_pd_auth.sh b/conf/init.check_ap_pd_auth.sh new file mode 100644 index 00000000..8175e754 --- /dev/null +++ b/conf/init.check_ap_pd_auth.sh @@ -0,0 +1,15 @@ +#!/vendor/bin/sh + +# This script sets up `ro.vendor.sjtag_ap_is_unlocked` for the non-fused +# device. For a fused device, this property should be set by +# betterbug->ss-restart-detector when PD is acquired. + +SJTAG_STATUS=0x$(cat /sys/devices/platform/sjtag_ap/interface/status) +SOFT_LOCK_BIT=4 +AUTH_PASS_BIT=8 + +# Unlocked or locked but auth passed. +if test "$((SJTAG_STATUS & (1 << SOFT_LOCK_BIT)))" = 0 -o \ + "$((SJTAG_STATUS & (1 << AUTH_PASS_BIT)))" != 0 ; then + setprop ro.vendor.sjtag_ap_is_unlocked true +fi diff --git a/conf/init.debug.rc b/conf/init.debug.rc index d4de2c87..3f8be42f 100644 --- a/conf/init.debug.rc +++ b/conf/init.debug.rc @@ -39,7 +39,13 @@ on property:ro.revision=PROTO1.1 on property:ro.revision=EVT1.0 setprop debug.hypervisor.metrics_tag "hwrev_a0" -# Enable etm/etm2dram when ramdump is enabled. -on property:ro.boot.ramdump=enabled +service vendor.check_ap_pd_auth_sh /vendor/bin/init.check_ap_pd_auth.sh + class main + user root + group root system + oneshot + +# Enable etm/etm2dram when ramdump is enabled, and ap-sjtag is unlocked. +on property:ro.boot.ramdump=enabled && property:ro.vendor.sjtag_ap_is_unlocked=true write /sys/devices/platform/exynos-etm/etm_on 1 write /sys/devices/platform/etm2dram/arm 1 diff --git a/device.mk b/device.mk index 4d398d17..fcace2d8 100644 --- a/device.mk +++ b/device.mk @@ -330,7 +330,8 @@ PRODUCT_COPY_FILES += \ ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT))) PRODUCT_COPY_FILES += \ - device/google/gs201/conf/init.debug.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.debug.rc + device/google/gs201/conf/init.debug.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.debug.rc \ + device/google/gs201/conf/init.check_ap_pd_auth.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init.check_ap_pd_auth.sh endif # Recovery files