{"id":280365,"date":"2016-11-02T16:05:03","date_gmt":"2016-11-02T13:05:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=280365"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=280365","title":{"rendered":"\u0411\u0435\u0441\u043f\u0440\u043e\u0432\u043e\u0434\u043d\u0430\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0430 STM32"},"content":{"rendered":"<p>\u0425\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 ESP8266 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u0441\u0440\u0435\u0434\u043d\u0438\u043a\u0430 \u043c\u0435\u0436\u0434\u0443 STM32 \u0438 openOCD. \u0423 \u044d\u0442\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432 \u0438 \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0437\u0432\u0430\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e (\u043f\u0440\u043e\u0432\u043e\u0434\u043d\u043e\u0433\u043e) \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u043e\u0442\u043b\u0430\u0434\u043a\u0438. <\/p>\n<p>  \u041f\u043b\u044e\u0441 \u0443 \u044d\u0442\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043e\u0434\u0438\u043d \u0438 \u043e\u043d \u043e\u0447\u0435\u0432\u0438\u0434\u0435\u043d, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u0439\u0434\u0443 \u0441\u0440\u0430\u0437\u0443 \u043a \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0430\u043c:<\/p>\n<ol>\n<li>\u0422\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u0430\u0442\u0447\u0438\u0442\u044c openOCD<\/li>\n<li>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0443 \u0432 ESP8266<\/li>\n<li>\u041d\u0438\u0437\u043a\u0430\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b<\/li>\n<\/ol>\n<p><a name=\"habracut\"><\/a><br \/>  \u041a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0412 openOCD \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 SWD, \u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e \u0442\u0430\u043c \u0435\u0441\u0442\u044c \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c remote_bitbang. \u0418\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0443\u0440\u043e\u0432\u043d\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0447\u0438\u0441\u043b\u0430\u043c\u0438 1 \u0438 0 \u0438 \u0434\u0430\u043b\u0435\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u043e \u0441\u0435\u0442\u0438. <\/p>\n<p>  \u041f\u0440\u0438\u0435\u043c\u043d\u0438\u043a (\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 ESP8266) \u0434\u043e\u043b\u0436\u0435\u043d \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u044d\u0442\u0438\u043c \u0447\u0438\u0441\u043b\u0430\u043c \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u0432\u044b\u0432\u043e\u0434\u0430\u0445 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e \u0432 remote_bitbang \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 SWD, \u043e\u0434\u043d\u0430\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0435 \u0442\u0443\u0434\u0430 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u0442\u0440\u0443\u0434\u043d\u043e:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0412\u043e\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0430\u0442\u0447<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"diff\">--- remote_bitbang.c\t2016-10-31 11:06:57.812267924 +0600 +++ remote_bitbang.c\t2016-10-31 12:33:57.921692808 +0600 @@ -120,11 +120,25 @@  \tremote_bitbang_putc(c);  }   +static int remote_bitbang_swdio_read (void) +{ +\tremote_swd_putc ('R'); +\treturn remote_bitbang_rread (); +} + +static void remote_bitbang_swdio_drive (bool is_output) +{ +\tchar c = is_output ? 'o' : 'i'; +\tremote_bitbang_putc (c); +} +  static struct bitbang_interface remote_bitbang_bitbang = {  \t.read = &remote_bitbang_read,  \t.write = &remote_bitbang_write,  \t.reset = &remote_bitbang_reset,  \t.blink = &remote_bitbang_blink, +\t.swdio_read = &remote_bitbang_swdio_read, +\t.swdio_drive = &remote_bitbang_swdio_drive,\t  };    static int remote_bitbang_init_tcp(void) @@ -271,10 +285,14 @@  \tCOMMAND_REGISTRATION_DONE,  };   +static const char * const remote_bitbang_transport[] = { &quot;jtag&quot;, &quot;swd&quot;, NULL }; +  struct jtag_interface remote_bitbang_interface = {  \t.name = &quot;remote_bitbang&quot;, +\t.transports = remote_bitbang_transport,  \t.execute_queue = &bitbang_execute_queue,  \t.commands = remote_bitbang_command_handlers, +\t.swd = &bitbang_swd,  \t.init = &remote_bitbang_init,  \t.quit = &remote_bitbang_quit,  }; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0443 ESP8266, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043f\u043e\u043d\u0438\u043c\u0430\u043b \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u044e\u0449\u0438\u0435 \u043e\u0442 openOCD. \u0414\u043b\u044f \u044d\u0442\u043e\u0439 \u0446\u0435\u043b\u0438 \u044f \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c SDK <a href=\"https:\/\/github.com\/SuperHouse\/esp-open-rtos\">esp-open-rtos<\/a>. \u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438 \u044f \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0443 \u2014 \u043e\u043d \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043e\u0431\u044a\u0435\u043c\u0438\u0441\u0442\u044b\u0439, \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0433\u043e \u0447\u0430\u0441\u0442\u044c, \u043a\u0430\u0441\u0430\u044e\u0449\u0443\u044e\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u044e\u0449\u0438\u0445 \u043e\u0442 openOCD.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043f\u043e\u0439\u043b\u0435\u0440<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#define SWCLK\t\t\t\t0 #define SWDIO\t\t\t\t2  IRAM void openocd_handler (void *pvParameters) { \tstruct netconn *nc = (struct netconn *) pvParameters; \tstruct netbuf *rbuf = NULL; \tchar *rx_buf; \tchar d, r; \terr_t err; \tuint16_t len; \tuint16_t i; \t \tgpio_set_pullup (SWCLK, false, false); \tgpio_set_pullup (SWDIO, false, false); \tgpio_enable (SWCLK, GPIO_OUTPUT); \tgpio_enable (SWDIO, GPIO_OUTPUT); \t \twhile (1) \t{ \t\tif ((err = netconn_recv (nc, &rbuf)) != ERR_OK) { \t\t\tprintf (&quot;R ERROR %d\\n&quot;, err); \t\t\treturn; \t\t} \t\t \t\tnetbuf_data (rbuf, (void **) &rx_buf, &len);\t \t\t \t\tfor (i = 0; i &lt; len; i++) \t\t{ \t\t\tswitch (rx_buf [i]) \t\t\t{ \t\t\tcase 'Q':\t\t\/\/ Quit \t\t\t\tnetconn_disconnect (nc); \t\t\t\treturn; \t\t\t \t\t\tcase '0'...'7': \t\t\t\td = rx_buf [i] - '0'; \t\t\t\tgpio_write (SWDIO, (d & 0x1)); \t\t\t\tgpio_write (SWCLK, !!(d & 0x4));\t\t\t\t\t\t\t\t \t\t\t\tbreak; \t\t\t \t\t\tcase 'i': \t\t\t\tgpio_enable (SWDIO, GPIO_INPUT); \t\t\t\tbreak; \t\t\t \t\t\tcase 'o': \t\t\t\tgpio_enable (SWDIO, GPIO_OUTPUT); \t\t\t\tbreak; \t\t\t \t\t\tcase 'R':\t\t\/\/ Writeback \t\t\t\tr = ((char) gpio_read (SWDIO)) + '0'; \t\t\t\tnetconn_write (nc, &r, 1, NETCONN_COPY); \t\t\t\tbreak;  \t\t\t} \t\t} \t\t \t\tnetbuf_delete (rbuf); \t} } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041f\u043e\u043b\u043d\u044b\u0439 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c <a href=\"https:\/\/github.com\/rooi-oog\/esplink\">\u0437\u0434\u0435\u0441\u044c.<\/a><\/p>\n<p>  \u042f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e ESP-01. \u0423 \u043d\u0435\u0435 \u0434\u0432\u0435 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435 \u043d\u043e\u0433\u0438 GPIO-0 \u0438 GPIO-2, \u043f\u0440\u0438\u0447\u0435\u043c \u043f\u0440\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043d\u0430 2-\u0439 \u043d\u043e\u0433\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0432\u044b\u0441\u043e\u043a\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0438\u043d\u0430\u0447\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0432\u043e\u0439\u0434\u0435\u0442 \u0432 \u0440\u0435\u0436\u0438\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0442\u044f\u043d\u0443\u0442\u044c \u043d\u043e\u0436\u043a\u0443 \u043a \u043f\u0438\u0442\u0430\u043d\u0438\u044e \u0447\u0435\u0440\u0435\u0437 10\u043a \u0440\u0435\u0437\u0438\u0441\u0442\u043e\u0440.<\/p>\n<p>  \u0427\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u043d\u0438\u0437\u043a\u043e\u0439 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b. \u0414\u0430, \u043f\u043e \u0448\u0430\u0433\u0430\u043c \u043e\u043d \u0445\u043e\u0434\u0438\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0443\u043d\u044b\u043b\u043e, \u043d\u043e \u0437\u0430\u043b\u0438\u0442\u044c \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0443, \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u0438\u043b\u0438 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0436\u043d\u043e. <\/p>\n<p>  \u0422\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u0435\u0441\u043b\u0438 \u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c openOCD \u043d\u0430 ESP8266 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0440\u0430\u0432\u043d\u0438\u043c\u043e\u0439 \u0441 st-link, \u043d\u043e \u044d\u0442\u043e \u044f \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f\u043c.<\/p>\n<p>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u043a\u043e\u043c\u0443-\u0442\u043e \u043c\u043e\u0433 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u0435\u043d.<br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/geektimes.ru\/post\/282160\/\"> https:\/\/geektimes.ru\/post\/282160\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0425\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 ESP8266 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u0441\u0440\u0435\u0434\u043d\u0438\u043a\u0430 \u043c\u0435\u0436\u0434\u0443 STM32 \u0438 openOCD. \u0423 \u044d\u0442\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432 \u0438 \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0437\u0432\u0430\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e (\u043f\u0440\u043e\u0432\u043e\u0434\u043d\u043e\u0433\u043e) \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u043e\u0442\u043b\u0430\u0434\u043a\u0438. <\/p>\n<p>  \u041f\u043b\u044e\u0441 \u0443 \u044d\u0442\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043e\u0434\u0438\u043d \u0438 \u043e\u043d \u043e\u0447\u0435\u0432\u0438\u0434\u0435\u043d, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u0439\u0434\u0443 \u0441\u0440\u0430\u0437\u0443 \u043a \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0430\u043c:<\/p>\n<ol>\n<li>\u0422\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u0430\u0442\u0447\u0438\u0442\u044c openOCD<\/li>\n<li>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0443 \u0432 ESP8266<\/li>\n<li>\u041d\u0438\u0437\u043a\u0430\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b<\/li>\n<\/ol>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-280365","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/280365","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=280365"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/280365\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=280365"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=280365"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=280365"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}