Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RISCV: Add some quirks to be compatible with CH32V3x chips #1576

Closed
wants to merge 65 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
cab0ce7
riscv_debug: Begun building a scan handler for RISC-V debug v0.13 dev…
dragonmux Feb 8, 2023
e971f4e
riscv_debug: Created a stub for initialising a DMI
dragonmux Feb 8, 2023
8b8a9cd
riscv_debug: Implemented a way to read/write the DTM control/status r…
dragonmux Feb 8, 2023
8591f9d
riscv_debug: Moved the JTAG-specific DTM handler into the JTAG DTM im…
dragonmux Mar 21, 2023
c6116c6
riscv_debug: Implemented support for reading and dispatching the DTM …
dragonmux Feb 8, 2023
ff93599
riscv_debug: Implemented reference counting and stub structures for t…
dragonmux Feb 8, 2023
9d6d31a
riscv_debug: Restructed riscv_dmi_init() and riscv_jtag_dtm_init() to…
dragonmux Feb 8, 2023
bccb9d8
riscv_debug: Handle the idle cycles component of the DTMCS register
dragonmux Feb 8, 2023
a21e4da
riscv_debug: Implemented a way to read the DMI address space
dragonmux Feb 8, 2023
f969d20
riscv_debug: Implemented logic for iterating and discovering DMs
dragonmux Feb 8, 2023
dac65a9
riscv_debug: Begun implementing the hart enumeration process
dragonmux Feb 8, 2023
5ff9be9
riscv_debug: Implemented enumeration of the harts associated with a DM
dragonmux Feb 8, 2023
be170e3
riscv_debug: Implemented support for grabbing the hart's address bus …
dragonmux Feb 8, 2023
8873ffc
riscv_debug: Implemented halt and resume support in preparation for r…
dragonmux Feb 8, 2023
886f952
riscv_debug: Implemented readout of CSRs and reading the 4 hart ident…
dragonmux Feb 8, 2023
869b3a6
riscv_debug: Implemented readout of the ISA register to determine add…
dragonmux Feb 8, 2023
e32e9e9
riscv_debug: Implemented the ability for riscv_reg_read() to do 128-,…
dragonmux Feb 9, 2023
1af6766
riscv_debug: Implemented support for discovering the target Hart's IS…
dragonmux Feb 9, 2023
a9aed1d
riscv_debug: Implemented writing to CSRs
dragonmux Feb 9, 2023
160c39f
riscv_debug: Created probe stubs for probing RISC-V 32- and 64-bit ta…
dragonmux Feb 9, 2023
0cf9ddb
riscv_debug: Set up the target designer code field
dragonmux Feb 9, 2023
5d34e84
riscv_debug: Documented the used CSR addresses
dragonmux Feb 9, 2023
d569c25
riscv_debug: Implemented the ability to force a CSR access to a speci…
dragonmux Feb 9, 2023
44ff42f
riscv_debug: Implemented single-stepping support in riscv_halt_resume()
dragonmux Feb 9, 2023
b62ee67
riscv_debug: Added definitions for the abstract memory access command
dragonmux Feb 9, 2023
ccb0180
riscv_debug: Implemented arbitrary memory read
dragonmux Feb 9, 2023
375c534
riscv_debug: Fixed the target hart not being halted during probing
dragonmux Feb 9, 2023
2a8d6ec
riscv_debug: Added some DEBUG_TARGET information to the CSR functions…
dragonmux Feb 9, 2023
0e42830
riscv_debug: Implemented the target check_error hook
dragonmux Feb 9, 2023
894e67e
riscv_debug: Made more of the DM and hart machinary available in the …
dragonmux Feb 9, 2023
303dc9b
riscv_debug: Moved the mem_read implementation into the bitness-speci…
dragonmux Feb 9, 2023
7a23e9b
riscv_debug: Forced the vendor ID to be read 32-bit per the privilege…
dragonmux Feb 9, 2023
b785227
stm32f1: Implemented a probe routine for GD32VF1
dragonmux Feb 9, 2023
0222b0a
riscv32: Implemented probing for the GD32VF1
dragonmux Feb 9, 2023
b97b1f3
riscv_debug: Handle the rv128 case by complaining to the user we don'…
dragonmux Feb 9, 2023
924a68b
riscv_debug: Begun implementing attach/detach
dragonmux Feb 9, 2023
21c47e0
riscv_debug: Populated target->cpuid and made use of it in gd32vf1_pr…
dragonmux Feb 9, 2023
1fdffd0
riscv_debug: Implemented building the target description XML
dragonmux Feb 10, 2023
1f3b55c
riscv_debug: Implemented regs_read for both rv32 and rv64
dragonmux Feb 10, 2023
100390c
riscv_debug: Halt the hart we're looking at to on attach, and resume …
dragonmux Feb 10, 2023
aac72c0
riscv32: Added some better documentation for what various things do
dragonmux Feb 10, 2023
4b46051
riscv64: Added some better documentation for what various things do
dragonmux Feb 10, 2023
93ec38d
riscv_debug: Fixed a couple of mistakes in the comments for riscv_dmi…
dragonmux Feb 10, 2023
ef9da51
riscv_debug: Implemented the target halt_poll hook
dragonmux Feb 10, 2023
2d57b3e
riscv_debug: Implemented discovery of the available "trigger" slots a…
dragonmux Feb 10, 2023
b68ac4e
riscv_debug: Implemented support machinary for being able to set watc…
dragonmux Feb 10, 2023
c595442
riscv_debug: Added documentation on where to find the debug specs used
dragonmux Feb 10, 2023
c510620
riscv_debug: Implemented a translator for a breakwatch size to match …
dragonmux Feb 10, 2023
024ea09
riscv32: Implemented the target breakwatch_set hook
dragonmux Feb 10, 2023
f2be6c9
riscv32: Implemented the target breakwatch_clear hook
dragonmux Feb 10, 2023
a52a7af
gdb_main: Added some comments to aid with understanding handle_z_pack…
dragonmux Feb 10, 2023
12ce818
stm32f1: Modified the Flash routines to work with GD32VF103 parts too
dragonmux Feb 11, 2023
47887cd
riscv_debug: Moved the part ID readout into its own function, fixing …
dragonmux Feb 11, 2023
334e5bd
riscv_debug: Implemented target reset
dragonmux Feb 11, 2023
806ba59
riscv_debug: Refactored out the DM state polling code into a new func…
dragonmux Feb 11, 2023
b4e5bbd
riscv_debug: Implemented polling for reset succeeding and then acknow…
dragonmux Feb 11, 2023
27ee42b
riscv32: Improved the checks in riscv32_breakwatch_set() to avoid usi…
dragonmux Feb 11, 2023
5984ece
riscv_debug: Cleaned up the nomenclature of riscv_halt_poll()'s halt …
dragonmux Feb 11, 2023
cbfb20d
riscv_debug: Implemented regs_write for both rv32 and rv64
dragonmux Feb 11, 2023
7869da3
riscv32: Implemented mem_write and a data packing helper
dragonmux Feb 11, 2023
d9692a3
riscv_debug: Transform JTAG ID Code designer into JEP-106 internal fo…
perigoso Feb 19, 2023
a3b1afc
riscv_debug: Fixed the vendor ID decode in riscv_hart_read_ids() to a…
dragonmux Mar 28, 2023
4d881c0
riscv_debug: Implemented poll timeouts for halt/resume
dragonmux Apr 1, 2023
9829a38
RISCV: Add some quirks to be compatible with CH32V3x chips. The error…
Jul 29, 2023
86a86ab
RISCV: WCH, take style remark into account
Jul 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 60 additions & 56 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,62 +23,66 @@ ifeq ($(ENABLE_DEBUG), 1)
CFLAGS += -DENABLE_DEBUG
endif

