Skip to content

Commit

Permalink
xtensa flash: minimal KC705 support
Browse files Browse the repository at this point in the history
- dummy flash driver for KC705/ML605
- experimental updates to board .cfg file
- flash erase, write support w/ 32-byte buffering (LX)
- algo support manually verified (NX)

Signed-off-by: ianst <ianst@cadence.com>
  • Loading branch information
ianstcdns committed Jan 31, 2024
1 parent 9659a9b commit 15af5d0
Show file tree
Hide file tree
Showing 8 changed files with 511 additions and 1 deletion.
31 changes: 31 additions & 0 deletions contrib/loaders/flash/xtensa/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# SPDX-License-Identifier: GPL-2.0-or-later

BIN2C = ../../../../src/helper/bin2char.sh

CROSS_COMPILE ?= xt-

CC=$(CROSS_COMPILE)clang
OBJCOPY=$(CROSS_COMPILE)objcopy
OBJDUMP=$(CROSS_COMPILE)objdump

AFLAGS = -c -static -nostartfiles -mlittle-endian -mtext-section-literals
CFLAGS = -c -nostdlib -nostartfiles -Os -g -fPIC

all: xtkcml705fl.inc

.PHONY: clean

%.elf: %.S
$(CC) $(AFLAGS) $< -o $@

%.lst: %.elf
$(OBJDUMP) -S $< > $@

%.bin: %.elf
$(OBJCOPY) -Obinary $< $@

%.inc: %.bin
$(BIN2C) < $< > $@

clean:
-rm -f *.elf *.lst *.bin *.inc
71 changes: 71 additions & 0 deletions contrib/loaders/flash/xtensa/xtkcml705fl.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */

/***************************************************************************
* Xtensa flasher for KC705/ML605 platforms
* Copyright (C) 2023 Cadence Design Systems
***************************************************************************/

/*
* Parameters:
* a10 = flash base (in), status (out)
* a11 = count (halfword-16bit)
* a12 = buffer start
* a13 = buffer end / scratch register
* a14 = target address
*
* NOTE: if count does not indicate a multiple of 32 bytes, this logic
* will round up to and program the next multiple of 32 bytes.
*/
.text

.align 4
_flash_prog_start:
j _flash_prog

.align 4
.literal_position

_flash_prog:
movi a13, 0x50 /* clear flash status register */
s16i a13, a10, 0

_flash_prog_loop:
movi a13, 0xe8 /* set flash into buffer program mode */
s16i a13, a14, 0
movi a13, 31 /* always program chunks of N=32 bytes (write N-1) */
s16i a13, a14, 0
.set i, 0
.rept 32
l16ui a13, a12, i
s16i a13, a14, i
.set i, i+2
.endr
movi a13, 32
sub a11, a11, a13 /* increment half-word count */
add a13, a13, a13 /* double a13 for incrementing buffer/target addresses */
add a12, a12, a13
add a14, a14, a13
movi a13, 0xd0 /* end buffer program mode */
s16i a13, a14, 0
_flash_prog_status_check:
l16ui a13, a10, 0
bbci a13, 7, _flash_prog_status_check
extui a13, a13, 0, 7
bnez a13, _flash_prog_error
bgei a11, 1, _flash_prog_loop

_flash_prog_done:
/* TODO: set program mode size of -1? */
movi a13, 0x50 /* clear status register */
s16i a13, a10, 0
movi a13, 0xff /* restore read array (normal) mode */
s16i a13, a10, 0
movi a10, 0
break 0, 0 /* Coded breakpoint at end of algo */
_flash_prog_error:
movi a10, -4
break 0, 0 /* Coded breakpoint at end of algo */

_idle_loop:
j _idle_loop

