9 years, 11 months ago.

Programming STM32 chips in custom application

I'm trying to do more homework before I go down the path of trying to embed a microcontroller directly into my own circuit design. I'm using Nucleo boards for prototyping, and they come with a break-off that contains the "ST-LINK/V2-1 debugger/programmer". That portion of the board contains more discreet components than the actual board hosting the microcontroller!

Does the ST-LINK portion handle the entire "drag and drop" programming capability of the board? IE it is what is acting like a USB drive when connected to a PC, etc.

If that is the case, what is the best way to handle on-board programming of the microcontroller? Can that be done through USB in a similar manner, or is that dependent on the ST-LINK support hardware?

If some kind of formal programmer is required, then I would most likely just use the ST-LINK board broken off a Nucleo board, as I read somewhere that it can act totally stand-alone.

Then the other question is future support and handling firmware upgrades. Can a microcontroller flash itself? If I have an SD slot, could my software watch for a specific file on an SD card, then have the microcontroller flash itself with that image? I think that is possible, because I saw an mbed project that automatically flashes the microcontroller with an image retrieved from the internet.

Thanks!

2 Answers

9 years, 11 months ago.

That should allow you to drag and drop program the new target MCU yes, assuming it is the same one, I don't think the drag and drop part is intended for other targets, but not sure about that.

Regarding the microcontroller flashing itself: Yes that is possible, it can program itself. However it is also far from trivial with many (potential) problems. The program you saw was on an LPC1768, which stored that image on its LocalFileSystem and then proceeded to reset itself, causing the interface chip to program it, it wasn't programming itself directly. That is possible, but as said, not straight forward.

Have you considered NXP microcontrollers? They have quite a line up where the MCU itself can appear as a drag and drop programming interface (so directly, with no interface MCU playing a role).

9 years, 11 months ago.

You can use the ST-LINK circuit on the Nucleo boards to in circuit program a micro-controller on your own board, but there is an easier way. Most of these micro-controllers can write to their own flash and you can add your own update code to allow for firmware updates, but for most of them you will need a programmer to load that code the first time and it may be possible to corrupt the firmware update code so that you need a tool like the ST-LINK to recover the code.

If you are looking for the simplest most robust way to do firmware updates, I recommend using one of the NXP LPC devices with the USB mass storage bootloader built into the ROM. This allows for drag and drop firmware updates without a separate chip and it cannot be corrupted because it is in Read Only Memory. This also allows you to build your board with blank parts and use the USB connector to install the firmware. Most of the newer NXP LPC devices include this bootloader in ROM, but the LPC1768 unfortunately does not. One way to see which parts include the bootloader is to look at the schematic for the NXP based platforms on the mbed site. They all have drag and drop programming, so if they do not have a second micro-controller for the firmware updates, that means the board uses the bootloader built into the part. Some of the platforms that take advantage of this are the Seeeduino Arch (not the Pro), the DipCortex boards, the TG-LPC11U35-501, and the mBuino board. I particularly like how the Seeeduino Arch board dual purposes the reset button so that a short pulse is a standard reset, and a long press resets the part into firmware update mode. I believe the LPC11U68 and LPC1549 also include the bootloader ROM, even though their boards also include the additional micro-controller.

I think the mBuino board demonstrates how simple it is to include firmware updates with the LPC devices.