cleverca22
Posts: 4357
Joined: Sat Aug 18, 2012 2:33 pm

Re: What about a keypress-enabled rescue micro-AP feature?

Wed Aug 04, 2021 4:02 am

Code: Select all

root@pi4:~# cat /sys/class/net/wlan0/device/modalias
sdio:c00v02D0dA9A6
root@pi4:~# modinfo sdio:c00v02D0dA9A6
filename:       /lib/modules/5.10.52-v8+/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko
alias:          sdio:c*v02D0dA9A6*
root@pi4:~# vcgencmd otp_dump | egrep '30:|28:'
28:d328cdce
30:00c03112
the modalias is kernel generated, in this case based on what the SDIO device self-identified itself as
there is then an alias defined in the module that will "claim" that alias, so you can just "modprobe sdio:c00v02D0dA9A6" and then modprobe finds the right driver

Code: Select all

root@pi400:~# cat /sys/class/net/wlan0/device/modalias
sdio:c00v02D0dA9A6
root@pi400:~# vcgencmd otp_dump | egrep '30:|28:'
28:daaa69e8
30:00c03130
and i can see my pi400 has the identical modalias as the pi4

Code: Select all

root@pi0:~# cat /sys/class/net/wlan0/device/modalias
sdio:c00v02D0dA9A6
root@pi0:~# vcgencmd otp_dump | egrep '30:|28:'
28:5c4c1ef6
30:009000c1
root@pi0:~# 
and to my surprise, the pi0w also has the identical modalias!

Code: Select all

root@pi0:~# cat /sys/class/net/wlan0/device/modalias
sdio:c00v02D0dA9A6
root@pi0:~# vcgencmd otp_dump | egrep '30:|28:'
28:451592ae
30:009000c1
and its not really a surprise that the 2nd pi0 is identical

cant test my pi3 currently, so thats all i can gather

epoch1970
Posts: 6915
Joined: Thu May 05, 2016 9:33 am
Location: France

Re: What about a keypress-enabled rescue micro-AP feature?

Wed Aug 04, 2021 8:36 am

Thank you for this.

It might be a typical case of "if there is no solution, there is no problem" but to be sure I'll restate the problem:
  • A user is given a headless Pi loaded with an OS, both unknown to them. Mission is to start it, login over the wireless network (sigh) and have fun. Pi starts and apparently shoots off for lunch.
  • My premise is that the µAP feature(tte) on Pis with built-in wireless interfaces, while shaky as hell, can be put to light-duty use in a case like this. I believe this to be true on Pi 3B, the only platform I have.
  • The admin of the Pi added a rescue button and software in the OS to start the µAP in case of emergency. The user knows that and presses the button.
  • If the µAP can run, the software must make the Pi scream "I'm coming" at the top of all its little LEDs. If for reasons the µAP cannot run, the button must appear absolutely dead. Positively no false positive, the user is lost enough at this point.
What drives µAP availability, then? The way I see it:
  1. Platform has to be Pi3B, 3B+, 3A+, 4B, 400, 0w
  2. A capable BRCM/CYW built-in interface has to be present in the OS (not disabled via overlay, not exported to some container)
  3. Wifi must not be hardware-blocked (rfkill)
  4. The interface must be in a state conducive to starting dual-mode (main interface idle or connected in STA mode, no p2p interface active. As per "iw phy0 info")
Checks #1, #3, #4 (hmm... p2p) are not a problem I think. For check #2, my intention was to look into the machine for a well-known chipset type connected via sdio. From there the code can peruse the name of the interface and its phy (nominally wlan0 and phy0) and start/stop the extra µAP interface.

I had seen ID codes for specific chipsets in linux in sdio_ids.h and expected to see "sdio:c*v02D0dA9A6*" on 3B, 0w, 3A+ and "sdio:c*v02D0dA9BF*" on 3B+, 4B and 400.

As things stand, I'm ready to accept the single modalias "sdio:c*v02D0dA9A6*" as a valid indicator. I'm also one to turn 180, but I refuse to grep "dmesg". It's uncouth and the code would need to run every check above (except #1) on each button press (things change so fast in userland...) so I'm trying to keep things minimal.

The "Any ideas?" expression is one of my buttons... But I will gladly take in your opinion or advice. Thanks for reading.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

drgeoff
Posts: 12174
Joined: Wed Jan 25, 2012 6:39 pm

Re: What about a keypress-enabled rescue micro-AP feature?

Wed Aug 04, 2021 10:18 am

epoch1970 wrote:
Tue Aug 03, 2021 6:24 pm
I would appreciate if one or a few discerning owners of:
  • Pi 3B+
  • Pi3A+
  • Pi0w
  • Pi4B (any RAM size)
  • Pi400
running a reasonably recent version of Raspios, and using the built-in wireless interface as wlan0 (stock setup) could run the following command for me, and paste results in this thread:

Code: Select all

systemd-hwdb query "$(cat /sys/class/net/wlan0/device/modalias)" && vcgencmd otp_dump | grep '30:'
From a ZeroW

ID_VENDOR_FROM_DATABASE=Broadcom Corp.
ID_MODEL_FROM_DATABASE=BCM43438 combo WLAN and Bluetooth Low Energy (BLE)
ID_SDIO_CLASS_FROM_DATABASE=Non-standard SDIO interface
30:009000c1
Quis custodiet ipsos custodes?

epoch1970
Posts: 6915
Joined: Thu May 05, 2016 9:33 am
Location: France

Re: What about a keypress-enabled rescue micro-AP feature?

Sun Aug 08, 2021 5:53 pm

User feedback with a simple "wall" command for CLI users:

Code: Select all

foo@lab:/$ 
                                                                               
Broadcast message from root@lab (somewhere) (Sun Aug  8 19:35:59 2021):        
                                                                               
Pinghy - Wireless access to this Raspberry Pi is now open!
         SSID: lab-Pi3B-162f
         * This is a security risk * Close access as soon as possible *
                                                                               
                                                                               
Broadcast message from root@lab (somewhere) (Sun Aug  8 19:36:12 2021):        
                                                                               
Pinghy - Wireless access to this Raspberry Pi is now closed
                                                                               
And via a totally crazy contraption named notifyd for GUI users:
pinghy.jpg
pinghy.jpg (86 KiB) Viewed 208 times
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

epoch1970
Posts: 6915
Joined: Thu May 05, 2016 9:33 am
Location: France

Re: What about a keypress-enabled rescue micro-AP feature?

Wed Aug 18, 2021 7:23 pm

All right folks, Pinghy has arrived: https://github.com/epoch1970/Pinghy

It's a prototype, nothing more.
I've tested it on Pi3B (as usual) and I think it works fine.
The install is easy but TBH the design is a bit shambolic, with gpio-button, triggerhappy, dhcpcd, systemd-networkd, notifyd all looking for a piece of the action.

Head over the project page, there is a long-ish description and a howto.
I hope it will work for some, and on other platforms than Pi3B.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Return to “Raspberry Pi OS”