jtaglib: add 20-bit DR shift function

This commit is contained in:
Triss 2022-07-20 01:08:13 +02:00
parent 985b390ba2
commit f1d416944c
7 changed files with 52 additions and 0 deletions

View File

@ -266,6 +266,33 @@ uint16_t jtag_default_dr_shift_16(struct jtdev *p, uint16_t data)
/* JTAG state = Run-Test/Idle */ /* JTAG state = Run-Test/Idle */
} }
/* Shifts a given 20-bit word into the JTAG data register through TDI.
* data : 20 bit data
* return: scanned TDO value
*/
uint32_t jtag_default_dr_shift_20(struct jtdev *p, uint32_t data)
{
/* JTAG state = Run-Test/Idle */
jtag_tms_set(p);
jtag_tck_clr(p);
jtag_tck_set(p);
/* JTAG state = Select DR-Scan */
jtag_tms_clr(p);
jtag_tck_clr(p);
jtag_tck_set(p);
/* JTAG state = Capture-DR */
jtag_tck_clr(p);
jtag_tck_set(p);
/* JTAG state = Shift-DR, Shift in TDI (20-bit) */
return jtag_default_shift(p, 20, data);
/* JTAG state = Run-Test/Idle */
}
void jtag_default_tms_sequence(struct jtdev *p, int bits, unsigned int value) void jtag_default_tms_sequence(struct jtdev *p, int bits, unsigned int value)
{ {
for (int i = 0; i < bits; ++i) { for (int i = 0; i < bits; ++i) {
@ -956,6 +983,14 @@ void jtag_erase_flash(struct jtdev *p,
jtag_ir_shift(p, IR_DATA_TO_ADDR); jtag_ir_shift(p, IR_DATA_TO_ADDR);
jtag_dr_shift_16(p, 0xA500); jtag_dr_shift_16(p, 0xA500);
jtag_tclk_set(p); jtag_tclk_set(p);
jtag_tclk_clr(p);
jtag_ir_shift(p, IR_ADDR_16BIT);
jtag_dr_shift_16(p, 0x012C);
jtag_ir_shift(p, IR_DATA_TO_ADDR);
jtag_dr_shift_16(p, 0xA510);
jtag_tclk_set(p);
jtag_release_cpu(p); jtag_release_cpu(p);
} }

View File

@ -123,6 +123,7 @@ int jtag_get_config_fuses(struct jtdev *p);
uint8_t jtag_default_ir_shift(struct jtdev *p, uint8_t ir); uint8_t jtag_default_ir_shift(struct jtdev *p, uint8_t ir);
uint8_t jtag_default_dr_shift_8(struct jtdev *p, uint8_t dr); uint8_t jtag_default_dr_shift_8(struct jtdev *p, uint8_t dr);
uint16_t jtag_default_dr_shift_16(struct jtdev *p, uint16_t dr); uint16_t jtag_default_dr_shift_16(struct jtdev *p, uint16_t dr);
uint32_t jtag_default_dr_shift_20(struct jtdev *p, uint32_t dr);
void jtag_default_tms_sequence(struct jtdev *p, int bits, unsigned int value); void jtag_default_tms_sequence(struct jtdev *p, int bits, unsigned int value);
void jtag_default_init_dap(struct jtdev *p); void jtag_default_init_dap(struct jtdev *p);

View File

@ -359,6 +359,7 @@ const struct jtdev_func jtdev_func_pif = {
.jtdev_ir_shift = jtag_default_ir_shift, .jtdev_ir_shift = jtag_default_ir_shift,
.jtdev_dr_shift_8 = jtag_default_dr_shift_8, .jtdev_dr_shift_8 = jtag_default_dr_shift_8,
.jtdev_dr_shift_16 = jtag_default_dr_shift_16, .jtdev_dr_shift_16 = jtag_default_dr_shift_16,
.jtdev_dr_shift_20 = jtag_default_dr_shift_20,
.jtdev_tms_sequence= jtag_default_tms_sequence, .jtdev_tms_sequence= jtag_default_tms_sequence,
.jtdev_init_dap = jtag_default_init_dap .jtdev_init_dap = jtag_default_init_dap
}; };

View File

@ -68,6 +68,7 @@ struct jtdev_func{
uint8_t (*jtdev_ir_shift)(struct jtdev *p, uint8_t ir); uint8_t (*jtdev_ir_shift)(struct jtdev *p, uint8_t ir);
uint8_t (*jtdev_dr_shift_8)(struct jtdev *p, uint8_t dr); uint8_t (*jtdev_dr_shift_8)(struct jtdev *p, uint8_t dr);
uint16_t (*jtdev_dr_shift_16)(struct jtdev *p, uint16_t dr); uint16_t (*jtdev_dr_shift_16)(struct jtdev *p, uint16_t dr);
uint32_t (*jtdev_dr_shift_20)(struct jtdev *p, uint32_t dr);
void (*jtdev_tms_sequence)(struct jtdev *p, int bits, unsigned int value); void (*jtdev_tms_sequence)(struct jtdev *p, int bits, unsigned int value);
void (*jtdev_init_dap)(struct jtdev *p); void (*jtdev_init_dap)(struct jtdev *p);
}; };

View File

@ -357,6 +357,7 @@ const struct jtdev_func jtdev_func_bp = {
.jtdev_ir_shift = jtag_default_ir_shift, .jtdev_ir_shift = jtag_default_ir_shift,
.jtdev_dr_shift_8 = jtag_default_dr_shift_8, .jtdev_dr_shift_8 = jtag_default_dr_shift_8,
.jtdev_dr_shift_16 = jtag_default_dr_shift_16, .jtdev_dr_shift_16 = jtag_default_dr_shift_16,
.jtdev_dr_shift_20 = jtag_default_dr_shift_20,
.jtdev_tms_sequence= jtag_default_tms_sequence, .jtdev_tms_sequence= jtag_default_tms_sequence,
.jtdev_init_dap = jtag_default_init_dap .jtdev_init_dap = jtag_default_init_dap
}; };

