How to set up a soft access point under Linux using a WLAN USB Dongle based on the Ralink RT3070 Chipset?

A Linux server, running on a Toradex Colibri T30 platform, shall provide wireless connectivity to some mobile clients without using a foreing network infrastructure. Well, the connman network manager is available by default out of the Toradex Linux image. So I tried to enable wifi tethering by using the connman network manager. But that gives me an error: <>.

So if connman doesn’t support wifi tethering (why ever), what’s the most recommended way to get an ap / tethering working on this particular plattform? Any experiences?

Thanks in advance!

Environment:
Linux (Toradex Image V2.5 Beta 3) on a Colibri T30 platform (V1.1C).
WLAN USB Dongle based on the Ralink RT3070 Chipset.

Rather than relying on connman one could e.g. use hostapd as follows:

First plug-in your Wi-Fi stick. As the Ambicom WL250N we previously sold in our web shop has the same chip set it should be detected and driver/firmware be loaded automatically:

[   40.583933] utmi_phy_irq: utmip remote wake detected
[   40.588921] tegra-ehci tegra-ehci.2: remote wakeup detected
[   40.940150] usb 2-1.3: new high speed USB device number 3 using tegra-ehci
[   41.087508] usb 2-1.3: New USB device found, idVendor=148f, idProduct=3070
[   41.094463] usb 2-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   41.101865] usb 2-1.3: Product: 802.11 n WLAN
[   41.106230] usb 2-1.3: Manufacturer: Ralink
[   41.110438] usb 2-1.3: SerialNumber: 1.0
[   41.199845] usb 2-1.3: reset high speed USB device number 3 using tegra-ehci

root@colibri-t30:~# lsusb | grep 3070
Bus 002 Device 003: ID 148f:3070 Ralink Technology, Corp. RT2870/RT3070 Wireless Adapter

root@colibri-t30:~# ip addr | grep -A 5 wlan
10: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop qlen 1000
    link/ether 00:10:7a:4f:74:21 brd ff:ff:ff:ff:ff:ff

Secondly we make sure the IP configuration of your Wi-Fi stick is taken care of by systemd-networkd requiring the following configuration file to be added:

/etc/systemd/network/hostapd.network
[Match]
Name=wlan0

[Network]
Address=192.168.12.1/24
DHCPServer=yes

Optionally the above would allow to enable e.g. IP forwarding as well as explained in its documentation.

As there seems to be sort of a race condition in bringing the Wi-Fi interface up modify the systemd-networkd.service file by adding the following ExecStartPre to its [Service] section as a workaround:

/lib/systemd/system/systemd-networkd.service
[Service]
ExecStartPre=/sbin/ip link set wlan0 up

Restart the systemd-networkd service:

root@colibri-t30:~# systemctl restart systemd-networkd

Unfortunately as the hostapd package is not available in any pre-compiled binary Angstrom feed as of yet one will have to do a custom Angstrom/OpenEmbedded/Yocto build including hostapd as explained on our developer website.

Alternatively install the following hostapd package (regular wired Ethernet connection required as further package dependencies need to be downloaded/installed as well):

root@colibri-t30:~# opkg update
...
root@colibri-t30:~# opkg install hostapd_2.4-r0.0_armv7at2hf-vfp-neon.ipk 

As the hostapd startup may suffer from a race condition on the Wi-Fi interface having been brought up by systemd-networkd one can adjust its configuration by Removing After=network.target from its [Unit] section and instead adding After/BindsTo as follows:

/lib/systemd/system/hostapd.service
[Unit]
BindsTo=sys-subsystem-net-devices-wlan0.device
After=sys-subsystem-net-devices-wlan0.device

Adjust the following configuration file to your liking and deploy it to /etc/hostapd.conf.

Start and/or enable the hostapd as a systemd service:

root@colibri-t30:~# systemctl start hostapd
root@colibri-t30:~# systemctl enable hostapd

And you should be all set.

Great guidance, thank you!
Hostapd and systemd-networkd works quite fine to me :slight_smile:

Some cases the command rfkill also helps:

    rfkill unblock wlan

Another question related to the same topic is: