8 years, 9 months ago.

STM32F3-Discovery or STM32F4-Discovery as mbed platform

Are there plans to extend the support to other boards STM32F3-Discovery or STM32F4-Discovery?

Question relating to:

The 32L0538DISCOVERY board helps you to discover the ultra-low-power microcontrollers of the STM32 L0 series.

On Ubuntu 14.04 with stlink installed, I was able to upload Seed Arch Max .bin's with

st-flash write ../disco_test_ARCH_MAX.bin 0x8000000

to get terminal in/out I had to add USBDevice library and include USBSerial.h for printf's

posted by tom dunigan 25 Apr 2016

2 Answers

8 years, 9 months ago.

The 32L0538DISCOVERY can fully support mbed because it has the ST-LINK/V2-1 interface hardware for drag&drop flashing and USB-Serial conversion. This board is of more recent date than most other Discovery boards which use the ST-LINK/V2 hardware. The nucleo boards all use the new ST-LINK/V2-1. The main difference between the old and the new ST-LINK is that the newer version uses an ST32F103CB (128K flash) and the older one has the ST32F103C8 (64K flash). The mbed drag&drop code probably does not fit in the smaller memory. When you run the ST-Link firmware upgrade tool it refuses to update the code to V2J24M11 and uses V2J23S0 instead.

However, you can use the free STM32 ST-Link utility to flash the discovery device with code produced by the online mbed compiler: Select an mbed (nucleo) platform that uses ''the same'' ST32 processor as on your discovery board, compile the code and save on your local harddisk. Then run the ST-Link utility to open the bin file and flash it on the discovery. Press reset and go.

The USB-Serial converter is not available on the ST-LINK/V2 disco and you need to use an external one (eg FT232 based).

Alternatively you can also disconnect the onboard ST-Link/V2 programming connections (SWDIO, SWCLK etc) and use an ST-LINK/V2-1 from a nucleo board. In that case you can have drag&drop support again and you can also connect the serial port from the discovery board to the external nucleo programmer. You will have to place or remove some jumpers/solderbridges. See schematics.

The procedure above worked for the STM32F0308 disco (select the F030 nucleo platform) and for the STM32F407 disco (select the Seeed Arch Max platform). Note that for the F407 you cant use the full 1M flash but only get 512K. It will not work for all disco platforms since some processor types (nr of portpins, peripherals, memory) are not supported by the online compiler.

The mbed library source code has already been extended for several of the Discovery boards. Unfortunately you can not use those extensions straight away in the online compiler. First option is to export the code for use with a local GCC, Keil etc compiler. Second option is to import the full mbed library source code in your online project and manually move some of the discovery code to the folder intended for an online supported nucleo board (eg /targets/hal/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303RE). That worked for the ST32F303VC disco board code which could be compiled when selecting the F303RE nucleo platform. Be aware of some limitations due to differences in memory size.

Here is some simple code that was compiled for the Arch Max platform and then runs on the F407 disco.

#include "mbed.h"
   
Ticker toggle_led_ticker;

//Four user LEDs, LD3 (orange), LD4 (green), LD5 (red) and LD6 (blue)
DigitalOut led3(PD_13);
DigitalOut led4(PD_12);
DigitalOut led5(PD_14);
DigitalOut led6(PD_15);

DigitalIn button(PA_0);

void toggle_led() {
  int tmp;

  tmp  = led3;
  led3 = led4;              
  led4 = led6;  
  led6 = led5;
  led5 = tmp;
}

int main() {
  led3 = 1;
  led5 = 0;  
  led6 = 0;                
  led4 = 0;

    
  // Init the ticker with the address of the function (toggle_led) to be attached and the interval (500 ms)
  toggle_led_ticker.attach(&toggle_led, 0.5);

  while (true) {
    // Do other things...
  }
}

Accepted Answer

I selected the NUCLEO-F030R8 platform for my STM32F0308-DISCOVERY platform, then compiled the code above with some adjustments for the LED pin, compiled it, saved it on the desktop, connected ST-Link utility to the Discovery platform, loaded thecode,disconnected ST-Link utility from the platform, pressed the reset button and tada : finally the led blinked ! Thanks

posted by -deleted- 04 Jul 2015

Hi there, I own a stm32f3 discovery (based on stm32f303vc6 mcu) and it already has stlink v2 so may it will be a good thing to add ot to mbed platforms. Any idea where port mapping should be written? The LEDs are on PortE which is not available on 303RE. Thanks

posted by Romeo B 15 Nov 2015

You can add port E by modifying the following file in mbed src: targets\hal\TARGET_STM\TARGET_STM32F3\TARGET_NUCLEO_F303RE\PortNames.h

#ifndef MBED_PORTNAMES_H
#define MBED_PORTNAMES_H

#ifdef __cplusplus
extern "C" {
#endif

typedef enum {
    PortA = 0,
    PortB = 1,
    PortC = 2,
    PortD = 3,
    PortE = 4,
    PortF = 5
} PortName;

#ifdef __cplusplus
}
#endif
#endif

You can then use it in your code:

DigitalOut led3(PE_9);
DigitalOut led4(PE_8);

In some case you may also need to add features to PeripheralNames.h etc. I think the easiest way is to just copy all the header files from the TARGET_DISCO_F303VC subdir to TARGET_NUCLEO_F303RE

posted by Wim Huiskamp 18 Nov 2015
8 years, 9 months ago.

It would be nice to have this as a supported board. I have two. you cannot use the online compiler, but see this link.

https://groups.google.com/forum/#!topic/mbed-devel/CgqJaojhSmk