[esptool] How to add the stub_flasher json files with pyinstaller on MacOS

PaulZC
Posts: 4
Joined: Thu Jan 04, 2024 11:52 am

[esptool] How to add the stub_flasher json files with pyinstaller on MacOS

Postby PaulZC » Thu Jan 04, 2024 12:24 pm

Hi,

We have written a PyQt5 GUI which uses esptool to upload firmware binaries onto ESP32: https://github.com/sparkfun/SparkFun_RT ... e_Uploader

I am updating it to use esptool 4.7.0: https://github.com/sparkfun/SparkFun_RT ... ree/v1.6.0 . It took me a while to work out that I needed to include the targets/stub_flasher json files for it to work correctly. I now have it working correctly on Windows and Linux. But I can not get it working on MacOS.

I am using GitHub Actions and pyinstaller to build the executables. I am using pip install esptool to install esptool before I call pyinstaller.

On Windows, here is where I add the json files and create the executable: https://github.com/sparkfun/SparkFun_RT ... ml#L42-L46

On Linux: https://github.com/sparkfun/SparkFun_RT ... ml#L41-L43

On MacOS, I do the same thing: https://github.com/sparkfun/SparkFun_RT ... ml#L42-L47

The GUI installs and runs OK on MacOS, but the esptool upload fails because it can not find the stub_flasher json file. The json files are copied into Contents/Resources (Contents/Resources/esptool/targets/stub_flasher). But the executable is in Contents/MacOS and it can not find the json files.

I tried copying the json files into Contents/MacOS (Contents/MacOS/esptool/targets/stub_flasher). But the executable was then "illegal" and would not run - I think because the json files are not signed?

I hope someone can tell me how to add the json files correctly on MacOS.

Thank you,
Paul

User avatar
ESP_Roland
Posts: 242
Joined: Tue Oct 09, 2018 10:28 am

Re: [esptool] How to add the stub_flasher json files with pyinstaller on MacOS

Postby ESP_Roland » Thu Jan 04, 2024 2:47 pm

This is how we do it for all platforms: https://github.com/espressif/esptool/bl ... ol.yml#L53

PaulZC
Posts: 4
Joined: Thu Jan 04, 2024 11:52 am

Re: [esptool] How to add the stub_flasher json files with pyinstaller on MacOS

Postby PaulZC » Thu Jan 04, 2024 4:43 pm

Hi ESP_Roland,

Yes, thanks, I'd seen that. Except there you are creating a onefile (-F) executable. I'm using onefile on Windows and Linux, but for MacOS I'm using --windowed , not --onefile. This is for historical reasons - I've run into issues before creating a PyQt5 GUI for MacOS where the only way to get it to work was to use --windowed, --onefile failed.

Please let me know if you've seen this issue before or have any other suggestions - thanks!

Best,
Paul

PaulZC
Posts: 4
Joined: Thu Jan 04, 2024 11:52 am

Re: [esptool] How to add the stub_flasher json files with pyinstaller on MacOS

Postby PaulZC » Fri Jan 05, 2024 7:24 pm

I like your trick of changing STUBS_DIR in esptool_test_stub.py: https://github.com/espressif/esptool/bl ... py#L24-L28

I tried to use the same trick, but still no joy... I've checked STUBS_DIR contains the correct path. I suspect the exec isn't working as intended? https://github.com/sparkfun/SparkFun_RT ... .py#L3-L19

PaulZC
Posts: 4
Joined: Thu Jan 04, 2024 11:52 am

Re: [esptool] How to add the stub_flasher json files with pyinstaller on MacOS

Postby PaulZC » Sat Jan 06, 2024 10:35 am

Well... Don't I feel stupid...!

Turns out this was a baud rate issue. I was trying to do the upload at 921600. That fails on my Mac Mini. As soon as I dropped to 460800 everything started working... In my defence, the fail looked exactly the same as when esptool couldn't find the json file.

OK. I'm off and running.

Many thanks ESP_Roland, all the best.

Who is online

Users browsing this forum: No registered users and 176 guests