ccimx6sbc: adapt recipes to support Atheros and Qualcomm wireless chips

Some packages require different scripts, configuration files or installations
depending on the wireless chip assembled on the target. In general, the way
to support both chips in one image is to have the recipes install both
versions of the aforementioned files, then leave only the strictly necessary
version once the wireless chip can be deduced.

In the case of the init-ifupdown recipe, this involves installing temporary
configuration fragments that are later erased. In the case of the standby
script, the logic can be implemented in a single file.

https://onedigi.atlassian.net/browse/DEL-7661
https://onedigi.atlassian.net/browse/DEL-7666

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
This commit is contained in:
Gabriel Valcazar 2021-09-20 13:11:28 +02:00
parent dcd97799c9
commit f3210db348
11 changed files with 151 additions and 27 deletions

View File

@ -29,6 +29,11 @@ QCA65XX_COMMON_PATCHES = " \
SRC_URI_append_ccimx6ul = " ${QCA65XX_COMMON_PATCHES}"
SRC_URI_append_ccimx6 = " ${QCA65XX_COMMON_PATCHES}"
SRC_URI_append_ccimx6sbc = " \
file://bluetooth-init_atheros \
file://main.conf_atheros \
"
inherit update-rc.d
PACKAGECONFIG_append = " experimental"
@ -47,10 +52,34 @@ do_install_append() {
fi
}
do_install_append_ccimx6sbc() {
install -m 0755 ${WORKDIR}/bluetooth-init_atheros ${D}${sysconfdir}/bluetooth-init_atheros
install -m 0644 ${WORKDIR}/main.conf_atheros ${D}${sysconfdir}/bluetooth/
sed -i -e "s,##BT_DEVICE_NAME##,${BT_DEVICE_NAME},g" \
${D}${sysconfdir}/bluetooth/main.conf_atheros
}
pkg_postinst_ontarget_${PN}_ccimx6sbc() {
# Only execute the script on wireless ccimx6 platforms
if [ -e "/proc/device-tree/bluetooth/mac-address" ]; then
for id in $(find /sys/devices -name modalias -print0 | xargs -0 sort -u -z | grep sdio); do
if [[ "$id" == "sdio:c00v0271d0301" ]] ; then
mv /etc/bluetooth-init_atheros /etc/bluetooth-init
mv /etc/bluetooth/main.conf_atheros /etc/bluetooth/main.conf
break
elif [[ "$id" == "sdio:c00v0271d050A" ]] ; then
rm /etc/bluetooth-init_atheros
rm /etc/bluetooth/main.conf_atheros
break
fi
done
fi
}
PACKAGES =+ "${PN}-init"
FILES_${PN} += " ${sysconfdir}/bluetooth/main.conf"
FILES_${PN}-init = " ${sysconfdir}/bluetooth-init \
FILES_${PN} += " ${sysconfdir}/bluetooth/main.conf*"
FILES_${PN}-init = " ${sysconfdir}/bluetooth-init* \
${sysconfdir}/init.d/bluetooth-init \
${systemd_unitdir}/system/bluetooth-init.service \
"

View File

