Is SWD-only BMP practical, and on Low-pin-count STM32?

gbulmer
Posts: 67
Joined: Wed Sep 23, 2015 12:04 am
Location: UK

Is SWD-only BMP practical, and on Low-pin-count STM32?

Post by gbulmer » Mon May 09, 2016 11:21 am

I've been idly pondering making a small hardware debugger based on the Black Magic Probe code. (This is a longer term project)

The sorts of things I do don't really have space for a 0.1" pitch JTAG header, and the 'official' ARM 0.05" 10-pin seems a bit awkward to make cables. The 6 pin/5 signal Serial-Wire Debug-Port (SW-DP/SWD) is much more attractive.

Also, I use off-the-shelf development boards like ST-Discoveries and ST-Nucleos, which only have the 6 pin/5 signal SWD headers anyway. So a 10-pin JTAG seems pointless. Wiring up a 10-pin JTAG for a Maple Mini is less attractive than SWD too.

Q1. Can anyone tell me if a SWD only Black Magic probe is supported in the firmware and drivers, or must it be a 10 pin JTAG?

I am tempted to reflash the on-board ST-Link with BMP (and may do that), but the project I have in mind appears to be tidier with my own ourduino-mini and a separate compact debugger, something like the Black Magic probe mini. However, the mini isn't very DIY friendly, it uses quite small parts.

I looked at the Black Magic Probe mini schematic.

If the 10-pin JTAG interface were reduced to SWD, saving a couple of I/O pins, I think an STM32F in a 20pin TSSOP20 would have enough I/O to implement it. The 20pin TSSOP should be a bit easier to DIY than an LQFP. I think about unskilled beginners making stuff, so this is important.

I had been thinking of using an STM32F042, because it has 'crystal-less' USB, and is available in a TSSOP20.
However the STM32F070 seems to be a similarly low-cost including an 8MHz crystal, and is available in a TSSOP20.

There is a ready-made ST-Nucleo for both of them, so development shouldn't be too hard.

Q2. Has anyone any views on STM32F042 vs STM32F070 as a basis for a Black Magic Probe?

User avatar
Rick Kimball
Posts: 1014
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: Is SWD-only BMP practical, and on Low-pin-count STM32?

Post by Rick Kimball » Mon May 09, 2016 1:34 pm

I've only ever used the blue pill BMP as an SWD device with just 2 jumper wires and gnd. Not sure if those chips have enough flash though to hold all the code.
-rick

User avatar
Slammer
Posts: 246
Joined: Tue Mar 01, 2016 10:35 pm
Location: Athens, Greece

Re: Is SWD-only BMP practical, and on Low-pin-count STM32?

Post by Slammer » Mon May 09, 2016 2:11 pm

I avoid to use crystal-less MCUs for applications with serial/usb communications. The STM32F070F6 may be a candidate for BMP, it has 32KB Flash and 6KB RAM, I think that this is enough. I dont know however the work required to adapt the firmware to the new MCU.

User avatar
Rick Kimball
Posts: 1014
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: Is SWD-only BMP practical, and on Low-pin-count STM32?

Post by Rick Kimball » Mon May 09, 2016 2:48 pm

Slammer wrote:I avoid to use crystal-less MCUs for applications with serial/usb communications. The STM32F070F6 may be a candidate for BMP, it has 32KB Flash and 6KB RAM, I think that this is enough. I dont know however the work required to adapt the firmware to the new MCU.
I had looked at doing this before with an LPC1114FN28 (Cortex-M0 32KB FLASH/4KB RAM), I went through the code and removed all the logic required for JTAG and got rid of board support for chips I wasn't going to use. I used a UART instead of the USB code which actually made it smaller. Even after all that code slash and burn I couldn't get it to fit into 32KB. Any Cortex-M0 chip is going to use more code to do the same amount of work as an M3.

With all the features for both JTAG and SWD it is still fairly small but not small enough for 32KB:

Code: Select all

$ arm-none-eabi-size blackmagic
   text	   data	    bss	    dec	    hex	filename
  53452	    168	   2132	  55752	   d9c8	blackmagic
I changed the compiler option to use cortex-m0 instead of m3 and recompiled. You can see it is a couple KB larger:

Code: Select all

$ arm-none-eabi-size blackmagic
   text	   data	    bss	    dec	    hex	filename
  55572	    168	   2132	  57872	   e210	blackmagic
-rick

User avatar
Slammer
Posts: 246
Joined: Tue Mar 01, 2016 10:35 pm
Location: Athens, Greece

Re: Is SWD-only BMP practical, and on Low-pin-count STM32?

Post by Slammer » Mon May 09, 2016 11:59 pm

