ST Nucleo F103RB with libOpenCM3 Framework, Compile errors

Hi,

Firstly my dev setup is as follows…
Mac OS 10.10.5
vsCode Version 1.19.3 (1.19.3)
PlatformIO, version 4.0.3
Board
ST Nucleo F103RB
Framework
libOpenCM3

test.c
main
int main(void)
{
}

I am trying to create a Dev environment using libOpenCM3
So I created a new project in PlatformIO
Project Name = xxx
Board = ST Nucleo F103RB
Framework = libOpenCM3

Project is created and initialised without errors.

I use an empty main { } then compile.
I get a massive list of errors e.g.
error “stm32 family not defined.”
error: ‘ADC_CR2_ADON’ undeclared
etc…
There are loads of undeclared’s (first use in this function)

If I create the exact same project except select Arduino
for the framework instead, everything compiles and links perfectly.

Can someone tell me why all these errors are occurring?

Thanks…

Yeah it has code like

#if defined(STM32F0)
#       include <libopencm3/stm32/f0/adc.h>
#elif defined(STM32F1)
#       include <libopencm3/stm32/f1/adc.h>
#elif defined(STM32F3)
#       include <libopencm3/stm32/f3/adc.h>
#elif defined(STM32F4)
#       include <libopencm3/stm32/f4/adc.h>
#elif defined(STM32L1)
#       include <libopencm3/stm32/l1/adc.h>
#else
#       error "stm32 family not defined."
#endif

But the board JSON file doesn’t declare it in the flags / macros

So could you add to your platformio.ini:

build_flags = -D STM32F1

Thanks,
I added that line and the “family not defined” error has now gone.

But I am having the following errors

Compiling .pio/build/nucleo_f103rb/src/PWM.o
arm-none-eabi-gcc: error: unrecognized command line option '-mlongcalls'; 
did you mean '-mlong-calls'?
arm-none-eabi-gcc: error: unrecognized command line option '-mtext-section-literals'; 
did you mean '-fext-numeric-literals'?
Compiling .pio/build/nucleo_f103rb/FrameworkLibOpenCM3/lib/stm32/f1/adc.o
arm-none-eabi-gcc: error: unrecognized command line option '-mlongcalls'; 
did you mean '-mlong-calls'?
arm-none-eabi-gcc: error: unrecognized command line option '-mtext-section-literals'; 
did you mean '-fext-numeric-literals'?
Compiling .pio/build/nucleo_f103rb/FrameworkLibOpenCM3/lib/stm32/common/adc_common_v1.o
arm-none-eabi-gcc: error: unrecognized command line option '-mlongcalls'; 
did you mean '-mlong-calls'?
arm-none-eabi-gcc: error: unrecognized command line option '-mtext-section-literals'; 
did you mean '-fext-numeric-literals'?
Compiling .pio/build/nucleo_f103rb/FrameworkLibOpenCM3/lib/stm32/can.o
arm-none-eabi-gcc: error: unrecognized command line option '-mlongcalls'; 
did you mean '-mlong-calls'?
arm-none-eabi-gcc: error: unrecognized command line option '-mtext-section-literals'; 
did you mean '-fext-numeric-literals'?
*** [.pio/build/nucleo_f103rb/src/PWM.o] Error 1
*** [.pio/build/nucleo_f103rb/FrameworkLibOpenCM3/lib/stm32/f1/adc.o] Error 1
*** [.pio/build/nucleo_f103rb/FrameworkLibOpenCM3/lib/stm32/common/adc_common_v1.o] Error 1
*** [.pio/build/nucleo_f103rb/FrameworkLibOpenCM3/lib/stm32/can.o] Error 1

How would I get rid of these errors to compile?

Regards

My Platformio.ini

[env:nucleo_f103rb]
platform = ststm32
board = nucleo_f103rb
board_build.f_cpu = 72000000L
framework = libopencm3
build_flags = -D STM32F1

Solved, Needed to restart PlatformIO.

Thanks