ST-link for MAC OS

Yes, I am doing it right now.

I deleted the STM32 framework and overloaded it with the platformio.
Next, pio update-dev then overloaded the platformio
And then pio run -t upload from the project folder

ruslanpavluchenko@Ruslans-MacBook-Pro-3 stm32cube-hal-blink % pio run -t upload
Processing disco_f051r8 (platform: ststm32; framework: stm32cube; board: disco_f051r8)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tool Manager: Installing platformio/tool-scons @ ~2.20501.7
Tool Manager: tool-scons @ 2.20501.191222 has been installed!
Tool Manager: Removing tool-scons @ 4.40001.0
Tool Manager: tool-scons @ 4.40001.0 has been removed!
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/disco_f051r8.html
PLATFORM: ST STM32 (9.0.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
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal.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_adc.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_adc_ex.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_can.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_cec.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_comp.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_cortex.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_crc.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_crc_ex.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_dac.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_dac_ex.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_dma.o
/Users/ruslanpavluchenko/.platformio/packages/framework-stm32cube/f0/Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_crc.c: In function 'CRC_Handle_8':
/Users/ruslanpavluchenko/.platformio/packages/framework-stm32cube/f0/Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_crc.c:475:8: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
        *(uint16_t volatile*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4*i]<<8) | (uint32_t)pBuffer[4*i+1];
        ^
/Users/ruslanpavluchenko/.platformio/packages/framework-stm32cube/f0/Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_crc.c:479:8: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
        *(uint16_t volatile*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4*i]<<8) | (uint32_t)pBuffer[4*i+1];
        ^
/Users/ruslanpavluchenko/.platformio/packages/framework-stm32cube/f0/Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_crc.c: In function 'CRC_Handle_16':
/Users/ruslanpavluchenko/.platformio/packages/framework-stm32cube/f0/Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_crc.c:511:8: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
        *(uint16_t volatile*) (&hcrc->Instance->DR) = pBuffer[2*i]; 
        ^
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_flash.o
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_flash_ex.o
*** [.pio/build/disco_f051r8/src/main.o] Error 1
Compiling .pio/build/disco_f051r8/FrameworkHALDriver/Src/stm32f0xx_hal_gpio.o
================================================================================= [FAILED] Took 2.37 seconds =================================================================================
ruslanpavluchenko@Ruslans-MacBook-Pro-3 stm32cube-hal-blink %

I have STM32F100RBT6, the blink project was loaded on blue pill using ST-Link 2 without any problems,but it does not load on STM32F100RBT6 in the Arduino framework.

blue pill ini
[env:bluepill_f103c8]
platform = ststm32
board = bluepill_f103c8
framework = arduino
upload_protocol = stlink

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

/////////code//////////
#include <Arduino.h>

#ifndef LED_BUILTIN
#define LED_BUILTIN PC13
#endif

void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
}

void loop()
{
digitalWrite(LED_BUILTIN, HIGH);
delay(100);
digitalWrite(LED_BUILTIN, LOW);
delay(100);
}

I donā€™t understand anything anymore, I loaded blink into blue pill several times and just played with blink speed, but now I tried to load blink into blue pills again, I didnā€™t change the settings, but hereā€™s what I got.

Loadings .PIO/build/bluepill_f103c8 / 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
To receive bug reports, read
http://openocd.org/doc/doxygen/bugs.html
debug_level: 1

hla_swd
no single

Error: open failed
in the ā€œprogramā€ procedure"
** OpenOCD initialization error * *
shutdown command called

5min later:)))
OH, MIRACLE! I disconnected the USB type C adapter from my Mac, waited for a while and turned it on, now the firmware is working again.

another 15 minutes later
, I checked both boards, blue pill really perfectly receives data on ST-Link in the Arduino framework, but STM32F100RBT6 does not want to react to my efforts.
At the same time this ini also works in the CUBE framework
[env:bluepill_f103c8]
platform = ststm32
board = bluepill_f103c8
framework = stm32cube
upload_protocol = stlink
build_flags = -DF1

True, the change to #define LED_PIN GPIO_PIN_13 did not lead to the led blink, but it is possible that the pins are marked differently, but this is not in this topic.

