jtaglib: Xv2 read/write reg now (finally) working, PC gets reset every so often due to other routines
This commit is contained in:
parent
649d82b695
commit
37aacaca2d
|
@ -932,6 +932,12 @@ int jtag_dev_init(struct jtdev *p) {
|
|||
if (!chip) {
|
||||
printc_err("jtaglib: unknown chip ID\n");
|
||||
} else {
|
||||
// NOTE: This prevents the device_probe_id() function (defined in
|
||||
// device.h) from probing the target identification again, as can
|
||||
// be seen at the start of the implementation of that function in
|
||||
// device.c . Thus, care needs to be taken to not let these two
|
||||
// functions diverge in behavior. v3hil contains yet another
|
||||
// implementation of this.
|
||||
p->base.chip = chip;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,13 +20,15 @@ static int jlfxv2_check_full_emu_state_ex(struct jtdev *p, const char* fnname)
|
|||
uint16_t dr;
|
||||
uint8_t jtag_id;
|
||||
|
||||
jtag_id = jtag_ir_shift(p, IR_CNTRL_SIG_CAPTURE);
|
||||
if (((dr = jtag_dr_shift_16(p, 0)) & 0x0301) == 0x0301) {
|
||||
return 1; // OK
|
||||
}
|
||||
for (int i = 0; i < 1/*10*/; ++i) {
|
||||
jtag_id = jtag_ir_shift(p, IR_CNTRL_SIG_CAPTURE);
|
||||
if (((dr = jtag_dr_shift_16(p, 0)) & 0x0301) == 0x0301) {
|
||||
return 1; // OK
|
||||
}
|
||||
|
||||
printc_err("jlfxv2: %s: not in full emu state, while expected!"
|
||||
" (dr=%04x jid=%02x)\n", fnname, dr, jtag_id);
|
||||
printc_err("jlfxv2: %s: not in full emu state, while expected!"
|
||||
" (dr=%04x jid=%02x)\n", fnname, dr, jtag_id);
|
||||
}
|
||||
p->failed = 1;
|
||||
|
||||
return 0;
|
||||
|
@ -452,9 +454,9 @@ static address_t jlfxv2_read_reg(struct jtdev *p, int reg)
|
|||
{ // libmsp430 BIOS name: ReadCpuReg
|
||||
uint16_t reglo, reghi;
|
||||
uint16_t jtag_id, jmb_addr;
|
||||
const bool alt_addr = true;
|
||||
const bool alt_addr = false;//true;
|
||||
|
||||
if (reg == 3) return 0; // CG
|
||||
if (reg == 2 || reg == 3) return 0; // CG
|
||||
|
||||
printc_dbg("read reg %d\n", reg);
|
||||
if (!jlfxv2_check_full_emu_state(p))
|
||||
|
@ -464,7 +466,7 @@ static address_t jlfxv2_read_reg(struct jtdev *p, int reg)
|
|||
jtag_tclk_clr(p);
|
||||
jtag_ir_shift(p, IR_DATA_16BIT);
|
||||
jtag_tclk_set(p);
|
||||
jtag_dr_shift_16(p, reg);
|
||||
jtag_dr_shift_16(p, ((reg << 8) & 0x0f00) | 0x0060);
|
||||
jtag_ir_shift(p, IR_CNTRL_SIG_16BIT);
|
||||
jtag_dr_shift_16(p, 0x1401);
|
||||
jtag_ir_shift(p, IR_DATA_16BIT);
|
||||
|
@ -510,6 +512,13 @@ static address_t jlfxv2_read_reg(struct jtdev *p, int reg)
|
|||
jtag_tclk_set(p);
|
||||
|
||||
printc_dbg("read reg %d: lo=%04x hi=%04x\n", reg, reglo, reghi);
|
||||
|
||||
jlfxv2_set_pc(p, SAFE_FRAM_PC);
|
||||
jtag_ir_shift(p, IR_CNTRL_SIG_16BIT);
|
||||
jtag_dr_shift_16(p, 0x0501);
|
||||
jtag_tclk_set(p);
|
||||
jtag_ir_shift(p, IR_ADDR_CAPTURE);
|
||||
|
||||
return reglo | ((address_t)reghi << 16);
|
||||
}
|
||||
|
||||
|
@ -519,13 +528,13 @@ static void jlfxv2_write_reg(struct jtdev *p, int reg, address_t value)
|
|||
jlfxv2_check_full_emu_state(p);
|
||||
printc_dbg("write reg %d %06x\n", reg, value);
|
||||
|
||||
jtag_ir_shift(p, IR_CNTRL_SIG_CAPTURE);
|
||||
jtag_dr_shift_16(p, 0);
|
||||
/*jtag_ir_shift(p, IR_CNTRL_SIG_CAPTURE);
|
||||
jtag_dr_shift_16(p, 0);*/
|
||||
|
||||
jtag_tclk_clr(p);
|
||||
jtag_ir_shift(p, IR_DATA_16BIT);
|
||||
jtag_tclk_set(p);
|
||||
jtag_dr_shift_16(p, 0x0080 | ((value >> 8) & 0x0f00));
|
||||
jtag_dr_shift_16(p, 0x0080 | ((value >> 8) & 0x0f00) | (reg & 0xf));
|
||||
|
||||
//jtag_tclk_clr(p);
|
||||
jtag_ir_shift(p, IR_CNTRL_SIG_16BIT);
|
||||
|
|
Loading…
Reference in New Issue