firmware-murata-infineon: generalize autocountry service

Make this service generic so it can be reused on every device containing
a Murata+Infineon chip.

In some platforms Worldwide pseudo-country could be 'XZ', in others it
could be 'WW'. Cover both of them.

In the meantime, improve the service to ensure the wifi device is
available by waiting for udev device discovery to settle, retrying
until the wireless interface responds to wl, and restarting the
oneshot unit on failure.

https://onedigi.atlassian.net/browse/DEL-9798

Signed-off-by: Gonzalo Ruiz <Gonzalo.Ruiz@digi.com>
This commit is contained in:
Gonzalo Ruiz 2026-04-20 17:28:41 +02:00
parent 8359b75ec0
commit 23c969f954
4 changed files with 58 additions and 24 deletions

View File

@ -12,8 +12,8 @@ SRC_URI = " \
git://github.com/murata-wireless/cyw-bt-patch;protocol=http;branch=master;destsuffix=cyw-bt-patch;name=cyw-bt-patch \ git://github.com/murata-wireless/cyw-bt-patch;protocol=http;branch=master;destsuffix=cyw-bt-patch;name=cyw-bt-patch \
git://github.com/murata-wireless/cyw-fmac-utils-imx32;protocol=http;branch=master;destsuffix=cyw-fmac-utils-imx32;name=cyw-fmac-utils-imx32 \ git://github.com/murata-wireless/cyw-fmac-utils-imx32;protocol=http;branch=master;destsuffix=cyw-fmac-utils-imx32;name=cyw-fmac-utils-imx32 \
git://github.com/murata-wireless/cyw-fmac-utils-imx64;protocol=http;branch=master;destsuffix=cyw-fmac-utils-imx64;name=cyw-fmac-utils-imx64 \ git://github.com/murata-wireless/cyw-fmac-utils-imx64;protocol=http;branch=master;destsuffix=cyw-fmac-utils-imx64;name=cyw-fmac-utils-imx64 \
file://cyw4373-autocountry \ file://autocountry \
file://cyw4373-autocountry.service \ file://autocountry.service \
" "
SRC_URI:append:ccmp1 = " \ SRC_URI:append:ccmp1 = " \
@ -57,14 +57,14 @@ do_install () {
if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
# Install systemd unit files # Install systemd unit files
install -d ${D}${systemd_unitdir}/system/ install -d ${D}${systemd_unitdir}/system/
install -m 0644 ${WORKDIR}/cyw4373-autocountry.service ${D}${systemd_unitdir}/system/cyw4373-autocountry.service install -m 0644 ${WORKDIR}/autocountry.service ${D}${systemd_unitdir}/system/autocountry.service
fi fi
install -d ${D}${sysconfdir}/init.d/ install -d ${D}${sysconfdir}/init.d/
# Install autocountry service # Install autocountry service
install -m 0755 ${WORKDIR}/cyw4373-autocountry ${D}${sysconfdir}/cyw4373-autocountry install -m 0755 ${WORKDIR}/autocountry ${D}${sysconfdir}/autocountry
ln -sf /etc/cyw4373-autocountry ${D}${sysconfdir}/init.d/cyw4373-autocountry ln -sf /etc/autocountry ${D}${sysconfdir}/init.d/autocountry
# Install WLAN client utility binary based on 32-bit/64-bit arch # Install WLAN client utility binary based on 32-bit/64-bit arch
if [ ${TARGET_ARCH} = "aarch64" ]; then if [ ${TARGET_ARCH} = "aarch64" ]; then
@ -151,10 +151,10 @@ do_install:append:ccimx95 () {
inherit update-rc.d systemd inherit update-rc.d systemd
INITSCRIPT_PACKAGES += "${PN}-autocountry" INITSCRIPT_PACKAGES += "${PN}-autocountry"
INITSCRIPT_NAME:${PN}-autocountry = "cyw4373-autocountry" INITSCRIPT_NAME:${PN}-autocountry = "autocountry"
INITSCRIPT_PARAMS:${PN}-autocountry = "start 19 2 3 4 5 . stop 21 0 1 6 ." INITSCRIPT_PARAMS:${PN}-autocountry = "start 19 2 3 4 5 . stop 21 0 1 6 ."
SYSTEMD_SERVICE:${PN}-autocountry = "cyw4373-autocountry.service" SYSTEMD_SERVICE:${PN}-autocountry = "autocountry.service"
SYSTEMD_PACKAGES = "${PN}-autocountry" SYSTEMD_PACKAGES = "${PN}-autocountry"
PACKAGES =+ " \ PACKAGES =+ " \
@ -171,16 +171,16 @@ FILES:${PN}-mfgtest = " \
" "
FILES:${PN}-autocountry = " \ FILES:${PN}-autocountry = " \
${sysconfdir}/cyw4373-autocountry \ ${sysconfdir}/autocountry \
${sysconfdir}/init.d/cyw4373-autocountry \ ${sysconfdir}/init.d/autocountry \
${systemd_unitdir}/system/cyw4373-autocountry.service \ ${systemd_unitdir}/system/autocountry.service \
" "
FILES:${PN}:append:ccmp2 = " \ FILES:${PN}:append:ccmp2 = " \
${sbindir}/mbt \ ${sbindir}/mbt \
" "
RDEPENDS:${PN}:append:ccmp1 = " ${PN}-autocountry" RDEPENDS:${PN}:append = " ${PN}-autocountry"
RDEPENDS:${PN}-autocountry:append = " ${PN}-mfgtest" RDEPENDS:${PN}-autocountry:append = " ${PN}-mfgtest"
INSANE_SKIP:${PN} += "build-deps" INSANE_SKIP:${PN} += "build-deps"

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
#=============================================================================== #===============================================================================
# #
# Copyright (C) 2024 by Digi International Inc. # Copyright (C) 2024-2026, Digi International Inc.
# All rights reserved. # All rights reserved.
# #
# This program is free software; you can redistribute it and/or modify it # This program is free software; you can redistribute it and/or modify it
@ -9,7 +9,7 @@
# the Free Software Foundation. # the Free Software Foundation.
# #
# #
# !Description: Enable Wireless autocountry feature (802.11d) # !Description: Enable Infineon Wireless autocountry feature (802.11d)
# #
#=============================================================================== #===============================================================================
@ -23,9 +23,30 @@ log() {
fi fi
} }
wait_for_wifi() {
timeout="${1:-30}"
count=0
while [ "${count}" -lt "${timeout}" ]; do
if wl country list >/dev/null 2>&1; then
return 0
fi
sleep 1
count=$((count + 1))
done
return 1
}
# Only for Wireless variants # Only for Wireless variants
if [ -d "/proc/device-tree/wireless" ]; then if [ -d "/proc/device-tree/wireless" ]; then
# Check if WorldWide regulatory domain is available if ! wait_for_wifi 30; then
log warning "Wireless device not ready after waiting 30 seconds"
exit 1
fi
# Check if 'XZ' WorldWide regulatory domain is available
if wl country list | grep -qs ^XZ; then if wl country list | grep -qs ^XZ; then
# Select WorldWide Country Code as driver operational region # Select WorldWide Country Code as driver operational region
wl country XZ/0 agg wl country XZ/0 agg
@ -35,4 +56,14 @@ if [ -d "/proc/device-tree/wireless" ]; then
wl autocountry 1 wl autocountry 1
log info "Set WorldWide regulatory domain" log info "Set WorldWide regulatory domain"
fi fi
# Check if 'WW' WorldWide regulatory domain is available
if wl country list | grep -qs ^WW; then
# Select WorldWide Country Code as driver operational region
wl country WW/0 agg
# Select WorldWide Country Code for use with Auto Contry Discovery
wl autocountry_default WW
# Enable 802.11d
wl autocountry 1
log info "Set WorldWide regulatory domain"
fi
fi fi

View File

@ -0,0 +1,13 @@
[Unit]
Description=Infineon autocountry (802.11d)
Wants=systemd-udev-settle.service
After=systemd-udev-settle.service network.target suspend.target
[Service]
Type=oneshot
ExecStart=/etc/autocountry
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target suspend.target

View File

@ -1,10 +0,0 @@
[Unit]
Description=CYW4373 autocountry (802.11d)
After=network.target suspend.target
[Service]
Type=oneshot
ExecStart=/etc/cyw4373-autocountry
[Install]
WantedBy=multi-user.target suspend.target