feat: M3 complete — WiFi, BT keyboard and mouse

Bluetooth (RTL8723D USB combo chip):
- GPIO pin 357 (active low) enables WiFi/BT hardware via x6200_gpio_set()
- bluez5_utils 5.64 (downgraded from 5.79 — HID input plugin broken in 5.79)
- rtl8723d_config.bin added to overlay (missing from linux-firmware package)
- S45wifi-bt: GPIO enable + modprobe btusb/uhid/hidp at boot
- S85bt-keyboard: auto-connect loop with scan+connect every 20s

WiFi (RTL8723DU):
- out-of-tree lwfinger/rtw88 driver (RTW88_8723DU not in kernel 6.1 mainline)
- linux-firmware RTL_RTW88 for rtw88/rtw8723d_fw.bin
- regulatory.db for cfg80211
- wpa_supplicant with multi-network config in /etc/wpa_supplicant.conf
- S46wifi: wpa_supplicant + udhcpc at boot

Key findings:
- RTL8723D USB WiFi (0bda:d723) requires out-of-tree rtw88 on kernel 6.1
- BT and WiFi share same USB device, both need GPIO 357 = 0 to power on
- bluez5 5.79 HID input plugin not linked into bluetoothd (build system bug)
This commit is contained in:
Joakim
2026-05-09 21:02:53 +02:00
parent e67ff6c019
commit 2526d5b087
19 changed files with 964 additions and 16 deletions

View File

@@ -1,5 +1,6 @@
menu "Mestre"
source "$BR2_EXTERNAL_MESTRE_PATH/package/x6200-control/Config.in"
source "$BR2_EXTERNAL_MESTRE_PATH/package/rtw88/Config.in"
endmenu

View File

@@ -35,3 +35,8 @@ CONFIG_SND_DUMMY=m
# Expose kernel config via /proc/config.gz (useful for debugging)
CONFIG_IKCONFIG=y
CONFIG_IKCONFIG_PROC=y
# HID via userspace (required for Bluetooth HID devices)
CONFIG_UHID=y
CONFIG_INPUT_UINPUT=y

View File

@@ -56,11 +56,13 @@ CONFIG_NET_IPIP=y
# CONFIG_INET_DIAG is not set
# CONFIG_IPV6 is not set
CONFIG_CAN=y
CONFIG_BT=m
CONFIG_BT_RFCOMM=m
CONFIG_BT_BNEP=m
CONFIG_BT_HIDP=m
CONFIG_BT_HCIBTUSB=m
CONFIG_BT=y
CONFIG_BT_RFCOMM=y
CONFIG_BT_BNEP=y
CONFIG_BT_HIDP=y
CONFIG_BT_HCIBTUSB=y
CONFIG_UHID=y
CONFIG_HIDRAW=y
CONFIG_CFG80211=m
CONFIG_CFG80211_DEVELOPER_WARNINGS=y
CONFIG_CFG80211_CERTIFICATION_ONUS=y

View File

@@ -0,0 +1,5 @@
Section "Device"
Identifier "LCD"
Driver "fbdev"
Option "Rotate" "CCW"
EndSection

View File

@@ -0,0 +1,45 @@
#!/bin/sh
# S45wifi-bt — aktiverar WiFi/BT-chipet (RTL8723D) via GPIO
#
# X6200:s WiFi/BT-chip är avstängt vid boot och måste aktiveras
# via GPIO pin 357 (active low) innan kernel-drivern kan använda det.
#
# Måste köras innan S40bluetoothd startar.
case "$1" in
start)
echo "Starting WiFi/BT hardware"
python3 - << 'PYEOF'
import ctypes
lib = ctypes.CDLL("libaether_x6200_control.so")
lib.x6200_gpio_init.restype = ctypes.c_bool
lib.x6200_gpio_set.argtypes = [ctypes.c_int, ctypes.c_int]
lib.x6200_gpio_init()
lib.x6200_gpio_set(357, 0) # active low — 0 = ON
PYEOF
sleep 1
modprobe btusb
modprobe uhid
modprobe hidp
sleep 3
echo "OK"
;;
stop)
python3 - << 'PYEOF'
import ctypes
lib = ctypes.CDLL("libaether_x6200_control.so")
lib.x6200_gpio_init.restype = ctypes.c_bool
lib.x6200_gpio_set.argtypes = [ctypes.c_int, ctypes.c_int]
lib.x6200_gpio_init()
lib.x6200_gpio_set(357, 1) # 1 = OFF
PYEOF
echo "WiFi/BT hardware stopped"
;;
restart)
$0 stop; sleep 1; $0 start
;;
*)
echo "Usage: $0 {start|stop|restart}" >&2
exit 1
;;
esac

View File

