Skip to main content
Visitor II
March 10, 2021
Question

Exchange data between microcontroller / C# programm and flash with same connection

  • March 10, 2021
  • 3 replies
  • 2504 views

Hi,

I have a question about STM32G4. I want to exchange data between microcontroller and a C# programm (by usb) on windows. But, sometimes I want to upgrade the program in the microcontroller with this same connection (usb)

How I can do this ? I need to integrate STLINK to the board and exchange data with it ?

Thanks !

    This topic has been closed for replies.

    3 replies

    Super User
    March 10, 2021

    For flash updates in-the-field, you can use USB DFU protocol and don't need ST-LINK. This can be done in addition to "normal" USB function like CDC (serial port), MSC and so on. If you also want to be able to debug or update your devices in the lab, you may attach pins/header for ST-LINK interface as well, like for the ST-LINK V3 SET or MINI.

    hth

    KnarfB

    KMiko.1Author
    Visitor II
    March 10, 2021

    Ok so, If I understand I add to my board the st link interface, I can send data (hex) via USB with normal USB function (CDC) and if i want to update via windows terminak I can also ?

    Graduate II
    March 10, 2021

    DFU, CDC or MSC methods just require a USB connection to the STM32 and USB Device implementation on the Target.

    An ST-LINK is only needed for debug connectivity and perhaps initial production programming ​

    KMiko.1Author
    Visitor II
    March 10, 2021

    Oh great ! So, i flash my program with an stlink for the first time and after I use an USB connection for exchange data (CDC) and update firmware (DFU) ?

    What I need to do this ? I'm searching for CDC function for exchange data, but for the DFU update ? I can do this with terminal command and just the firmware file ?

    thanks !

    ST Employee
    March 17, 2021

    Hello KMiko.1 (Community Member),

    The device contains embedded bootloader which can be used on each device to write firmware to the Flash. Embedded bootloader can use various interfaces to connect to device: USB, USART, SPI, I2C. To activate the bootloader - there depends from BOOT0, BOOT1 option bytes (see reference manual RM0440) and then restart the device. And please read application note about STM32 bootloaders: AN2606.

    Regards

    Igor