STM32_gen_PeripheralPins.py is broken in MbedOS 6.6

I can’t make the script provided with MbedOS 6.6.0 work while the one provided by mbedOS 6.1.0 works.

  • MbedOS 6.6.0
  • Windows 10 20H2 64 bits
  • Python 2.7.14
  • option -m STM32 (as recommended by -h)

C:\Users\lluis\Downloads\mbed-os-mbed-os-6.6.0\mbed-os-mbed-os-6.6.0\targets\TARGET_STM\tools>python.exe STM32_gen_PeripheralPins.py -m STM32

Script version 1.19

Checking STM32_open_pin_data repo...
*** git clone done

STM32_open_pin_data DB version STM32CubeMX-DB.6.0.10

 * Output directory: C:\Users\lluis\Downloads\mbed-os-mbed-os-6.6.0\mbed-os-mbed-os-6.6.0\targets\TARGET_STM\tools\targets_custom\TARGET_STM\TARGET_STM32F0\TARGET_STM32F030x6\TARGET_STM32F030C6T
 * Generating PeripheralPins.c and PinNames.h with 'STM32_open_pin_data\mcu\STM32F030C6Tx.xml'
 * GPIO file: STM32_open_pin_data\mcu\IP\GPIO-STM32F031_gpio_v1_0_Modes.xml
Traceback (most recent call last):
  File "STM32_gen_PeripheralPins.py", line 1855, in <module>
    parse_pins()
  File "STM32_gen_PeripheralPins.py", line 1343, in parse_pins
    if "Variant" in s.attributes:
  File "C:\Python27\lib\xml\dom\minidom.py", line 522, in __getitem__
    return self._attrs[attname_or_tuple]
KeyError: 0

Hi
I am sorry, I am verifying script with only python 3…
If you find a way to keep both python version compatibility, I will be happy to review the pull request!
Thx

Python 2.7.14 has been released in sept. 2017. Python 2 has been deprecated since January 1st 2020.

It is highly encouraged to upgrade to Python 3, with which the script will work out of the box.

Fair enough! I normally don’t use python so I was using the one that was installed by Mbed CLI.

I’ve just installed python 3.9 and it works :slight_smile:

Thanks!

Thanks

Glad you did! :slight_smile: