0
\$\begingroup\$

I am designing a PCB using an STM32 MCU to control a motor. My main concern is being able to use STM32CUBE IDE or the Arduino IDE to program the board. I don't want to spend a lot of money on a JTAG board or on the ST-Link since it would double my project costs. My plan was to use this USB-UART converter to program the STM32 through its UART pins. (https://www.digikey.com/en/products/detail/ftdi-future-technology-devices-international-ltd/FT231XS-R/3029139)

I would then connect that to a USB header that I could plug into my PC with.

Are there any glaring issues with this approach? I'm not concerned about debugging since the software is very simple and an oscilloscope will tell me what I need to know.

\$\endgroup\$
5
  • 3
    \$\begingroup\$ You never said which STM32 model. Depending on model, it might support flashing via USB directly. Also, a genuine ST-Link is only about 20 USD or 20 EUR. Because it allows you to debug over JTAG and SWD, it is well worth having one when developing the firmware. \$\endgroup\$
    – Justme
    Commented Mar 29 at 15:32
  • 2
    \$\begingroup\$ The ST-Link will save you a lot of time. Is your time really that cheap? \$\endgroup\$
    – kkrambo
    Commented Mar 30 at 16:09
  • \$\begingroup\$ As the firmware aspect of it is not very involved. There is little to no debugging that I foresee with this project. I guess I can buy the STlink, I am just trying to keep my BOM as small as I can \$\endgroup\$
    – Cqllysto
    Commented Mar 30 at 18:32
  • 2
    \$\begingroup\$ The ST-Link can be external to your board and reused from board to board (and project to project). I don't understand why you would include it on your BOM. You should only need to add a Cortex debug connector to your BOM, for connecting the ST-Link to the board. In your USB-UART design, would you be putting the FTDI chip and a USB connector on your board? Doesn't that result in a larger BOM? \$\endgroup\$
    – kkrambo
    Commented Mar 31 at 10:19
  • \$\begingroup\$ A genuine ST-LinkV2 is a one-off $25 development cost (not a BOM line-item). Knock-offs can be had for $10. Although recommendations are off-topic, for more professional use and many different MCUs, you can't go wrong with a Segger J-Link. \$\endgroup\$
    – brhans
    Commented Sep 21 at 20:27

1 Answer 1

1
\$\begingroup\$

Normally you do not program MCUs through on-board circuitry at all; that's an evaluation board thing for rapid testing. Placing such circuits on the board itself will bloat the BoM, making it expensive. To cheap out on the actual USB debugger by adding more parts to the PCB instead is senseless.

For Cortex M, there are a few sensible options:

  • Standard SWD connectors, male 2x5 1.27mm (0.05''). Program through an in-circuit debugger.These have the advantages of being cheap and standard.

    The down-side is that 1.27mm IDC connectors on ribbon cable are trash. They are trash for debugging and they are extra trash for production purposes. The problem is that the IDC connection itself tends to take a lot of strain when you disconnect it while pulling on the ribbon cable (you shouldn't remove it like that, but everyone does). When they fail, they fail in subtle ways.

  • Standard JTAG connectors, classic double-row header strips, male 2x10 2,54mm (0.1''). Program through an in-circuit debugger. Very cheap and standard.

    These are more rugged than the 1.27mm ones. However, they take up ridiculous amounts of board space.

  • Custom connector. Use whatever suits the product best and adapt cable assemblies. "Card edge" for example, is one way to skip the need for soldered connectors on the PCBA, but they also take quite a bit of space.

  • Buy MCUs pre-programmed. This is the most cost-efficient option if you have high volumes and are comfortable with providing the executable to a contractor. You probably still want the option to attach a debugger though, so maybe still leave room for a SWD connector even if you don't have it mounted.

Please note that you shouldn't be using some programming IDE in production. The chances of messing up increase and you really don't want the production crew having full access to the source. Not necessarily a trust issue, but more like introducing a huge potential for goof-ups: suppose someone downloads the debug build instead of the release build by accident etc.

Instead, the executable should be provided in one of the standard formats: bin/hex/s19 etc. Just to be downloaded through whatever program your USB adapter fancies.

As for which in-circuit debugger to pick, there's lots (and product recommendations is off-topic). But consider if you wish to use it for debugging only, debugging + production or for production only. Someone mentioned ST-Link - also consider if a specific brand is good enough or if you wish to use the debugger in future projects also, where you do not necessarily intend to use an ST part. ST-Link probably won't let you do that.

\$\endgroup\$

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.