Skip to main content
angry.sioux
Associate II
November 9, 2022
Question

How to program stm32L552 using SWD interface

  • November 9, 2022
  • 2 replies
  • 1388 views

I use my own application to program different devices, arm in particular. Now, i'd like to support stm32L552. So, if TZEN = 0 it works fine.

if TZEN = 1, DBANK = 1, SECWM1_PSTRT - set as secure, SECWM2_PSTRT - set as non-secure, RDP = 0xaa (level 0) i cant read flash using SWD. STM32CubeProgrammer works perfectly in both cases.

I'd appreciate any help

This topic has been closed for replies.

2 replies

Technical Moderator
November 11, 2022

Hello @angry.sioux​ and welcome to the Community :)

Check if the SWD is mapped on the right pin.

I advise you to refer to this article: Security:How to disable TrustZone in STM32L5xx devices during development phase

Imen

"When your question is answered, please close this topic by clicking ""Accept as Solution"".ThanksImen"
angry.sioux
Associate II
November 14, 2022

I found a way that made things a bit better.

There is WAIT response if i access to AP register. But.

If i read a register twice the error goes away.

f.e. schematically

//do not need to read, just write

write_register ( SELECT_REG, bank select for CSW_REG)

write_register ( SELECT_REG, bank select for TAR_REG) - error, WAIT

but

write_register ( SELECT_REG, bank select for CSW_REG)

read_reg(CSW_REG) - dummy read, enough for "no error", but returns trash.

read_reg(CSW_REG) - returns appropriate value

write_register ( SELECT_REG, bank select for TAR_REG) - no error, great

but

if i halt and reset core i got DHCSR_S_LOCKUP

angry.sioux
Associate II
November 11, 2022

Hi Imen,

>>Check if the SWD is mapped on the right pin.

I cannot read only the FLASH in case of TZEN = 1. But I read registers (CTRL_STAT, IDR...), can read OPTR, FLASHSIZE_BASE and so on. So, it;s not about a SWD pin.

>>I advise you to refer ....

I have read  Security:How to disable TrustZone in STM32L5xx devices during development phase and did not find an answer. Otherwise I would never reach out to for a favor.

Thank you