Syntax error in ld-file at linking

When running platformio run I get the error:

platformio run
Processing disco_f072rb (board: disco_f072rb_libopencm; platform:; framework: libopencm3)
Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: ST STM32 6.1.0 #35b13fb > ST Discovery F072RB
HARDWARE: STM32F072RBT6 48MHz, 16KB RAM, 128KB Flash
DEBUG: Current (stlink) On-board (stlink) External (blackmagic, jlink)
 - framework-libopencm3 9bf6ce8
 - toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
LDF: Library Dependency Finder ->
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Linking .pio/build/disco_f072rb/firmware.elf
/Users/bodokaiser/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld:/Users/bodokaiser/.platformio/packages/framework-libopencm3@src-9c8ebe1ef30e0eefffb6631e281f274d/lib/stm32/f0/stm32f07xzb.ld:429: syntax error
collect2: error: ld returned 1 exit status
*** [.pio/build/disco_f072rb/firmware.elf] Error 1

The custom board setup disco_f072rb_libopencm3 can be found here.
The platformio source code can be found here.

When I open /Users/bodokaiser/.platformio/packages/framework-libopencm3@src-9c8ebe1ef30e0eefffb6631e281f274d/lib/stm32/f0/stm32f07xzb.ld and check line 429 I find a lonely */. Maybe we are missing the corresponding opening /*.

Any ideas what to do?

This indicates that the modification of isn’t working properly.

The current PlatformIO builder for libopencm3 modifies the .ld files by resolving INCLUDE directives. Unfortunately, the latest libopencm3 .ld files also contain an INCLUDE directive in the comments, which is not supposed to be resolved. PlatformIO does it anyway. On the first run it works, on the second run it creates an invalid file. Then you get the error you describe.

To fix it:

Reset the ld file:

cd ~/.platformio/packages/framework-libopencm3/lib/stm32/f0
git checkout stm32f07xzb.ld

Then check the modification again. You might have lost it with some update.

Instead of modifying, you can also modify stm32f07xzb.ld: Just remove the INCLUDE directive that serves as an example and is placed in a comment block.

I cannot reset stm32f07xzb.ld because

fatal: not a git repository (or any of the parent directories): .git

The content of stm32f07xzb.ld is:

 * This file is part of the libopencm3 project.
 * Copyright (C) 2015 Karl Palsson <>
 * This library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * GNU Lesser General Public License for more details.
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library.  If not, see <>.

/* Linker script for STM32F07xzB, 128k flash, 16k RAM. */

/* Define memory regions. */
	rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K
	ram (rwx) : ORIGIN = 0x20000000, LENGTH = 16K

/* Include the common ld script. */
INCLUDE libopencm3_stm32f0.ld

I removed the last line without effect.

I also manually replaced stm32f07xzb.ld with the file in the libopencm3 repository also without effect.

Delete all folders starting with framework-libopencm in ~/.platformio/packages. PlatformIO will restore them as needed.