SPL with STM32VLDISCOVERY

Seems like no drivers or wrong drivers installed the ST-Link V1. When you download Zadig (https://zadig.akeo.ie/), and go Options → Show All Devices, what drivers does it show for the ST-Link? (There may be multiple interfaces).

Zadig output:
image

Should i replace the driver?

Tha’s the USB storage device. Is that the only ST-Link device in the list?

yep. cant find any other st-link device

Then try changing the driver to WinUSB or libusb-win32 if that doesn’t work.

If OpenOCD recognizes none of it, you can still uninstall these drivers in the Windows device manager to go back t othe USBSTOR driver.

I changed the driver to WinUSB.
I checked verbose upload again and the output is:

Processing disco_f100rb (platform: ststm32; board: disco_f100rb; framework: spl; build_flags: -DSTM32F10X_MD)
--------------------------------------------------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/disco_f100rb.html
PLATFORM: ST STM32 (17.5.0) > ST STM32VLDISCOVERY
HARDWARE: STM32F100RBT6 24MHz, 8KB RAM, 128KB Flash
DEBUG: Current (stlink) On-board (stlink) External (blackmagic, cmsis-dap, jlink)
PACKAGES:
 - framework-spl @ 2.10202.0+sha.5c2d987 (git+https://github.com/maxgerhardt/pio-framework-spl-stm32.git)
 - tool-dfuutil @ 1.11.0
 - tool-dfuutil-arduino @ 1.11.0
 - tool-openocd @ 3.1200.0 (12.0)
 - tool-stm32duino @ 1.0.2
 - toolchain-gccarmnoneeabi @ 1.70201.0 (7.2.1)
Warning! Cannot find a linker script for the required board! Firmware will be linked with a default linker script!        
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
MethodWrapper(["checkprogsize"], [".pio\build\disco_f100rb\firmware.elf"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.0% (used 0 bytes from 8192 bytes)
Flash: [          ]   0.2% (used 316 bytes from 131072 bytes)
.pio\build\disco_f100rb\firmware.elf  :

section             size        addr

.isr_vector          484   134217728

.text                316   134218212

.rodata                0   134218528

.data                  0   536870912

.bss                   0   536870912

._user_heap_stack   1536   536870912

.ARM.attributes       49           0

.comment             126           0

Total               2511
<lambda>(["upload"], [".pio\build\disco_f100rb\firmware.elf"])
AVAILABLE: blackmagic, cmsis-dap, jlink, stlink
CURRENT: upload_protocol = stlink
openocd -d2 -s C:\Users\25sha\.platformio\packages\tool-openocd/openocd/scripts -f interface/stlink.cfg -c "transport select hla_swd" -f target/stm32f1x.cfg -c "program {.pio\build\disco_f100rb\firmware.elf}  verify reset; shutdown;"
xPack Open On-Chip Debugger 0.12.0-01004-g9ea7f3d64-dirty (2023-01-30-15:04)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
debug_level: 2

hla_swd
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD     
Info : clock speed 1000 kHz
Info : STLINK V1J13S0 (API v2) VID:PID 0483:3744
Error: SRST error
Info : [stm32f1x.cpu] Cortex-M3 r1p1 processor detected
Info : [stm32f1x.cpu] target has 6 breakpoints, 4 watchpoints
Info : starting gdb server for stm32f1x.cpu on 3333
Info : Listening on port 3333 for gdb connections
[stm32f1x.cpu] halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08000b4c msp: 0x20000400
** Programming Started **
Info : device id = 0x10016420
Info : flash size = 128 KiB
Warn : Adding extra erase range, 0x08000320 .. 0x080003ff
** Programming Finished **
** Verify Started **
** Verified OK **
** Resetting Target **
shutdown command invoked
============================================== [SUCCESS] Took 1.61 seconds ==============================================

Now ST-LINK utility dont recognize the device…

Although the upload said success there are still few errors there that i’m not sure made the upload really successfull…

The upload looks okay. Not sure about the SRST erro but the device is recognize properly.

Maybe upload a blink LED bode? The user manual says

LD3: Green LED LD3 labeled PC9 is connected to the I/O PC9 of STM32F100RBT6B.
LD4: Blue LED LD4 labeled PC8 is connected to the I/O PC8 of STM32F100RBT6B.

So a code like (updated)

#include <stm32f10x_gpio.h>
#include <stm32f10x_rcc.h>
#define LEDPORT (GPIOC)
#define LEDPIN (GPIO_Pin_9)
#define ENABLE_GPIO_CLOCK (RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE))

/* timing is not guaranteed :) */
void simple_delay(uint32_t us)
{
    /* simple delay loop */
    while (us--) {
        asm volatile ("nop");
    }
}

/* system entry point */
int main(void)
{
    /* gpio init struct */
    GPIO_InitTypeDef gpio;
    /* reset rcc */
    RCC_DeInit();
    /* enable clock GPIO */
    ENABLE_GPIO_CLOCK;
    /* use LED pin */
    gpio.GPIO_Pin = LEDPIN;
    /* mode: output push pull */
    gpio.GPIO_Mode = GPIO_Mode_Out_PP;
    gpio.GPIO_Speed = GPIO_Speed_2MHz;
    /* apply configuration */
    GPIO_Init(LEDPORT, &gpio);
    /* main program loop */
    for (;;) {
        /* set led on */
        GPIO_SetBits(LEDPORT, LEDPIN);
        /* delay */
        simple_delay(100000);
        /* clear led */
        GPIO_ResetBits(LEDPORT, LEDPIN);
        /* delay */
        simple_delay(100000);
    }

    /* never reached */
    return 0;
}

There also seems to be an issue with the selected startup file when using the regular platform and framework = spl. I’ve corrected these issues in a custom platform fork and created the example project https://github.com/maxgerhardt/pio-stm32vldiscovery.

(Not needed if you want to program it with e.g. Arduino or STM32Cube).

The change is only in the platform under the platform.ini file?

Yes, because that contains all the fixes for the SPL version update, the core: "stm32", deriving the right STM32F1XX_MD_VL macro and selecting the right startup assembly file.

Is there any need to change tha build_flags = -DSTM32F10X_MD?

I tried to upload the suggested code to the board and I received an error:

In file included from C:\Users\25sha\.platformio\packages\framework-spl\stm32\spl\variants\stm32f1\inc/stm32f10x_can.h:31:0,
                 from C:\Users\25sha\.platformio\packages\framework-spl\stm32\spl\variants\stm32f1\src\stm32f10x_can.c:22:
C:\Users\25sha\.platformio\packages\framework-spl\stm32\cmsis\variants\stm32f1/stm32f10x.h:275:3: error: expected ',' or '}' before 'ADC1_IRQn'
   ADC1_IRQn                   = 18,     /*!< ADC1 global Interrupt                                */
   ^~~~~~~~~
In file included from C:\Users\25sha\.platformio\packages\framework-spl\stm32\spl\variants\stm32f1\inc/stm32f10x_gpio.h:31:0,
                 from src\main.c:1:
C:\Users\25sha\.platformio\packages\framework-spl\stm32\cmsis\variants\stm32f1/stm32f10x.h:275:3: error: expected ',' or '}' before 'ADC1_IRQn'
   ADC1_IRQn                   = 18,     /*!< ADC1 global Interrupt                                */
   ^~~~~~~~~
In file included from C:\Users\25sha\.platformio\packages\framework-spl\stm32\spl\variants\stm32f1\inc/stm32f10x_bkp.h:31:0,
                 from C:\Users\25sha\.platformio\packages\framework-spl\stm32\spl\variants\stm32f1\src\stm32f10x_bkp.c:22:
C:\Users\25sha\.platformio\packages\framework-spl\stm32\cmsis\variants\stm32f1/stm32f10x.h:275:3: error: expected ',' or '}' before 'ADC1_IRQn'
   ADC1_IRQn                   = 18,     /*!< ADC1 global Interrupt                                */
   ^~~~~~~~~
In file included from C:\Users\25sha\.platformio\packages\framework-spl\stm32\cmsis\variants\stm32f1\system_stm32f10x.c:64:0:
C:\Users\25sha\.platformio\packages\framework-spl\stm32\cmsis\variants\stm32f1\stm32f10x.h:275:3: error: expected ',' or '}' before 'ADC1_IRQn'
   ADC1_IRQn                   = 18,     /*!< ADC1 global Interrupt                                */
   ^~~~~~~~~
In file included from C:\Users\25sha\.platformio\packages\framework-spl\stm32\spl\variants\stm32f1\inc/misc.h:31:0,
                 from C:\Users\25sha\.platformio\packages\framework-spl\stm32\spl\variants\stm32f1\src\misc.c:23:
C:\Users\25sha\.platformio\packages\framework-spl\stm32\cmsis\variants\stm32f1/stm32f10x.h:275:3: error: expected ',' or '}' before 'ADC1_IRQn'
   ADC1_IRQn                   = 18,     /*!< ADC1 global Interrupt                                */
   ^~~~~~~~~
In file included from C:\Users\25sha\.platformio\packages\framework-spl\stm32\spl\variants\stm32f1\inc/stm32f10x_adc.h:31:0,
                 from C:\Users\25sha\.platformio\packages\framework-spl\stm32\spl\variants\stm32f1\src\stm32f10x_adc.c:22:
C:\Users\25sha\.platformio\packages\framework-spl\stm32\cmsis\variants\stm32f1/stm32f10x.h:275:3: error: expected ',' or '}' before 'ADC1_IRQn'
   ADC1_IRQn                   = 18,     /*!< ADC1 global Interrupt                                */
   ^~~~~~~~~
*** [.pio\build\disco_f100rb\FrameworkSPL\stm32f10x_bkp.o] Error 1
*** [.pio\build\disco_f100rb\FrameworkCMSISVariant\system_stm32f10x.o] Error 1
*** [.pio\build\disco_f100rb\FrameworkSPL\misc.o] Error 1
*** [.pio\build\disco_f100rb\src\main.o] Error 1
*** [.pio\build\disco_f100rb\FrameworkSPL\stm32f10x_adc.o] Error 1
*** [.pio\build\disco_f100rb\FrameworkSPL\stm32f10x_can.o] Error 1
==================================== [FAILED] Took 4.68 seconds ====================================

I opened the stm32f10x.h file and I cant find the reason for the error. doesnt seems like there’s something missing

This works perfectly fine for me on Windows. Please delete C:\Users\25sha\.platformio\packages\framework-spl and retry building.

Delete the whole C:\Users\25sha\.platformio\ if needed. The fixed board definitions are already in the platform.

Managed to make it work. I needed to delete the build_flags declaration under platformio.ini

Thanks a lot.
Now I need to figure out how to debug this board

Since OpenOCD can already upload, it’s very likely that debugging works too already. Just hit the play button in the debug sidebar.

grafik

Debugging working too. Mananged to see into the registers and everything i needed.

Thanks a lot.