Specifying an alternate linker file

I am trying to specify an alternate linker file for my application but I am seeing some conflicting information here and in the docs. This is my current platformio.ini

platform = ststm32
board = bw_swan_r5
board_build.ldscript = $PROJECT_DIR/utilities/ldscript.ld
build_flags = 
upload_protocol = stlink
framework = arduino
lib_deps = 
	blues/Blues Wireless Notecard@^1.3.13
	adafruit/Adafruit GFX Library@^1.10.14
	adafruit/Adafruit SSD1306@^2.5.3
	adafruit/Adafruit Unified Sensor@^1.1.5
	adafruit/Adafruit BME280 Library@^2.2.2
	adafruit/Adafruit LIS3DH@^1.2.3
	adafruit/Adafruit NeoPixel@^1.10.4

board_build.ldscriptis the setting I saw in the docs, but it doesn’t seem to be picked up any way I build. I also added the -L ldflag but that doesn’t seem to be picked up either. When i do a clean and Verbose upload, the output still shows me the default ld files:

arm-none-eabi-g++ -o .pio/build/bw_swan_r5/firmware.elf -T /Users/satch/.platformio/packages/framework-arduinoststm32/system/ldscript.ld -mfpu=fpv4-sp-d16 -mfloat-abi=hard -Os -mthumb -mcpu=cortex-m4 --specs=nano.specs -Wl,--gc-sections,--relax -Wl,--check-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--defsym=LD_MAX_SIZE=2097152 -Wl,--defsym=LD_MAX_DATA_SIZE=655360 -Wl,--defsym=LD_FLASH_OFFSET=0x0 -Wl,--default-script /Users/satch/.platformio/packages/framework-arduinoststm32/variants/STM32L4xx/L4R5Z\(G-I\)Y_L4R9Z\(G-I\)Y_L4S5ZIY_L4S9ZIY/ldscript.ld

Any suggestions for what I should/can change?

I’m not sure if this directive supports the variable substitution. I’ll check it out.

1 Like

Thanks @maxgerhardt, I changed it to just board_build.ldscript = utilities/ldscript.ld but it still doesn’t pick it up. I don’t think the file path is the issue, it seems like the config setting just isn’t being picked-up at all.

NVM, I got it. In a true :person_facepalming: moment, I realized this morning after walking away that I was building a different project in the workspace. All good now, nothing to see here.

1 Like