From e4ed881dd7f781a787df0b97a087e5bbda05b609 Mon Sep 17 00:00:00 2001 From: Piotr Dymacz Date: Fri, 17 Feb 2023 00:07:18 +0100 Subject: [PATCH] mcu: support OpenWiFi with uCentral On device running OpenWiFi with uCentral, additional copy of the initial UCI configuration will be generated in '/etc/config-shadow/'. As part of the MCU configuration is done during runtime, after the 'config-shadow' is created, we should update it as well to keep everything in sync. Signed-off-by: Piotr Dymacz --- feeds/mcu/mcu/files/mcu.hotplug | 12 ++++++++++++ feeds/mcu/mcu/files/mcu.sh | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/feeds/mcu/mcu/files/mcu.hotplug b/feeds/mcu/mcu/files/mcu.hotplug index 461c3f462..54b17963f 100644 --- a/feeds/mcu/mcu/files/mcu.hotplug +++ b/feeds/mcu/mcu/files/mcu.hotplug @@ -92,6 +92,18 @@ mcu_hotplug_setup() { sect="${sn:0:8}_usb" mcu_logi "no matching MCU config found, adding new (disabled): '$sect'" + [ -d /etc/config-shadow ] && { + uci -c /etc/config-shadow -q batch <<-EOF + set mcu.${sect}=mcu + set mcu.${sect}.interface=usb + set mcu.${sect}.bootloader=mcuboot + set mcu.${sect}.sn=$sn + set mcu.${sect}.disabled=1 + EOF + + uci -c /etc/config-shadow -q commit mcu + } + uci -q batch <<-EOF set mcu.${sect}=mcu set mcu.${sect}.interface=usb diff --git a/feeds/mcu/mcu/files/mcu.sh b/feeds/mcu/mcu/files/mcu.sh index 012ef6e4c..4fd5b3665 100644 --- a/feeds/mcu/mcu/files/mcu.sh +++ b/feeds/mcu/mcu/files/mcu.sh @@ -351,6 +351,11 @@ mcu_sn_check_and_update() { [ -n "$sn_dev" ] && { if [ -z "$sn" ]; then + [ -d /etc/config-shadow ] && { + uci -c /etc/config-shadow -q set mcu.${SECT}.sn="$sn_dev" + uci -c /etc/config-shadow -q commit mcu + } + uci -q set mcu.${SECT}.sn="$sn_dev" uci -q commit mcu else @@ -424,6 +429,11 @@ mcu_fw_check_and_update() { [ "$active_slot" = "1" ] && firmware="$slot1_fw" [ -n "$firmware" ] && { + [ -d /etc/config-shadow ] && { + uci -c /etc/config-shadow -q set mcu.${SECT}.firmware="$firmware" + uci -c /etc/config-shadow -q commit mcu + } + uci -q set mcu.${SECT}.firmware="$firmware" uci -q commit mcu