Hi,
I have issue with OpenOCD and STM32L552 (256 kiB FLASH).
STM32L5x has 2 option bytes telling what dual-bank config is used: DBANK and DB256K.
Issues it, that page size depends only on DBANK, even for devices with 256kiB.
Tested with STM32CUbeProgrammer and STM32L552. Also tested with OpenOCD which erases only 2kiB, even though OpenOCD reports 4kiB pages.
In commit 092cfe16fb9cf6d6a308d62246fb648b0709ecd3 introducing support of L5 devices, there seems to be the culprit of issue.
if ((use_dbank_bit && (options & BIT(22))) ||
(!use_dbank_bit && (options & BIT(21)))) {
STM32 flash driver code for these MCUs decides by DBANK for 512 kiB and by DB256K for 256 kiB and this is not correct.
From my understanding and observations:
for 512 kiB devices, DBANK affects page size and single-bank/dual-bank selection
for 256 kiB devices, DBANK affects page size and DB256K affects single-bank/dual-bank selection (probably, not tested)
This issue causes flash programming fail when there is already something in flash and page needs to be erased at first. I assume, that problem is wrong page erasure.
On which devices was this code tested?
Hi Patrik,
Thanks for reporting the issue.
this change was tested on NUCLEO-L552ZE-Q containing STM32L552ZET6QU device
BTW the device contains 512K of flash
I will check and come back with further details.
Hi Patrik,
could you check if the proposed patch works for you:
https://review.openocd.org/c/openocd/+/6538
PS: I was not able to test on a device with 256k Flash
Hi Tarek,
I've built patched version of openocd, but I was unable to flash MCU in any configuration. Probably due to different issue. Page size detection seems to be correct. At least according to output of "flash info 0".
(Initial report was done on older openocd release https://github.com/xpack-dev-tools/openocd-xpack/releases/tag/v0.11.0-1)
Configuration:
STlink V2-1 (NUCLEO-L552ZE-Q), (STlink V2 clone with same results)
MCU STM32L552RCT6 on separate board, external (stable) power supply
Please see following logs:
OpenOCD output:
Telnet commands:
Could it be, due to HLA SWD only probe?
well, as you said the current cfg file do support the STM32L5 devices using non HLA adapters
since secure debugging requires changing the AP CSW when changing from secure to non-secure and vice versa
but nothing prevent us from modifying the cfg to work with STM32L5 with HLA adapters but only when the device is non-secure
IDK if ST-Link clones do support non-hla mode aka dapdirect using the "interface/stlink-dap.cfg"
I would be interested if you can give it a try
meanwhile I will try to adapt the cfg to work with HLA adapters
again here is a WIP change that permits to use the target/stm3él5x.cfg with HLA adapters
please let me know if this permits to debug the device in non-secure mode :
https://review.openocd.org/c/openocd/+/6546
please be aware that as it's stated in the commit msg using HLA adapters does not permit to debug the device in secure mode.
Hi Patrik,
could you please check if the following changes fixes your issues:
https://review.openocd.org/c/openocd/+/6538/3
https://review.openocd.org/c/openocd/+/6546/3
Hi Tarek,
I am currently away from my equipment and that won't change till the end of this week. After that, I'll be keen to check your changes and give a feedback.
Patrik
13 Sep 2021 16:14:01 Tarek BOCHKATI tarekboch@users.sourceforge.net:
Related
Tickets:
#317Hi,
sorry for late reply.
Both change sets seems to work in my scenario. I was able to erase/flash pages on L552 256kiB flash version, when DBANK was set (2kiB pages) with ST-Link v2. No issues.
Thanks Patrik !
hopefully #6538 : flash/stm32l4x: fix dual bank support for STM32L552xC devices is already merged
awaiting the merge of #6546 : tcl/stm32l5x|u5x: support HLA adapters in non-secure mode only
then I will close the ticket.
Hi, any progress on #6546? I t looks like there are several small fixes required and then it would be ready for merge.
6546 merged, closing the ticket