From c24d1d96a770714eb36d4efb8bff962cf1d46865 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Thu, 16 Jul 2020 08:17:32 +0200 Subject: [PATCH] sysinfo: adapt script after removal of deprecated fsl_otp driver - OTP section - Use just one fixed path to the OTP nvmem device descriptor (instead of a loop). - Use '-v' for dumping all values with hexdump. - TrustFence section - For cc8x, determine if the device is closed by checking a new boolean property on the DT: digi,tf-open|closed - For the rest, check the SEC_CONFIG[1] bit using the new nvmem descriptor. - Change log from 'Device status' to 'Security status' - Report UNKNOWN if nvmem device does not exist. Signed-off-by: Hector Palacios https://jira.digi.com/browse/DEL-7185 (cherry picked from commit f6a8de006791184b0087143ef8759e38a0f2e8b9) --- .../recipes-digi/sysinfo/sysinfo/sysinfo | 39 ++++++++++++------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/meta-digi-dey/recipes-digi/sysinfo/sysinfo/sysinfo b/meta-digi-dey/recipes-digi/sysinfo/sysinfo/sysinfo index 03f93b264..ca3e7cd44 100755 --- a/meta-digi-dey/recipes-digi/sysinfo/sysinfo/sysinfo +++ b/meta-digi-dey/recipes-digi/sysinfo/sysinfo/sysinfo @@ -235,18 +235,17 @@ make_report(){ echo "- -" echo "--------------------------------------" echo "" - if [ -d /sys/fsl_otp ]; then - for f in /sys/fsl_otp/*; do - echo -e "$f:\t$(cat $f)" - done + if grep -qs '\' /proc/device-tree/compatible; then + OTP_PATH="/sys/devices/platform/scu/scu\:imx8qx-ocotp/imx-scu-ocotp0" + else + OTP_PATH="/sys/bus/nvmem/devices/imx-ocotp0" + fi + + if [ -e ${OTP_PATH}/nvmem ]; then + echo "${OTP_PATH}:" + hexdump -C -v ${OTP_PATH}/nvmem echo "" fi - for d in /sys/bus/nvmem/devices/imx-ocotp*; do - [ -e $d ] || continue - echo "$d:" - hexdump -C $d/nvmem - echo "" - done echo "--------------------------------------" echo "- -" @@ -255,11 +254,23 @@ make_report(){ echo "--------------------------------------" echo "" - if [ -e /sys/fsl_otp/HW_OCOTP_CFG5 ]; then - if [ "$(($(cat /sys/fsl_otp/HW_OCOTP_CFG5) & 2))" != "0" ]; then - echo "Device status: [CLOSED]" + if grep -qs '\' /proc/device-tree/compatible; then + if [ -f "/proc/device-tree/digi,tf-closed" ]; then + echo "Security status: [CLOSED]" + elif [ -f "/proc/device-tree/digi,tf-open" ]; then + echo "Security status: [OPEN]" + fi + else + if [ -e ${OTP_PATH}/nvmem ]; then + # Check SEC_CONFIG on OCOTP_CFG5 (ADDR=6) bit 1. + SEC_CONFIG_WORD=$(dd if=${OTP_PATH}/nvmem of=/dev/stdout bs=4 skip=6 count=1 status=none | hexdump -n 4 -v -e '1/4 "%08x\n"') + if [ "$((${SEC_CONFIG_WORD} & 0x2))" != "0" ]; then + echo "Security status: [CLOSED]" + else + echo "Security status: [OPEN]" + fi else - echo "Device status: [OPEN]" + echo "Security status: [UNKNOWN]" fi fi