Summary: Warm boots often automatically connect to wifi. Cold boots often fail. I can't figure out why.
Details: The following is a cold boot sequence. Raspberry Pi Zero has been up for ~15 minutes at this point. This shows the failure and how I manually recover. But it's rather annoying to have to do this so often.
$ ssh chris@alarmpi.local
ssh: Could not resolve hostname alarmpi.local: Name or service not known
$ sudo picocom /dev/ttyACM0
##login
[chris@alarmpi ~]$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
link/ether b8:27:eb:87:65:80 brd ff:ff:ff:ff:ff:ff
[chris@alarmpi ~]$ sudo systemctl restart netctl-auto@wlan0.service
[chris@alarmpi ~]$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether b8:27:eb:87:65:80 brd ff:ff:ff:ff:ff:ff
inet 10.0.0.112/24 brd 10.0.0.255 scope global dynamic noprefixroute wlan0
valid_lft 604791sec preferred_lft 529191sec
inet6 2601:282:701:3410:ba27:ebff:fe87:6580/64 scope global dynamic mngtmpaddr
valid_lft 6712sec preferred_lft 6712sec
inet6 fe80::ba27:ebff:fe87:6580/64 scope link
valid_lft forever preferred_lft forever
## logout of the pi, and now I can ssh in remotely OK, as expected.
Attached is a journal for the above sequence. The journal shows that the Pi first tries to connect to "ClubC316" even though this is not the default set in 'wifi-menu' and also this AP isn't anywhere nearby (hundreds of miles away).
[ 34.369790] alarmpi network[248]: Starting network profile 'wlan0-ClubC316'...
It does connect to the correct AP.
[ 45.334344] alarmpi systemd-networkd[208]: wlan0: Connected WiFi access point: altitude (f8:a0:97:6e:c7:e7)
But for unknown reasons it gets dropped.
[ 47.902222] alarmpi dhcpcd[467]: dhcp_readbpf: wlan0: Network is down
And it just gives up, never trying to connect to "altitude" again.
[ 76.640461] alarmpi dhcpcd[467]: timed out
However, manually restarting netctl-auto@wlan0.service works, and sticks.
Suspiciously I have:
/etc/systemd/system/netctl@wlan0\x2dClubC316.service.d
But no equivalent for "altitude". Systemctl shows the following units.
netctl-auto@wlan0.service
netctl.service
netctl@wlan0\x2dClubC316.service
I only ever used 'wifi-menu' to connect to both of these APs: first one (in the life of this installation for this Pi) is "ClubC316" and the second one is "altitude".
Anyway, confused.