Skip to main content
Atilla Mete Turedi
Associate III
September 28, 2017
Solved

Custom Board Design with STM32L4 - Flash Programming and JTAG Questions

  • September 28, 2017
  • 1 reply
  • 1745 views
Posted on September 28, 2017 at 09:20

Dear Community,

I went through most of the application notes, the datasheet and the reference manual but since I am a hardware guy, I want to make sure that I understand things correctly before I start the design. I am consent with basic yes/no confirmations from people with experience.

1. I can program a bare metal MCU using the 10-pin JTAG connector alone.

2. I can use the IAR EWARM + Segger J-Link Pro combination for debug and flash programming.

3. I can set all JTAG pins (PA13, PA14, PA15, PB3 and PB4) to their alternate functions.

4. Each time the MCU is reset, even if JTAG was previously disabled by the application program, all JTAG pins are set back to JTAG functionality and JTAG is enabled.

I just want to make sure that, I can use JTAG and only JTAG for flash programming of the MCU and my application program can use all the pins used by JTAG as GPIOs. 

And more thing, this might sound dumb but none of the alternate functions are actually named 'GPIO' in the datasheet. How do I set them as just basic GPIO and not one of the alternate functions?

Best Regards,

Mete

#stm32 #iar #gpio #jtag #ewarm #stm32l4
This topic has been closed for replies.
Best answer by AvaTar
Posted on October 04, 2017 at 10:21

Can anyone help with this please?

Sure, albeit I'm no hardware guy.

1. I can program a bare metal MCU using the 10-pin JTAG connector alone.

Yes, in theory.

Practically, it is highly recommended to make provisions to set the BOOT0/BOOT1 pins to defined states during startup.

Jumper would be good.

During development, you might need to start into the system bootloader, which requires this pins.

2. I can use the IAR EWARM + Segger J-Link Pro combination for debug and flash programming.

Yes, I have used this combination commercially (with Base instead of Pro version).

3. I can set all JTAG pins (PA13, PA14, PA15, PB3 and PB4) to their alternate functions.

Yes, but software guy will not love you for that.

Experiences show that saved HW costs are 'overcompensated' through more complicated and prolonged development and debugging / error tracing with field returns.

4. Each time the MCU is reset, even if JTAG was previously disabled by the application program, all JTAG pins are set back to JTAG functionality and JTAG is enabled.

Correct, if you do not enable the 'Readout Protection' feature. This would, depending on the level, disable JTAG all together.

Make sure that the alternate functionality does not require hardware/components on those pins that interfere with JTAG functionality.

There are several application notes about this topic (JTAG, Bootloader, boot modes, etc.).

I suggest to discuss this topics with your SW colleagues, and check their requirements.

1 reply

Atilla Mete Turedi
Associate III
October 4, 2017
Posted on October 04, 2017 at 09:28

Can anyone help with this please?

AvaTar
AvaTarAnswer
Senior III
October 4, 2017
Posted on October 04, 2017 at 10:21

Can anyone help with this please?

Sure, albeit I'm no hardware guy.

1. I can program a bare metal MCU using the 10-pin JTAG connector alone.

Yes, in theory.

Practically, it is highly recommended to make provisions to set the BOOT0/BOOT1 pins to defined states during startup.

Jumper would be good.

During development, you might need to start into the system bootloader, which requires this pins.

2. I can use the IAR EWARM + Segger J-Link Pro combination for debug and flash programming.

Yes, I have used this combination commercially (with Base instead of Pro version).

3. I can set all JTAG pins (PA13, PA14, PA15, PB3 and PB4) to their alternate functions.

Yes, but software guy will not love you for that.

Experiences show that saved HW costs are 'overcompensated' through more complicated and prolonged development and debugging / error tracing with field returns.

4. Each time the MCU is reset, even if JTAG was previously disabled by the application program, all JTAG pins are set back to JTAG functionality and JTAG is enabled.

Correct, if you do not enable the 'Readout Protection' feature. This would, depending on the level, disable JTAG all together.

Make sure that the alternate functionality does not require hardware/components on those pins that interfere with JTAG functionality.

There are several application notes about this topic (JTAG, Bootloader, boot modes, etc.).

I suggest to discuss this topics with your SW colleagues, and check their requirements.

waclawek.jan
Super User
October 4, 2017
Posted on October 04, 2017 at 11:24

We are using SWD (that's just 2 signals and GND in basic setup instead of 4 of JTAG) plus reset where the pins are shared.

Where the pins are shared, it's good to assign very simple functionality to these, so that they could be handled with minimal debugging, and are not necessary during the main course of programming/debugging.

---

The other question - in GPIO there are 2 registers for setting up the behaviour - MODER selects between GPIO In, GPIO Out, Alternate Function and Analog (the 'F1 family is slightly different as it's the oldest family and this detail was not very well designed there). Only if Alternate Function is selected for a pin in MODER, the selection of function through AFRL/AFRH is valid.

JW