This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430F5659: Python Firmware Upgrader Setup Fails

Part Number: MSP430F5659

OS: Windows 10
Python Version: 3.11.2

Steps to reproduce:

1. Download and unzip Python_Firmware_Upgrader-5_20_07_01.zip.

2. Follow Installation instructions in release_Notes_Example_Python_Firmware_Upgrader.html

Observed Behaviour:

Installation fails at the python distribute step.  Errors generated:

c:\distribute-0.7.3>python setup.py install
Traceback (most recent call last):
  File "c:\distribute-0.7.3\setup.py", line 8, in <module>
    import setuptools
  File "c:\distribute-0.7.3\setuptools\__init__.py", line 2, in <module>
    from setuptools.extension import Extension, Library
  File "c:\distribute-0.7.3\setuptools\extension.py", line 5, in <module>
    from setuptools.dist import _get_unpatched
  File "c:\distribute-0.7.3\setuptools\dist.py", line 7, in <module>
    from setuptools.command.install import install
  File "c:\distribute-0.7.3\setuptools\command\__init__.py", line 8, in <module>
    from setuptools.command import install_scripts
  File "c:\distribute-0.7.3\setuptools\command\install_scripts.py", line 3, in <module>
    from pkg_resources import Distribution, PathMetadata, ensure_directory
  File "c:\distribute-0.7.3\pkg_resources.py", line 1518, in <module>
    register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'

c:\distribute-0.7.3>

Additional information:  I tried to skip past the distribute step and I was able to successfully install pwinusb.  However, when I then attempt to run the gui with the recommended command, "set PYTHONPATH=.\python-msp430-tools& python TargetGUI.py", I get the following error:

c:\Python_Firmware_Upgrader>set PYTHONPATH=.\python-msp430-tools& python TargetGUI.py
  File "c:\Python_Firmware_Upgrader\TargetGUI.py", line 125
    self.logger.addHandler(self.myHandler)
TabError: inconsistent use of tabs and spaces in indentation

c:\Python_Firmware_Upgrader>

Expected behaviour:  Installation completes.

Update:  I was able to fix the syntax error in TargetGUI.py by replacing the hard tab at line 125 with enough spaces to line up with the previous line.  However, when I ran the command again, I got a different error:

set PYTHONPATH=.\python-msp430-tools& python TargetGUI.py
Traceback (most recent call last):
  File "C:\Python_Firmware_Upgrader\TargetGUI.py", line 45, in <module>
    import tkMessageBox
ModuleNotFoundError: No module named 'tkMessageBox'

C:\Python_Firmware_Upgrader>

So, still no joy.

Update 2: I tried the command-line method as well and got back the following errors:

C:\Python_Firmware_Upgrader>set PYTHONPATH=.\python-msp430-tools& python -m msp430.bsl5.hid_1 -e -v -P ./blinky5659.txt
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Python_Firmware_Upgrader\python-msp430-tools\msp430\bsl5\hid_1.py", line 11, in <module>
    import ttk
ModuleNotFoundError: No module named 'ttk'

C:\Python_Firmware_Upgrader>

  • How about to double click the exe file Python_Firmware_UpgraderGUI.exe?

  • Yes, of course I know how to double-click on the GUI but that doesn't get me what I want.

    I want to control what is being programmed and the GUI doesn't seem to have any options.  For example, I want to be able to change the BSL password but the GUI doesn't have that option.  I want to be able to send a hex file that modifies the Information Memory but the GUI doesn't seem to allow that either.  If I want to erase the information memory before programming the application, the GUI doesn't have that option.   I want to extract the memory and save it but the GUI doesn't have that feature either.

    All the GUI does is load the application main flash memory.  That's it.  Nothing else.  If the hex file includes the information memory, it doesn't end up in the target.  The GUI is really just a demo - not very useful for real life.

    What I want to do is change the default behaviour so that the tool is useful.

    I have no idea how the GUI actually works under the hood.   Is it just a shell that somehow calls the lower level python scripts or is it actually a compiled binary?  That's not obvious.  If it is the latter, I assume that there is some utility that converts the python to a windows binary but I can't find it elsewhere.  So, I tried following the instructions in the included documentation in hopes I could get something that I could actually use.

  • You can use the BSL scripter that will support specific commend modification 

    www.ti.com/.../slau655g.pdf

  • BSL Scripter is an alternative tool.  I will look into the tool in due course.  If I find problems with that tool, I will open a separate question about that tool.

    I will not mark this question as resolved because the problems described in the original question still exist.

  • Hi Allan,

    One think I want to clarify is how do you get those errors? Do you want to execute the source code directly? Or just with the .exe file?

    If you use the exe file, make sure you trigger the device into USB BSL first and it will detected by the PC and then you can rescan it by the GUI and download the firmware. 

  • The errors I described in my original posting do not occur with the windows exe file. 

    I wanted to excute the python scripts in order to observe and modify behaviour, add or change features, etc.

    I know how to use the exe file - I can successfully program flash image with it. That is NOT what this topic is about.

  • Ok, for your using case, the python-msp430-tools is correct resources.

    One thing you should take care is that the software above is developed based on python 2 that is not compatible with python 3. 

    Recommend you to install the python 2.6 to run the code.

**Attention** This is a public forum