Skip to content

VECT_TAB_OFFSET patch #2134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

VECT_TAB_OFFSET patch #2134

wants to merge 1 commit into from

Conversation

thijses
Copy link

@thijses thijses commented Sep 19, 2023

Summary

fix LD_FLASH_OFFSET build flag in platformio-build.py. Previously, setting LD_FLASH_OFFSET or VECT_TAB_OFFSET would be overridden by the builder. This small patch allows you to actually set the build flag manually (e.g. for custom bootloader applications). I also added a little warning for when the aforementioned parameters get overridden by the builder.

This PR fixes/implements the following features

  • LD_FLASH_OFFSET build_flag fix
  • LD_FLASH_OFFSET / VECT_TAB_OFFSET override warning

motivation

i am implementing my own BLE OTA bootloader for the STM32WB55, so i need to compile code with a vector table (VTOR) offset. For an applied example, see this example sketch

Validation

i'm not entirely sure how to demonstrate that it's working, so here is an excerpt of builder output after setting:

build_flags = -Wl,--defsym=LD_FLASH_OFFSET=0xF000 ; Note: offset value must be a multiple of 0x200

Processing OTA_z_STM32WB55 (platform: ststm32; board: nucleo_wb55rg_p; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/nucleo_wb55rg_p.html
PLATFORM: ST STM32 (16.0.0) > P-Nucleo WB55RG
HARDWARE: STM32WB55RG 64MHz, 192KB RAM, 512KB Flash
DEBUG: Current (stlink) On-board (stlink) External (blackmagic, cmsis-dap, jlink)
PACKAGES:
 - framework-arduinoststm32 @ 0.0.0+sha.ddd6e9c
 - framework-cmsis @ 2.50700.210515 (5.7.0)
 - tool-dfuutil @ 1.11.0
 - tool-openocd @ 3.1200.0 (12.0)
 - tool-stm32duino @ 1.0.2
 - toolchain-gccarmnoneeabi @ 1.100301.220327 (10.3.1)
existing LD_FLASH_OFFSET link-flag found: 0xf000    Setting VECT_TAB_OFFSET accordingly
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 15 compatible libraries
Scanning dependencies...
Dependency Graph
|-- STM32duinoBLE @ 1.2.5
|-- STM32WB55_custom_arduino_bootloader
Building in release mode
Compiling .pio\build\OTA_z_STM32WB55\FrameworkArduinoVariant\PeripheralPins.c.o
Compiling .pio\build\OTA_z_STM32WB55\FrameworkArduinoVariant\generic_clock.c.o
Compiling .pio\build\OTA_z_STM32WB55\FrameworkArduinoVariant\variant_P_NUCLEO_WB55RG.cpp.o
Compiling .pio\build\OTA_z_STM32WB55\FrameworkArduinoVariant\variant_generic.cpp.o
Compiling .pio\build\OTA_z_STM32WB55\SrcWrapper\src\HAL\stm32yyxx_hal.c.o
Compiling .pio\build\OTA_z_STM32WB55\SrcWrapper\src\HAL\stm32yyxx_hal_adc.c.o
...

where the line of important is:

existing LD_FLASH_OFFSET link-flag found: 0xf000 Setting VECT_TAB_OFFSET accordingly

Code formatting

(i couldn't find the style guide?)

@fpistm
Copy link
Member

fpistm commented Sep 19, 2023

Hi @thijses . Thanks for this PR. I guess @valeros would be interested to review it ?

@valeros
Copy link
Contributor

valeros commented Sep 19, 2023

Hi there, thanks for pinging me. While @thijses work was made with the best interests of the project in mind, the changes seem quite project specific to me and can be handled simply by using the combination of the build_flags and build_unflags options. Additionally, I'm working on a PR with the latest changes to the build script, so the current revision of the PlatformIO build script will receive some minor changes that apparently will conflict with this PR.

@fpistm
Copy link
Member

fpistm commented Sep 19, 2023

Thanks @valeros for the quick feedback,
If I well understood, you think this change is not requires and user have to use custom flag so this change should not be merged?

@valeros
Copy link
Contributor

valeros commented Sep 19, 2023

If I well understood, you think this change is not requires and user have to use custom flag so this change should not be merged?

That's right, the PR I'm working on should simplify this issue in a bit more generic way.

@fpistm
Copy link
Member

fpistm commented Sep 19, 2023

OK.
So @thijses .
I close this PR as it will be deprecated by @valeros future update.

@fpistm fpistm closed this Sep 19, 2023
@fpistm fpistm added the wontfix This will not be worked on label Sep 19, 2023
@thijses
Copy link
Author

thijses commented Sep 19, 2023

impressively fast response, and fair enough conclusion. Looking forward to @valeros's future update.

P.S., for posterity:
Yes, one can indeed solve it with build_unflags:

build_unflags = -Wl,--defsym=LD_FLASH_OFFSET=0x0
build_flags = -Wl,--defsym=LD_FLASH_OFFSET=0xF000
                     -D VECT_TAB_OFFSET=0xF000

My platformio scripting has been slowly improving, so i genuinely did not know how to make it work with just build_ options untill now. Always nice to learn something new!

@fpistm
Copy link
Member

fpistm commented Sep 21, 2023

@thijses
@valeros submitetd the PR: #2135 , hope this answer to your need.

@thijses
Copy link
Author

thijses commented Sep 21, 2023

yes indeed, thank you :)

@fpistm
Copy link
Member

fpistm commented Sep 21, 2023

yes indeed, thank you :)

Mainly thanks to @valeros who was very reactive 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants