Debugging and/or flashing multiple microcontrollers - Page 1
Forum section: electronics / projects

author: Dr_Neoo
author_rank: Contributor
timestamp: February 26, 2020, 11:37:50 pm
content: Hello,I'm working on a system which will exsist of multiple microcontroller (STM32). The boards will not be easily accessible once installed and I have been considering different solution on how to program or debug each one after installation. Some of the ideas I have considered so far are:* Simply breaking out each SWD header to a connector and using this with an external debugger. Biggest downside is need for a large connector.* Using a bootloader via uart/can/usb. Downside is loosing debugger functionality and is not guranteed to reduce wiring.* Creating an internal PCB with an embedded usb hub and one ST-Link or similar debugger for every microcontroller in the system. Seems like the best solution but I'm unsure how running through a hub will affect the debuggers?The system is a one-off and will be used for development so cost isn't the main consern. The focus is getting something that can be integrated in a small space without large amount of time needed to develop it.How would you go about solving this? I'm sure there are a lot of possible solutions I have not considered so I look forward to hear your thoughts!

author: Prehistoricman
author_rank: Regular Contributor
timestamp: February 27, 2020, 01:13:18 am
content: How about having a tristate buffer on each micro that gets switched on when you want to talk to that specific micro? The enable signal can go via a shift register to achieve only 2 wires for n devices.

author: Scrts
author_rank: Frequent Contributor
timestamp: February 27, 2020, 04:09:27 pm
content: AFAIK normal JTAG requires a 10 pin header? Just route as a normal daisy chained JTAG going from TDI to TDO and routing TCK and TMS to each device...

author: SiliconWizard
author_rank: Super Contributor
timestamp: February 27, 2020, 04:18:40 pm
content: Quote from: Scrts on February 27, 2020, 04:09:27 pmThat would work for normal JTAG, but not for SWD. There is no easy way to daisy-chain SWD. But you can handle this with some extra logic.

author: Pack34
author_rank: Frequent Contributor
timestamp: February 27, 2020, 04:54:19 pm
content: Isn't this what bootloaders are for? Program through the UARTs and chain all of them together. Then when you doing a programming cycle, just target the one at the end of the chain and then work your way back.

author: Dr_Neoo
author_rank: Contributor
timestamp: February 28, 2020, 08:42:58 pm
content: Quote from: Scrts on February 27, 2020, 04:09:27 pmThanks for the suggestion. I have not worked with JTAG before and searched around a bit for daisy chained STM32 processors. Do you have any recommendations for good resources on the subject?

author: Doctorandus_P
author_rank: Super Contributor
timestamp: February 29, 2020, 08:07:05 am
content: JTAG is a standarised protocol just by many manufacturers of uC's FPGA's and other logic chips.If you're unfamiliar with JTAG, then start by reading a bit about JTAG itself to build up a bit of background.https://en.wikipedia.org/wiki/JTAG"External links" on the wikipedia page llinks to further tutorials.The JTAG protocol itself is standarised, but the way a programmer that uses it communicates with a PC is not.A long time ago I built an "Altera Byte Blaster". Back then it was a TTL chip on a breadboard with wires to the LPT port.There are many manufacturers of programmers that use JTAG, lots of them are proprietary, but open source variants also come to mind."Black magic probe" pops up in my mind, but I have no experience with it.ST sells ST-Link which does JTAG.

author: dmendesf
author_rank: Frequent Contributor
timestamp: February 29, 2020, 10:24:16 am
content: It's true that JTAG is daisy-chainable but check if your programmer has the capability to program/debug the Nth device in a chain ... My experience is that outside the world of FPGA programmers only very expensive and proprietary ones (designed for board level debugging) have this capability.

author: SiliconWizard
author_rank: Super Contributor
timestamp: February 29, 2020, 03:08:59 pm
content: Dang guys. AFAIK and as I said above, most STM32 MCUs (that I know of at least, maybe except some very old ones?) support SWD but not JTAG.

author: NiHaoMike
author_rank: Super Contributor
timestamp: February 29, 2020, 03:42:48 pm
content: How about use a mux controlled by an Arduino or similar to select which microcontroller is connected for debug?

author: prasimix
author_rank: Unknown
timestamp: February 29, 2020, 04:12:06 pm
content: Quote from: Dr_Neoo on February 26, 2020, 11:37:50 pmYou need just 3-pin connector for SWD, with 2 or 2.54 mm raster it is not so big or about 5 mm is too big in your case?

author: bson
author_rank: Unknown
timestamp: February 29, 2020, 07:20:29 pm
content: Quote from: Dr_Neoo on February 26, 2020, 11:37:50 pmThe 0.050" 10-pin connector used by STlink V3 is really quite small and easy to drop down just about anywhere.The connector that mates to the stock cable is aSamtec FTSH-105-01-L-DV-K(PDF datasheet).Another option is to useTag-Connect TC2030-NL, which needs only a footprint and requires nothing to be populated on the board. A legged version that grabs a pair of holes exists too (I've used both and they work well, but the legged one is preferable IMO during development as it's more secure). Slightly bigger, but also very easy to fit. Note that the cable ends in a 6 pin .1" IDC; an adapter board for STLink v3 is trivial.