@@ -0,0 +1,44 @@
#!/bin/sh
# S46wifi — ansluter till WiFi via wpa_supplicant
#
# Körs efter S45wifi-bt (GPIO aktivering av chipet).
# Använder /etc/wpa_supplicant.conf för nätverkslista.
IFACE="wlan0"
PIDFILE="/var/run/wpa_supplicant.pid"
LOG="/var/log/wifi.log"
case "$1" in
start)
echo "Starting WiFi"
ip link set "$IFACE" up
sleep 2
wpa_supplicant -B \
-i "$IFACE" \
-c /etc/wpa_supplicant.conf \
-P "$PIDFILE" \
>> "$LOG" 2>&1
# Hämta IP via DHCP
sleep 3
dhclient "$IFACE" >> "$LOG" 2>&1 || \
udhcpc -i "$IFACE" -b -p /var/run/udhcpc.pid >> "$LOG" 2>&1
echo "OK"
;;
stop)
echo "Stopping WiFi"
[ -f "$PIDFILE" ] && kill $(cat "$PIDFILE") 2>/dev/null
rm -f "$PIDFILE"
ip link set "$IFACE" down
echo "OK"
;;
restart)
$0 stop; sleep 1; $0 start
;;
*)
echo "Usage: $0 {start|stop|restart}" >&2
exit 1
;;
esac

View File

@@ -0,0 +1,58 @@
#!/bin/sh
# S85bt-keyboard — auto-connect Linocell BTK16 BT-tangentbord
#
# Försöker ansluta tangentbordet vid boot och startar en bakgrundsprocess
# som reconnectar automatiskt när tangentbordet kommer inom räckhåll.
#
# Tangentbordet måste vara parat och trustat sedan tidigare.
# Para manuellt med: bluetoothctl pair ED:96:00:23:E2:02
# bluetoothctl trust ED:96:00:23:E2:02
KEYBOARD_ADDR="ED:96:00:23:E2:02"
PIDFILE="/var/run/bt-keyboard.pid"
LOG="/var/log/bt-keyboard.log"
connect_keyboard() {
bluetoothctl power on > /dev/null 2>&1
bluetoothctl connect "$KEYBOARD_ADDR" > /dev/null 2>&1
}
watch_loop() {
while true; do
# Kolla om tangentbordet är anslutet
if ! bluetoothctl info "$KEYBOARD_ADDR" 2>/dev/null | grep -q "Connected: yes"; then
connect_keyboard
fi
sleep 10
done
}
case "$1" in
start)
echo "Starting BT keyboard auto-connect"
# Försök första anslutning i bakgrunden (tangentbordet kanske inte är i närheten)
(sleep 5 && connect_keyboard) &
# Starta watch-loop som reconnectar när tgb dyker upp
watch_loop >> "$LOG" 2>&1 &
echo $! > "$PIDFILE"
echo "OK"
;;
stop)
echo "Stopping BT keyboard auto-connect"
if [ -f "$PIDFILE" ]; then
kill $(cat "$PIDFILE") 2>/dev/null
rm -f "$PIDFILE"
fi
bluetoothctl disconnect "$KEYBOARD_ADDR" > /dev/null 2>&1
echo "OK"
;;
restart)
$0 stop; sleep 1; $0 start
;;
*)
echo "Usage: $0 {start|stop|restart}" >&2
exit 1
;;
esac

View File

@@ -0,0 +1,116 @@
# $OpenBSD: sshd_config,v 1.104 2021/07/02 05:11:21 dtucker Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/bin:/sbin:/usr/bin:/usr/sbin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value.
#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key
# Ciphers and keying
#RekeyLimit default none
# Logging
#SyslogFacility AUTH
#LogLevel INFO
# Authentication:
#LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
#PubkeyAuthentication yes
# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys
#AuthorizedPrincipalsFile none
#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
# Change to no to disable s/key passwords
#KbdInteractiveAuthentication yes
# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the KbdInteractiveAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via KbdInteractiveAuthentication may bypass
# the setting of "PermitRootLogin prohibit-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and KbdInteractiveAuthentication to 'no'.
#UsePAM no
#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none
# no default banner path
#Banner none
# override default of no subsystems
Subsystem sftp /usr/libexec/sftp-server
# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# PermitTTY no
# ForceCommand cvs server

View File

@@ -0,0 +1,16 @@
ctrl_interface=/var/run/wpa_supplicant
update_config=1
country=SE
# Lägg till dina nätverk här:
network={
ssid="Ditt_natverk_1"
psk="ditt_losenord_1"
priority=10
}
network={
ssid="Ditt_natverk_2"
psk="ditt_losenord_2"
priority=5
}

View File

@@ -0,0 +1 @@
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBaWQsEKvTUbfTSKEa9sEuu7LpJm9Z07eSluIQV7+AxA joakim@cameron

View File

