flash/stm32l4x: STM32L5 support programming when TZEN=1 and RDP=0x55 35/6035/17
authorTarek BOCHKATI <tarek.bouchkati@gmail.com>
Fri, 22 Jan 2021 12:15:52 +0000 (13:15 +0100)
committerOleksij Rempel <linux@rempel-privat.de>
Thu, 26 Aug 2021 06:21:38 +0000 (06:21 +0000)
when RDP level is 0.5 the provided work-area should reside in non-secure RAM
to ensure that:
 - add a hint in the driver level
 - reduce the usage of secure RAM only when TZEN=1 and RDP is not 0.5
   (check the target configuration file)

Change-Id: Idbf2325e609b84ef8480eefdb49a176fdf7e07c7
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6035
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Tested-by: jenkins
src/flash/nor/stm32l4x.c
tcl/target/stm32l5x.cfg

index db8d5e78d3175d5ecf010b5e06ce7acf37c594c0..de36d56c71796af5130835af7010190577e7dd17 100644 (file)
@@ -1434,6 +1434,13 @@ static int stm32l4_write(struct flash_bank *bank, const uint8_t *buffer,
        if (retval != ERROR_OK)
                goto err_lock;
 
+       /* For TrustZone enabled devices, when TZEN is set and RDP level is 0.5,
+        * the debug is possible only in non-secure state.
+        * Thus means the flashloader will run in non-secure mode,
+        * and the workarea need to be in non-secure RAM */
+       if (stm32l4_info->tzen && (stm32l4_info->rdp == RDP_LEVEL_0_5))
+               LOG_INFO("RDP level is 0.5, the work-area should reside in non-secure RAM");
+
        retval = stm32l4_write_block(bank, buffer, offset, count / 8);
 
 err_lock:
index 02297e36996fed5d0f7dd262874ff5b871d87886..0616df1cbabe7808f11483a4867be28f18ea1a8d 100644 (file)
@@ -173,7 +173,11 @@ $_TARGETNAME configure -event gdb-flash-erase-start {
        } {
                ahb_ap_secure_access
                echo "TZEN option bit enabled"
-               set use_secure_workarea 1
+
+               # check if FLASH_OPTR.RDP is not Level 0.5
+               if {[expr {$FLASH_OPTR & 0xFF}] != 0x55} {
+                       set use_secure_workarea 1
+               }
        }
 
        set workarea_addr [$_TARGETNAME cget -work-area-phys]

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)