1 /***************************************************************************
2 * Copyright (C) 2010 by Spencer Oliver *
3 * spen@spen-soft.co.uk *
5 * Copyright (C) 2011 Øyvind Harboe *
6 * oyvind.harboe@zylin.com *
8 * Copyright (C) 2011 Clement Burin des Roziers *
9 * clement.burin-des-roziers@hikob.com *
11 * Copyright (C) 2017 Armin van der Togt *
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. *
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 ***************************************************************************/
32 r0 - destination address
35 r3 - bytes per half page
38 r0 - destination write pointer
39 r1 - source read pointer
40 r2 - source limit address
41 r3 - bytes per half page
43 r5 - pages left in current half page
47 /* offsets of registers from flash reg base */
48 #define STM32_FLASH_SR_OFFSET 0x18
53 // r2 = source + half pages * bytes per half page
59 // initialize pages left in current half page
62 // load word from address in r1 and increase r1 by 4
64 // store word to address in r0 and increase r0 by 4
66 // check for end of half page
70 // read status register into r6, loop while bottom bit is set
71 ldr r6, [r4, #STM32_FLASH_SR_OFFSET]
75 // compare r1 and r2, loop if not equal
79 // Set breakpoint to exit