Беспроводная отладка STM32

ESP8266 STM32 openOCD. () .

, :

  1. openOCD
  2. ESP8266

. openOCD SWD, remote_bitbang. , 1 0 .

( ESP8266) . remote_bitbang SWD, :

--- remote_bitbang.c	2016-10-31 11:06:57.812267924 +0600
+++ remote_bitbang.c	2016-10-31 12:33:57.921692808 +0600
@@ -120,11 +120,25 @@
 	remote_bitbang_putc(c);
 }
 
+static int remote_bitbang_swdio_read (void)
+{
+	remote_swd_putc ('R');
+	return remote_bitbang_rread ();
+}
+
+static void remote_bitbang_swdio_drive (bool is_output)
+{
+	char c = is_output ? 'o' : 'i';
+	remote_bitbang_putc (c);
+}
+
 static struct bitbang_interface remote_bitbang_bitbang = {
 	.read = &remote_bitbang_read,
 	.write = &remote_bitbang_write,
 	.reset = &remote_bitbang_reset,
 	.blink = &remote_bitbang_blink,
+	.swdio_read = &remote_bitbang_swdio_read,
+	.swdio_drive = &remote_bitbang_swdio_drive,	
 };
 
 static int remote_bitbang_init_tcp(void)
@@ -271,10 +285,14 @@
 	COMMAND_REGISTRATION_DONE,
 };
 
+static const char * const remote_bitbang_transport[] = { "jtag", "swd", NULL };
+
 struct jtag_interface remote_bitbang_interface = {
 	.name = "remote_bitbang",
+	.transports = remote_bitbang_transport,
 	.execute_queue = &bitbang_execute_queue,
 	.commands = remote_bitbang_command_handlers,
+	.swd = &bitbang_swd,
 	.init = &remote_bitbang_init,
 	.quit = &remote_bitbang_quit,
 };


ESP8266, , openOCD. SDK esp-open-rtos. — , , openOCD.

#define SWCLK				0
#define SWDIO				2

IRAM void openocd_handler (void *pvParameters)
{
	struct netconn *nc = (struct netconn *) pvParameters;
	struct netbuf *rbuf = NULL;
	char *rx_buf;
	char d, r;
	err_t err;
	uint16_t len;
	uint16_t i;
	
	gpio_set_pullup (SWCLK, false, false);
	gpio_set_pullup (SWDIO, false, false);
	gpio_enable (SWCLK, GPIO_OUTPUT);
	gpio_enable (SWDIO, GPIO_OUTPUT);
	
	while (1)
	{
		if ((err = netconn_recv (nc, &rbuf)) != ERR_OK) {
			printf ("R ERROR %d\n", err);
			return;
		}
		
		netbuf_data (rbuf, (void **) &rx_buf, &len);	
		
		for (i = 0; i < len; i++)
		{
			switch (rx_buf [i])
			{
			case 'Q':		// Quit
				netconn_disconnect (nc);
				return;
			
			case '0'...'7':
				d = rx_buf [i] - '0';
				gpio_write (SWDIO, (d & 0x1));
				gpio_write (SWCLK, !!(d & 0x4));								
				break;
			
			case 'i':
				gpio_enable (SWDIO, GPIO_INPUT);
				break;
			
			case 'o':
				gpio_enable (SWDIO, GPIO_OUTPUT);
				break;
			
			case 'R':		// Writeback
				r = ((char) gpio_read (SWDIO)) + '0';
				netconn_write (nc, &r, 1, NETCONN_COPY);
				break; 
			}
		}
		
		netbuf_delete (rbuf);
	}
}


.

ESP-01. GPIO-0 GPIO-2, 2- . 10 .

. , , , .

, openOCD ESP8266 st-link, .

, - .

Source: https://habr.com/ru/post/de398781/


All Articles