Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firmware updater fails on OSX Monterey #10

Open
Numero7 opened this issue Nov 14, 2021 · 12 comments
Open

Firmware updater fails on OSX Monterey #10

Numero7 opened this issue Nov 14, 2021 · 12 comments

Comments

@Numero7
Copy link

Numero7 commented Nov 14, 2021

I have trouble running the artemis_firmware_uploader_gui under MacOSX Monterey.

The following steps occur each time I try to launch the updater. The icon for the "artemis_firmware_uploader_gui" takes a few seconds to appear in the dock, no window shows up, the application uses 100% of a CPU and is non-responsive, the only option left is "force to quit".

@PaulZC
Copy link
Contributor

PaulZC commented Nov 15, 2021

Hi Hugo (@Numero7 ),

Thank you for raising this issue. I will ask my colleagues if they can recompile the executable for Monterey - I do not have a Mac!

Very best wishes,
Paul

@adamgarbo
Copy link

Hi @Numero7,

Thanks for reporting this issue. I went to update my OpenLog Artemis tonight and realized something was up. I can also confirm that the uploaded doesn't work on macOS Monterey (12.0.1) or Big Sur (11.6). I suspect recompiling for Monterey will also enable it to work on Big Sur.

Cheers,
Adam

@PaulZC
Copy link
Contributor

PaulZC commented Nov 26, 2021

Hi @Numero7 / @adamgarbo ,

We are working on this - but it is a resources issue... Very few of us have Macs!

If either of you are able to build the executable and send us a Pull Request, we'd appreciate it very much.

Best wishes,
Paul

@adamgarbo
Copy link

adamgarbo commented Nov 26, 2021

Hi @PaulZC,

I was able to get things working by running the Python code directly:

python3 artemis_firmware_uploader_gui.py

I'm currently trying to build a new executable but am running into some issues with PyQt5. Will try to get it sorted and submit a PR!

Cheers,
Adam

@adamgarbo
Copy link

Sorry, folks!

I tried using the same command @oclyke used to build the previous executable:
pyinstaller --onefile --noconsole --distpath=. --icon=artemis_firmware_uploader_gui.ico --add-data="artemis_svl.bin:." --add-data="Artemis-Logo-Rounded.png:." artemis_firmware_uploader_gui.py

But I can't seem to get past the following error:

~ % /Users/adam/Documents/GitHub/Artemis-Firmware-Upload-GUI/tools/artemis_firmware_uploader_gui ; exit; qt.qpa.plugin: Could not find the Qt platform plugin "cocoa" in "" This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

I'm unsure if this is related to my Python environments, or changes in Big Sur/Monterey. I can manually run the Python code using Conda but just can't seem to build a new executable.

Cheers,
Adam

@adamgarbo
Copy link

By the way, I've included the workflow I used in macOS below. After creating a new Conda environment, there are only a few libraries required to run the Python code directly and attempt to build a new executable.

conda create --name sparkfun
conda activate sparkfun
conda install pyserial
conda install pyqt 
conda install pycryptodome 
conda install pyinstaller

Once the above libraries are installed, the Python code works and quickly launches the GUI. Attempting to use pyinstaller to build a new executable results in a 39.5 MB file, but attempting to double click the artemis_firmware_uploader_gui file results in the same program hang as before. I believe the previous Qt-related error I was getting is due to other conflicts. A new clean Python environment doesn't yield the same error.

Cheers,
Adam

@PaulZC
Copy link
Contributor

PaulZC commented Nov 29, 2021

Many thanks for giving this a try Adam - we really appreciate it.

All the best,
Paul

@adamgarbo
Copy link

adamgarbo commented Nov 29, 2021

Upon further investigation, this looks to be related to an issue with PyInstaller (pyinstaller/pyinstaller#5107), but also ultimately due to the fact that Apple changed the way it handles dynamic libraries:

https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11_0_1-release-notes

New in macOS Big Sur 11.0.1, the system ships with a built-in dynamic linker cache of all system-provided libraries. As part of this change, copies of dynamic libraries are no longer present on the filesystem. Code that attempts to check for dynamic library presence by looking for a file at a path or enumerating a directory will fail. Instead, check for library presence by attempting to dlopen() the path, which will correctly check for the library in the cache. (62986286)

The solution appears to be to use dlopen() but I suspect this is more trouble than it's worth. It may be easier just to advise users to run the GUI manually using Python commands.

Cheers,
Adam

@ghost
Copy link

ghost commented Aug 25, 2022

More information on this:

On macOS, a terminal command executable will not have an event loop/windowing system. To be a windowed/GUI application, you need to be an “Application”.

You get this with pyinstaller by adding “—windowed” switch to the command line, and removing the “–onefile” switch from the command (I was using the Linux command line included in the comments of the source python file.

This is the full command that works:

pyinstaller --windowed -n ArtemisFirmwareUploader --noconsole --distpath=. --icon=artemis_firmware_uploader_gui.ico --add-data="artemis_svl.bin:." --add-data="Artemis-Logo-Rounded.png:." artemis_firmware_uploader_gui.py

Note, this also named the output “ArtemisFirmwareUploader”, which is the mac app naming pattern.

Running this command creates a folder called “ArtemisFirmwareUploader.app]" – which is a mac application (it’s how mac apps work if you were not aware). Double clicking this directory from Finder (Mac GUI), the uploader app starts right up.

From there, you can package up this app into a disk image fiile (.dmg) and it's ready for install/use on macOS.

Once we figure out logistics, we'll get the app packaged and uploaded.

-Kirk

@PaulZC
Copy link
Contributor

PaulZC commented Mar 5, 2023

Hi @Numero7 @adamgarbo ,

I finally found time to publish the new version of the GUI - based on @kirk-sfe 's refactored version. The executables are now compiled using GitHub Actions and are automatically attached to each new release.

Can you please give v3.0.0 a try and let me know what you find?

https://github.com/sparkfun/Artemis-Firmware-Upload-GUI/releases

Sincere thanks,
Paul

@adamgarbo
Copy link

Hi @PaulZC,

Thanks for the update.

I can confirm the .dmg file successfully installed and opened on macOS Ventura 13.2.1. I haven't tested uploading firmware yet but that was never the issue.

Cheers,
Adam

@ghost
Copy link

ghost commented Mar 6, 2023

Hi @adamgarbo ,

If there are any issues let us know. With the core of this cross platform build process/uploader in place, we want to keep this in solid working order going forward. We expect that issues should be relatively easy to fix at this point.

Cheers,
-Kirk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants