Build process crashes when I try to use `build_unflags`

I’m using Arduino for STM32. My application is designed to run along with bootloader, so I need to set custom location of interrupt vectors table.

When I try to pass custom vector table start address by defining VECT_TAB_ADDR, I get the following error:

TypeError: unhashable type: 'list':
File "C:\.platformio\penv\lib\site-packages\platformio\builder\main.py", line 162:
env.SConscript("$BUILD_SCRIPT")
File "C:\.platformio\packages\tool-scons\script\..\engine\SCons\Script\SConscript.py", line 541:
return _SConscript(self.fs, *files, **subst_kw)
File "C:\.platformio\packages\tool-scons\script\..\engine\SCons\Script\SConscript.py", line 250:
exec _file_ in call_stack[-1].globals
File "C:\.platformio\platforms\ststm32\builder\main.py", line 127:
target_elf = env.BuildProgram()
File "C:\.platformio\packages\tool-scons\script\..\engine\SCons\Environment.py", line 224:
return self.method(*nargs, **kwargs)
File "C:\.platformio\penv\lib\site-packages\platformio\builder\tools\platformio.py", line 67:
env.ProcessUnFlags(env.get("BUILD_UNFLAGS"))
File "C:\.platformio\packages\tool-scons\script\..\engine\SCons\Environment.py", line 224:
return self.method(*nargs, **kwargs)
File "C:\.platformio\penv\lib\site-packages\platformio\builder\tools\platformio.py", line 173:
all_flags = set(all_flags)

My platformio.ini file’s relevant portion:

build_flags = -Wl,-T./my.ld -v -DVECT_TAB_ADDR=134238208
build_unflags = -DVECT_TAB_ADDR=134217728

Adding a space between -D and VECT_TAB_ADDR doesn’t help.

After adding some debug output in platformio.py file, it became clear that all_flags is a nested list: [['VECT_TAB_ADDR', '134217728']]. After changing the line 173 in platformio.py to all_flags = set(all_flags[0]) it doesn’t crash any more, but I don’t know if this is the right way.

Also, it still doesn’t work, the compilation process still gives a warning that VECT_TAB_ADDR is redefined. Apparently, this symbol is added to defines after build_unflags is processed.

Thanks! Fixed in

It would be nice to add to docs an explanation why build_unflags cannot unset a flag which is set by framework build script.
Or in general: when do you need to use build_unflags and when do you need to use extra script.

PS Thanks for such awesome project!

Could you try pio upgrade --dev and remove extra script? All should work now with the default option.

You help us make it better and better :wink: Thank you so much for all reported issues.

Yes, it works. Thanks!