connman wifi autoconnect

Hi!
I can’t seem to get connman to bring up my USB WiFi connection automatically on boot. Seems to happen on both 4.4 and 4.9 kernels. Suggestions welcome.

I’d like to move away from having ethernet on my older boards. I’m using WiPi dongles that work perfectly fine if I manually connect… but… shrug. I’ve spent time looking through the archives here but haven’t turned up anything that helps. I admit that doesn’t mean it’s not out there, just I’ve reached the point of asking for assistance while I continue to try and work it out.

Cheers

P.

Some info:

$ cat /etc/dogtag
rcn-ee.net console Debian Image 2017-08-11

$ uname -r
4.9.45-ti-r57

$lsusb -v -d $(lsusb | grep -i ralink | cut -f 6 -d \ )
Bus 001 Device 003: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x148f Ralink Technology, Corp.
idProduct 0x5370 RT5370 Wireless Adapter
bcdDevice 1.01
iManufacturer 1 Ralink
iProduct 2 802.11 n WLAN
iSerial 3 1.0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 67
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 450mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 7
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 5 1.0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x03 EP 3 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x04 EP 4 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x05 EP 5 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x06 EP 6 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Device Qualifier (for other device speed):
bLength 10
bDescriptorType 6
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
bNumConfigurations 1
Device Status: 0x0000
(Bus Powered)

$ sudo dmesg |grep rt2
[ 30.969242] ieee80211 phy0: rt2x00_set_rt: Info - RT chipset 5390, rev 0502 detected
[ 31.173473] ieee80211 phy0: rt2x00_set_rf: Info - RF chipset 5370 detected
[ 31.273462] ieee80211 phy0: rt2x00lib_request_firmware: Info - Loading firmware file ‘rt2870.bin’
[ 31.276910] usbcore: registered new interface driver rt2800usb
[ 31.286871] ieee80211 phy0: rt2x00lib_request_firmware: Info - Firmware detected - version: 0.36

$ sudo cat /var/lib/connman/wifi_xxxxxxxxxxx_managed_psk/settings
[wifi_xxxxxxxxxxx_managed_psk]
Name=yyyyy
SSID=deadbeef
Frequency=2412
Favorite=true
AutoConnect=true
Modified=2017-09-08T10:57:48.977181Z
Passphrase=zzzzzzzzzzzzzzzzzzzzzzzzzzz
IPv4.method=dhcp
IPv6.method=auto
IPv6.privacy=disabled
IPv4.DHCP.LastAddress=a.b.c.d

$/sbin/ifconfig wlan0
wlan0: flags=-28669<UP,BROADCAST,MULTICAST,DYNAMIC> mtu 1500
ether 00:c1:41:34:0e:7c txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

I found a thing from Adafruit for 3.8 kernel https://github.com/adafruit/wifi-reset

It was nice but is relying on iwconfig to do its magic

So I rewrote it for connman

https://gitlab.com/petelawler/wifi-reset

Haven’t tested it really with anything apart from 4.4 and 4.9 kernels. Your mileage may vary. Works for me.

Like all hacks, it’s a not a good hack because it’s clean but because it works.

I’ve not looked deeply under the hood but I suspect what’s going on is that connman is firing off everything before the USB bus is fully enumerated and necessary firmware is loaded. At least, that’s my wild stab in the dark.