flash/stm32f1x: add support for RISC-V GigaDevice GD32VF103
The device has compatible flash macro with STM32F1 family, reuse stm32f1x driver code. Detect non-ARM target - for simplicy test target type name 'riscv' and the address has 32 bits. In case of RISC-V CPU use simple chunked write algo - async algo cannot be used as the core implemented in this device doesn't allow memory access while running. Change-Id: Ie3886fbd8573652691f91a02335812a7300689f7 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/6704 Tested-by: jenkins Reviewed-by: Tim Newsome <tim@sifive.com>
This commit is contained in:
28
contrib/loaders/flash/gd32vf103/Makefile
Normal file
28
contrib/loaders/flash/gd32vf103/Makefile
Normal file
@@ -0,0 +1,28 @@
|
||||
BIN2C = ../../../../src/helper/bin2char.sh
|
||||
|
||||
CROSS_COMPILE ?= riscv-none-embed-
|
||||
|
||||
CC=$(CROSS_COMPILE)gcc
|
||||
OBJCOPY=$(CROSS_COMPILE)objcopy
|
||||
OBJDUMP=$(CROSS_COMPILE)objdump
|
||||
|
||||
CFLAGS = -march=rv32i -mabi=ilp32 -static -nostartfiles -nostdlib -Os -g -fPIC
|
||||
|
||||
all: gd32vf103.inc
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
%.elf: %.c
|
||||
$(CC) $(CFLAGS) $< -o $@
|
||||
|
||||
%.lst: %.elf
|
||||
$(OBJDUMP) -S $< > $@
|
||||
|
||||
%.bin: %.elf
|
||||
$(OBJCOPY) -Obinary $< $@
|
||||
|
||||
%.inc: %.bin
|
||||
$(BIN2C) < $< > $@
|
||||
|
||||
clean:
|
||||
-rm -f *.elf *.lst *.bin *.inc
|
||||
33
contrib/loaders/flash/gd32vf103/gd32vf103.c
Normal file
33
contrib/loaders/flash/gd32vf103/gd32vf103.c
Normal file
@@ -0,0 +1,33 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define FLASH_BSY (1 << 0)
|
||||
#define FLASH_PGERR (1 << 2)
|
||||
#define FLASH_WRPRTERR (1 << 4)
|
||||
|
||||
void flash_write(volatile uint32_t *flash_sr,
|
||||
uint32_t hwords_count,
|
||||
uint16_t *buffer,
|
||||
uint16_t *target_addr) __attribute__((naked));
|
||||
|
||||
void flash_write(volatile uint32_t *flash_sr,
|
||||
uint32_t hwords_count,
|
||||
uint16_t *buffer,
|
||||
uint16_t *target_addr)
|
||||
{
|
||||
do {
|
||||
*target_addr = *buffer++;
|
||||
|
||||
register uint32_t sr;
|
||||
do {
|
||||
sr = *flash_sr;
|
||||
} while (sr & FLASH_BSY);
|
||||
|
||||
if (sr & (FLASH_PGERR | FLASH_WRPRTERR))
|
||||
break;
|
||||
|
||||
target_addr++;
|
||||
} while (--hwords_count);
|
||||
asm("ebreak");
|
||||
}
|
||||
4
contrib/loaders/flash/gd32vf103/gd32vf103.inc
Normal file
4
contrib/loaders/flash/gd32vf103/gd32vf103.inc
Normal file
@@ -0,0 +1,4 @@
|
||||
/* Autogenerated with ../../../../src/helper/bin2char.sh */
|
||||
0x83,0x57,0x06,0x00,0x13,0x06,0x26,0x00,0x23,0x90,0xf6,0x00,0x83,0x27,0x05,0x00,
|
||||
0x13,0xf7,0x17,0x00,0xe3,0x1c,0x07,0xfe,0x93,0xf7,0x47,0x01,0x63,0x98,0x07,0x00,
|
||||
0x93,0x85,0xf5,0xff,0x93,0x86,0x26,0x00,0xe3,0x9c,0x05,0xfc,0x73,0x00,0x10,0x00,
|
||||
Reference in New Issue
Block a user