]> git.sur5r.net Git - openocd/blob - contrib/loaders/flash/stm32lx.S
Fix flash writing on stm32l0
[openocd] / contrib / loaders / flash / stm32lx.S
1 /***************************************************************************
2  *   Copyright (C) 2010 by Spencer Oliver                                  *
3  *   spen@spen-soft.co.uk                                                  *
4  *                                                                         *
5  *   Copyright (C) 2011 Ã˜yvind Harboe                                      *
6  *   oyvind.harboe@zylin.com                                               *
7  *                                                                         *
8  *   Copyright (C) 2011 Clement Burin des Roziers                          *
9  *   clement.burin-des-roziers@hikob.com                                   *
10  *                                                                         *
11  *   Copyright (C) 2017 Armin van der Togt                                 *
12  *   armin@otheruse.nl                                                     *
13  *                                                                         *
14  *   This program is free software; you can redistribute it and/or modify  *
15  *   it under the terms of the GNU General Public License as published by  *
16  *   the Free Software Foundation; either version 2 of the License, or     *
17  *   (at your option) any later version.                                   *
18  *                                                                         *
19  *   This program is distributed in the hope that it will be useful,       *
20  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
21  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
22  *   GNU General Public License for more details.                          *
23  *                                                                         *
24  *   You should have received a copy of the GNU General Public License     *
25  *   along with this program; if not, write to the                         *
26  *   Free Software Foundation, Inc.,                                       *
27  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.           *
28  ***************************************************************************/
29
30
31 // Build : arm-eabi-gcc -c stm32lx.S
32         .text
33         .syntax unified
34         .cpu cortex-m0
35         .thumb
36         .thumb_func
37         .global write
38
39 /*
40         r0 - destination address
41         r1 - source address
42         r2 - count
43 */
44
45         // r2 = source + count * 4
46         lsls    r2, r2, #2
47         adds    r2, r1, r2
48         // Go to compare
49         b       test_done
50 write_word:
51         // load word from address in r1 and increase r1 by 4
52         ldmia r1!, {r3}
53         // store word to address in r0 and increase r0 by 4
54         stmia r0!, {r3}
55 test_done:
56         // compare r1 and r2
57         cmp     r1, r2
58         // loop if not equal
59         bne     write_word
60
61         // Set breakpoint to exit
62         bkpt    #0x00
63