I'm developing a fixture tool to test a custom PCB with ST Bluenrg1 (STM32 M0 core + bluetooth).

This fixture tool has its own MCU working at 5V.

I would like to flash automatically first previous to test the pins of the board, but I'm looking for a best solution to do this without spending 600 EURO in a "Flasher ARM" (which allows stand-alone flashing via hand-shake protocol).

The idea is to use the MCU of the testing tool to ask the Flasher to start the upload of the firmware, and answer to the Testing Tool if it has been done correctly or not.

I'm checking options with raspberry + OpenODC, raspberry + usb STlinkv2, looking for flashers with stand-alone mode... but I'm getting a little bit confused with the best option (best option with relativelly low cost).

Which solutions do you use when want to program your MCUs without computer?

UPDATED: I’m using SWD protocol to program it with a computer and a STLINKv2 programmer. I do it by hand, previous to test the connections in the testing fixture tool. I would like to include this programming step in the Testing fixture tool, and make it as simple as possible, as this will be done in the warehouse by other people (the idea is the testing tool to upload first the code and if everything is Ok, test the connections)

the testing fixture tool looks like this

  • 1
    \$\begingroup\$ each mcu has its own solution(s) so you pick from those. a cortex-m0 core means that swd is certainly available and there are various very low cost solutions there. including sometimes built in bootloaders with their own protocols. An ftdi breakout board with mpsse can with the right software program any of these protocols that dont involve different voltage levels. and those can be had for $15 full retail. There is no reason to be paying more than that to program/develop on a cortex-m. the stlinks are $10. jlink clones $5 and so on. \$\endgroup\$
    – old_timer
    Commented Dec 16, 2019 at 12:59
  • \$\begingroup\$ there is no such thing as "best", its all relative. My best, his best, her best may not be the best one for you. Depends on your setup which there isnt enough space here for you to describe. You read the datasheet/documentation for the part in question and choose the option if only one or one of the options if more than one. Or use a different part. \$\endgroup\$
    – old_timer
    Commented Dec 16, 2019 at 13:01
  • \$\begingroup\$ I design with this in mind st.com/en/development-tools/st-link-v2.html \$\endgroup\$ Commented Dec 16, 2019 at 13:42
  • \$\begingroup\$ Pi gpio to SWD works with openocd, may not be electrically robust but spares are cheap. Any embedded Linux system could typically host a USB SWD just make sure (with a scope) it can actually drive NRST. You would not want your tool to be based on an MCU alone as the other part of this is typically record keeping. \$\endgroup\$ Commented Dec 16, 2019 at 15:17
  • \$\begingroup\$ Your edit only reiterates what was already true: the component pieces are the same as your current PC setup, what you need is to find a smaller system that can do the PC's job and give it a simple user interface like a small monitor, a button to push, a good/bad indicator, generate whatever serial number sticker / unique signed certificate / general output you require, etc - this is really not an MCU job, though you might end up needing an MCU as a delegate to do some particular task on behalf of a larger system. \$\endgroup\$ Commented Dec 16, 2019 at 20:25

2 Answers 2


You're looking for a bootloader. Luckily the Bluenrg series comes with bootloader developed by ST. You can refer to AN4872 for the details.

From the document

The BlueNRG-1 and BlueNRG-2 bootloader is activated by hardware forcing high DIO7 at device reset.

Take care that the Bluenrg is a 3.3V MCU (If I remember correctly), you may need to additional hardware changes.

  • \$\begingroup\$ You can also get a production programer which stores the code in itself rather than needs to connect to a PC but $$$ \$\endgroup\$
    – DKNguyen
    Commented Dec 16, 2019 at 3:28
  • \$\begingroup\$ No. This is a place for SWD as the question asks, not a bootloader \$\endgroup\$ Commented Dec 16, 2019 at 15:16
  • 1
    \$\begingroup\$ @ChrisStratton I disagree,The question isn't about SWD. As far as I understand a bootloader is perfectly suited for OP's need. \$\endgroup\$
    – Anubhav
    Commented Dec 17, 2019 at 8:40
  • \$\begingroup\$ I'd contend that a bootloader is perfectly suited as well. You could feasibly store the entire application in memory of a 'flashing' mcu, which just deploys it using the ST bootloader, and verify the result with the bootloader checksum option. ST's bootloaders are very lightweight and fairly straightforward to implement. \$\endgroup\$
    – Ocanath
    Commented May 18, 2022 at 14:54
  • \$\begingroup\$ bootloader is the way to go here , hell its the textbook use case, to program a device in the field. Yeah the raspberry pi solution is fun but one mcu talking to another mcu's bootloaders sending it the new firmware through uart/spi etc... is the faster cleaner way in my opinion. \$\endgroup\$ Commented Aug 14, 2022 at 20:15

I'm also doing the same, using a raspberry (but PC linux will work as well), a st-link v2 clone, and a bash script:

pass the bin file to the script, it downloads the firmware to be programmed from a server, then:

  1. use st-info to know if a target MCU is connected, if so
  2. try to program (with mass erase, if needed)
  3. secure the device
  4. use st-info to know when the target MCU is disconnected

It uses a buzzer (with oscillator) connected to raspberry GPIO to emit error alerts or notify the successful programming.

The script can be freely download from https://docs.creasol.it/progstm32

What it does not work is the reset: at the end of device securing, the st-link v2 clone sends an hardware reset (through NRST) followed by some SWD commands that do not permit to make firmware starting (for automatic testing after programming). This should be an issue of the st-link v2 dongle.

If "firmware starting after programming" is not needed, this solution works very well, expecially because it downloads automatically the new version of firmware to be programmed (very useful for the assembling factory).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.