damogranlabs / VS-Code-STM32-IDE

Use VS Code as STM32 IDE with CubeMX
MIT License
247 stars 52 forks source link

IndexError: list index out of range #40

Open jaygitdev opened 4 years ago

jaygitdev commented 4 years ago

Hello! I ran into an issue when following your guide. Full disclosure, I used an existing project that had a file that is kept in the debug folder rather than the root folder (as your update file expected). My solution was to move the makefile to the root directory (which could cause issues with the links if it's looking for paths relative to another folder).

What's the best way to handle this? Do I need to adjust the makefile to make all the paths relative to the root folder? Is there a way to have STM32CubeIde output a makefile in the root directory from an existing project? Is there a way to change an ideScript file to change where it's looking for the makefile? And if so, would it be possible to have the script file ask the location of the makefile?

Below is the output I received:

C:\STM32 projects\TESTPROJECT\TESTPROJECT>C:/Users/jaybee/.platformio/python37/python.exe "c:/STM32 projects/TESTPROJECT/TESTPROJECT/ideScripts/update.py"
Update started.

Existing '.vscode' folder used.
One STM32CubeMX file found: TESTPROJECT.ioc
Existing 'Makefile' file will be restored from 'Makefile.backup'.
Copy of file (new name: Makefile): c:/STM32 projects/TESTPROJECT/TESTPROJECT/Makefile.backup
Makefile 'print-variable' function added.
Valid 'buildData.json' file found.

        Default path to 'arm-none-eabi-gcc executable (arm-none-eabi-gcc.exe)' detected at 'C:\Program Files (x86)\GNU Arm Embedded Toolchain\9 2020-q2-update\bin\arm-none-eabi-gcc.EXE'
        Use this path? [y/n]: n

        Enter path or command for 'arm-none-eabi-gcc executable (arm-none-eabi-gcc.exe)':
        Paste here and press Enter: C:\Users\jaybee\AppData\Roaming\GNU MCU Eclipse\ARM Embedded GCC\bin\arm-none-eabi-gcc.exe

        Default path to 'make executable (make.exe)' detected at 'C:\MinGW\bin\make.EXE'
        Use this path? [y/n]: C:\Users\jaybee\AppData\Roaming\GNU MCU Eclipse\Build Tools\2.12-20190422-1053\bin\"C:\Users\jaybee\AppData\Roaming\GNU MCU Eclipse\Build Tools\2.12-20190422-1053\bin\make.exe

        Default path to 'make executable (make.exe)' detected at 'C:\MinGW\bin\make.EXE'
        Use this path? [y/n]: n

        Enter path or command for 'make executable (make.exe)':
        Paste here and press Enter: C:\Users\jaybee\AppData\Roaming\GNU MCU Eclipse\Build Tools\2.12-20190422-1053\bin\"C:\Users\jaybee\AppData\Roaming\GNU MCU Eclipse\Build Tools\2.12-20190422-1053\bin\make.exe
        Path/command not valid:  C:/Users/jaybee/AppData/Roaming/GNU MCU Eclipse/Build Tools/2.12-20190422-1053/bin/C:/Users/jaybee/AppData/Roaming/GNU MCU Eclipse/Build Tools/2.12-20190422-1053/bin/make.exe

        Enter path or command for 'make executable (make.exe)':
        Paste here and press Enter: C:\Users\jaybee\AppData\Roaming\GNU MCU Eclipse\Build Tools\2.12-20190422-1053\bin\"C:\Users\jaybee\AppData\Roaming\GNU MCU Eclipse\Build Tools\2.12-20190422-1053\bin\make.exe
        Path/command not valid:  C:/Users/jaybee/AppData/Roaming/GNU MCU Eclipse/Build Tools/2.12-20190422-1053/bin/C:/Users/jaybee/AppData/Roaming/GNU MCU Eclipse/Build Tools/2.12-20190422-1053/bin/make.exe

        Enter path or command for 'make executable (make.exe)':
        Paste here and press Enter: C:\Users\jaybee\AppData\Roaming\GNU MCU Eclipse\Build Tools\2.12-20190422-1053\bin\make.exe

        Enter path or command for 'OpenOCD executable (openocd.exe)':
        Paste here and press Enter: C:\Users\jaybee\AppData\Roaming\GNU MCU Eclipse\OpenOCD\0.10.0-12-20190422-2015\bin\openocd.exe

        Enter path or command for 'OpenOCD ST Link interface path ('stlink.cfg')':
        Paste here and press Enter: C:\Users\jaybee\AppData\Roaming\GNU MCU Eclipse\OpenOCD\0.10.0-12-20190422-2015\scripts\target\stm32w108_stlink.cfg

        Python version 3 or later installation not detected, please install or enter custom path/command below.

        Enter path or command for 'python':
        Paste here and press Enter: C:\Users\jaybee\AppData\Local\Programs\Python\Python38-32\python.exe
'toolsPaths.json' file updated!

        Enter path(s) to OpenOCD configuration file(s):
                Example: 'target/stm32f0x.cfg'. Absolute or relative to OpenOCD /scripts/ folder.
                If more than one file is needed, separate with comma.
                Paste here and press Enter: C:\Users\jaybee\AppData\Roaming\GNU MCU Eclipse\OpenOCD\0.10.0-12-20190422-2015\scripts\target\stm32w108xx.cfg

        Enter path or command for 'stm32SvdPath':
        Paste here and press Enter: C:\Users\jaybee\AppData\Roaming\GNU MCU Eclipse\Keil.STM32WBxx_DFP.1.1.0\CMSIS\SVD\STM32WB55_CM4.svd

ERROR (634 seconds).
Unexpected error occured during 'Update' procedure. Exception:
Traceback (most recent call last):
  File "c:/STM32 projects/TESTPROJECT/TESTPROJECT/ideScripts/update.py", line 56, in <module>
    makefileData = makefile.getMakefileData(makeExePath, gccExePath)
  File "c:\STM32 projects\TESTPROJECT\TESTPROJECT\ideScripts\updateMakefile.py", line 109, in getMakefileData
    projectName = self.getMakefileVariable(makeExePath, gccExePath, self.mkfStr.projectName)[0]
IndexError: list index out of range

C:\STM32 projects\TESTPROJECT\TESTPROJECT>

Thanks!

schperplata commented 4 years ago

These scripts were meant to be used with default CubeMX outputs and file locations. This means that Makefile is expected to be located at the root of the directory, as normally generated by CubeMX. Although it would be possible to ask user whre Makefile is located, I assume this would cause a lot of problems (as you mentioned). But hey, you can simply try it out! Set BP at ideScripts\utilities.py:192 and override makefilePath variable with your custom location using debug panel.

Anyway, at the time this project was my main IDE, CubeMX had virtually no settings for Makefile. In fact, I had a lot of troubles when I was modifying source list in VS Code, while regenerating project in CubeMX. Seems like Cube MX internally cache makefile data and must be re-opened to acknowledge Makefile file changes by VS Code. That was one of the main reasons for me to move to their IDE, although I love VS Code.

Try:

I'am not maintaning this project anymore, but, don't be afraid to take a deeper look into it - it is simple python after all. :) Good luck.