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
--- ** [tickets:#317] STM32L5 wrong page size** **Status:** new **Milestone:** 0.11.0 **Labels:** stm32lx flash **Created:** Wed Aug 25, 2021 02:33 PM UTC by Patrik Bachan **Last Updated:** Mon Sep 06, 2021 12:44 PM UTC **Owner:** nobody 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](https://review.openocd.org/gitweb?p=openocd.git;a=commitdiff;h=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? --- Sent from sourceforge.net because openocd-devel@lists.sourceforge.net is subscribed to https://sourceforge.net/p/openocd/tickets/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/openocd/admin/tickets/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.