ST-link for MAC OS

I was given a STM controller to try, I have STM32F0DISCOVERY, MacBook, Catalina, VSC and Platformio. How to upload a sketch to STM32F0DISCOVERY? This DEV board uses st-link, but as I understand it, something in my configuration does not support st-link. I read a lot on the forum but no answer came.

This combination should be fully supported. Just specify (in platformio.ini):

debug_tool = stlink
upload_protocol = stlink

and press the upload button in the status bar.

In order to better support, you please provide more information:

  • Where are you stuck? What did you try? What didnā€™t work? What error message or log output did you get?
  • What does your platformio.ini look like?

Maybe here it will not be difficult for someone to show the small code for stm32 and an example of the platformio.ini :pray:
Apparently I just donā€™t understand something

What error message are you gettingā€¦

Examples are e.g. at platform-ststm32/examples/arduino-blink at develop Ā· platformio/platform-ststm32 Ā· GitHub

Make sure to use the appropriate board name. I think you want ST STM32F0DISCOVERY ā€” PlatformIO latest documentation.

1 Like

How are we supposed to help you if you donā€™t provide any information? Iā€™ve asked specific question but you havenā€™t answered any of them.

From your information so far we donā€™t understand if you have run into a specific problem (it doesnā€™t compile, it doesnā€™t upload, it runs but doesnā€™t behave as expected) or if you donā€™t where to start and need guidance.

Please help us help you.

I did according to the instructions platform-ststm32/examples/arduino-blink at develop Ā· platformio/platform-ststm32 Ā· GitHub, but at the ā€œplatformio runā€ step I get this kind of infinite loop

Building .pio/build/robotdyn_blackpill_f303cc/firmware.bin
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   2.3% (used 960 bytes from 40960 bytes)
Flash: [          ]   4.5% (used 11720 bytes from 262144 bytes)
==================================================================================== [SUCCESS] Took 6.08 seconds ====================================================================================