Iā€™m still confused regarding the boards and chips you have. You mention a Blue Pill (STM32F103C8), Discovery board with STM32F100RBT6 and in platfromio.ini you also have declared a Discovery board with a STM32F051R8.

STM32F100RBT6

If you have an STM32F100RBT6, then itā€™s missing in the platformio.ini that you have post two posts ago.

I can easily get an Arduino blink sketch to compile if the board is set to disco_f100rb with this configuration:

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

STM32F041R8

If you have a STM32F051RB, then you have to resort to STM32Cube (HAL).

Given this platformio.ini configuration:

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

I can easily get your STM32Cube code to compile if I simplify the #include statements. Instead of all the #ifdef and #includes, I just use:

#include <stm32f0xx.h>

No need for any additional build settings.

Build Settings

Iā€™m not sure if the build setting -DF1 is really needed. In the above working examples, I didnā€™t need them and Iā€™ve nevr used them before.

If you really have an STM32F051R8 and the setting is needed, then itā€™s -DF0 as this chip is from the F0 family.

The combination of STM32F051R8 and -DF1 is certainly invalid.

1 Like

Iā€™ll try to put things in order.
I have three boards
1 STM32VLDISCOVERY (and all problems are associated with it)
2 STM32F103C8T6 (blue pill)
3 STM32F030F4P6
The 1st board is equipped with ST-link, has some peripherals on board in the form of buttons and LEDs, and I wanted to launch it.
I started the 2nd and 3rd boards without problems.

cube hall project ini file
STM32F103C8T6 (blue pill)

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

STM32F030F4P6

[env:demo_f030f4]
platform = ststm32
board = demo_f030f4
framework = stm32cube
upload_protocol = stlink
build_flags = -DF0

But the first STM32VLDISCOVERY board with stm32f100r8t6b chip does not work with this configs
1

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

2

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

My only assumption is that STM32VLDISCOVERY is broken, I took it from a friend, but it has not been used for several years and although the LEDs are on when the power is turned on, there may be some kind of gap with the ST-link, I do not see any other problems.

If you write me a config that should work 100%, I will check it. I have no more versions: (((

platformio.ini

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

----------CODE---------------

#if F0
#include "stm32f0xx_hal.h"
#elif F1
//#include "stm32f1xx_hal.h"
  #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_13
#define LED_PIN                                GPIO_PIN_9 
#define LED_GPIO_PORT                          GPIOC
#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(100);
  }
}

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){}

ā€¦

CURRENT: upload_protocol = stlink
Uploading .pio/build/disco_f051r8/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
        http://openocd.org/doc/doxygen/bugs.html
debug_level: 1

srst_only separate srst_nogate srst_open_drain connect_deassert_srst

in procedure 'program'
** OpenOCD init failed **
shutdown command invoked

*** [upload] Error 1

So if you want to work with the STM32VLDISCOVERY now then that has a STM32F100RB MCU and so you definitely need that config you already posted

What is the log when doing a ā€œUploadā€ with the STM32Cube project there?

If uploading still fails, can you install st-util as described on GitHub - stlink-org/stlink: Open source STM32 MCU programming toolset, open the stlink-gui program and try to connect to the chip there with the ā€œConnect with System software reset requestā€ setting?

Thanks for the help, but Iā€™ll do it differently. I will try to run this board where it already worked before, on my friendā€™s computer, and if it works there, I will continue my experiments. In the meantime, due to the fact that out of three boards work, and the third does not want to work, I can assume that something is wrong with this board.

If you havenā€™t completely given up on the STM32VLDISCOVERY yet: Check the jumpers. The board might have been reconfigured to be used as an ST-Link for an MCU on another board.

1 Like

I did not refuse and this board seems interesting to me as a sandbox, but the jumpers is the first thing I checked. But apparently there is something wrong with the board. The Chinese ST-link has been detected and updated with the standard ST-link-007 Mac app(STLinkUpgrade.jar) and this board has not been found. Unfortunately :(((
I am very grateful for your help, because if not for this, I would have wandered in the dark for a long time and did not understand what to do.