pyocd / pyOCD

Open source Python library for programming and debugging Arm Cortex-M microcontrollers
https://pyocd.io
Apache License 2.0
1.13k stars 484 forks source link

Pyocd and Pyinstaller problem. #1733

Open fabio-ric-silva opened 3 weeks ago

fabio-ric-silva commented 3 weeks ago

Solved!! The issue already was put below! Thank you so much!

Hello, there! I hope you all are doing great!

Dears.

I have created a simple graphical interface for selecting the hex file to be written to the target. In this app, it has a button for testing if the CMSIS-DAP interface is present on the system.

If I execute the script from the python 3.13 (or whatever version) on the system (W10), it works very fine! But when creating a *.exe from pyinstaller, the app is executed but doesn't find the CMSIS-DAP interface!

I have done hundreds of attempts including --hidden-imports, but, none worked!

Someone had the same problem and could find a solution?

Thanks in advance!

sudoQF commented 3 weeks ago

Hello fabio-ric-silva, I encountered the same issue while working with python 3.10. To be able to do an executable with pyocd inside you need to manually collect entry point pyocd.probe and collect dynamic libs capstone an also collect some package paths: datas_probe, hiddenimports_probe = collect_entry_point('pyocd.probe') capstone_libs = collect_dynamic_libs("capstone") pyocd_path = get_package_paths('pyocd')[1] cmsis_path = get_package_paths('cmsis_pack_manager')[1]

added_files = [(pyocd_path, 'pyocd/.'), (cmsis_path, 'cmsis_pack_manager/.')] + datas_probe hiddenimports = hiddenimports_probe binaries = capstone_libs

And then when creating the Analysis class: binaries=binaries, datas=added_files, hiddenimports=hiddenimports,

Hope it helps!

fabio-ric-silva commented 3 weeks ago

Thank you for your attention! I will study very well your code for a better understanding!

Sincerely;