flash Kinetis: handle all types of watchdog, disable in reset-init
[openocd.git] / contrib / loaders / watchdog / armv7m_kinetis_wdog32.s
1 /***************************************************************************
2 * Copyright (C) 2017 Tomas Vanek *
3 * vanekt@fbl.cz *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc. *
18 ***************************************************************************/
19
20 /*
21 Disable watchdog, 32-bit version for newer Kinetis
22 Parameters:
23 r0 ... WDOG32 base (in)
24
25 Used instruction set should work on both Cortex-M4 and M0+
26 */
27
28 .text
29 .syntax unified
30 .cpu cortex-m0
31 .thumb
32
33 /* WDOG registers offsets */
34 WDOG_CS = 0
35 WDOG_CNT = 4
36 WDOG_TOVAL = 8
37
38 WDOG_KEY = 0xd928c520
39
40 .thumb_func
41 start:
42 /* test WDOG_CS bit CMD32EN */
43 ldr r2, [r0, WDOG_CS]
44 ldr r3, =0x2000
45 tst r2, r3
46 ldr r3, =WDOG_KEY
47 beq cmd16
48
49 /* WDOG_CNT = key */
50 str r3, [r0, WDOG_CNT]
51 b unlocked
52
53 cmd16:
54 /* WDOG_CNT = key, halfword by halfword */
55 strh r3, [r0, WDOG_CNT]
56 lsrs r3, r3, #16
57 strh r3, [r0, WDOG_CNT]
58
59 /* WDOG_CS: clear EN bit 7, set UPDATE bit 5 */
60 unlocked:
61 movs r4, #0x80
62 bics r2, r4
63 movs r4, #0x20
64 orrs r2, r4
65 str r2, [r0, WDOG_CS]
66 /* All active WDOG registers have to be updated, set dummy timeout */
67 /* WDOG_TOVAL = 0x400 */
68 ldr r3, =0x400
69 str r3, [r0, WDOG_TOVAL]
70 /* OpenOCD checks exit point address. Jump to the very end. */
71 b done
72
73 .pool
74
75 /* Avoid padding at .text segment end. Otherwise exit point check fails. */
76 .skip ( . - start + 2) & 2, 0
77 done:
78 bkpt #0
79
80 .end
81

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)