Thanks for the info Rick.
So, the F103C8T6 is the minimum requirement.
Anyway I cant see a reason not to use this MCU, the price is minimal and the soldering is not so difficult, and most of all, it is possible to use the blue/red pill directly, or on a small PCB.... nothing is more cost effective.

gbulmer
Posts: 67
Joined: Wed Sep 23, 2015 12:04 am
Location: UK

Re: Is SWD-only BMP practical, and on Low-pin-count STM32?

Post by gbulmer » Tue May 10, 2016 4:50 pm

Rick Kimball wrote:I've only ever used the blue pill BMP as an SWD device with just 2 jumper wires and gnd. ...
Thank you.
So BMP doesn't 'need' any other JTAG signals connected.
Rick Kimball wrote:... Not sure if those chips have enough flash though to hold all the code.
Argh! Yes, forgot about that. The TSSOP20 parts are more limited than in other packages. It's the same for STM32F042. Maybe I am back to the LQFP48 :-(

How much Flash does BMP need?

I haven't done the register-level comparison, but I am hoping the STM070's USB is closer to the STM32F103's USB making it easier to port BMP.
Last edited by gbulmer on Sat May 14, 2016 10:08 pm, edited 1 time in total.

devan
Posts: 49
Joined: Sat May 14, 2016 1:45 am

Re: Is SWD-only BMP practical, and on Low-pin-count STM32?

Post by devan » Sat May 14, 2016 2:01 am

I've been lurking for a while, but a DIY SWD-only debugger using the STM32F042Fx chip is one of my side projects, so I finally decided to register.

As others have pointed out, fitting the full BMP functionality (with the GDB protocol and target MCU flash algorithms) may not be possible in only 32KiB of flash. However, if you're willing to have the host computer manage more of the debugging logic (via OpenOCD or a commercial debugger), you can easily fit a CMSIS-DAP debug implementation in < 16KiB.

I just double checked the size of my current firmware, and it's sitting at about 14KiB right now.
https://github.com/devanlai/dap42

With the TSSOP-20 package, you can build a debugger with SWD, 3-5 GPIO, and one hardware UART xor SWO input.

User avatar
Rick Kimball
Posts: 1014
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: Is SWD-only BMP practical, and on Low-pin-count STM32?

Post by Rick Kimball » Sat May 14, 2016 2:14 am

Nice stuff devan!
-rick

gbulmer
Posts: 67
Joined: Wed Sep 23, 2015 12:04 am
Location: UK

Re: Is SWD-only BMP practical, and on Low-pin-count STM32?

Post by gbulmer » Sat May 14, 2016 10:24 pm

devan wrote:I've been lurking for a while, but a DIY SWD-only debugger using the STM32F042Fx chip is one of my side projects, so I finally decided to register.

As others have pointed out, fitting the full BMP functionality (with the GDB protocol and target MCU flash algorithms) may not be possible in only 32KiB of flash. However, if you're willing to have the host computer manage more of the debugging logic (via OpenOCD or a commercial debugger), you can easily fit a CMSIS-DAP debug implementation in < 16KiB.

I just double checked the size of my current firmware, and it's sitting at about 14KiB right now.
https://github.com/devanlai/dap42

With the TSSOP-20 package, you can build a debugger with SWD, 3-5 GPIO, and one hardware UART xor SWO input.
Thank you very much for all of that helpful information. Lovely news. Best of luck.
Are you thinking of releasing as Open Source, or is it too early to say?

gbulmer
Posts: 67
Joined: Wed Sep 23, 2015 12:04 am
Location: UK

Re: Is SWD-only BMP practical, and on Low-pin-count STM32?

Post by gbulmer » Sat May 14, 2016 10:33 pm

Rick Kimball wrote:I went through the code and removed all the logic required for JTAG and got rid of board support for chips I wasn't going to use. I used a UART instead of the USB code which actually made it smaller. Even after all that code slash and burn I couldn't get it to fit into 32KB. Any Cortex-M0 chip is going to use more code to do the same amount of work as an M3.

With all the features for both JTAG and SWD it is still fairly small but not small enough for 32KB:

Code: Select all

$ arm-none-eabi-size blackmagic
   text	   data	    bss	    dec	    hex	filename
  53452	    168	   2132	  55752	   d9c8	blackmagic
I changed the compiler option to use cortex-m0 instead of m3 and recompiled. You can see it is a couple KB larger:

Code: Select all

$ arm-none-eabi-size blackmagic
   text	   data	    bss	    dec	    hex	filename
  55572	    168	   2132	  57872	   e210	blackmagic
I apologise for not responding sooner.

Thank you for this.
You've already done the work for what I was only thinking. (That is pretty much my algorithm nowadays :-)
So that pretty much rules out all ST's current TSOP20 as parts for BMP; AFAICT, they are never more than 32kB.
A bit of a shame as they are the closest I/O capability fit that are easy to DIY.

Post Reply