PlatformIO Community

IAP STM32 bluepill application with offset (start) address

I created two project with CubeIDE for the STM32F429 and STM32F413, this contains a bootloader and modbus OTA download and program. To achieve this changes was made to the startup_xxx.s files as well as the xxx.ld file. I want to do the same for bluepil/blackpil but for another project done in platformio (arduino). How do I force platform io to use my startupxxx.s and yyyy.ld file.
I found some info like
LDSCRIPT_PATH=’$PROJECT_DIR\STM32Fxx.ld’
and
-DVECT_TAB_OFFSET=0x5000

Per code you can control the linker script with a

board_build.ldscript = <path to ld script>

directive in the platformio.ini.

Per code you can do a little trick: Place your own startup s file in the project’s src/ directory as normal, so that it will be assembled and linked. Now to get rid of STM32Cube’s default startup file you can redirect to another file that doesn’t exist and thus get’s ignored.

board_build.stm32cube.startup_file = garbage.s

You might also want to set

board_upload.offset_address = 0x5000

so that PlatformIO will automatically flash the binary with the given offset (see code).

It’s probably a good idea to also set

build_flags = -DVECT_TAB_OFFSET=0x5000

so that binary is compiled with the right offsets.

Many thanks for the prompt reply . … will try this in the morning

Hi, I’ve predefined the VECT_TAB_OFFSET which is

build_flags = 
-DSTM32F10X_MD
-DVECT_TAB_OFFSET=0x2000

However, when compiling the code, the define is overridden by a definition in system_stm32f10x.c file

#define VECT_TAB_OFFSET  0x0 /*!< Vector Table base offset field.

Here is compiling result

Processing blackboard_f103c8 (platform: ststm32; board: blackboard_f103c8; framework: spl)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/blackboard_f103c8.html
PLATFORM: ST STM32 (13.0.0) > BlackBoard F103C8
HARDWARE: STM32F103C8T6 72MHz, 20KB RAM, 64KB Flash
DEBUG: Current (stlink) External (blackmagic, cmsis-dap, jlink, stlink)
PACKAGES:
-framework-spl 2.10201.0 (1.2.1)
-toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
LDF: Library Dependency Finder → http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies…
No dependencies
Building in release mode
Compiling .pio\build\blackboard_f103c8\src\main.o
Compiling .pio\build\blackboard_f103c8\FrameworkCMSISVariant\gcc_ride7\startup_stm32f10x_cl.o
Compiling .pio\build\blackboard_f103c8\FrameworkCMSISVariant\gcc_ride7\startup_stm32f10x_hd.o
Compiling .pio\build\blackboard_f103c8\FrameworkCMSISVariant\gcc_ride7\startup_stm32f10x_hd_vl.o
Compiling .pio\build\blackboard_f103c8\FrameworkCMSISVariant\gcc_ride7\startup_stm32f10x_ld.o
Compiling .pio\build\blackboard_f103c8\FrameworkCMSISVariant\gcc_ride7\startup_stm32f10x_ld_vl.o
Compiling .pio\build\blackboard_f103c8\FrameworkCMSISVariant\gcc_ride7\startup_stm32f10x_md.o
Compiling .pio\build\blackboard_f103c8\FrameworkCMSISVariant\gcc_ride7\startup_stm32f10x_md_vl.o
Compiling .pio\build\blackboard_f103c8\FrameworkCMSISVariant\gcc_ride7\startup_stm32f10x_xl.o
Compiling .pio\build\blackboard_f103c8\FrameworkCMSISVariant\startup_stm32f10x_md.o
Compiling .pio\build\blackboard_f103c8\FrameworkCMSISVariant\system_stm32f10x.o
Compiling .pio\build\blackboard_f103c8\FrameworkSPL\misc.o
Compiling .pio\build\blackboard_f103c8\FrameworkSPL\stm32f10x_adc.o
Compiling .pio\build\blackboard_f103c8\FrameworkSPL\stm32f10x_bkp.o
Compiling .pio\build\blackboard_f103c8\FrameworkSPL\stm32f10x_can.o
Compiling .pio\build\blackboard_f103c8\FrameworkSPL\stm32f10x_cec.o
Compiling .pio\build\blackboard_f103c8\FrameworkSPL\stm32f10x_crc.o
Compiling .pio\build\blackboard_f103c8\FrameworkSPL\stm32f10x_dac.o
Compiling .pio\build\blackboard_f103c8\FrameworkSPL\stm32f10x_dbgmcu.o
Compiling .pio\build\blackboard_f103c8\FrameworkSPL\stm32f10x_dma.o
Compiling .pio\build\blackboard_f103c8\FrameworkSPL\stm32f10x_exti.o
Compiling .pio\build\blackboard_f103c8\FrameworkSPL\stm32f10x_flash.o
Compiling .pio\build\blackboard_f103c8\FrameworkSPL\stm32f10x_gpio.o
Compiling .pio\build\blackboard_f103c8\FrameworkSPL\stm32f10x_i2c.o
Compiling .pio\build\blackboard_f103c8\FrameworkSPL\stm32f10x_iwdg.o
C:\Users\James.platformio\packages\framework-spl\stm32\cmsis\variants\stm32f1\system_stm32f10x.c:128:0: warning: “VECT_TAB_OFFSET” redefined
#define VECT_TAB_OFFSET 0x0 /*!< Vector Table base offset field.
:0:0: note: this is the location of the previous definition
Compiling .pio\build\blackboard_f103c8\FrameworkSPL\stm32f10x_pwr.o
Archiving .pio\build\blackboard_f103c8\libFrameworkCMSISVariant.a
Compiling .pio\build\blackboard_f103c8\FrameworkSPL\stm32f10x_rcc.o
Compiling .pio\build\blackboard_f103c8\FrameworkSPL\stm32f10x_rtc.o
Compiling .pio\build\blackboard_f103c8\FrameworkSPL\stm32f10x_sdio.o
Compiling .pio\build\blackboard_f103c8\FrameworkSPL\stm32f10x_spi.o
Compiling .pio\build\blackboard_f103c8\FrameworkSPL\stm32f10x_tim.o
Compiling .pio\build\blackboard_f103c8\FrameworkSPL\stm32f10x_usart.o
Compiling .pio\build\blackboard_f103c8\FrameworkSPL\stm32f10x_wwdg.o
Archiving .pio\build\blackboard_f103c8\libFrameworkSPL.a
Linking .pio\build\blackboard_f103c8\firmware.elf
Checking size .pio\build\blackboard_f103c8\firmware.elf
Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
RAM: [= ] 5.6% (used 1140 bytes from 20480 bytes)
Flash: [ ] 3.3% (used 2156 bytes from 65536 bytes)
Building .pio\build\blackboard_f103c8\firmware.bin
Adding dfu suffix to firmware.bin
dfu-suffix (dfu-util) 0.9

Please let me know how to fix this issue. Thanks in advance