From 71b3623b59b3e2cc2618dc682af9e54c3307769c Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Thu, 4 Nov 2021 09:20:02 +0100 Subject: [PATCH] init-ifupdown: adapt recipe for read-only-rootfs This recipe had a post install script to do the following: - create runlevel symlinks. - comment the 'auto' lines of /etc/network/interfaces if running on a non-Wi-Fi variant. - add Atheros or QCA bridge examples depending on the detected chip. - add wlan1 interface only if QCA chip is detected. This post install cannot run on a read-only-rootfs so the recipe has been reworked to do the same things at build time: - the runlevel symlinks have been removed because they are taken care of by a poky class. - add a pre-up condition (the existance of a wireless entry on the device tree) so that the interface is not brought up if the condition is not met. - for the cc6/cc6n, since the Wi-Fi chip can be Atheros or QCA, add specific wlan1 and br0 fragments with a pre-up condition basing on the detected ID of the Wi-Fi chip Signed-off-by: Hector Palacios https://onedigi.atlassian.net/browse/DEL-7708 --- .../ccimx6sbc/interfaces.br0.atheros.example | 3 +- .../ccimx6sbc/interfaces.br0.example | 8 ++ .../ccimx6sbc/interfaces.wlan1.atheros.dhcp | 8 ++ .../ccimx6sbc/interfaces.wlan1.atheros.static | 11 +++ .../ccimx6sbc/interfaces.wlan1.dhcp | 8 ++ .../ccimx6sbc/interfaces.wlan1.static | 11 +++ .../init-ifupdown-1.0/interfaces.br0.example | 3 +- .../init-ifupdown-1.0/interfaces.p2p | 1 + .../init-ifupdown-1.0/interfaces.wlan1.dhcp | 2 + .../init-ifupdown-1.0/interfaces.wlan1.static | 2 + .../init-ifupdown/init-ifupdown_1.0.bbappend | 92 +++++-------------- 11 files changed, 79 insertions(+), 70 deletions(-) create mode 100644 meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.br0.example create mode 100644 meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.atheros.dhcp create mode 100644 meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.atheros.static create mode 100644 meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.dhcp create mode 100644 meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.static diff --git a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.br0.atheros.example b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.br0.atheros.example index 6244da561..4b78aaca9 100644 --- a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.br0.atheros.example +++ b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.br0.atheros.example @@ -1,5 +1,5 @@ -## Example bridge between eth0 and wlan0 +## Example bridge between eth0 and wlan0 (Atheros AR6233) #auto br0 #iface br0 inet static # bridge_ports eth0 wlan0 @@ -7,3 +7,4 @@ # netmask 255.255.255.0 # bridge_wpa_driver nl80211 # bridge_wpa_conf /etc/wpa_supplicant.conf +# pre-up [ $(find /sys/devices -name modalias -print0 | xargs -0 sort -u -z | grep sdio:c00v0271d0301) ] diff --git a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.br0.example b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.br0.example new file mode 100644 index 000000000..34545bee0 --- /dev/null +++ b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.br0.example @@ -0,0 +1,8 @@ + +## Example bridge between eth0 and wlan1 (Qualcomm QCA65x4) +#auto br0 +#iface br0 inet static +# bridge_ports eth0 wlan1 +# address 192.168.42.50 +# netmask 255.255.255.0 +# pre-up [ $(find /sys/devices -name modalias -print0 | xargs -0 sort -u -z | grep sdio:c00v0271d050A) ] diff --git a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.atheros.dhcp b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.atheros.dhcp new file mode 100644 index 000000000..e6f114131 --- /dev/null +++ b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.atheros.dhcp @@ -0,0 +1,8 @@ + +# Wi-Fi AP interface (Atheros AR6233) +#auto wlan1 +iface wlan1 inet dhcp + udhcpc_opts -S -b >/dev/null & + pre-up [ $(find /sys/devices -name modalias -print0 | xargs -0 sort -u -z | grep sdio:c00v0271d0301) ] + wpa-driver nl80211 + wpa-conf /etc/wpa_supplicant.conf diff --git a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.atheros.static b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.atheros.static new file mode 100644 index 000000000..eb8af110e --- /dev/null +++ b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.atheros.static @@ -0,0 +1,11 @@ + +# Wi-Fi AP interface (Atheros AR6233) +#auto wlan1 +iface wlan1 inet static + address ##WLAN1_STATIC_IP## + netmask ##WLAN1_STATIC_NETMASK## + gateway ##WLAN1_STATIC_GATEWAY## + dns-nameservers ##WLAN1_STATIC_DNS## + pre-up [ $(find /sys/devices -name modalias -print0 | xargs -0 sort -u -z | grep sdio:c00v0271d0301) ] + wpa-driver nl80211 + wpa-conf /etc/wpa_supplicant.conf diff --git a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.dhcp b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.dhcp new file mode 100644 index 000000000..3f35e5aa4 --- /dev/null +++ b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.dhcp @@ -0,0 +1,8 @@ + +# Wi-Fi AP interface (Qualcomm QCA65x4) +#auto wlan1 +iface wlan1 inet dhcp + udhcpc_opts -S -b >/dev/null & + pre-up [ $(find /sys/devices -name modalias -print0 | xargs -0 sort -u -z | grep sdio:c00v0271d050A) ] + post-up ##WLAN1_POST_UP_ACTION## + pre-down ##WLAN1_PRE_DOWN_ACTION## diff --git a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.static b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.static new file mode 100644 index 000000000..aa6bd09ea --- /dev/null +++ b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/ccimx6sbc/interfaces.wlan1.static @@ -0,0 +1,11 @@ + +# Wi-Fi AP interface (Qualcomm QCA65x4) +#auto wlan1 +iface wlan1 inet static + address ##WLAN1_STATIC_IP## + netmask ##WLAN1_STATIC_NETMASK## + gateway ##WLAN1_STATIC_GATEWAY## + dns-nameservers ##WLAN1_STATIC_DNS## + pre-up [ $(find /sys/devices -name modalias -print0 | xargs -0 sort -u -z | grep sdio:c00v0271d050A) ] + post-up ##WLAN1_POST_UP_ACTION## + pre-down ##WLAN1_PRE_DOWN_ACTION## diff --git a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.br0.example b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.br0.example index 60e05fe52..1a0ffdf42 100644 --- a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.br0.example +++ b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.br0.example @@ -1,7 +1,8 @@ -## Example bridge between eth0 and wlan1 +## Example bridge between eth0 and wlan1 (Qualcomm QCA65x4) #auto br0 #iface br0 inet static # bridge_ports eth0 wlan1 # address 192.168.42.50 # netmask 255.255.255.0 +# pre-up [ -d /proc/device-tree/wireless ] diff --git a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.p2p b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.p2p index 18a4503cc..7d828005c 100644 --- a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.p2p +++ b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.p2p @@ -8,3 +8,4 @@ iface ##WLAN_P2P_INTERFACE## inet static dns-nameservers ##P2P0_STATIC_DNS## wpa-driver ##WPA_DRIVER## wpa-conf /etc/wpa_supplicant_p2p.conf + pre-up [ -d /proc/device-tree/wireless ] diff --git a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.wlan1.dhcp b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.wlan1.dhcp index 887f3034a..cc42c3377 100644 --- a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.wlan1.dhcp +++ b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.wlan1.dhcp @@ -1,6 +1,8 @@ +# Wi-Fi AP interface (Qualcomm QCA65x4) #auto wlan1 iface wlan1 inet dhcp udhcpc_opts -S -b >/dev/null & + pre-up [ -d /proc/device-tree/wireless ] post-up ##WLAN1_POST_UP_ACTION## pre-down ##WLAN1_PRE_DOWN_ACTION## diff --git a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.wlan1.static b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.wlan1.static index 17e4a1090..35f5b29c6 100644 --- a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.wlan1.static +++ b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown-1.0/interfaces.wlan1.static @@ -1,9 +1,11 @@ +# Wi-Fi AP interface (Qualcomm QCA65x4) #auto wlan1 iface wlan1 inet static address ##WLAN1_STATIC_IP## netmask ##WLAN1_STATIC_NETMASK## gateway ##WLAN1_STATIC_GATEWAY## dns-nameservers ##WLAN1_STATIC_DNS## + pre-up [ -d /proc/device-tree/wireless ] post-up ##WLAN1_POST_UP_ACTION## pre-down ##WLAN1_PRE_DOWN_ACTION## diff --git a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown_1.0.bbappend b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown_1.0.bbappend index 7faf9e811..31139edbf 100644 --- a/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown_1.0.bbappend +++ b/meta-digi-dey/recipes-core/init-ifupdown/init-ifupdown_1.0.bbappend @@ -22,15 +22,16 @@ SRC_URI_append = " \ ${@oe.utils.conditional('HAS_WIFI_VIRTWLANS', 'true', '${WIFI_VIRTWLANS_FILES}', '', d)} \ " -SRC_URI_append_ccimx6sbc = " file://interfaces.br0.atheros.example" +SRC_URI_append_ccimx6sbc = " \ + file://interfaces.wlan1.atheros.static \ + file://interfaces.wlan1.atheros.dhcp \ + 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/ @@ -68,14 +69,11 @@ do_install_append() { install_wlan1 fi - # 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 + cat ${WORKDIR}/interfaces.br0.example >> ${D}${sysconfdir}/network/interfaces + if [ "${MACHINE}" = "ccimx6sbc" ]; then + # On ccimx6, append also the Atheros fragments so the user can + # decide which one to use depending on the wireless MAC used on the SOM. + cat ${WORKDIR}/interfaces.br0.atheros.example >> ${D}${sysconfdir}/network/interfaces fi } @@ -89,67 +87,25 @@ 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 - # 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} + cat ${WORKDIR}/interfaces.wlan1.${WLAN1_MODE} >> ${D}${sysconfdir}/network/interfaces + if [ "${MACHINE}" = "ccimx6sbc" ]; then + cat ${WORKDIR}/interfaces.wlan1.atheros.${WLAN1_MODE} >> ${D}${sysconfdir}/network/interfaces fi - [ -n "${WLAN1_AUTO}" ] && sed -i -e 's/^#auto wlan1/auto wlan1/g' ${TARGET_WLAN1_FILE} + [ -n "${WLAN1_AUTO}" ] && sed -i -e 's/^#auto wlan1/auto wlan1/g' ${D}${sysconfdir}/network/interfaces fi # Remove config entries if corresponding variable is not defined - [ -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} + [ -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 # Replace interface parameters - 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} + 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 } - -# Disable wireless interfaces on first boot for non-wireless variants -pkg_postinst_ontarget_${PN}() { - if [ ! -d "/proc/device-tree/wireless" ]; then - sed -i -e '/^auto wlan/{s,^,#,g};/^auto p2p/{s,^,#,g}' /etc/network/interfaces - fi - - # Create the symlinks in the different runlevels - if type update-rc.d >/dev/null 2>/dev/null; then - 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 -} - -inherit ${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", "remove-pkg-postinst-ontarget", "", d)}