@ -24,6 +24,11 @@ SRC_URI_append_ccimx6 = " ${QCA65XX_COMMON_PATCHES}"
SRC_URI_append_ccimx8x = " ${QCA65XX_COMMON_PATCHES}"
SRC_URI_append_ccimx8m = " ${QCA65XX_COMMON_PATCHES}"
SRC_URI_append_ccimx6sbc = " \
file://bluetooth-init_atheros \
file://main.conf_atheros \
"
inherit update-rc.d
do_install_append() {
@ -47,14 +52,38 @@ do_install_append() {
sed -i -e '/#include/{s,src/shared/,,g}' ${D}${includedir}/bluetooth-internal/att.h
}
do_install_append_ccimx6sbc() {
install -m 0755 ${WORKDIR}/bluetooth-init_atheros ${D}${sysconfdir}/bluetooth-init_atheros
install -m 0644 ${WORKDIR}/main.conf_atheros ${D}${sysconfdir}/bluetooth/
sed -i -e "s,##BT_DEVICE_NAME##,${BT_DEVICE_NAME},g" \
${D}${sysconfdir}/bluetooth/main.conf_atheros
}
pkg_postinst_ontarget_${PN}_ccimx6sbc() {
# Only execute the script on wireless ccimx6 platforms
if [ -e "/proc/device-tree/bluetooth/mac-address" ]; then
for id in $(find /sys/devices -name modalias -print0 | xargs -0 sort -u -z | grep sdio); do
if [[ "$id" == "sdio:c00v0271d0301" ]] ; then
mv /etc/bluetooth-init_atheros /etc/bluetooth-init
mv /etc/bluetooth/main.conf_atheros /etc/bluetooth/main.conf
break
elif [[ "$id" == "sdio:c00v0271d050A" ]] ; then
rm /etc/bluetooth-init_atheros
rm /etc/bluetooth/main.conf_atheros
break
fi
done
fi
}
PACKAGES =+ "${PN}-init"
PACKAGECONFIG_append = " health-profiles \
mesh \
btpclient \
"
FILES_${PN} += " ${sysconfdir}/bluetooth/main.conf"
FILES_${PN}-init = " ${sysconfdir}/bluetooth-init \
FILES_${PN} += " ${sysconfdir}/bluetooth/main.conf*"
FILES_${PN}-init = " ${sysconfdir}/bluetooth-init* \
${sysconfdir}/init.d/bluetooth-init \
${systemd_unitdir}/system/bluetooth-init.service \
"

View File

@ -1,4 +1,4 @@
# Copyright (C) 2013-2020 Digi International.
# Copyright (C) 2013-2021 Digi International.
FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"
@ -11,6 +11,8 @@ SRC_URI += " \
file://wpa_supplicant_p2p.conf \
"
SRC_URI_append_ccimx6sbc = " file://wpa_supplicant_p2p.conf_atheros"
do_install_append() {
install -m 600 ${WORKDIR}/wpa_supplicant_p2p.conf ${D}${sysconfdir}/wpa_supplicant_p2p.conf
sed -i -e "s,##WLAN_P2P_DEVICE_NAME##,${WLAN_P2P_DEVICE_NAME},g" \
@ -18,8 +20,19 @@ do_install_append() {
}
do_install_append_ccimx6sbc() {
# Customize supplicant file
cat <<EOF >>${D}${sysconfdir}/wpa_supplicant.conf
# Install atheros variant of the p2p .conf file
install -m 600 ${WORKDIR}/wpa_supplicant_p2p.conf_atheros ${D}${sysconfdir}/wpa_supplicant_p2p.conf_atheros
sed -i -e "s,##WLAN_P2P_DEVICE_NAME##,${WLAN_P2P_DEVICE_NAME},g" \
${D}${sysconfdir}/wpa_supplicant_p2p.conf_atheros
}
pkg_postinst_ontarget_${PN}_ccimx6sbc() {
# Only execute the script on wireless ccimx6 platforms
if [ -e "/proc/device-tree/wireless/mac-address" ]; then
for id in $(find /sys/devices -name modalias -print0 | xargs -0 sort -u -z | grep sdio); do
if [[ "$id" == "sdio:c00v0271d0301" ]] ; then
# Customize supplicant file
cat <<EOF >>/etc/wpa_supplicant.conf
# -- SoftAP mode
# ap_scan=2
@ -34,6 +47,14 @@ do_install_append_ccimx6sbc() {
# }
EOF
mv /etc/wpa_supplicant_p2p.conf_atheros /etc/wpa_supplicant_p2p.conf
break
elif [[ "$id" == "sdio:c00v0271d050A" ]] ; then
rm /etc/wpa_supplicant_p2p.conf_atheros
break
fi
done
fi
}
PACKAGE_ARCH = "${MACHINE_ARCH}"

View File

@ -3,7 +3,7 @@
#
# standby
#
# Copyright (C) 2009-2019 by Digi International Inc.
# Copyright (C) 2009-2021 by Digi International Inc.
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it
@ -40,7 +40,8 @@ suspend_interfaces() {
for i in $(sed -ne 's,^\(wlan[0-9]\)=.*,\1,g;T;p' /var/run/ifstate | sort -r); do
ifdown "${i}" && RESUME_IFACES="${RESUME_IFACES:+${RESUME_IFACES} }${i}"
done
grep -qs '^ath6kl_sdio' /proc/modules && rmmod ath6kl_sdio ath6kl_core
[ -e /sys/module/ath6kl_sdio ] && rmmod ath6kl_sdio ath6kl_core && wlan_device_id="301"
[ -e /sys/module/wlan ] && rmmod wlan && wlan_device_id="50A"
fi
# Suspend bluetooth interface
@ -55,7 +56,7 @@ resume_interfaces() {
# Resume wireless interfaces
if [ -d "/proc/device-tree/wireless" ]; then
# Trigger wireless module loading event, and wait until the interface exists
udevadm trigger --action=add --attr-match="modalias=sdio:c00v0271d0301"
udevadm trigger --action=add --attr-match="modalias=sdio:c00v0271d0${wlan_device_id}"
timeout 5 sh -c "while [ ! -d /sys/class/net/wlan0 ]; do sleep .2; done" 2>/dev/null
# Bring up the interfaces that were bring down on suspend

View File

@ -3,7 +3,7 @@
#
# standby-actions
#
# Copyright (C) 2019 by Digi International Inc.
# Copyright (C) 2019-2021 by Digi International Inc.
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it
@ -27,7 +27,8 @@ if [ "${1}" == "pre" ]; then
done
echo ${RESUME_IFACES} > /tmp/suspend_wlan_ifaces
grep -qs '^ath6kl_sdio' /proc/modules && rmmod ath6kl_sdio ath6kl_core
[ -e /sys/module/ath6kl_sdio ] && rmmod ath6kl_sdio ath6kl_core && echo "301" > /tmp/suspend_wlan_device_id
[ -e /sys/module/wlan ] && rmmod wlan && echo "50A" > /tmp/suspend_wlan_device_id
fi
# Suspend bluetooth interface
@ -40,7 +41,8 @@ elif [ "${1}" == "post" ]; then
# Resume wireless interfaces
if [ -d "/proc/device-tree/wireless" ]; then
# Trigger wireless module loading event, and wait until the interface exists
udevadm trigger --action=add --attr-match="modalias=sdio:c00v0271d0301"
udevadm trigger --action=add --attr-match="modalias=sdio:c00v0271d0$(cat /tmp/suspend_wlan_device_id)"
rm -rf /tmp/suspend_wlan_driver
timeout 5 sh -c "while [ ! -d /sys/class/net/wlan0 ]; do sleep .2; done" 2>/dev/null
# Bring up the interfaces that were brought down on suspend

View File

@ -1,4 +1,4 @@
# Copyright (C) 2013-2020 Digi International Inc.
# Copyright (C) 2013-2021 Digi International Inc.
FILESEXTRAPATHS_prepend := "${THISDIR}/${BP}:"
@ -22,10 +22,15 @@ SRC_URI_append = " \
${@oe.utils.conditional('HAS_WIFI_VIRTWLANS', 'true', '${WIFI_VIRTWLANS_FILES}', '', d)} \
"
SRC_URI_append_ccimx6sbc = " file://interfaces.br0.atheros.example"
SYSTEMD_SERVICE_${PN} = "ifupdown.service"
WPA_DRIVER ?= "nl80211"
IS_CCIMX6 ?= "0"
IS_CCIMX6_ccimx6sbc = "1"
do_install_append() {
# Install 'ifupdown' scripts
install -m 0755 ${WORKDIR}/p2plink ${D}${sysconfdir}/network/if-up.d/
@ -63,7 +68,15 @@ do_install_append() {
install_wlan1
fi
cat ${WORKDIR}/interfaces.br0.example >> ${D}${sysconfdir}/network/interfaces
# On ccimx6, install the two possible br0 fragments in the filesystem
# so we can decide which one to use during runtime depending on the
# wireless MAC used on the SOM.
if [ "${IS_CCIMX6}" = "1" ]; then
install -m 0644 ${WORKDIR}/interfaces.br0.example ${D}${sysconfdir}
install -m 0644 ${WORKDIR}/interfaces.br0.atheros.example ${D}${sysconfdir}
else
cat ${WORKDIR}/interfaces.br0.example >> ${D}${sysconfdir}/network/interfaces
fi
}
install_virtwlans() {
@ -76,24 +89,34 @@ WLAN1_POST_UP_ACTION = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'syst
WLAN1_PRE_DOWN_ACTION = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemctl stop hostapd@wlan1.service', '/etc/init.d/hostapd stop', d)}"
install_wlan1() {
TARGET_WLAN1_FILE="${D}${sysconfdir}/network/interfaces"
if [ -n "${HAVE_WIFI}" ]; then
cat ${WORKDIR}/interfaces.wlan1.${WLAN1_MODE} >> ${D}${sysconfdir}/network/interfaces
[ -n "${WLAN1_AUTO}" ] && sed -i -e 's/^#auto wlan1/auto wlan1/g' ${D}${sysconfdir}/network/interfaces
# On the ccimx6, install the wlan1 fragment in the filesystem
# so we can decide if we want to incorporate it or not
# depending on the wireless MAC used on the SOM.
if [ "${IS_CCIMX6}" = "1" ]; then
TARGET_WLAN1_FILE="${D}${sysconfdir}/interfaces.wlan1.example"
install -m 0644 ${WORKDIR}/interfaces.wlan1.${WLAN1_MODE} ${TARGET_WLAN1_FILE}
else
cat ${WORKDIR}/interfaces.wlan1.${WLAN1_MODE} >> ${TARGET_WLAN1_FILE}
fi
[ -n "${WLAN1_AUTO}" ] && sed -i -e 's/^#auto wlan1/auto wlan1/g' ${TARGET_WLAN1_FILE}
fi
# Remove config entries if corresponding variable is not defined
[ -z "${WLAN1_STATIC_DNS}" ] && sed -i -e "/##WLAN1_STATIC_DNS##/d" ${D}${sysconfdir}/network/interfaces
[ -z "${WLAN1_STATIC_GATEWAY}" ] && sed -i -e "/##WLAN1_STATIC_GATEWAY##/d" ${D}${sysconfdir}/network/interfaces
[ -z "${WLAN1_STATIC_IP}" ] && sed -i -e "/##WLAN1_STATIC_IP##/d" ${D}${sysconfdir}/network/interfaces
[ -z "${WLAN1_STATIC_NETMASK}" ] && sed -i -e "/##WLAN1_STATIC_NETMASK##/d" ${D}${sysconfdir}/network/interfaces
[ -z "${WLAN1_STATIC_DNS}" ] && sed -i -e "/##WLAN1_STATIC_DNS##/d" ${TARGET_WLAN1_FILE}
[ -z "${WLAN1_STATIC_GATEWAY}" ] && sed -i -e "/##WLAN1_STATIC_GATEWAY##/d" ${TARGET_WLAN1_FILE}
[ -z "${WLAN1_STATIC_IP}" ] && sed -i -e "/##WLAN1_STATIC_IP##/d" ${TARGET_WLAN1_FILE}
[ -z "${WLAN1_STATIC_NETMASK}" ] && sed -i -e "/##WLAN1_STATIC_NETMASK##/d" ${TARGET_WLAN1_FILE}
# Replace interface parameters
sed -i -e "s,##WLAN1_STATIC_IP##,${WLAN1_STATIC_IP},g" ${D}${sysconfdir}/network/interfaces
sed -i -e "s,##WLAN1_STATIC_NETMASK##,${WLAN1_STATIC_NETMASK},g" ${D}${sysconfdir}/network/interfaces
sed -i -e "s,##WLAN1_STATIC_GATEWAY##,${WLAN1_STATIC_GATEWAY},g" ${D}${sysconfdir}/network/interfaces
sed -i -e "s,##WLAN1_STATIC_DNS##,${WLAN1_STATIC_DNS},g" ${D}${sysconfdir}/network/interfaces
sed -i -e "s,##WLAN1_POST_UP_ACTION##,${WLAN1_POST_UP_ACTION},g" ${D}${sysconfdir}/network/interfaces
sed -i -e "s,##WLAN1_PRE_DOWN_ACTION##,${WLAN1_PRE_DOWN_ACTION},g" ${D}${sysconfdir}/network/interfaces
sed -i -e "s,##WLAN1_STATIC_IP##,${WLAN1_STATIC_IP},g" ${TARGET_WLAN1_FILE}
sed -i -e "s,##WLAN1_STATIC_NETMASK##,${WLAN1_STATIC_NETMASK},g" ${TARGET_WLAN1_FILE}
sed -i -e "s,##WLAN1_STATIC_GATEWAY##,${WLAN1_STATIC_GATEWAY},g" ${TARGET_WLAN1_FILE}
sed -i -e "s,##WLAN1_STATIC_DNS##,${WLAN1_STATIC_DNS},g" ${TARGET_WLAN1_FILE}
sed -i -e "s,##WLAN1_POST_UP_ACTION##,${WLAN1_POST_UP_ACTION},g" ${TARGET_WLAN1_FILE}
sed -i -e "s,##WLAN1_PRE_DOWN_ACTION##,${WLAN1_PRE_DOWN_ACTION},g" ${TARGET_WLAN1_FILE}
}
# Disable wireless interfaces on first boot for non-wireless variants
@ -107,5 +130,24 @@ pkg_postinst_ontarget_${PN}() {
update-rc.d ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS}
fi
COMPAT="/proc/device-tree/compatible"
WIFI_MAC="/proc/device-tree/wireless/mac-address"
# Only execute the script on wireless ccimx6 platforms
if [ -e ${WIFI_MAC} -a $(grep fsl,imx6dl ${COMPAT} || grep fsl,imx6q ${COMPAT} | grep -v fsl,imx6qp) ]; then
for id in $(find /sys/devices -name modalias -print0 | xargs -0 sort -u -z | grep sdio); do
if [[ "$id" == "sdio:c00v0271d0301" ]] ; then
cat /etc/interfaces.br0.atheros.example >> /etc/network/interfaces
rm /etc/network/if-pre-up.d/virtwlans /etc/network/if-post-down.d/virtwlans
break
elif [[ "$id" == "sdio:c00v0271d050A" ]] ; then
cat /etc/interfaces.wlan1.example >> /etc/network/interfaces
cat /etc/interfaces.br0.example >> /etc/network/interfaces
break
fi
done
rm /etc/interfaces.*.example
fi
exit 0
}