Sample Header Ad - 728x90

wpa_cli saves network configurations in an invalid format when attempting to write to the configuration file

0 votes
0 answers
27 views
I’m trying to manage my wireless LAN interface using wpa_supplicant on my i.MX8 running Yocto Scarthgap. I can scan for available networks and connect successfully using the wpa_cli utility. However, when I try to save the current network configuration to the .conf file to persist it, wpa_supplicant fails to start on reboot due to an incorrect file format. Steps I followed before reboot to connect to an AP
> add_network
0
CTRL-EVENT-NETWORK-ADDED 0

> > set_network 0 ssid "MyNetwork"
OK
> set_network 0 psk "MyPassPhrase"
OK
> enable_network 0
OK
CTRL-EVENT-SCAN-STARTED 
CTRL-EVENT-SCAN-RESULTS 
Trying to associate with SSID 'MyNetwork'
.....
CTRL-EVENT-CONNECTED - Connection to xxxxxx completed [id=0 id_str=]

> > save_config
OK
> quit
This is what my .conf file in /etc/wpa_supplicant/wpa_supplicant-wlan0.conf looks like after I run save_config .
ctrl_interface=/run/wpa_supplicant
ctrl_interface_group=wheel
update_config=1
filter_ssids=1
ignore_old_scan_res=1

network={
	ssid="MyNetwork"
	psk=*
}
On reboot systemd failed to start wpa_supplicant service
root@imx8qxp:~# journalctl -xe -u wpa_supplicant@wlan0.service 
Jul 09 16:03:46 imx8qxp systemd: Started WPA supplicant daemon (interface-specific version). 
-- Subject: A start job for unit wpa_supplicant@wlan0.service has finished successfully 
-- Defined-By: systemd 
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel  
--  
-- A start job for unit wpa_supplicant@wlan0.service has finished successfully. 
--  
-- The job identifier is 100. 
Jul 09 16:03:46 imx8qxp systemd: wpa_supplicant@wlan0.service: Main process exited, code=exited, status=255/EXCEPTION 
-- Subject: Unit process exited 
-- Defined-By: systemd 
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel  
--  
-- An ExecStart= process belonging to unit wpa_supplicant@wlan0.service has exited. --  -- The process' exit code is 'exited' and its exit status is 255. 
Jul 09 16:03:46 imx8qxp systemd: wpa_supplicant@wlan0.service: Failed with result 'exit-code'. -- Subject: Unit failed 
-- Defined-By: systemd 
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel  
--  
-- The unit wpa_supplicant@wlan0.service has entered the 'failed' state with result 'exit-code'.
On further investigation by trying to start wpa_supplicant manually
root@imx8qxp:~# wpa_supplicant -B -dd -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
Line 9: Invalid PSK '*'.
Line 9: failed to parse psk '*'.
Line 10: failed to parse network block.
Failed to read or parse configuration '/etc/wpa_supplicant/wpa_supplicant-wlan0.conf'.
I did try to manually generate the passphrase using the command wpa_passphrase SSID PASSWORD > /etc/wpa_supplicant/wpa_supplicant-wlan0.conf and there were no issues with it after reboot. I get this error only when trying to save network config from wpa_cli. I also tried recreating it on an ubuntu 24 machine but could not successfully reproduce the issue. While the obvious solution is to use wpa_passphrase directly, I'm interested in understanding why this issue occurs in the first place. Despite searching online, I haven’t come across anyone experiencing this exact problem. Could it be that I’m missing a step when saving the network configuration using wpa_cli? What causes this behaviour, and is there a correct way to persist network settings without manually trying to write to the file? I don't prefer using the wpa_passphrase command because I ultimately want to use wpa_ctrl C APIs and would not prefer messing with the .conf files in the application layer.
Asked by Meghana (1 rep)
Aug 1, 2025, 09:11 AM
Last activity: Aug 1, 2025, 09:22 AM