Creating STM32 Arduino framework firmware with bootloader

Hi,

How do I create firmware using STM32 Arduino framework that is usable with bootloader? As far as I understand, I need to tell linker to shift the firmware to higher addresses. How can I do that? Should I just pass some flag to linker, or there’s some option that can be added to platformio.ini? Perhaps any examples?

My MCU is STM32F103CB.

1 Like

I’ve noticed there’s upload_protocol = dfu option that, according to builder\frameworks\arduino\maple\stm32f1.py sets appropriate linker script to offset the application to 0x8002000 address.

It apparently can be used with any bootloader, including custom. The only requirement is to fit the bootloader code in the freed ROM region. If it doesn’t fit, that file and bootloader script can be edited, though.

1 Like

Does anyone know how to supply custom .ld file path to the linker to avoid editing the files supplied with PlatformIO?
I can put it into variant’s ld subfolder inside Arduino STM32 framework, but what about a subfolder inside a project folder?

Got it.
-Wl,-T./my.ld. The path is relative to project root dir.

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.

It was a bug, it’s fixed now for some time already.
No more questions :slight_smile:

Добрый день…
Я правда на 401 и тоже из Ардуино попытался прыгнуть!
.
Потом в PlatformIO перешёл в Кубе.
Не помогло , похоже вектор прерывания не устанавливается!
Как его настроить?
Начал разбираться в Путоновских скриптах, но я больше С++ иАрдуино… пока не понял…
Спасибо…если прочитаете!