Gareth McMullin
10 years ago
7 changed files with 54 additions and 60 deletions
@ -1,43 +0,0 @@ |
|||
.global _start |
|||
|
|||
_start: |
|||
ldr r0, _flashbase |
|||
ldr r1, _addr |
|||
mov r2, pc |
|||
add r2, #(_data - . - 2) |
|||
ldr r3, _size |
|||
mov r5, #1 |
|||
_next: |
|||
cmp r3, #0 |
|||
beq _done |
|||
@ Write PG command to FLASH_CR |
|||
str r5, [r0, #0x10] |
|||
@ Write data to flash (half-word) |
|||
ldrh r4, [r2] |
|||
strh r4, [r1] |
|||
|
|||
_wait: @ Wait for BSY bit to clear |
|||
ldr r4, [r0, #0x0C] |
|||
mov r6, #1 |
|||
tst r4, r6 |
|||
bne _wait |
|||
|
|||
sub r3, #2 |
|||
add r1, #2 |
|||
add r2, #2 |
|||
b _next |
|||
_done: |
|||
bkpt |
|||
|
|||
@.align 4 |
|||
.org 0x28 |
|||
_flashbase: |
|||
.word 0x40022000 |
|||
_addr: |
|||
.word 0 |
|||
_size: |
|||
.word 12 |
|||
_data: |
|||
.word 0xAAAAAAAA |
|||
.word 0xBBBBBBBB |
|||
.word 0xCCCCCCCC |
@ -1 +0,0 @@ |
|||
0x4809, 0x490A, 0x467A, 0x322C, 0x4B09, 0x2501, 0x2B00, 0xD00A, 0x6105, 0x8814, 0x800C, 0x68C4, 0x2601, 0x4234, 0xD1FB, 0x3B02, 0x3102, 0x3202, 0xE7F2, 0xBE00, 0x2000, 0x4002, 0x0000, 0x0000, 0x000C, 0x0000, 0xAAAA, 0xAAAA, 0xBBBB, 0xBBBB, 0xCCCC, 0xCCCC, |
@ -0,0 +1,34 @@ |
|||
/*
|
|||
* This file is part of the Black Magic Debug project. |
|||
* |
|||
* Copyright (C) 2015 Black Sphere Technologies Ltd. |
|||
* Written by Gareth McMullin <gareth@blacksphere.co.nz> |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
#include "libopencm3/stm32/flash.h" |
|||
|
|||
void __attribute__((naked)) |
|||
stm32f1_flash_write_stub(uint16_t *dest, uint16_t *src, uint32_t size) |
|||
{ |
|||
while (size) { |
|||
FLASH_CR = FLASH_CR_PG; |
|||
*dest++ = *src++; |
|||
size -= 2; |
|||
while (FLASH_SR & FLASH_SR_BSY) |
|||
; |
|||
} |
|||
asm("bkpt"); |
|||
} |
|||
|
@ -0,0 +1 @@ |
|||
0x4613, 0xE010, 0x4A09, 0x2401, 0x6014, 0x4602, 0x1C90, 0x460C, 0x1CA1, 0x8824, 0x8014, 0x3B02, 0xBF00, 0x4A05, 0x6812, 0xF002, 0x0201, 0x2A00, 0xD1F9, 0x2B00, 0xD1EC, 0xBE00, 0x2010, 0x4002, 0x200C, 0x4002, |
Loading…
Reference in new issue