diff --git a/br-ext-chip-goke/configs/gk7205v300_ultimate_defconfig b/br-ext-chip-goke/configs/gk7205v300_ultimate_defconfig index 8dd5a190ec..9342067a60 100644 --- a/br-ext-chip-goke/configs/gk7205v300_ultimate_defconfig +++ b/br-ext-chip-goke/configs/gk7205v300_ultimate_defconfig @@ -69,6 +69,8 @@ BR2_PACKAGE_LIBOGG_OPENIPC=y BR2_PACKAGE_LIBWEBSOCKETS_OPENIPC=y BR2_PACKAGE_LINUX_FIRMWARE_OPENIPC=y BR2_PACKAGE_LINUX_FIRMWARE_OPENIPC_MEDIATEK_MT7601U=y +BR2_PACKAGE_TXW8301_OPENIPC=y +BR2_PACKAGE_TXW8301_OPENIPC_USB=y BR2_PACKAGE_AWS_WEBRTC=y BR2_PACKAGE_MAJESTIC_FONTS=y BR2_PACKAGE_MAJESTIC_WEBUI=y diff --git a/br-ext-chip-sigmastar/configs/ssc338q_ultimate_defconfig b/br-ext-chip-sigmastar/configs/ssc338q_ultimate_defconfig index b398a66b3e..ece8aab7f5 100644 --- a/br-ext-chip-sigmastar/configs/ssc338q_ultimate_defconfig +++ b/br-ext-chip-sigmastar/configs/ssc338q_ultimate_defconfig @@ -77,5 +77,7 @@ BR2_PACKAGE_RTL8733BU_OPENIPC=y BR2_PACKAGE_SIGMASTAR_OSDRV_INFINITY6E=y BR2_PACKAGE_UACME_OPENIPC=y BR2_PACKAGE_VTUND_OPENIPC=y +BR2_PACKAGE_TXW8301_OPENIPC=y +BR2_PACKAGE_TXW8301_OPENIPC_USB=y BR2_PACKAGE_YAML_CLI=y BR2_PACKAGE_ZEROTIER_ONE=y diff --git a/general/package/Config.in b/general/package/Config.in index 61d0f53b64..cd260a81c5 100644 --- a/general/package/Config.in +++ b/general/package/Config.in @@ -104,6 +104,7 @@ source "$BR2_EXTERNAL_GENERAL_PATH/package/siproxd-openipc/Config.in" source "$BR2_EXTERNAL_GENERAL_PATH/package/ssv615x-openipc/Config.in" source "$BR2_EXTERNAL_GENERAL_PATH/package/ssv635x-openipc/Config.in" source "$BR2_EXTERNAL_GENERAL_PATH/package/ssw101b/Config.in" +source "$BR2_EXTERNAL_GENERAL_PATH/package/txw8301-openipc/Config.in" source "$BR2_EXTERNAL_GENERAL_PATH/package/uacme-openipc/Config.in" source "$BR2_EXTERNAL_GENERAL_PATH/package/uclibc-compat/Config.in" source "$BR2_EXTERNAL_GENERAL_PATH/package/uqmi-openipc/Config.in" diff --git a/general/package/txw8301-openipc/Config.in b/general/package/txw8301-openipc/Config.in new file mode 100644 index 0000000000..04c8d752e1 --- /dev/null +++ b/general/package/txw8301-openipc/Config.in @@ -0,0 +1,34 @@ +config BR2_PACKAGE_TXW8301_OPENIPC + bool "txw8301-openipc" + depends on BR2_LINUX_KERNEL + help + Taixin TXW8301 802.11ah (HaLow) FMAC driver for Linux. + Supports SDIO, USB, and UART interface modules. + + Firmware blob is required at /lib/firmware/taixin/hgicf.bin + (installed via modprobe.d fw_file override). + Runtime config at /etc/hgicf.conf. + + https://github.com/TXW8301/TXW8301-FMAC-linux-driver + +if BR2_PACKAGE_TXW8301_OPENIPC + +choice + prompt "Interface type" + default BR2_PACKAGE_TXW8301_OPENIPC_USB + +config BR2_PACKAGE_TXW8301_OPENIPC_SDIO + bool "SDIO/SPI" + help + Select for SDIO or SPI-connected TXW8301 modules. + +config BR2_PACKAGE_TXW8301_OPENIPC_USB + bool "USB" + help + Select for USB-connected TXW8301 modules. + +endchoice +endif + +comment "txw8301-openipc needs a Linux kernel to be built" + depends on !BR2_LINUX_KERNEL diff --git a/general/package/txw8301-openipc/files/S35txw8301 b/general/package/txw8301-openipc/files/S35txw8301 new file mode 100644 index 0000000000..ae17a3ef6e --- /dev/null +++ b/general/package/txw8301-openipc/files/S35txw8301 @@ -0,0 +1,64 @@ +#!/bin/sh + +IFACE="hg0" +PIDFILE="/var/run/udhcpc.${IFACE}.pid" +CONF="/etc/hgicf.conf" + +load_module() { + if ! lsmod | grep -q "^hgicf"; then + modprobe hgicf 2>/dev/null || insmod /lib/modules/$(uname -r)/extra/hgicf.ko + fi +} + +wait_iface() { + local i=0 + while [ $i -lt 5 ]; do + ip link show "${IFACE}" >/dev/null 2>&1 && return 0 + sleep 1 + i=$((i + 1)) + done + return 1 +} + +start() { + echo -n "Starting TXW8301 HaLow (${IFACE}): " + load_module + if ! wait_iface; then + echo "FAIL (interface ${IFACE} not found)" + return 1 + fi + ip link set "${IFACE}" up + # Run DHCP only if hgicf.conf has dhcpc=1 or conf is absent + if [ ! -f "${CONF}" ] || grep -q "^dhcpc=1" "${CONF}"; then + udhcpc -b -i "${IFACE}" -p "${PIDFILE}" \ + -x hostname:$(hostname) -A 3 -T 3 -t 5 -R \ + >/dev/null 2>&1 + fi + echo "OK" +} + +stop() { + echo -n "Stopping TXW8301 HaLow (${IFACE}): " + if [ -f "${PIDFILE}" ]; then + kill "$(cat ${PIDFILE})" 2>/dev/null + rm -f "${PIDFILE}" + fi + ip link show "${IFACE}" >/dev/null 2>&1 && ip link set "${IFACE}" down + rmmod hgicf 2>/dev/null || true + echo "OK" +} + +case "$1" in + start|stop) + $1 + ;; + restart) + stop + sleep 1 + start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 + ;; +esac diff --git a/general/package/txw8301-openipc/hgicf.conf.default b/general/package/txw8301-openipc/hgicf.conf.default new file mode 100644 index 0000000000..5a86aa3ba2 --- /dev/null +++ b/general/package/txw8301-openipc/hgicf.conf.default @@ -0,0 +1,9 @@ +freq_range=9080,9240,8 +bss_bw=8 +tx_mcs=255 +chan_list=9080,9160,9240 +key_mgmt=WPA-PSK +wpa_psk= +ssid=HALOW_XXXXXX +mode=sta +dhcpc=1 diff --git a/general/package/txw8301-openipc/hgicf_sdio.bin b/general/package/txw8301-openipc/hgicf_sdio.bin new file mode 100644 index 0000000000..cd58cc4c0a Binary files /dev/null and b/general/package/txw8301-openipc/hgicf_sdio.bin differ diff --git a/general/package/txw8301-openipc/hgicf_usb.bin b/general/package/txw8301-openipc/hgicf_usb.bin new file mode 100644 index 0000000000..57952dd917 Binary files /dev/null and b/general/package/txw8301-openipc/hgicf_usb.bin differ diff --git a/general/package/txw8301-openipc/modprobe-txw8301.conf b/general/package/txw8301-openipc/modprobe-txw8301.conf new file mode 100644 index 0000000000..95c3e2f682 --- /dev/null +++ b/general/package/txw8301-openipc/modprobe-txw8301.conf @@ -0,0 +1,2 @@ +# Override fw_file to use vendor subdirectory in /lib/firmware +options hgicf fw_file=taixin/hgicf.bin diff --git a/general/package/txw8301-openipc/txw8301-openipc.mk b/general/package/txw8301-openipc/txw8301-openipc.mk new file mode 100644 index 0000000000..cd51c3e779 --- /dev/null +++ b/general/package/txw8301-openipc/txw8301-openipc.mk @@ -0,0 +1,53 @@ +################################################################################ +# +# txw8301-openipc +# +################################################################################ + +TXW8301_OPENIPC_SITE_METHOD = git +TXW8301_OPENIPC_SITE = https://github.com/TXW8301/TXW8301-FMAC-linux-driver +TXW8301_OPENIPC_VERSION = 867b5a55515d10c541786f3c5c5ab6002832f8b5 + +TXW8301_OPENIPC_LICENSE = GPL-2.0, proprietary (hgicf firmware blob) +TXW8301_OPENIPC_REDISTRIBUTE = NO + +# Module source lives under hgic_fmac/, not at the repo root. +TXW8301_OPENIPC_MODULE_SUBDIRS = hgic_fmac + +# CONFIG_HGIC_SDIO / CONFIG_HGIC_USB are plain kbuild make variables, not +# Kconfig symbols. Pass them via MODULE_MAKE_OPTS so Buildroot's kernel-module +# infra forwards them to: make -C $(LINUX_DIR) M=$(@D)/hgic_fmac modules +# CONFIG_COMPILE_ERR_SUPPRESS suppresses GCC date-stamp warnings promoted to +# errors on newer toolchains (-Wno-date-time -Wno-unused-result -Wno-format). +ifeq ($(BR2_PACKAGE_TXW8301_OPENIPC_SDIO),y) +TXW8301_OPENIPC_MODULE_MAKE_OPTS = CONFIG_HGICF=m CONFIG_HGIC_SDIO=y CONFIG_COMPILE_ERR_SUPPRESS=y +TXW8301_OPENIPC_FW_BLOB = hgicf_sdio.bin +else ifeq ($(BR2_PACKAGE_TXW8301_OPENIPC_USB),y) +TXW8301_OPENIPC_MODULE_MAKE_OPTS = CONFIG_HGICF=m CONFIG_HGIC_USB=y CONFIG_COMPILE_ERR_SUPPRESS=y +TXW8301_OPENIPC_FW_BLOB = hgicf_usb.bin +endif + +# GNUmakefile in tools/test_app/ places binaries under bin/$(notdir $(CC))/. +TXW8301_OPENIPC_CC_NAME = $(notdir $(TARGET_CC)) + +define TXW8301_OPENIPC_BUILD_CMDS + $(MAKE) -C $(@D)/tools/test_app CC="$(TARGET_CC)" CFLAGS="$(TARGET_CFLAGS)" +endef + +define TXW8301_OPENIPC_INSTALL_TARGET_CMDS + $(INSTALL) -D -m 644 $(TXW8301_OPENIPC_PKGDIR)/$(TXW8301_OPENIPC_FW_BLOB) \ + $(TARGET_DIR)/lib/firmware/taixin/hgicf.bin + $(INSTALL) -D -m 644 $(TXW8301_OPENIPC_PKGDIR)/modprobe-txw8301.conf \ + $(TARGET_DIR)/etc/modprobe.d/txw8301.conf + $(INSTALL) -D -m 644 $(TXW8301_OPENIPC_PKGDIR)/hgicf.conf.default \ + $(TARGET_DIR)/etc/hgicf.conf + $(INSTALL) -D -m 755 $(@D)/tools/test_app/bin/$(TXW8301_OPENIPC_CC_NAME)/hgpriv \ + $(TARGET_DIR)/usr/bin/hgpriv + $(INSTALL) -D -m 755 $(@D)/tools/test_app/bin/$(TXW8301_OPENIPC_CC_NAME)/hgicf \ + $(TARGET_DIR)/usr/bin/hgicf + $(INSTALL) -D -m 755 $(TXW8301_OPENIPC_PKGDIR)/files/S35txw8301 \ + $(TARGET_DIR)/etc/init.d/S35txw8301 +endef + +$(eval $(kernel-module)) +$(eval $(generic-package))