mainsail-crew / MainsailOS

This Raspberry Pi distribution for managing Klipper 3D printers with Mainsail provides all you need.
https://docs.mainsail.xyz/setup/mainsail-os
GNU General Public License v3.0
554 stars 273 forks source link

Changing Wifi network not possible #134

Closed MaikelKelder closed 2 years ago

MaikelKelder commented 2 years ago

What happened

After the initial setup and filled in Wifi SSID and password, logon is succesful after the installation. Yet, changing to another WiFI SSID doesnt seem to work, not by file edit, not by klipperscreen.

By klipperscreen you see that he initiates Wifi, but it will never connect to new network.

What did you expect to happen

Joining other WIfi network after entering SSID and password, manual file edit, OR by klipperscreen.

How to reproduce

Change Wifi by file editting or klipperscreen.

Additional information

I dont have expertise in Mainsail, yet found this to possible bug, I hope to help in this way and that my foundings are correct.

KwadFan commented 2 years ago

Hey, we try to reproduce that this weekend.

Did you flash the Image with rpi-imager and set wifi credentials on setup?

MaikelKelder commented 2 years ago

Imaged with balenaetcher. Configured the WiFi with a file edit. WiFi works after setup in pi.

On Sat, 13 Aug 2022 at 10:46, Stephan Wendel @.***> wrote:

Hey, we try to reproduce that this weekend.

Did you flash the Image with rpi-imager and set wifi credentials on setup?

— Reply to this email directly, view it on GitHub https://github.com/mainsail-crew/MainsailOS/issues/134#issuecomment-1214027049, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJAM5W73AU7OQSVQN3X4UL3VY5OFBANCNFSM554LSCKQ . You are receiving this because you authored the thread.Message ID: @.***>

KwadFan commented 2 years ago

So, after flash you edited the mainsailos-wpa-supplicant.txt and it doesnt work. What do you mean by "WiFi works after setup in pi." exactly? I have to reproduce the steps as nearly I could, so I need an exact description what you have done.

What editor was used to edit the file?

Regards

MaikelKelder commented 2 years ago

After creating the image on the sd, and editing the file as you describe, you put it in the raspberry first time and WiFi works.

It’s when you try to change it after this, it doesn’t work, edited with notepad++ and normal notepad (Windows).

Also tried to change it from klipperscreen, where you choose a WiFi from the gui, that also fails.

Hope this makes sense to reproduce.

M. On Sat, 13 Aug 2022 at 12:39, Stephan Wendel @.***> wrote:

So, after flash you edited the mainsailos-wpa-supplicant.txt and it doesnt work. What do you mean by "WiFi works after setup in pi." exactly? I have to reproduce the steps as nearly I could, so I need an exact description what you have done.

What editor was used to edit the file?

Regards

— Reply to this email directly, view it on GitHub https://github.com/mainsail-crew/MainsailOS/issues/134#issuecomment-1214135667, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJAM5W4622BEZWQRBT2NHQ3VY53OXANCNFSM554LSCKQ . You are receiving this because you authored the thread.Message ID: @.***>

KwadFan commented 2 years ago

To my sadness we can confirm it, but I need some time to investigate the root cause.

I will provide a solution as soon it is fixed for existing installations.

Sorry for the hazzle.

MaikelKelder commented 2 years ago

No hassle at all, I appreciate the effort put into it to find it and trying to solve it, respect all the way!

On Sat, 13 Aug 2022 at 18:03, Stephan Wendel @.***> wrote:

To my sadness we can confirm it, but I need some time to investigate the root cause.

I will provide a solution as soon it is fixed for existing installations.

Sorry for the hazzle.

— Reply to this email directly, view it on GitHub https://github.com/mainsail-crew/MainsailOS/issues/134#issuecomment-1214181871, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJAM5W2C2BQX4EXG5OC7AJTVY7BLTANCNFSM554LSCKQ . You are receiving this because you authored the thread.Message ID: @.***>

KwadFan commented 2 years ago

I did some investigation, In rpi-imager the softlink that points to the mainsailos-wpa-supplicant.txt, which is created by CustomPIOS ( the framework used to manipulate the base image) gets overwritten and does not work as intended anymore.

I have to do a test with balena also.

At this poitn I have no clue how to solve that easily but will provide a solution asap.

KwadFan commented 2 years ago

Hey @MaikelKelder,

It seems thats not our fault. I found the following in the Raspberry PI OS docs. You will need to define a wpa_supplicant.conf file for your particular wireless network. Put this file onto the boot folder of the SD card. When the Raspberry Pi boots for the first time, it will copy that file into the correct location in the Linux root file system and use those settings to start up wireless networking.

https://www.raspberrypi.com/documentation/computers/configuration.html#configuring-networking-2

I think they internally changed the behavior that leads to a behavior that CustomPIOS try to change with its "network module" This changes from a real file "wpa_supplicant.conf" to a symlink to /boot/mainsail-wpa-supplicant.txt.

But this symlink gets overwritten if you try to change WiFi Settings with raspi-config and maybe ( I cant confirm that ) by KlipperScreen. Also it will be overwritten if you use rpi-imager to setup your WiFi and brake the existing symlink to the known txt file.

This is reproducable because normally it changes your clear text password in the txt file in /boot to an psk hash, but that dont happen either.

Could you maybe confirm that a wpa_supplicant.conf in boot do work?

Regards

MaikelKelder commented 2 years ago

I can try this in a few days probably, dont have a printer to test it on right now, but building a new Voron 2.4 at this moment. If thats ok, I will give this method a try.

Great find, didnt know something changed in the PI OS.

Maikel.

On Sun, 14 Aug 2022 at 19:44, Stephan Wendel @.***> wrote:

Hey @MaikelKelder https://github.com/MaikelKelder,

It seems thats not our fault. I found the following in the Raspberry PI OS docs. You will need to define a wpa_supplicant.conf file for your particular wireless network. Put this file onto the boot folder of the SD card. When the Raspberry Pi boots for the first time, it will copy that file into the correct location in the Linux root file system and use those settings to start up wireless networking.

https://www.raspberrypi.com/documentation/computers/configuration.html#configuring-networking-2

I think they internally changed the behavior that leads to a behavior that CustomPIOS try to change with its "network module" This changes from a real file "wpa_supplicant.conf" to a symlink to /boot/mainsail-wpa-supplicant.txt.

But this symlink gets overwritten if you try to change WiFi Settings with raspi-config and maybe ( I cant confirm that ) by KlipperScreen. Also it will be overwritten if you use rpi-imager to setup your WiFi and brake the existing symlink to the known txt file.

This is reproducable because normally it changes your clear text password in the txt file in /boot to an psk hash, but that dont happen either.

Could you maybe confirm that a wpa_supplicant.conf in boot do work?

Regards

— Reply to this email directly, view it on GitHub https://github.com/mainsail-crew/MainsailOS/issues/134#issuecomment-1214421301, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJAM5WZHEQFZJBRQ6VJICILVZEV63ANCNFSM554LSCKQ . You are receiving this because you were mentioned.Message ID: @.***>

KwadFan commented 2 years ago

After some further digging it turns out that wpa_cli is the guilty one. KlipperScreen uses wpa_cli to set WiFi settings, however wpa_cli overrides our softlink to /boot/mainsail-wpa-supplicant.txt.

I am working on a solution, but I think it will end up in making an example file and you have to put a wpa_supplicant.conf to /boot.

This is the mentioned way of Raspberry Foundation.