From 28385e1913411cfb5cfca34742b9e13517c0366c Mon Sep 17 00:00:00 2001 From: rocknix Date: Thu, 2 Oct 2025 21:33:53 +0000 Subject: [PATCH] Add intial serial number check logic --- .../platforms/SM8250/009-serial-number-path | 8 ++++++ .../hardware/quirks/profile.d/999-export | 1 + .../packages/ui/emulationstation/package.mk | 7 +++-- .../sources/serial_number_check | 27 +++++++++++++++++++ 4 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 projects/ROCKNIX/packages/hardware/quirks/platforms/SM8250/009-serial-number-path create mode 100644 projects/ROCKNIX/packages/ui/emulationstation/sources/serial_number_check diff --git a/projects/ROCKNIX/packages/hardware/quirks/platforms/SM8250/009-serial-number-path b/projects/ROCKNIX/packages/hardware/quirks/platforms/SM8250/009-serial-number-path new file mode 100644 index 0000000000..c5b7703504 --- /dev/null +++ b/projects/ROCKNIX/packages/hardware/quirks/platforms/SM8250/009-serial-number-path @@ -0,0 +1,8 @@ +#!/bin/sh + +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2025 ROCKNIX (https://github.com/ROCKNIX) + +cat </storage/.config/profile.d/009-serial-number-path +DEVICE_SERIAL_NUMBER_PATH=("/sys/devices/soc0/serial_number") +EOF diff --git a/projects/ROCKNIX/packages/hardware/quirks/profile.d/999-export b/projects/ROCKNIX/packages/hardware/quirks/profile.d/999-export index b107574e85..f406cdc3cd 100755 --- a/projects/ROCKNIX/packages/hardware/quirks/profile.d/999-export +++ b/projects/ROCKNIX/packages/hardware/quirks/profile.d/999-export @@ -46,6 +46,7 @@ export OS_VERSION \ DEVICE_PWM_FAN \ DEVICE_PWM_MOTOR \ DEVICE_ROTATED_SDL \ + DEVICE_SERIAL_NUMBER_PATH \ DEVICE_SLEEP_DPMS \ DEVICE_SW_HP_SWITCH \ DEVICE_TDP_RANGE \ diff --git a/projects/ROCKNIX/packages/ui/emulationstation/package.mk b/projects/ROCKNIX/packages/ui/emulationstation/package.mk index fe3c630a94..a7abcc3ee5 100644 --- a/projects/ROCKNIX/packages/ui/emulationstation/package.mk +++ b/projects/ROCKNIX/packages/ui/emulationstation/package.mk @@ -2,7 +2,7 @@ # Copyright (C) 2024-present ROCKNIX (https://github.com/ROCKNIX) PKG_NAME="emulationstation" -PKG_VERSION="a08f44d24cdbb048b0bce9222b5ceb880298436f" +PKG_VERSION="a081efb94a734fb788bb9286f071647a7765d80b" PKG_GIT_CLONE_BRANCH="master" PKG_LICENSE="GPL" PKG_SITE="https://github.com/ROCKNIX/emulationstation-next" @@ -55,13 +55,16 @@ makeinstall_target() { cp -rf ${PKG_BUILD}/resources/* ${INSTALL}/usr/config/emulationstation/resources/ rm -rf ${INSTALL}/usr/config/emulationstation/resources/logo.png - mkdir -p ${INSTALL}/usr/bin + mkdir -p ${INSTALL}/usr/bin cp ${PKG_BUILD}/es_settings ${INSTALL}/usr/bin chmod 0755 ${INSTALL}/usr/bin/es_settings cp ${PKG_BUILD}/start_es.sh ${INSTALL}/usr/bin chmod 0755 ${INSTALL}/usr/bin/start_es.sh + cp ${PKG_BUILD}/serial_number_check ${INSTALL}/usr/bin + chmod 0755 ${INSTALL}/usr/bin/serial_number_check + mkdir -p ${INSTALL}/usr/lib/${PKG_PYTHON_VERSION} cp -rf ${PKG_DIR}/bluez/* ${INSTALL}/usr/lib/${PKG_PYTHON_VERSION} diff --git a/projects/ROCKNIX/packages/ui/emulationstation/sources/serial_number_check b/projects/ROCKNIX/packages/ui/emulationstation/sources/serial_number_check new file mode 100644 index 0000000000..2890c6bcfa --- /dev/null +++ b/projects/ROCKNIX/packages/ui/emulationstation/sources/serial_number_check @@ -0,0 +1,27 @@ +#!/bin/bash + +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2025-present ROCKNIX (https://github.com/ROCKNIX) + +. /etc/profile + +if [ -z "${DEVICE_SERIAL_NUMBER_PATH}" ]; then + log $0 "SERIAL NUMBER CHECK: This device has no unique serial number to check, skipping and continue to Emulation Station" + exit 0 +else + DEVICE_SERIAL_NUMBER="$(cat ${DEVICE_SERIAL_NUMBER_PATH})" + log $0 "SERIAL NUMBER CHECK: DEVICE SERIAL NUMBER: ${DEVICE_SERIAL_NUMBER}" +fi + +STORED_SERIAL_NUMBER=$(get_setting "device.serial.number") +if [ ! -n "${STORED_SERIAL_NUMBER}" ]; then + set_setting "device.serial.number" "${DEVICE_SERIAL_NUMBER}" + echo 1 > "/storage/serial_number_check_status" + log $0 "SERIAL NUMBER CHECK: No storted serial number found, saving SOC serial number to system.cfg and show warning." +elif [ ! "${STORED_SERIAL_NUMBER}" == "${DEVICE_SERIAL_NUMBER}" ]; then + set_setting "device.serial.number" "${DEVICE_SERIAL_NUMBER}" + echo 1 > "/storage/serial_number_check_status" + log $0 "SERIAL NUMBER CHECK: Device and stored serial numbers do not match, show warning." +else + log $0 "SERIAL NUMBER CHECK: Device and stored serial numbers match, continue to Emulation Station." +fi