View File

@ -268,6 +268,7 @@ const struct jtdev_func jtdev_func_gpio = {
.jtdev_ir_shift = jtag_default_ir_shift, .jtdev_ir_shift = jtag_default_ir_shift,
.jtdev_dr_shift_8 = jtag_default_dr_shift_8, .jtdev_dr_shift_8 = jtag_default_dr_shift_8,
.jtdev_dr_shift_16 = jtag_default_dr_shift_16, .jtdev_dr_shift_16 = jtag_default_dr_shift_16,
.jtdev_dr_shift_20 = jtag_default_dr_shift_20,
.jtdev_tms_sequence= jtag_default_tms_sequence, .jtdev_tms_sequence= jtag_default_tms_sequence,
.jtdev_init_dap = jtag_default_init_dap .jtdev_init_dap = jtag_default_init_dap
}; };

View File

@ -157,6 +157,17 @@ static uint16_t jtmf_dr_shift_16(struct jtdev *p, uint16_t dr)
return outbuf[0] | ((uint16_t)outbuf[1] << 8); return outbuf[0] | ((uint16_t)outbuf[1] << 8);
} }
static uint32_t jtmf_dr_shift_20(struct jtdev *p, uint32_t dr)
{
struct mehfet_device* d = JTMF_GET_DEV(p);
uint8_t inbuf[3] = { dr & 0xff, (dr >> 8) & 0xff, (dr >> 16) & 0x0f };
uint8_t outbuf[3];
int r = mehfet_cmd_drshift(d->trans, 20, inbuf, outbuf);
if (r < 0) p->failed = 1;
return outbuf[0] | ((uint32_t)outbuf[1] << 8) | ((uint32_t)outbuf[2] << 16);
}
static void jtmf_tms_sequence(struct jtdev *p, int bits, unsigned int value) static void jtmf_tms_sequence(struct jtdev *p, int bits, unsigned int value)
{ {
struct mehfet_device* d = JTMF_GET_DEV(p); struct mehfet_device* d = JTMF_GET_DEV(p);
@ -207,6 +218,7 @@ static const struct jtdev_func jtdev_func_mehfet = {
.jtdev_ir_shift = jtmf_ir_shift, .jtdev_ir_shift = jtmf_ir_shift,
.jtdev_dr_shift_8 = jtmf_dr_shift_8, .jtdev_dr_shift_8 = jtmf_dr_shift_8,
.jtdev_dr_shift_16 = jtmf_dr_shift_16, .jtdev_dr_shift_16 = jtmf_dr_shift_16,
.jtdev_dr_shift_20 = jtmf_dr_shift_20,
.jtdev_tms_sequence= jtmf_tms_sequence, .jtdev_tms_sequence= jtmf_tms_sequence,
.jtdev_init_dap = jtmf_init_dap .jtdev_init_dap = jtmf_init_dap
}; };