SRC = \
adiv5.c \
adiv5_jtag.c \
adiv5_swd.c \
command.c \
cortexa.c \
cortexm.c \
crc32.c \
efm32.c \
exception.c \
gdb_if.c \
gdb_main.c \
gdb_hostio.c \
gdb_packet.c \
gdb_reg.c \
hex_utils.c \
hc32l110.c \
imxrt.c \
jtag_devs.c \
jtag_scan.c \
lmi.c \
lpc_common.c \
lpc11xx.c \
lpc17xx.c \
lpc15xx.c \
lpc40xx.c \
lpc43xx.c \
lpc546xx.c \
lpc55xx.c \
kinetis.c \
main.c \
maths_utils.c \
morse.c \
msp432e4.c \
msp432p4.c \
nrf51.c \
nxpke04.c \
remote.c \
rp.c \
sam3x.c \
sam4l.c \
samd.c \
samx5x.c \
sfdp.c \
spi.c \
stm32f1.c \
ch32f1.c \
stm32f4.c \
stm32h5.c \
stm32h7.c \
stm32l0.c \
stm32l4.c \
stm32g0.c \
renesas.c \
target.c \
target_flash.c \
SRC = \
adiv5.c \
adiv5_jtag.c \
adiv5_swd.c \
command.c \
cortexa.c \
cortexm.c \
crc32.c \
efm32.c \
exception.c \
gdb_if.c \
gdb_main.c \
gdb_hostio.c \
gdb_packet.c \
gdb_reg.c \
hex_utils.c \
hc32l110.c \
imxrt.c \
jtag_devs.c \
jtag_scan.c \
lmi.c \
lpc_common.c \
lpc11xx.c \
lpc17xx.c \
lpc15xx.c \
lpc40xx.c \
lpc43xx.c \
lpc546xx.c \
lpc55xx.c \
kinetis.c \
main.c \
maths_utils.c \
morse.c \
msp432e4.c \
msp432p4.c \
nrf51.c \
nxpke04.c \
remote.c \
riscv32.c \
riscv64.c \
riscv_debug.c \
riscv_jtag_dtm.c \
rp.c \
sam3x.c \
sam4l.c \
samd.c \
samx5x.c \
sfdp.c \
spi.c \
stm32f1.c \
ch32f1.c \
stm32f4.c \
stm32h5.c \
stm32h7.c \
stm32l0.c \
stm32l4.c \
stm32g0.c \
renesas.c \
target.c \
target_flash.c \
target_probe.c

