usb implementation provided by Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
Glued together again by me. With this change, gdbserver actually enters debug and gdbserver
stays open!
sl->backend->enter_swd_mode(sl);
}
+// Force the core into the debug mode -> halted state.
+void stlink_force_debug(stlink_t *sl) {
+ D(sl, "\n*** stlink_force_debug_mode ***\n");
+ sl->backend->force_debug(sl);
+}
+
void stlink_exit_dfu_mode(stlink_t *sl) {
D(sl, "\n*** stlink_exit_dfu_mode ***\n");
sl->backend->exit_dfu_mode(sl);
void (*write_reg) (stlink_t *sl, uint32_t reg, int idx);
void (*step) (stlink_t * stl);
int (*current_mode) (stlink_t * stl);
+ void (*force_debug) (stlink_t *sl);
} stlink_backend_t;
struct _stlink {
void stlink_write_reg(stlink_t *sl, uint32_t reg, int idx);
void stlink_step(stlink_t *sl);
int stlink_current_mode(stlink_t *sl);
+ void stlink_force_debug(stlink_t *sl);
// unprocessed
- void stlink_force_debug(stlink_t *sl);
-
int stlink_erase_flash_mass(stlink_t* sl);
int stlink_write_flash(stlink_t* sl, stm32_addr_t address, uint8_t* data, unsigned length);
// Force the core into the debug mode -> halted state.
-void stlink_force_debug(stlink_t *sl) {
+void _stlink_sg_force_debug(stlink_t *sl) {
struct stlink_libsg *sg = sl->backend_data;
D(sl, "\n*** stlink_force_debug ***\n");
clear_cdb(sg);
_stlink_sg_read_reg,
_stlink_sg_write_reg,
_stlink_sg_step,
- _stlink_sg_current_mode
+ _stlink_sg_current_mode,
+ _stlink_sg_force_debug
};
stlink_t* stlink_open(const char *dev_name, const int verbose) {
}
+void _stlink_usb_force_debug(stlink_t *sl) {
+ struct stlink_libusb *slu = sl->backend_data;
+ unsigned char* const buf = sl->q_buf;
+ ssize_t size;
+
+ memset(buf, 0, sizeof (sl->q_buf));
+
+ buf[0] = STLINK_DEBUG_COMMAND;
+ buf[1] = STLINK_DEBUG_FORCEDEBUG;
+ size = send_recv(slu, buf, STLINK_CMD_SIZE, buf, sizeof (sl->q_buf));
+ if (size == -1) {
+ printf("[!] send_recv\n");
+ return;
+ }
+}
+
+
void _stlink_usb_enter_swd_mode(stlink_t * sl) {
struct stlink_libusb * const slu = sl->backend_data;
unsigned char* const buf = sl->q_buf;
_stlink_usb_read_reg,
_stlink_usb_write_reg,
_stlink_usb_step,
- _stlink_usb_current_mode
+ _stlink_usb_current_mode,
+ _stlink_usb_force_debug
};