0

I have a microcontroller STM32F051 and I want to program it. I looked for IDE that I would be able to use and I found TRUESTUDIO that I'm using. I wanted to know how should I do to send the program I made into the microcontroller. Do I need any specific programmer (like an electronic device for Microchip Pics) ? When I clic the button debug, I get an error "Error in initializing ST-Link device. Reason: Failed to connect to device. Please check power and cabling to target." I'm not sure if I misunderstood something. I download the software and I selected my specific version of microcontroller, but it seems that it doesn't recognize it...

user54517
  • 2,020
  • 5
  • 30
  • 47
  • 1
    Is your microcontroller on a board? Is it a Discovery Kit eval board? – kkrambo Apr 20 '17 at 17:17
  • A couple of things to try. In the debugger setup ensure you have the interface set to SWI and not JTAG. Also make sure you have the correct version of ST-Link set. I think there two options (although this should probably autodetect), one for older ST-Links without comm ports and one for the newer embed enabled. Also check the jumpers on the dev board are setup correctly. – Realtime Rik Apr 21 '17 at 06:49
  • I checked everything, the interface is set to SWI, I got the correct version of ST-link and jumpers are setup correctly. For information, my microcontroller is on a bord, it is the STM32FO-Discovery board – user54517 Apr 22 '17 at 13:54

1 Answers1

0

Yes, no matter what the mcu you will need some interface, be it as simple as a usb connector tied to the chip, or a debug header using some other device or electronics. For an stm32 chip many of the discovery boards and the nucleo boards (in particular the ones with a breakaway end, you dont have to break it off, just remove some jumpers to use it on other devices (not necessarily ST devices)). These parts also have a serial bootloader inside that you cant change so it is always there, and can sometimes use one of the nucleo stlink debuggers (do some research as to ones that offer a virtual uart, not all of them do, cheaper than the dedicated stlink dongles) or say an ftdi usb breakout board (under $2 on ebay).

There are numerous options for programming these parts as in writing software, can just use gnu tools and roll your own drivers (pretty easy the documentation is pretty good), get one of the ST libraries that they offer (for free) or if you have a Nucleo you might be able to use mbed or arduino to develop.

We really need to know more about the board you have this part on, is it just a breakout board or as asked in the comments did you buy a nucleo board or a discovery board? Are you running linux, windows or mac or other or are flexible on what host?

old_timer
  • 69,149
  • 8
  • 89
  • 168
  • If a nucleo board, and I recommend getting one or a few they start at like $10. to "program" the flash on the board you drag and drop your binary file on the virtual file system (appears like thumb/flash drive when you plug the board in). and thats it.. – old_timer Apr 20 '17 at 20:11
  • If I remember correctly using Atollic Truestudio you can easily program and debug using the built in ST-Link on the Nucleo and Discovery boards. You can also do this using an straight Eclipse / GCC setup however it is a little bit harder as you have to setup OpenOCD which can be a pain. IAR and Kiel will work off the shelf with ST-Link – Realtime Rik Apr 21 '17 at 06:46
  • I find openocd to be pretty easy esp with the stlink, ymmv...Yes it can be a pain in general depending on the target/interface. – old_timer Apr 21 '17 at 07:50
  • I have the STM32F0-Discovery board, and I'm on Windows10. I tried Mbed, it seems to be really easy to program with Mbed, but it's said that I have to drag and drop the binary file downloaded to the board. But when I plug the microcontroller into my computer, it is not recognized as a device when I go on "Computer". I don't have access to the board as I would have for a usb key. – user54517 Apr 22 '17 at 14:00
  • hmm, search for stlink firmware update at ST and try that tool, perhaps you just need a firmware update for windows to recognize it. Otherwise you may have to come in via openocd or the serial bootloader... – old_timer Apr 22 '17 at 14:16