@@ -126,7 +126,17 @@ BR2_PACKAGE_STRACE=y
# - Network Manager (using simple /etc/network/interfaces for now)
# ---------------------------------------------------------------------------
BR2_GLOBAL_PATCH_DIR="../br2_external/board/x6200/patches"
# x6200
BR2_PACKAGE_X6200_CONTROL=y
# MISC
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON3_CTYPES=y
BR_PACKAGE_JOE=y
# Audio
BR2_PACKAGE_ALSA_UTILS=y
BR2_PACKAGE_ALSA_UTILS_APLAY=y
BR2_PACKAGE_ALSA_UTILS_AMIXER=y
@@ -135,12 +145,47 @@ BR2_PACKAGE_ALSA_LIB=y
BR2_PACKAGE_ALSA_LIB_MIXER=y
BR2_PACKAGE_ALSA_LIB_PCM=y
BR2_PACKAGE_ALSA_LIB_RAWMIDI=y
BR2_PACKAGE_X6200_CONTROL=y
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON3_CTYPES=y
BR2_PACKAGE_PULSEAUDIO=y
BR2_PACKAGE_PULSEAUDIO_DAEMON=y
BR2_PACKAGE_PULSEAUDIO_MODULE_ALSA=y
BR2_PACKAGE_PULSEAUDIO=y
BR2_PACKAGE_PULSEAUDIO_DAEMON=y
BR2_PACKAGE_PULSEAUDIO_MODULE_ALSA=y
# X11
BR2_PACKAGE_XORG7=y
BR2_PACKAGE_XSERVER_XORG_SERVER=y
BR2_PACKAGE_XAPP_XINIT=y
BR2_PACKAGE_XDRIVER_XF86_VIDEO_FBDEV=y
BR2_PACKAGE_XDRIVER_XF86_INPUT_LIBINPUT=y
BR2_PACKAGE_XKEYBOARD_CONFIG=y
BR2_PACKAGE_LIBINPUT=y
BR2_PACKAGE_XTERM=y
# GTK3
BR2_PACKAGE_LIBGTK3=y
BR2_PACKAGE_LIBGTK3_X11=y
BR2_PACKAGE_LIBEPOXY=y
# BT TGB MOUSE & WIFI
BR2_PACKAGE_LINUX_FIRMWARE=y
BR2_PACKAGE_LINUX_FIRMWARE_RTL_87XX=y
BR2_PACKAGE_LINUX_FIRMWARE_RTL_87XX_BT=y
BR2_PACKAGE_BLUEZ5_UTILS=y
BR2_PACKAGE_BLUEZ5_UTILS_CLIENT=y
BR2_PACKAGE_BLUEZ5_UTILS_DEPRECATED=y
BR2_PACKAGE_BLUEZ5_UTILS_TOOLS=y
BR2_PACKAGE_BLUEZ5_UTILS_PLUGINS_HID=y
BR2_PACKAGE_BLUEZ5_UTILS_TOOLS_HID2HCI=y
BR2_PACKAGE_EUDEV=y
BR2_PACKAGE_XKEYBOARD_CONFIG=y
BR2_PACKAGE_XINPUT=y
BR2_PACKAGE_XAPP_XRANDR=y
BR2_PACKAGE_LINUX_FIRMWARE_RTL_RTW88=y
BR2_PACKAGE_RTW88=y
BR2_PACKAGE_LINUX_FIRMWARE_REGULATORY=y
BR2_PACKAGE_WPA_SUPPLICANT=y
BR2_PACKAGE_WPA_SUPPLICANT_PASSPHRASE=y
BR2_PACKAGE_WPA_SUPPLICANT_CTRL_IFACE=y
BR2_PACKAGE_DHCP=y
BR2_PACKAGE_DHCP_CLIENT=y

View File

@@ -0,0 +1,8 @@
config BR2_PACKAGE_RTW88
bool "rtw88 out-of-tree WiFi driver"
depends on BR2_LINUX_KERNEL
help
Out-of-tree Realtek rtw88 driver from lwfinger/rtw88.
Adds RTL8723DU USB WiFi support not available in kernel 6.1.
https://github.com/lwfinger/rtw88

View File

@@ -0,0 +1,16 @@
################################################################################
#
# rtw88 — out-of-tree Realtek WiFi driver
# Includes RTL8723DU USB support not yet in kernel 6.1 mainline.
# Based on gdyuldin/AetherX6200Buildroot's recipe.
#
################################################################################
RTW88_VERSION = 461b696b51317ba4ca585a4ddb32f2e72cd4efc9
RTW88_SITE = https://github.com/lwfinger/rtw88
RTW88_SITE_METHOD = git
RTW88_LICENSE = GPL-2.0
RTW88_INSTALL_STAGING = YES
$(eval $(kernel-module))
$(eval $(generic-package))