flash/nor, contrib/loaders: move numicro M0 write assembly to contrib/loaders

Simply move numicro M0 flash write assembly to contrib/loaders. Also,
modify corresponding Makefile and generated numicro_m0.inc.

To make the path more general, this patch rename the path
"contrib/loaders/flash/numicro_m4" to "contrib/loaders/flash/numicro" as
well.

Signed-off-by: Jian-Hong Pan <chienhung.pan@gmail.com>
Change-Id: I9adea24c2b3c97319a9b015cf50257f3d131dc26
Reviewed-on: https://review.openocd.org/c/openocd/+/7346
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
Jian-Hong Pan 2022-11-13 12:43:14 +08:00 committed by Antonio Borneo
parent 63336f4aaf
commit 9ffda10298
6 changed files with 82 additions and 59 deletions

View File

@ -9,9 +9,9 @@ OBJCOPY=$(CROSS_COMPILE)objcopy
OBJDUMP=$(CROSS_COMPILE)objdump OBJDUMP=$(CROSS_COMPILE)objdump
AFLAGS = -static -nostartfiles -mlittle-endian -mcpu=cortex-m4 -Wa,-EL AFLAGS = -static -nostartfiles -mlittle-endian -Wa,-EL
all: numicro_m4.inc all: numicro_m0.inc numicro_m4.inc
.PHONY: clean .PHONY: clean

View File

@ -0,0 +1,73 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/***************************************************************************
* Copyright (C) 2015 Nemui Trinomius *
* nemuisan_kawausogasuki@live.jp *
* *
* Copyright (C) 2017 Zale Yu *
* CYYU@nuvoton.com *
* *
* Copyright (C) 2022 Jian-Hong Pan *
* chienhung.pan@gmail.com *
***************************************************************************/
.text
.cpu cortex-m0
.thumb
/* Params:
* r0 - workarea buffer / result
* r1 - target address
* r2 - wordcount
* Clobbered:
* r4 - tmp
* r5 - tmp
* r6 - tmp
* r7 - tmp
*/
.L1:
/* for(register uint32_t i=0;i<wcount;i++){ */
mov r4, r0
mov r3, #0
.L2:
sub r5, r1, r0
add r7, r4, r5
cmp r3, r2
beq .L7
.L4:
/* NUMICRO_FLASH_ISPADR = faddr; */
ldr r6, .L8
str r7, [r6]
/* NUMICRO_FLASH_ISPDAT = *pLW; */
ldmia r4!, {r7}
ldr r5, .L8+4
str r7, [r5]
/* faddr += 4; */
/* pLW++; */
/* Trigger write action */
/* NUMICRO_FLASH_ISPTRG = ISPTRG_ISPGO; */
ldr r5, .L8+8
mov r6, #1
str r6, [r5]
.L3:
/* while((NUMICRO_FLASH_ISPTRG & ISPTRG_ISPGO) == ISPTRG_ISPGO){}; */
ldr r7, [r5]
lsl r7, r7, #31
bmi .L3
add r3, r3, #1
b .L2
.L7:
/* return (NUMICRO_FLASH_ISPCON & ISPCON_ISPFF); */
ldr r3, .L8+12
ldr r0, [r3]
mov r1, #64
and r0, r1
.L9:
bkpt #0
.L8:
.word 0x5000C004
.word 0x5000C008
.word 0x5000C010
.word 0x5000C000

View File

@ -0,0 +1,5 @@
/* Autogenerated with ../../../../src/helper/bin2char.sh */
0x04,0x1c,0x00,0x23,0x0d,0x1a,0x67,0x19,0x93,0x42,0x0c,0xd0,0x08,0x4e,0x37,0x60,
0x80,0xcc,0x08,0x4d,0x2f,0x60,0x08,0x4d,0x01,0x26,0x2e,0x60,0x2f,0x68,0xff,0x07,
0xfc,0xd4,0x01,0x33,0xee,0xe7,0x05,0x4b,0x18,0x68,0x40,0x21,0x08,0x40,0x00,0xbe,
0x04,0xc0,0x00,0x50,0x08,0xc0,0x00,0x50,0x10,0xc0,0x00,0x50,0x00,0xc0,0x00,0x50,

View File

@ -681,66 +681,11 @@ static uint32_t numicro_fmc_cmd(struct target *target, uint32_t cmd, uint32_t ad
/* NuMicro Program-LongWord Microcodes */ /* NuMicro Program-LongWord Microcodes */
static const uint8_t numicro_flash_write_code[] = { static const uint8_t numicro_flash_write_code[] = {
/* Params: #include "../../../contrib/loaders/flash/numicro/numicro_m0.inc"
* r0 - workarea buffer / result
* r1 - target address
* r2 - wordcount
* Clobbered:
* r4 - tmp
* r5 - tmp
* r6 - tmp
* r7 - tmp
*/
/* .L1: */
/* for(register uint32_t i=0;i<wcount;i++){ */
0x04, 0x1C, /* mov r4, r0 */
0x00, 0x23, /* mov r3, #0 */
/* .L2: */
0x0D, 0x1A, /* sub r5, r1, r0 */
0x67, 0x19, /* add r7, r4, r7 */
0x93, 0x42, /* cmp r3, r2 */
0x0C, 0xD0, /* beq .L7 */
/* .L4: */
/* NUMICRO_FLASH_ISPADR = faddr; */
0x08, 0x4E, /* ldr r6, .L8 */
0x37, 0x60, /* str r7, [r6] */
/* NUMICRO_FLASH_ISPDAT = *pLW; */
0x80, 0xCC, /* ldmia r4!, {r7} */
0x08, 0x4D, /* ldr r5, .L8+4 */
0x2F, 0x60, /* str r7, [r5] */
/* faddr += 4; */
/* pLW++; */
/* Trigger write action */
/* NUMICRO_FLASH_ISPTRG = ISPTRG_ISPGO; */
0x08, 0x4D, /* ldr r5, .L8+8 */
0x01, 0x26, /* mov r6, #1 */
0x2E, 0x60, /* str r6, [r5] */
/* .L3: */
/* while((NUMICRO_FLASH_ISPTRG & ISPTRG_ISPGO) == ISPTRG_ISPGO){}; */
0x2F, 0x68, /* ldr r7, [r5] */
0xFF, 0x07, /* lsl r7, r7, #31 */
0xFC, 0xD4, /* bmi .L3 */
0x01, 0x33, /* add r3, r3, #1 */
0xEE, 0xE7, /* b .L2 */
/* .L7: */
/* return (NUMICRO_FLASH_ISPCON & ISPCON_ISPFF); */
0x05, 0x4B, /* ldr r3, .L8+12 */
0x18, 0x68, /* ldr r0, [r3] */
0x40, 0x21, /* mov r1, #64 */
0x08, 0x40, /* and r0, r1 */
/* .L9: */
0x00, 0xBE, /* bkpt #0 */
/* .L8: */
0x04, 0xC0, 0x00, 0x50,/* .word 1342226436 */
0x08, 0xC0, 0x00, 0x50,/* .word 1342226440 */
0x10, 0xC0, 0x00, 0x50,/* .word 1342226448 */
0x00, 0xC0, 0x00, 0x50 /* .word 1342226432 */
}; };
static const uint8_t numicro_m4_flash_write_code[] = { static const uint8_t numicro_m4_flash_write_code[] = {
#include "../../../contrib/loaders/flash/numicro_m4/numicro_m4.inc" #include "../../../contrib/loaders/flash/numicro/numicro_m4.inc"
}; };
/* Program LongWord Block Write */ /* Program LongWord Block Write */