18 changes: 18 additions & 0 deletions contrib/loaders/flash/xtensa/xtkcml705fl.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* Autogenerated with ../../../../src/helper/bin2char.sh */
0x06,0x00,0x00,0x00,0x5c,0x0d,0xd2,0x5a,0x00,0xd2,0xa0,0xe8,0xd2,0x5e,0x00,0x1c,
0xfd,0xd2,0x5e,0x00,0xd2,0x1c,0x00,0xd2,0x5e,0x00,0xd2,0x1c,0x01,0xd2,0x5e,0x01,
0xd2,0x1c,0x02,0xd2,0x5e,0x02,0xd2,0x1c,0x03,0xd2,0x5e,0x03,0xd2,0x1c,0x04,0xd2,
0x5e,0x04,0xd2,0x1c,0x05,0xd2,0x5e,0x05,0xd2,0x1c,0x06,0xd2,0x5e,0x06,0xd2,0x1c,
0x07,0xd2,0x5e,0x07,0xd2,0x1c,0x08,0xd2,0x5e,0x08,0xd2,0x1c,0x09,0xd2,0x5e,0x09,
0xd2,0x1c,0x0a,0xd2,0x5e,0x0a,0xd2,0x1c,0x0b,0xd2,0x5e,0x0b,0xd2,0x1c,0x0c,0xd2,
0x5e,0x0c,0xd2,0x1c,0x0d,0xd2,0x5e,0x0d,0xd2,0x1c,0x0e,0xd2,0x5e,0x0e,0xd2,0x1c,
0x0f,0xd2,0x5e,0x0f,0xd2,0x1c,0x10,0xd2,0x5e,0x10,0xd2,0x1c,0x11,0xd2,0x5e,0x11,
0xd2,0x1c,0x12,0xd2,0x5e,0x12,0xd2,0x1c,0x13,0xd2,0x5e,0x13,0xd2,0x1c,0x14,0xd2,
0x5e,0x14,0xd2,0x1c,0x15,0xd2,0x5e,0x15,0xd2,0x1c,0x16,0xd2,0x5e,0x16,0xd2,0x1c,
0x17,0xd2,0x5e,0x17,0xd2,0x1c,0x18,0xd2,0x5e,0x18,0xd2,0x1c,0x19,0xd2,0x5e,0x19,
0xd2,0x1c,0x1a,0xd2,0x5e,0x1a,0xd2,0x1c,0x1b,0xd2,0x5e,0x1b,0xd2,0x1c,0x1c,0xd2,
0x5e,0x1c,0xd2,0x1c,0x1d,0xd2,0x5e,0x1d,0xd2,0x1c,0x1e,0xd2,0x5e,0x1e,0xd2,0x1c,
0x1f,0xd2,0x5e,0x1f,0x2c,0x0d,0xd0,0xbb,0xc0,0xda,0xdd,0xda,0xcc,0xda,0xee,0xd2,
0xa0,0xd0,0xd2,0x5e,0x00,0xd2,0x1a,0x00,0x77,0x6d,0xf9,0xd0,0xd0,0x64,0xdc,0x4d,
0xa6,0x1b,0x02,0x86,0xc4,0xff,0x5c,0x0d,0xd2,0x5a,0x00,0xd2,0xa0,0xff,0xd2,0x5a,
0x00,0x0c,0x0a,0x00,0x40,0x00,0x7c,0xca,0x00,0x40,0x00,0x06,0xff,0xff,
3 changes: 2 additions & 1 deletion src/flash/nor/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ NOR_DRIVERS = \
%D%/w600.c \
%D%/xcf.c \
%D%/xmc1xxx.c \
%D%/xmc4xxx.c
%D%/xmc4xxx.c \
%D%/xtkcml705fl.c

NORHEADERS = \
%D%/core.h \
Expand Down
1 change: 1 addition & 0 deletions src/flash/nor/driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,5 +308,6 @@ extern const struct flash_driver w600_flash;
extern const struct flash_driver xcf_flash;
extern const struct flash_driver xmc1xxx_flash;
extern const struct flash_driver xmc4xxx_flash;
extern const struct flash_driver xtkcml705fl_flash;

#endif /* OPENOCD_FLASH_NOR_DRIVER_H */
1 change: 1 addition & 0 deletions src/flash/nor/drivers.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ static const struct flash_driver * const flash_drivers[] = {
&xmc4xxx_flash,
&w600_flash,
&rsl10_flash,
&xtkcml705fl_flash,
NULL,
};

Expand Down
Loading

0 comments on commit 15af5d0

Please sign in to comment.