Processing sparky_v1 (board: sparky_v1; platform: ststm32; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/sparky_v1.html
PLATFORM: ST STM32 (8.0.0) > Sparky V1 F303
HARDWARE: STM32F303CCT6 72MHz, 40KB RAM, 256KB Flash
DEBUG: Current (blackmagic) External (blackmagic, jlink, stlink)
PACKAGES: 
 - framework-arduinoststm32 4.10900.200819 (1.9.0) 
 - framework-cmsis 2.50501.200527 (5.5.1) 
 - toolchain-gccarmnoneeabi 1.90201.191206 (9.2.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 37 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/sparky_v1/FrameworkArduinoVariant/PeripheralPins.c.o
Compiling .pio/build/sparky_v1/FrameworkArduinoVariant/variant.cpp.o
Compiling .pio/build/sparky_v1/FrameworkArduino/HardwareSerial.cpp.o
...
Compiling .pio/build/sparky_v1/src/Blink.cpp.o
Linking .pio/build/sparky_v1/firmware.elf
Checking size .pio/build/sparky_v1/firmware.elf
Building .pio/build/sparky_v1/firmware.bin
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   2.3% (used 960 bytes from 40960 bytes)
Flash: [          ]   4.4% (used 11576 bytes from 262144 bytes)
==================================================================================== [SUCCESS] Took 6.64 seconds ====================================================================================

Processing vake_v1 (board: vake_v1; platform: ststm32; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/vake_v1.html
PLATFORM: ST STM32 (8.0.0) > VAkE v1.0
HARDWARE: STM32F446RET6 180MHz, 128KB RAM, 512KB Flash
DEBUG: Current (blackmagic) External (blackmagic, jlink, stlink)
PACKAGES: 
 - framework-arduinoststm32 4.10900.200819 (1.9.0) 
 - framework-cmsis 2.50501.200527 (5.5.1) 
 - toolchain-gccarmnoneeabi 1.90201.191206 (9.2.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 37 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/vake_v1/FrameworkArduinoVariant/PeripheralPins.c.o
Compiling .pio/build/vake_v1/FrameworkArduinoVariant/variant.cpp.o
Compiling .pio/build/vake_v1/FrameworkArduino/HardwareSerial.cpp.o
Compiling .pio/build/vake_v1/FrameworkArduino/HardwareTimer.cpp.o
...
Compiling .pio/build/vake_v1/FrameworkArduino/abi.cpp.o
Compiling .pio/build/vake_v1/FrameworkArduino/avr/dtostrf.c.o
/Users/ruslanpavluchenko/.platformio/packages/framework-arduinoststm32/cores/arduino/Tone.cpp:136:2: warning: #warning "TIMER_TONE or HAL_TIM_MODULE_ENABLED not defined" [-Wcpp]
  136 | #warning "TIMER_TONE or HAL_TIM_MODULE_ENABLED not defined"
      |  ^~~~~~~
Compiling .pio/build/vake_v1/FrameworkArduino/board.c.o
Compiling .pio/build/vake_v1/FrameworkArduino/hooks.c.o
Compiling .pio/build/vake_v1/FrameworkArduino/itoa.c.o
Compiling .pio/build/vake_v1/FrameworkArduino/main.cpp.o
Compiling .pio/build/vake_v1/FrameworkArduino/new.cpp.o
Compiling .pio/build/vake_v1/FrameworkArduino/pins_arduino.c.o
Compiling .pio/build/vake_v1/FrameworkArduino/stm32/OpenAMP/libmetal/device.c.o
Compiling .pio/build/vake_v1/FrameworkArduino/stm32/OpenAMP/libmetal/generic/condition.c.o
Compiling .pio/build/vake_v1/FrameworkArduino/stm32/OpenAMP/libmetal/generic/cortexm/sys.c.o
Compiling .pio/build/vake_v1/FrameworkArduino/stm32/OpenAMP/libmetal/generic/generic_device.c.o
Compiling .pio/build/vake_v1/FrameworkArduino/stm32/OpenAMP/libmetal/generic/generic_init.c.o
Compiling .pio/build/vake_v1/FrameworkArduino/stm32/OpenAMP/libmetal/generic/generic_io.c.o
Compiling .pio/build/vake_v1/FrameworkArduino/stm32/OpenAMP/libmetal/generic/generic_shmem.c.o

...
Compiling .pio/build/vake_v1/SrcWrapper/src/stm32/rtc.c.o
Compiling .pio/build/vake_v1/SrcWrapper/src/stm32/stm32_def.c.o
Compiling .pio/build/vake_v1/SrcWrapper/src/stm32/stm32_eeprom.c.o
Compiling .pio/build/vake_v1/SrcWrapper/src/stm32/system_stm32yyxx.c.o
Compiling .pio/build/vake_v1/SrcWrapper/src/stm32/timer.c.o
Compiling .pio/build/vake_v1/SrcWrapper/src/stm32/uart.c.o
Compiling .pio/build/vake_v1/SrcWrapper/src/syscalls.c.o
Compiling .pio/build/vake_v1/src/Blink.cpp.o
Linking .pio/build/vake_v1/firmware.elf
Checking size .pio/build/vake_v1/firmware.elf
Building .pio/build/vake_v1/firmware.bin
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.9% (used 1188 bytes from 131072 bytes)
Flash: [          ]   2.2% (used 11480 bytes from 524288 bytes)
==================================================================================== [SUCCESS] Took 6.78 seconds ====================================================================================

Processing st3dp001_eval (board: st3dp001_eval; platform: ststm32; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/st3dp001_eval.html
PLATFORM: ST STM32 (8.0.0) > 3DP001V1 Evaluation board for 3D printer
HARDWARE: STM32F401VGT6 84MHz, 96KB RAM, 512KB Flash
DEBUG: Current (stlink) On-board (stlink) External (blackmagic, jlink)
PACKAGES: 
 - framework-arduinoststm32 4.10900.200819 (1.9.0) 
 - framework-cmsis 2.50501.200527 (5.5.1) 
 

***pio run***
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.9% (used 880 bytes from 98304 bytes)
Flash: [          ]   2.1% (used 10788 bytes from 524288 bytes)
==================================================================================== [SUCCESS] Took 2.33 seconds ====================================================================================

Processing nucleo_wb55rg_p (board: nucleo_wb55rg_p; platform: ststm32; 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 (8.0.0) > P-Nucleo WB55RG
HARDWARE: STM32WB55RG 64MHz, 192.00KB RAM, 512KB Flash
DEBUG: Current (stlink) On-board (stlink) External (blackmagic, jlink)
PACKAGES: 
 - framework-arduinoststm32 4.10900.200819 (1.9.0) 
 - framework-cmsis 2.50501.200527 (5.5.1) 
 - toolchain-gccarmnoneeabi 1.90201.191206 (9.2.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 37 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio/build/nucleo_wb55rg_p/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.5% (used 940 bytes from 196604 bytes)
Flash: [          ]   2.5% (used 13056 bytes from 524288 bytes)
==================================================================================== [SUCCESS] Took 2.06 seconds ====================================================================================

Processing nucleo_h743zi (board: nucleo_h743zi; platform: ststm32; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/nucleo_h743zi.html
PLATFORM: ST STM32 (8.0.0) > ST Nucleo H743ZI
HARDWARE: STM32H743ZIT6 400MHz, 512KB RAM, 2MB Flash
DEBUG: Current (stlink) On-board (stlink) External (blackmagic, jlink)
PACKAGES: 
 - framework-arduinoststm32 4.10900.200819 (1.9.0) 
 - framework-cmsis 2.50501.200527 (5.5.1) 
 - toolchain-gccarmnoneeabi 1.90201.191206 (9.2.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 37 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio/build/nucleo_h743zi/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.2% (used 1052 bytes from 524288 bytes)
Flash: [          ]   0.8% (used 17392 bytes from 2097152 bytes)
==================================================================================== [SUCCESS] Took 2.43 seconds ====================================================================================

Processing nucleo_g071rb (board: nucleo_g071rb; platform: ststm32; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
^CBuild interrupted.
Error: Aborted by user
ruslanpavluchenko@Ruslans-MacBook-Pro arduino-blink %

As said in

You only want an environment which contains your specific board. The README also tells you to only run it for a specific environment (-e <env>). Since your board isnā€™t listed in the platformio.ini you should replace it with

[env:disco_f051r8]
platform = ststm32
board = disco_f051r8
framework = arduino

Max, first let me thank you for your help with setting up MKII, everything works great, I could test my code on a real device.
Now about STM, I have to transfer my project to the STM platform due to the steep possibility of customizing the frequencies and bit depth for the PWM signal. I, as an amateur, thought that moving to another platform knowing if/then would be easy, but unfortunately I do not understand the ideology of building an STM project. I am doing an STM project under arduino and I donā€™t understand, I am doing it under CUB and I understand even less. To begin with, I need to at least understand how to load the code. I will understand the details in the process.
So, as the simplest option, I chose STM in the arduino frmework, created a project with these settings and I get:
Linking .pio / build / disco_f100rb / firmware.elf
.pio / build / disco_f100rb / libFrameworkCMSISDevice.a (startup_stm32f100xb.o): In function LoopFillZerobss': (.text.Reset_Handler + 0x2e): undefined reference to main ā€™
collect2: error: ld returned 1 exit status
*** [.pio / build / disco_f100rb / firmware.elf] Error 1

In all honesty, I donā€™t understand what this is about.
If the solution is on the surface, please help me.

this is my devboard:
https://www.st.com/en/evaluation-tools/stm32vldiscovery.html

I tried both the written platform documentation and as stated above, it does not work, the error is the same

[env:disco_f100rb]
platform = ststm32
board = disco_f100rb
framework = arduino
upload_protocol = stlink

[env:disco_f051r8]
platform = ststm32
board = disco_f051r8
framework = arduino

The error says that no main() function could be found in your project which is called into from the Reset_Handler. Does this function not exist?

To shed some light on that one would need to see the exact project youā€™re compiling. It looks to me as if you want to use the Arduino framework on the disco_f100rb. This should work perfectly line, as demonstrated by the example projects linkedabove.

Iā€™m not even migrating my project yet, I just took an example blink and try to download it to understand if it works or not.
1.
[env:disco_f100rb]
platform = ststm32
board = disco_f100rb
framework = arduino
upload_protocol = stlink

error:
Uploading .pio/build/disco_f100rb/firmware.elf
xPack OpenOCD, x86_64 Open On-Chip Debugger 0.10.0+dev-00378-ge5be992df (2020-06-26-12:31)
Licensed under GNU GPL v2
For bug reports, read
OpenOCD: Bug Reporting
debug_level: 1

hla_swd
in procedure ā€˜programā€™
** OpenOCD init failed **
shutdown command invoked

*** [upload] Error 1

[env:disco_f051r8]
platform = ststm32
board = disco_f051r8
framework = arduino
upload_protocol = stlink

ā€¦

  • toolchain-gccarmnoneeabi 1.90201.191206 (9.2.1)
    Error: This board doesnā€™t support arduino framework!

The blinking LEDs were charged earlier, possibly at the factory.

If you have a STM32F0DISCOVERY board (with the STM32F051R8T6 chip), you cannot use the Arduino framework. There is no Arduino core that supports this chip.

If you have a STM32VLDISCOVERY board (with the STM32F100RBT6 chip), then the Arduino framework works just fine. Iā€™ve just verified it. Please show the blink example you are using so we can provide you more specific help.

I also read that my chip cannot work in arduino framework, and I took the example of a blink cube, but the result is the same (

platformio.ini

[env:disco_f051r8]

platform = ststm32
framework = stm32cube
board = disco_f051r8
debug_tool = stlink
upload_protocol = stlink
board_build.mcu = stm32f051r8t6
/////////////CODE/////////////
#if F0
#include "stm32f0xx_hal.h"
#elif F1
#include "stm32f1xx_hal.h"
#elif F2
#include "stm32f2xx_hal.h"
#elif F3
#include "stm32f3xx_hal.h"
#elif F4
#include "stm32f4xx_hal.h"
#elif F7
#include "stm32f7xx_hal.h"
#elif L0
#include "stm32l0xx_hal.h"
#elif L1
#include "stm32l1xx_hal.h"
#elif L4
#include "stm32l4xx_hal.h"
#else
#error "Unsupported STM32 Family"
#endif

#define LED_PIN                                GPIO_PIN_5
#define LED_GPIO_PORT                          GPIOA
#define LED_GPIO_CLK_ENABLE()                  __HAL_RCC_GPIOA_CLK_ENABLE()

int main(void)
{
  HAL_Init();
  
  LED_GPIO_CLK_ENABLE();
  
  GPIO_InitTypeDef GPIO_InitStruct;
  
  GPIO_InitStruct.Pin = LED_PIN;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_PULLUP;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
  HAL_GPIO_Init(LED_GPIO_PORT, &GPIO_InitStruct); 

  while (1)
  {
    HAL_GPIO_TogglePin(LED_GPIO_PORT, LED_PIN);
    
    HAL_Delay(1000);
  }
}

void SysTick_Handler(void)
{
  HAL_IncTick();
}

void NMI_Handler(void)
{
}

void HardFault_Handler(void)
{
  while (1) {}
}


void MemManage_Handler(void)
{
  while (1) {}
}

void BusFault_Handler(void)
{
  while (1) {}
}

void UsageFault_Handler(void)
{
  while (1) {}
}

void SVC_Handler(void)
{
}


void DebugMon_Handler(void)
{
}

void PendSV_Handler(void)
{
}

Compiling .pio/build/disco_f051r8/src/main.o
src/main.c:20:2: error: #error ā€œUnsupported STM32 Familyā€
#error ā€œUnsupported STM32 Familyā€
^~~~~
ā€¦

You need to read the code youā€™re compiling. The main.c expects you to define -DF1 if you are compiling for a STM32F1 board, this is done via build_flags in the original example. So, just add build_flags = -DF1 to your platformio.ini. Also check if you need to change the blink pin as itā€™s currently set to PA5. (Youā€™d need to check the discovery boardā€™s schematics for that).

If that error appears again thereā€™s probably something wrong with the reset_config in OpenOCD. You may try to: Hold down the reset button before the upload is started, and release it when OpenOCD starts up (at the right time), or modify the reset_config in the OpenOCD config files for your board (which you can find out by doing a ā€œVerbose Uploadā€ and looking at the -f *.cfg flags in the openocd command). There are threads about that (STM32F411CE (BlackPill) + STLink V2 + Arduino on Ubuntu - #2 by maxgerhardt)

Thanks, I really didnā€™t understand the purpose of the flags for compilation, I never used it, now I understand what it is for!
I changed the ini file

[env:disco_f051r8]
platform = ststm32
framework = stm32cube
board = disco_f051r8
debug_tool = stlink
upload_protocol = stlink
build_flags = -DF1

And changed the GPIO to the corresponding one - 9 (on the board, the LEDs are signed PC8, PC9)

(penv) ruslanpavluchenko@Ruslans-MacBook-Pro-3 stm32cube-hal-blink % pio run -t upload
Processing disco_f051r8 (platform: ststm32; framework: stm32cube; board: disco_f051r8)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/disco_f051r8.html
PLATFORM: ST STM32 (8.1.0) > ST STM32F0DISCOVERY
HARDWARE: STM32F051R8T6 48MHz, 8KB RAM, 64KB Flash
DEBUG: Current (stlink) On-board (stlink) External (blackmagic, jlink)
PACKAGES: 
 - framework-stm32cube 2.0.200813 
 - tool-dfuutil 1.9.200310 
 - tool-ldscripts-ststm32 0.1.0 
 - tool-openocd 2.1000.200630 (10.0) 
 - tool-stm32duino 1.0.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 10 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/disco_f051r8/src/main.o
src/main.c:4:10: fatal error: stm32f1xx_hal.h: No such file or directory

***********************************************************************
* Looking for stm32f1xx_hal.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:stm32f1xx_hal.h"
* Web  > https://platformio.org/lib/search?query=header:stm32f1xx_hal.h
*
***********************************************************************

 #include "stm32f1xx_hal.h"
          ^~~~~~~~~~~~~~~~~
compilation terminated.
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_smbus.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_spi.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_spi_ex.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_tim.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_tim_ex.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_tsc.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_uart.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_uart_ex.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_usart.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_wwdg.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_ll_adc.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_ll_comp.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_ll_crc.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_ll_crs.o
*** [.pio/build/disco_f051r8/src/main.o] Error 1
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_ll_dac.o
================================================================================= [FAILED] Took 1.06 seconds =================================================================================
(penv) ruslanpavluchenko@Ruslans-MacBook-Pro-3 stm32cube-hal-blink %

Okay that doesnā€™t look good. That file is supposed to be in ~/.platformio/packages/framework-stm32cube/f1/Drivers/STM32F1xx_HAL_Driver/Inc, where ~/ is the user home directory. Can you manually look if the file is in there?

If not, remove the framework-stm32cube folder so that PIO will re-download a fresh, good version of it.

Yes, the file is where it should be!

As a last try, can you change (in the main.c) the #include "stm32f1xx_hal.h" to #include <stm32f1xx_hal.h> and in the platformio.ini change -DF1 to -DF1=1?

Without results:(

#elif F1
// #include "stm32f1xx_hal.h"
#include <stm32f1xx_hal.h>
#elif F2
[env:disco_f051r8]
platform = ststm32
framework = stm32cube
board = disco_f051r8
debug_tool = stlink
upload_protocol = stlink
;build_flags = -DF1
build_flags = -DF1=1
(penv) ruslanpavluchenko@Ruslans-MacBook-Pro-3 stm32cube-hal-blink % pio run -t upload
Processing disco_f051r8 (platform: ststm32; framework: stm32cube; board: disco_f051r8)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/disco_f051r8.html
PLATFORM: ST STM32 (8.1.0) > ST STM32F0DISCOVERY
HARDWARE: STM32F051R8T6 48MHz, 8KB RAM, 64KB Flash
DEBUG: Current (stlink) On-board (stlink) External (blackmagic, jlink)
PACKAGES: 
 - framework-stm32cube 2.0.200813 
 - tool-dfuutil 1.9.200310 
 - tool-ldscripts-ststm32 0.1.0 
 - tool-openocd 2.1000.200630 (10.0) 
 - tool-stm32duino 1.0.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 10 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/disco_f051r8/src/main.o
src/main.c:5:12: fatal error: stm32f1xx_hal.h: No such file or directory

***********************************************************************
* Looking for stm32f1xx_hal.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:stm32f1xx_hal.h"
* Web  > https://platformio.org/lib/search?query=header:stm32f1xx_hal.h
*
***********************************************************************

   #include <stm32f1xx_hal.h>
            ^~~~~~~~~~~~~~~~~
compilation terminated.
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_i2c.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_i2c_ex.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_i2s.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_irda.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_iwdg.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_pcd.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_pcd_ex.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_pwr.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_pwr_ex.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_rcc.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_rcc_ex.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_rtc.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_rtc_ex.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_smartcard.o
*** [.pio/build/disco_f051r8/src/main.o] Error 1
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_smartcard_ex.o
================================================================================= [FAILED] Took 1.14 seconds =================================================================================
(penv) ruslanpavluchenko@Ruslans-MacBook-Pro-3 stm32cube-hal-blink %

Ah, Iā€™ve also just noticed that youā€™re not running the latest ST-STM32 platform version (youā€™re on 8.1.0 whereas the latest is 9.0.0 from 2 days ago). Please do a Platform Update via VSCode

Also it wouldnā€™t hurt to update to the most recent PlatformIO core version. Open a PlatformIO Core CLI, execute pio upgrade --dev, and restart VSCode after that.

If compiling after that doesnā€™t work Iā€™d kindly ask @manuelbl, who works on Mac, to try and comile the platform-ststm32/examples/stm32cube-hal-blink at develop Ā· platformio/platform-ststm32 Ā· GitHub project with a platformio.ini of

[env:disco_f051r8]
platform = ststm32
framework = stm32cube
board = disco_f051r8
debug_tool = stlink
upload_protocol = stlink
build_flags = -DF1=1

and see if he runs into the same header file not found error.

EDIT: Above platformio.ini is bullshit because itā€™s activating -DF1 series macro for a F0 chip.