ifeq (,$(filter all_platforms,$(MAKECMDGOALS)))
Expand Down
3 changes: 3 additions & 0 deletions src/gdb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,10 +682,13 @@ static void handle_z_packet(char *packet, const size_t plen)
else
ret = target_breakwatch_clear(cur_target, type, addr, len);

/* If the target handler was unable to set/clear the break/watch-point, return an error */
if (ret < 0)
gdb_putpacketz("E01");
/* If the handler does not support the kind requested, return empty string */
else if (ret > 0)
gdb_putpacketz("");
/* Otherwise let GDB know that everything went well */
else
gdb_putpacketz("OK");
}
Expand Down
5 changes: 5 additions & 0 deletions src/target/adiv5.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@
#define JTAG_IDCODE_PARTNO_MASK (0xffffU << JTAG_IDCODE_PARTNO_OFFSET)
#define JTAG_IDCODE_DESIGNER_OFFSET 1U
#define JTAG_IDCODE_DESIGNER_MASK (0x7ffU << JTAG_IDCODE_DESIGNER_OFFSET)
/* Bits 10:7 - JEP-106 Continuation code */
/* Bits 6:0 - JEP-106 Identity code */
#define JTAG_IDCODE_DESIGNER_JEP106_CONT_OFFSET 7U
#define JTAG_IDCODE_DESIGNER_JEP106_CONT_MASK (0xfU << ADIV5_DP_DESIGNER_JEP106_CONT_OFFSET)
#define JTAG_IDCODE_DESIGNER_JEP106_CODE_MASK (0x7fU)

#define JTAG_IDCODE_ARM_DPv0 UINT32_C(0x4ba00477)

Expand Down
5 changes: 5 additions & 0 deletions src/target/jep106.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@
#define JEP106_MANUFACTURER_RASPBERRY 0x913U /* Raspberry Pi */
#define JEP106_MANUFACTURER_RENESAS 0x423U /* Renesas */
#define JEP106_MANUFACTURER_XILINX 0x309U /* Xilinx */
/*
* This JEP code should belong to "Andes Technology Corporation", but is used on RISC-V by GigaDevice,
* so in the unlikely event we need to support chips by them, here be dragons.
*/
#define JEP106_MANUFACTURER_RV_GIGADEVICE 0x61eU

/*
* This code is not listed in the JEP106 standard, but is used by some stm32f1 clones
Expand Down
8 changes: 5 additions & 3 deletions src/target/jtag_devs.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "general.h"
#include "jtag_scan.h"
#include "adiv5.h"
#include "riscv_debug.h"
#include "jtag_devs.h"

const jtag_dev_descr_s dev_descr[] = {
Expand Down Expand Up @@ -112,9 +113,10 @@ const jtag_dev_descr_s dev_descr[] = {
},
},
{
.idcode = 0x0000063dU,
.idmask = 0x00000fffU,
.descr = "Xambala: RVDBG013.",
.idcode = 0x0000563dU,
.idmask = 0x0fffffffU,
.descr = "RISC-V debug v0.13.",
.handler = riscv_jtag_dtm_handler,
},
{
.idcode = 0x000007a3U,
Expand Down
Loading