max32xxx: Support for MAX32XXX devices.
[openocd.git] / contrib / loaders / flash / max32xxx / max32xxx.s
1 /***************************************************************************
2 * Copyright (C) 2016 by Maxim Integrated *
3 * Kevin Gillespie <kevin.gillespie@maximintegrated.com *
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, see <http://www.gnu.org/licenses/>. *
17 ***************************************************************************/
18
19 .text
20 .syntax unified
21 .cpu cortex-m3
22 .thumb
23 .thumb_func
24
25 /*
26 * Params :
27 * r0 = workarea start
28 * r1 = workarea end
29 * r2 = target address
30 * r3 = count (32bit words)
31 * r4 = pFLASH_CTRL_BASE
32 *
33 * Clobbered:
34 * r5 = FLASHWRITECMD
35 * r7 - rp
36 * r8 - wp, tmp
37 */
38
39 write:
40
41 wait_fifo:
42 ldr r8, [r0, #0] /* read wp */
43 cmp r8, #0 /* abort if wp == 0 */
44 beq exit
45 ldr r7, [r0, #4] /* read rp */
46 cmp r7, r8 /* wait until rp != wp */
47 beq wait_fifo
48
49 mainloop:
50 str r2, [r4, #0x00] /* FLSH_ADDR - write address */
51 add r2, r2, #4 /* increment target address */
52 ldr r8, [r7], #4
53 str r8, [r4, #0x30] /* FLSH_DATA0 - write data */
54 ldr r5, [r4, #0x08] /* FLSH_CN */
55 orr r5, r5, #1
56 str r5, [r4, #0x08] /* FLSH_CN - enable write */
57 busy:
58 ldr r8, [r4, #0x08] /* FLSH_CN */
59 tst r8, #1
60 bne busy
61
62 cmp r7, r1 /* wrap rp at end of buffer */
63 it cs
64 addcs r7, r0, #8 /* skip loader args */
65 str r7, [r0, #4] /* store rp */
66 subs r3, r3, #1 /* decrement word count */
67 cbz r3, exit /* loop if not done */
68 b wait_fifo
69 exit:
70 bkpt

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)