stuff
This commit is contained in:
parent
e92afbcc06
commit
b51e47810f
|
@ -78,16 +78,46 @@ void mehfet_hw_tclk_burst(uint32_t ncyc) {
|
||||||
sbw_tclk_burst(ncyc);
|
sbw_tclk_burst(ncyc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mehfet_hw_reset_tap(void) {
|
enum mehfet_resettap_status mehfet_hw_reset_tap(enum mehfet_resettap_flags flags) {
|
||||||
// TDI always 1
|
enum mehfet_resettap_status rv = 0;
|
||||||
// TMS=1,1,1,1,1,1 -- reset TAP state to initial
|
|
||||||
// TMS=0 -- test-logic-reset to run-test/idle
|
|
||||||
// TMS=1,0,1,0,1 -- perform fuse check
|
|
||||||
// TMS=1,0 -- back to run-test/idle (needed for SBW only)
|
|
||||||
|
|
||||||
//const uint16_t tms_seq = 0x1abf;//0x3f | (0<<6) | (0x15 << 7) | (0x1 << 12);
|
if (flags & mehfet_rsttap_do_reset) {
|
||||||
const uint8_t tms_seq[2] = {0xbf,0x1a};
|
// TDI always 1
|
||||||
sbw_tms_sequence(14, true, tms_seq);
|
// TMS=1,1,1,1,1,1 -- reset TAP state to initial
|
||||||
|
// TMS=0 -- test-logic-reset to run-test/idle
|
||||||
|
// TMS=1,0,1,0,1 -- perform fuse check
|
||||||
|
// TMS=1,0 -- back to run-test/idle (needed for SBW only)
|
||||||
|
|
||||||
|
//const uint16_t tms_seq = 0x1abf;//0x3f | (0<<6) | (0x15 << 7) | (0x1 << 12);
|
||||||
|
const uint8_t tms_seq[2] = {0xbf,0x1a};
|
||||||
|
sbw_tms_sequence(14, true, tms_seq);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags & mehfet_rsttap_fuse_do) {
|
||||||
|
// TDI always 1
|
||||||
|
// TMS=01010110 // same sequence as above, but without TAP reset
|
||||||
|
const uint8_t tms_seq = 0x6a;
|
||||||
|
sbw_tms_sequence(8, true, &tms_seq);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags & mehfet_rsttap_fuse_read) {
|
||||||
|
for (size_t i = 0; i < 3; ++i) {
|
||||||
|
mehfet_hw_shift_ir(0x14); // CNTRL_SIG_CAPTURE
|
||||||
|
uint16_t dr = mehfet_hw_shift_dr16(0xaaaa);
|
||||||
|
if (dr == 0x5555) {
|
||||||
|
rv |= mehfet_rsttap_fuse_blown;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags & mehfet_rsttap_highspeed) {
|
||||||
|
sbw_set_freq(true, 350e3);
|
||||||
|
} else {
|
||||||
|
sbw_set_freq(false, 50e3);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t mehfet_hw_shift_ir(uint8_t newir) {
|
uint8_t mehfet_hw_shift_ir(uint8_t newir) {
|
||||||
|
|
|
@ -286,12 +286,12 @@ static void my_hid_set_report_cb(uint8_t instance, uint8_t report_id,
|
||||||
#if CFG_TUD_CDC > 0
|
#if CFG_TUD_CDC > 0
|
||||||
static void my_cdc_line_coding_cb(uint8_t itf, cdc_line_coding_t const* line_coding) {
|
static void my_cdc_line_coding_cb(uint8_t itf, cdc_line_coding_t const* line_coding) {
|
||||||
switch (itf) {
|
switch (itf) {
|
||||||
/*#ifdef DBOARD_HAS_UART
|
#ifdef DBOARD_HAS_UART
|
||||||
case CDC_N_UART:
|
case CDC_N_UART:
|
||||||
cdc_uart_set_coding(line_coding->bit_rate, line_coding->stop_bits,
|
cdc_uart_set_coding(line_coding->bit_rate, line_coding->stop_bits,
|
||||||
line_coding->parity, line_coding->data_bits);
|
line_coding->parity, line_coding->data_bits);
|
||||||
break;
|
break;
|
||||||
#endif*/
|
#endif
|
||||||
#ifdef USE_USBCDC_FOR_STDIO
|
#ifdef USE_USBCDC_FOR_STDIO
|
||||||
case CDC_N_STDIO:
|
case CDC_N_STDIO:
|
||||||
stdio_usb_line_coding_cb(line_coding);
|
stdio_usb_line_coding_cb(line_coding);
|
||||||
|
|
|
@ -366,10 +366,10 @@ void mehfet_task(void) {
|
||||||
|
|
||||||
case mehfet_reset_tap:
|
case mehfet_reset_tap:
|
||||||
if (!(mehfet_hw_get_caps() & mehfet_cap_has_reset_tap)) write_resp(mehfet_nocaps, 0, NULL);
|
if (!(mehfet_hw_get_caps() & mehfet_cap_has_reset_tap)) write_resp(mehfet_nocaps, 0, NULL);
|
||||||
else if (cmdhdr.len != 0) write_resp_str(mehfet_badargs, "ResetTAP takes no parameters");
|
else if (cmdhdr.len != 1) write_resp_str(mehfet_badargs, "ResetTAP takes one parameter byte");
|
||||||
else {
|
else {
|
||||||
mehfet_hw_reset_tap();
|
uint8_t v = mehfet_hw_reset_tap(read_pl());
|
||||||
write_resp(mehfet_ok, 0, NULL);
|
write_resp(mehfet_ok, 1, &v);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case mehfet_irshift:
|
case mehfet_irshift:
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// vim: set et:
|
||||||
|
|
||||||
#ifndef M_ISP_MEHFET
|
#ifndef M_ISP_MEHFET
|
||||||
#define M_ISP_MEHFET
|
#define M_ISP_MEHFET
|
||||||
|
@ -12,54 +13,65 @@ void mehfet_deinit(void);
|
||||||
void mehfet_task(void);
|
void mehfet_task(void);
|
||||||
|
|
||||||
enum mehfet_cmd {
|
enum mehfet_cmd {
|
||||||
mehfet_info = 0x01,
|
mehfet_info = 0x01,
|
||||||
mehfet_status = 0x02,
|
mehfet_status = 0x02,
|
||||||
mehfet_connect = 0x03,
|
mehfet_connect = 0x03,
|
||||||
mehfet_disconnect = 0x04,
|
mehfet_disconnect = 0x04,
|
||||||
mehfet_delay = 0x05,
|
mehfet_delay = 0x05,
|
||||||
mehfet_reset_target = 0x06,
|
mehfet_reset_target = 0x06,
|
||||||
mehfet_get_old_lines = 0x07,
|
mehfet_get_old_lines = 0x07,
|
||||||
mehfet_tdio_seq = 0x08,
|
mehfet_tdio_seq = 0x08,
|
||||||
mehfet_tms_seq = 0x09,
|
mehfet_tms_seq = 0x09,
|
||||||
mehfet_tclk_edge = 0x0a,
|
mehfet_tclk_edge = 0x0a,
|
||||||
mehfet_tclk_burst = 0x0b,
|
mehfet_tclk_burst = 0x0b,
|
||||||
mehfet_reset_tap = 0x0c,
|
mehfet_reset_tap = 0x0c,
|
||||||
mehfet_irshift = 0x0d,
|
mehfet_irshift = 0x0d,
|
||||||
mehfet_drshift = 0x0e,
|
mehfet_drshift = 0x0e,
|
||||||
mehfet_loop = 0x0f,
|
mehfet_loop = 0x0f,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum mehfet_status {
|
enum mehfet_status {
|
||||||
mehfet_ok = 0x00,
|
mehfet_ok = 0x00,
|
||||||
|
|
||||||
mehfet_badargs = 0x7b,
|
mehfet_badargs = 0x7b,
|
||||||
mehfet_nocaps = 0x7c,
|
mehfet_nocaps = 0x7c,
|
||||||
mehfet_badstate = 0x7d,
|
mehfet_badstate = 0x7d,
|
||||||
mehfet_invalidcmd = 0x7e,
|
mehfet_invalidcmd = 0x7e,
|
||||||
mehfet_error = 0x7f
|
mehfet_error = 0x7f
|
||||||
};
|
};
|
||||||
|
|
||||||
enum mehfet_caps {
|
enum mehfet_caps {
|
||||||
mehfet_cap_jtag_noentry = 1<<0,
|
mehfet_cap_jtag_noentry = 1<<0,
|
||||||
mehfet_cap_jtag_entryseq = 1<<1,
|
mehfet_cap_jtag_entryseq = 1<<1,
|
||||||
mehfet_cap_sbw_entryseq = 1<<2,
|
mehfet_cap_sbw_entryseq = 1<<2,
|
||||||
|
|
||||||
mehfet_cap_has_reset_tap = 1<< 8,
|
mehfet_cap_has_reset_tap = 1<< 8,
|
||||||
mehfet_cap_has_irshift = 1<< 9,
|
mehfet_cap_has_irshift = 1<< 9,
|
||||||
mehfet_cap_has_drshift = 1<<10,
|
mehfet_cap_has_drshift = 1<<10,
|
||||||
mehfet_cap_has_loop = 1<<11,
|
mehfet_cap_has_loop = 1<<11,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum mehfet_conn {
|
enum mehfet_conn {
|
||||||
mehfet_conn_none = 0,
|
mehfet_conn_none = 0,
|
||||||
mehfet_conn_auto = 0,
|
mehfet_conn_auto = 0,
|
||||||
|
|
||||||
mehfet_conn_jtag_noentry = 1,
|
mehfet_conn_jtag_noentry = 1,
|
||||||
mehfet_conn_jtag_entryseq = 2,
|
mehfet_conn_jtag_entryseq = 2,
|
||||||
mehfet_conn_sbw_entryseq = 3,
|
mehfet_conn_sbw_entryseq = 3,
|
||||||
|
|
||||||
mehfet_conn_typemask = 0x7f,
|
mehfet_conn_typemask = 0x7f,
|
||||||
mehfet_conn_nrstmask = 0x80
|
mehfet_conn_nrstmask = 0x80
|
||||||
|
};
|
||||||
|
|
||||||
|
enum mehfet_resettap_flags {
|
||||||
|
mehfet_rsttap_do_reset = 1<<0, // reset TAP to run-test/idle state
|
||||||
|
mehfet_rsttap_fuse_do = 1<<1, // perform fuse check procedure (TMS pulses) on target
|
||||||
|
mehfet_rsttap_fuse_read = 1<<2, // check whether the JTAG fuse has been blown
|
||||||
|
mehfet_rsttap_highspeed = 1<<3, // can move to high-speed transport afterwards
|
||||||
|
// (fuse check procedure is max 50 kHz)
|
||||||
|
};
|
||||||
|
enum mehfet_resettap_status {
|
||||||
|
mehfet_rsttap_fuse_blown = 0x80
|
||||||
};
|
};
|
||||||
|
|
||||||
// hw routines
|
// hw routines
|
||||||
|
@ -86,10 +98,17 @@ void mehfet_hw_tms_seq(uint32_t ncyc, bool tdilvl, const uint8_t* tms);
|
||||||
void mehfet_hw_tclk_edge(bool newtclk);
|
void mehfet_hw_tclk_edge(bool newtclk);
|
||||||
void mehfet_hw_tclk_burst(uint32_t ncyc);
|
void mehfet_hw_tclk_burst(uint32_t ncyc);
|
||||||
|
|
||||||
void mehfet_hw_reset_tap(void);
|
enum mehfet_resettap_status mehfet_hw_reset_tap(enum mehfet_resettap_flags flags);
|
||||||
uint8_t mehfet_hw_shift_ir(uint8_t newir);
|
uint8_t mehfet_hw_shift_ir(uint8_t newir);
|
||||||
// drin is not const here, as the implementation may want to shuffle stuff around
|
// drin is not const here, as the implementation may want to shuffle stuff around
|
||||||
void mehfet_hw_shift_dr(uint32_t nbits, uint8_t* drin, uint8_t* drout);
|
void mehfet_hw_shift_dr(uint32_t nbits, uint8_t* drin, uint8_t* drout);
|
||||||
|
static inline uint16_t mehfet_hw_shift_dr16(uint16_t newdr) {
|
||||||
|
uint8_t drin[2], drout[2];
|
||||||
|
drin[0] = (uint8_t)newdr;
|
||||||
|
drin[1] = (uint8_t)(newdr >> 8);
|
||||||
|
mehfet_hw_shift_dr(16, drin, drout);
|
||||||
|
return drout[0] | ((uint16_t)drout[1] << 8);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue