[update] unused stlinkv2 commands

pull/11/head
Fabien Le Mentec 2011-10-15 17:21:35 -05:00
rodzic 0c24d59554
commit 840f5e4821
2 zmienionych plików z 68 dodań i 1 usunięć

Wyświetl plik

@ -18,7 +18,7 @@ extern "C" {
// Max data transfer size.
// 6kB = max mem32_read block, 8kB sram
//#define Q_BUF_LEN 96
#define Q_BUF_LEN 1024 * 100
#define Q_BUF_LEN (1024 * 100)
// st-link vendor cmd's
#define USB_ST_VID 0x0483

Wyświetl plik

@ -414,6 +414,9 @@ void _stlink_usb_read_mem32(stlink_t *sl, uint32_t addr, uint16_t len) {
stlink_print_data(sl);
}
#if 1 /* stlinkv1 */
void _stlink_usb_read_all_regs(stlink_t *sl, reg *regp) {
struct stlink_libusb * const slu = sl->backend_data;
unsigned char* const buf = sl->q_buf;
@ -448,6 +451,41 @@ void _stlink_usb_read_all_regs(stlink_t *sl, reg *regp) {
DD(sl, "rw2 = 0x%08x\n", read_uint32(sl->q_buf, 80));
}
#else /* stlinkv2 */
static void _stlink_usb_read_all_regs(stlink_t *sl, reg *regp) {
struct stlink_libusb * const slu = sl->backend_data;
unsigned char* const buf = sl->q_buf;
unsigned char* const cmd_buf = sl->c_buf;
ssize_t size;
int i;
#define STLINK_JTAG_COMMAND 0xf2
#define STLINK_JTAG_READALLREGS2 0x3a
memset(cmd_buf, 0, STLINK_CMD_SIZE);
cmd_buf[0] = STLINK_JTAG_COMMAND;
cmd_buf[1] = STLINK_JTAG_READALLREGS2;
size = send_recv(slu, cmd_buf, STLINK_CMD_SIZE, buf, 84);
if (size == -1) {
printf("[!] send_recv\n");
return;
}
sl->q_len = (size_t) size;
for(i=0; i<16; i++)
regp->r[i]= read_uint32(sl->q_buf, i*4);
regp->xpsr = read_uint32(sl->q_buf, 64);
regp->main_sp = read_uint32(sl->q_buf, 68);
regp->process_sp = read_uint32(sl->q_buf, 72);
regp->rw = read_uint32(sl->q_buf, 76);
regp->rw2 = read_uint32(sl->q_buf, 80);
}
#endif /* stlinkv1 */
void _stlink_usb_read_reg(stlink_t *sl, int r_idx, reg *regp) {
struct stlink_libusb * const slu = sl->backend_data;
unsigned char* const buf = sl->q_buf;
@ -490,6 +528,9 @@ void _stlink_usb_read_reg(stlink_t *sl, int r_idx, reg *regp) {
}
}
#if 1 /* stlinkv1 */
void _stlink_usb_write_reg(stlink_t *sl, uint32_t reg, int idx) {
struct stlink_libusb * const slu = sl->backend_data;
unsigned char* const buf = sl->q_buf;
@ -510,6 +551,32 @@ void _stlink_usb_write_reg(stlink_t *sl, uint32_t reg, int idx) {
stlink_print_data(sl);
}
#else /* stlinkv2 */
void _stlink_usb_write_reg(stlink_t *sl, uint32_t reg, int idx) {
struct stlink_libusb * const slu = sl->backend_data;
unsigned char* const buf = sl->q_buf;
unsigned char *cmd_buf = sl->c_buf;
ssize_t size;
#define STLINK_JTAG_WRITEREG2 0x34
memset(cmd_buf, 0, STLINK_CMD_SIZE);
cmd_buf[0] = STLINK_JTAG_COMMAND;
cmd_buf[1] = STLINK_JTAG_WRITEREG2;
cmd_buf[2] = idx;
write_uint32(cmd_buf + 3, reg);
size = send_recv(slu, cmd_buf, STLINK_CMD_SIZE, buf, 2);
if (size == -1) {
printf("[!] send_recv\n");
return;
}
sl->q_len = (size_t) size;
stlink_print_data(sl);
}
#endif /* stlinkv1 */
stlink_backend_t _stlink_usb_backend = {
_stlink_usb_close,
_stlink_usb_exit_debug_mode,