Or perhaps related. According to the bug report at https://github.com/raspberrypi/rpi-imag ... 2964188448Just coincidence.
Code:
After creating an image for the Zero 2 W, I noticed something in the firstrun.sh script on line 42`if [ -f /usr/lib/raspberrypi-sys-mods/imager_custom ]; then/usr/lib/raspberrypi-sys-mods/imager_custom set_wlan 'somessid' 'randomstring' 'US'`There is a newline after country code. Removing this new line allowed my PIs to connect on first startup.- escapeshellarg(generalTab.fieldWifiCountry.editText)
Given 'escapeshellarg' did not add an erroneous new line to the 'somessid' item it may be that the newline was part of the country code value, or maybe because it is retrieved via '.editText' rather than '.text' ?
Should be easy enough to test by adding whatever the equivalent of this would be in the '.qml' file -
Code:
print("Debug generalTab.fieldWifiCountry")print("via .text >>>" + generalTab.fieldWifiCountry.text + "<<<")print("via .editText >>>" + generalTab.fieldWifiCountry.editText + "<<<")Code:
Debug generalTab.fieldWifiCountryvia .text >>>US<<<via .editText >>>US<<<So it comes down to being a standard debugging exercise. I would probably jump straight to a pragmatic resolution, apply defensive coding practices, ensure 'escapeshellarg' strips out newlines, CR, LF and anything else not allowed.
I would note that the erroneous newlines are within the single-quotes which 'escapeshellarg' adds.And in that case there must be some other explanation. Maybe my mis-direction might at least get RP Devs to acknowledge the Issue.
Or maybe they are correct and having gratuitous NewLine characters in firstrun.sh is not service-affecting? Again, just coincidence that removing those NL bytes restores expected behaviour?
And generating a command line with an erroneous newline would seem to me to create something which would require its removal to make it work. But if it's one of those commands which Linux adds a further prompt for when input is incomplete I guess it could still be an acceptable command.
The question then would be what the command actually sees. If it sees 'US\n' rather than 'US' then it might not match that with its known list, may not do anything at all, with the result that wireless doesn't get configured.
Code:
pi@Pi4B:/tmp $ ./cli-test.py 'UK'Len = 2 | 55 4B | UKpi@Pi4B:/tmp $Code:
pi@Pi4B:/tmp $ ./cli-test.py 'UK> 'Len = 3 | 55 4B 0A | UKpi@Pi4B:/tmp $If country code is an editable field it may be some have selected that with no intent to edit it, then pressed return as some sort of "OK" for the whole lot, and that return has found its way into country code as a terminating new line, which then gets passed onwards.
Note : This commentary only relates to the erroneous newline issue. There may be more than that which causes the first run to not work as expected which I haven't even considered.
Statistics: Posted by hippy — Fri Jul 11, 2025 2:41 pm