スキップしてメイン コンテンツに移動

STM32F103C6T6を デュアルUSB Serial Converterにする

実はType-C インターフェースのSTM32F103C8T6を注文した(つもりだった)のですが、後でよく見るとC8T6ではなくC6T6だった事にあとで気づいてしまいました。
C6T6はRAM/FlashともにC8T6より少ないうえ、USARTが2つしかないため、C8T6向けのファームウェアを持ってくるのに制約がありますし、もちろんプロジェクトを作るにしても制約がありますのでこのままではお蔵入りさせるしかありません。しかし、もったいないので何かに使えるようにしておきたいと思うのですが、たとえば以前紹介したC8T6向けのTriple CDCはUSARTを3つ使用するのでそのままでは使えません。どうしたものかと思いまず他のDual CDCのKeil向けのソースをCubeIDEでコンパイルできるようにしたのですが、通信はできないわけではないがCubeProgrammerでUARTでターゲットに接続できないうえ、USB接続するのに少し手間がかかるので、これはダメでした。さらにDualではなくSingleでソースをCubeIDEを使ってコードをおこしてみたのですが、これも通信はできるがCubeProgrammerのほうはダメでした。そこでもう一度気を取り直し、Triple CDCのソースを編集してDual CDCにしてみたところ思ったよりも簡単に編集でき、通信もCubeProgrammerも動作したので、本稿を挙げてみることにしました。

2023/09/24追記:rs232接続ではなく、tx/rxのみ使用する場合、9600等の低速だと、テキストサイズが大きめの場合、残念ながら暴走します。また、同じく、9600等の低速だと、zmodemによるファイル転送はサイズの大小にかかわらず、暴走してしまいます。なおkermitの場合は9600でもファイル転送できました。また、115200の場合はzmodemによるファイル転送は同時に2つ送受信できますが、テキストサイズが極端に大きい場合(例えば8k bytes)暴走します。逆に921600の場合、テキストサイズが100kを超える場合でも暴走しませんでした。また、CubeProgrammerは115200でのみ動作確認できました。なお、rs232接続でのテストは行っていません。
使用にあたって当方は責任を一切おいませんので、あしからずご了承ください。追記以上

まず、ツール類のインストールをしますが、Debianの場合以下のようにします。
sudo apt-get install build-essential gcc-arm-none-eabi binutils-arm-none-eabi git stlink-tools
つづいてソースをgit cloneしておきます。
cd ~
mkdir stm32
cd stm32
git clone https://github.com/STMicroelectronics/STM32CubeF1
git clone https://github.com/r2axz/bluepill-serial-monster
以下diffです。
diff -urN bluepill-serial-monster/device_config.c bluepill-dual-cdc/device_config.c
--- bluepill-serial-monster/device_config.c	2023-07-02 19:29:23.470152568 +0900
+++ bluepill-dual-cdc/device_config.c	2023-07-10 06:42:19.951516456 +0900
@@ -9,7 +9,7 @@
 #include 
 #include "device_config.h"

-#define DEVICE_CONFIG_FLASH_SIZE    0x10000UL
+#define DEVICE_CONFIG_FLASH_SIZE    0x8000UL
 #define DEVICE_CONFIG_NUM_PAGES     2
 #define DEVICE_CONFIG_PAGE_SIZE     0x400UL
 #define DEVICE_CONFIG_FLASH_END     (FLASH_BASE + DEVICE_CONFIG_FLASH_SIZE)
@@ -51,21 +51,6 @@
                     /* txa */ { .port = GPIOB, .pin =  1, .dir = gpio_dir_output, .speed = gpio_speed_medium, .func = gpio_func_general, .output = gpio_output_pp, .polarity = gpio_polarity_high  },
                 }
             },
-            /*  Port 2 */
-            {
-                .pins = 
-                {
-                    /*  rx */ { .port = GPIOB, .pin = 11, .dir = gpio_dir_input,  .pull = gpio_pull_up, .polarity = gpio_polarity_high },
-                    /*  tx */ { .port = GPIOB, .pin = 10, .dir = gpio_dir_output, .speed = gpio_speed_medium, .func = gpio_func_alternate, .output = gpio_output_pp, .polarity = gpio_polarity_high  },
-                    /* rts */ { .port = GPIOB, .pin = 14, .dir = gpio_dir_output, .speed = gpio_speed_medium, .func = gpio_func_general, .output = gpio_output_pp, .polarity = gpio_polarity_low },
-                    /* cts */ { .port = GPIOB, .pin = 13, .dir = gpio_dir_input,  .pull = gpio_pull_down, .polarity = gpio_polarity_low },
-                    /* dsr */ { .port = GPIOB, .pin =  6, .dir = gpio_dir_input,  .pull = gpio_pull_up, .polarity = gpio_polarity_low },
-                    /* dtr */ { .port = GPIOA, .pin =  6, .dir = gpio_dir_output, .speed = gpio_speed_medium, .func = gpio_func_general, .output = gpio_output_pp, .polarity = gpio_polarity_low  },
-                    /* dcd */ { .port = GPIOB, .pin =  9, .dir = gpio_dir_input,  .pull = gpio_pull_up, .polarity = gpio_polarity_low },
-                    /*  ri */ { .port = GPIOA, .pin =  8, .dir = gpio_dir_input,  .pull = gpio_pull_up, .polarity = gpio_polarity_low },
-                    /* txa */ { .port = GPIOA, .pin =  7, .dir = gpio_dir_output, .speed = gpio_speed_medium, .func = gpio_func_general, .output = gpio_output_pp, .polarity = gpio_polarity_high  },
-                }
-            },
         }
     }
 };
diff -urN bluepill-serial-monster/Makefile bluepill-dual-cdc/Makefile
--- bluepill-serial-monster/Makefile	2023-07-02 19:29:23.470152568 +0900
+++ bluepill-dual-cdc/Makefile	2023-07-10 06:48:35.121515751 +0900
@@ -1,5 +1,5 @@
 # General Target Settings
-TARGET = bluepill-serial-monster
+TARGET = bluepill-dual-cdc
 SRCS   = main.c system_clock.c system_interrupts.c status_led.c usb_core.c usb_descriptors.c\
        usb_io.c usb_uid.c usb_panic.c usb_cdc.c cdc_shell.c gpio.c device_config.c

@@ -14,15 +14,15 @@

 # STM32Cube Path
 STM32CUBE      = ${STM32CUBE_PATH}
-STM32_STARTUP  = $(STM32CUBE)/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xb.s
+STM32_STARTUP  = $(STM32CUBE)/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103x6.s
 STM32_SYSINIT  = $(STM32CUBE)/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c
-STM32_LDSCRIPT = $(STM32CUBE)/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F103XB_FLASH.ld
+STM32_LDSCRIPT = $(STM32CUBE)/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/linker/STM32F103X6_FLASH.ld

 STM32_INCLUDES += -I$(STM32CUBE)/Drivers/CMSIS/Core/Include
 STM32_INCLUDES += -I$(STM32CUBE)/Drivers/CMSIS/Core_A/Include
 STM32_INCLUDES += -I$(STM32CUBE)/Drivers/CMSIS/Device/ST/STM32F1xx/Include

-DEFINES                = -DSTM32F103xB -DHSE_VALUE=8000000U
+DEFINES                = -DSTM32F103x6 -DHSE_VALUE=8000000U
 CPUFLAGS       = -mthumb -mcpu=cortex-m3
 WARNINGS       = -Wall
 OPTIMIZATION   = -O3
diff -urN bluepill-serial-monster/usb_cdc.c bluepill-dual-cdc/usb_cdc.c
--- bluepill-serial-monster/usb_cdc.c	2023-07-02 19:29:23.470152568 +0900
+++ bluepill-dual-cdc/usb_cdc.c	2023-07-10 07:05:11.711517111 +0900
diff -urN bluepill-serial-monster/usb_cdc.h bluepill-dual-cdc/usb_cdc.h
@@ -55,7 +55,7 @@
 /* Helper Functions */

 static USART_TypeDef* const usb_cdc_port_usarts[] = {
-    USART1, USART2, USART3
+    USART1, USART2
 };

 static USART_TypeDef* usb_cdc_get_port_usart(int port) {
@@ -75,7 +75,6 @@
     static DMA_Channel_TypeDef* const port_dma_channels[][usb_cdc_port_direction_last] = {
         { DMA1_Channel5,  DMA1_Channel4 },
         { DMA1_Channel6,  DMA1_Channel7 },
-        { DMA1_Channel3,  DMA1_Channel2 },
     };
     if (port < (sizeof(port_dma_channels) / sizeof(*port_dma_channels)) &&
         port_dir < usb_cdc_port_direction_last) {
@@ -87,7 +86,6 @@
 static uint8_t const usb_cdc_port_data_endpoints[] = {
     usb_endpoint_address_cdc_0_data,
     usb_endpoint_address_cdc_1_data,
-    usb_endpoint_address_cdc_2_data,
 };

 static uint8_t usb_cdc_get_port_data_ep(int port) {
@@ -109,7 +107,6 @@
 static uint8_t const usb_cdc_port_interrupt_endpoints[] = {
     usb_endpoint_address_cdc_0_interrupt,
     usb_endpoint_address_cdc_1_interrupt,
-    usb_endpoint_address_cdc_2_interrupt,
 };

 static uint8_t usb_cdc_get_port_notification_ep(int port) {
@@ -120,7 +117,7 @@
 }

 static uint8_t const usb_cdc_port_interfaces[] = {
-    usb_interface_cdc_0, usb_interface_cdc_1, usb_interface_cdc_2
+    usb_interface_cdc_0, usb_interface_cdc_1
 };

 static int usb_cdc_get_port_interface(int port) {
@@ -492,13 +489,6 @@
     usb_cdc_port_tx_complete(1);
 }

-void DMA1_Channel2_IRQHandler() {
-    (void)DMA1_Channel2_IRQHandler;
-    uint32_t status = DMA1->ISR & ( DMA_ISR_TCIF2 );
-    DMA1->IFCR = status;
-    usb_cdc_port_tx_complete(2);
-}
-
 /* USART Interrupt Handlers */

 __attribute__((always_inline)) inline static void usb_cdc_usart_irq_handler(int port, USART_TypeDef * usart,
@@ -528,11 +518,6 @@
     usb_cdc_usart_irq_handler(1, usb_cdc_port_usarts[1], usb_cdc_states[1].txa_bitband_clear);
 }

-void USART3_IRQHandler() {
-    (void)USART3_IRQHandler;
-    usb_cdc_usart_irq_handler(2, usb_cdc_port_usarts[2], usb_cdc_states[2].txa_bitband_clear);
-}
-
 /* Port Configuration & Control Lines Functions */

 void usb_cdc_reconfigure_port_pin(int port, cdc_pin_t pin) {
@@ -573,8 +558,6 @@
 void usb_cdc_reset() {
     const device_config_t *device_config = device_config_get();
     usb_cdc_enabled = 0;
-    NVIC_SetPriority(DMA1_Channel2_IRQn, SYSTEM_INTERRUTPS_PRIORITY_HIGH);
-    NVIC_EnableIRQ(DMA1_Channel2_IRQn);
     NVIC_SetPriority(DMA1_Channel4_IRQn, SYSTEM_INTERRUTPS_PRIORITY_HIGH);
     NVIC_EnableIRQ(DMA1_Channel4_IRQn);
     NVIC_SetPriority(DMA1_Channel7_IRQn, SYSTEM_INTERRUTPS_PRIORITY_HIGH);
@@ -589,14 +572,12 @@
     gpio_pin_init(&device_config->config_pin);
     /* USART & DMA Reset and Setup */
     RCC->APB2ENR |= RCC_APB2ENR_USART1EN;
-    RCC->APB1ENR |= RCC_APB1ENR_USART2EN | RCC_APB1ENR_USART3EN;
+    RCC->APB1ENR |= RCC_APB1ENR_USART2EN;
     RCC->AHBENR |= RCC_AHBENR_DMA1EN;
     RCC->APB2RSTR |= RCC_APB2RSTR_USART1RST;
     RCC->APB1RSTR |= RCC_APB1RSTR_USART2RST;
-    RCC->APB1RSTR |= RCC_APB1RSTR_USART3RST;
     RCC->APB2RSTR &= ~(RCC_APB2RSTR_USART1RST);
     RCC->APB1RSTR &= ~(RCC_APB1RSTR_USART2RST);
-    RCC->APB1RSTR &= ~(RCC_APB1RSTR_USART3RST);
     memset(&usb_cdc_states, 0, sizeof(usb_cdc_states));
     for (int port=0; port<USB_CDC_NUM_PORTS; port++) {
         (void)usb_cdc_states[port]._rx_data;
@@ -622,8 +603,6 @@
     NVIC_EnableIRQ(USART1_IRQn);
     NVIC_SetPriority(USART2_IRQn, SYSTEM_INTERRUTPS_PRIORITY_CRITICAL);
     NVIC_EnableIRQ(USART2_IRQn);
-    NVIC_SetPriority(USART3_IRQn, SYSTEM_INTERRUTPS_PRIORITY_CRITICAL);
-    NVIC_EnableIRQ(USART3_IRQn);
 }

 void usb_cdc_enable() {
--- bluepill-serial-monster/usb_cdc.h	2023-07-02 19:29:23.470152568 +0900
+++ bluepill-dual-cdc/usb_cdc.h	2023-07-10 06:34:43.551515315 +0900
@@ -198,7 +198,7 @@
 
 /* CDC Device Definitions */
 
-#define USB_CDC_NUM_PORTS                       3
+#define USB_CDC_NUM_PORTS                       2
 #define USB_CDC_BUF_SIZE                        0x400
 #define USB_CDC_CRTL_LINES_POLLING_INTERVAL     20 /* ms */
 #define USB_CDC_CONFIG_PORT                     0
diff -urN bluepill-serial-monster/usb_descriptors.c bluepill-dual-cdc/usb_descriptors.c
--- bluepill-serial-monster/usb_descriptors.c	2023-07-02 19:29:23.470152568 +0900
+++ bluepill-dual-cdc/usb_descriptors.c	2023-07-10 06:57:14.471512832 +0900
@@ -56,20 +56,6 @@
         .tx_size    = USB_CDC_DATA_1_ENDPOINT_SIZE,
         .event_handler = usb_cdc_data_endpoint_event_handler,
     },
-    /*  CDC 2 Interrupt Endpoint */
-    { 
-        .type       = usb_endpoint_type_interrupt,
-        .rx_size    = 0,
-        .tx_size    = USB_CDC_INTERRUPT_ENDPOINT_SIZE,
-        .event_handler = 0,
-    },
-     /*  CDC 2 Data Endpoint */
-    { 
-        .type       = usb_endpoint_type_bulk,
-        .rx_size    = USB_CDC_DATA_2_ENDPOINT_SIZE,
-        .tx_size    = USB_CDC_DATA_2_ENDPOINT_SIZE,
-        .event_handler = usb_cdc_data_endpoint_event_handler,
-    },
 };
 
 const usb_string_descriptor_t usb_string_lang                   = USB_ARRAY_DESC(usb_language_code_en_US);
@@ -78,7 +64,6 @@
 const usb_string_descriptor_t usb_string_serial                 = USB_STRING_DESC("NO SERIAL"); /* Placeholder, replaced by STM32 UID */
 const usb_string_descriptor_t usb_string_uart_1_interface_name  = USB_STRING_DESC("UART1");
 const usb_string_descriptor_t usb_string_uart_2_interface_name  = USB_STRING_DESC("UART2");
-const usb_string_descriptor_t usb_string_uart_3_interface_name  = USB_STRING_DESC("UART3");
 
 const usb_string_descriptor_t *usb_string_descriptors[usb_string_index_last] = {
     &usb_string_lang,
@@ -87,7 +72,6 @@
     &usb_string_serial,
     &usb_string_uart_1_interface_name,
     &usb_string_uart_2_interface_name,
-    &usb_string_uart_3_interface_name,
 };
 
 const usb_device_descriptor_t usb_device_descriptor = {
@@ -112,7 +96,7 @@
         .bLength                = sizeof(usb_configuration_descriptor.config),
         .bDescriptorType        = usb_descriptor_type_configuration,
         .wTotalLength           = sizeof(usb_configuration_descriptor),
-        .bNumInterfaces         = 6,
+        .bNumInterfaces         = 4,
         .bConfigurationValue    = 1,
         .iConfiguration         = usb_string_index_none,
         .bmAttributes           = USB_CFG_ATTR_RESERVED,
@@ -282,87 +266,4 @@
         .wMaxPacketSize         = USB_CDC_DATA_1_ENDPOINT_SIZE,
         .bInterval              = 0,
     },
-    .comm_iad_2 = {
-        .bLength                = sizeof(usb_configuration_descriptor.comm_iad_2),
-        .bDescriptorType        = usb_descriptor_type_interface_assoc,
-        .bFirstInterface        = usb_interface_cdc_2,
-        .bInterfaceCount        = 2,
-        .bFunctionClass         = usb_class_cdc,
-        .bFunctionSubClass      = usb_subclass_cdc_acm,
-        .bFunctionProtocol      = USB_PROTOCOL_CDC_DEFAULT,
-        .iFunction              = usb_string_index_none,
-    },
-    .comm_2 = {
-        .bLength                = sizeof(usb_configuration_descriptor.comm_2),
-        .bDescriptorType        = usb_descriptor_type_interface,
-        .bInterfaceNumber       = usb_interface_cdc_2,
-        .bAlternateSetting      = 0,
-        .bNumEndpoints          = 1,
-        .bInterfaceClass        = usb_class_cdc,
-        .bInterfaceSubClass     = usb_subclass_cdc_acm,
-        .bInterfaceProtocol     = USB_PROTOCOL_CDC_DEFAULT,
-        .iInterface             = usb_string_index_uart_3_interface_name,
-    },
-    .cdc_hdr_2 = {
-        .bFunctionLength        = sizeof(usb_configuration_descriptor.cdc_hdr_2),
-        .bDescriptorType        = usb_descriptor_type_cs_interface,
-        .bDescriptorSubType     = usb_descriptor_subtype_cdc_header,
-        .bcdCDC                 = USB_BCD_VERSION(1, 1, 0),
-    },
-    .cdc_mgmt_2 = {
-        .bFunctionLength        = sizeof(usb_configuration_descriptor.cdc_mgmt_2),
-        .bDescriptorType        = usb_descriptor_type_cs_interface,
-        .bDescriptorSubType     = usb_descriptor_subtype_cdc_call_management,
-        .bmCapabilities         = 0,
-        .bDataInterface         = usb_interface_cdc_2 + 1,
-    },
-    .cdc_acm_2 = {
-        .bFunctionLength        = sizeof(usb_configuration_descriptor.cdc_acm_2),
-        .bDescriptorType        = usb_descriptor_type_cs_interface,
-        .bDescriptorSubType     = usb_descriptor_subtype_cdc_acm,
-        .bmCapabilities         = USB_CDC_ACM_CAPABILITIES,
-    },
-    .cdc_union_2 = {
-        .bFunctionLength        = sizeof(usb_configuration_descriptor.cdc_union_2),
-        .bDescriptorType        = usb_descriptor_type_cs_interface,
-        .bDescriptorSubType     = usb_descriptor_subtype_cdc_union,
-        .bMasterInterface0      = usb_interface_cdc_2,
-        .bSlaveInterface0       = usb_interface_cdc_2 + 1,
-    },
-    .comm_ep_2 = {
-        .bLength                = sizeof(usb_configuration_descriptor.comm_ep_2),
-        .bDescriptorType        = usb_descriptor_type_endpoint,
-        .bEndpointAddress       = usb_endpoint_direction_in | usb_endpoint_address_cdc_2_interrupt,
-        .bmAttributes           = usb_endpoint_type_interrupt,
-        .wMaxPacketSize         = USB_CDC_INTERRUPT_ENDPOINT_SIZE,
-        .bInterval              = USB_CDC_INTERRUPT_ENDPOINT_POLLING_INTERVAL,
-    },
-    .data_2 = {
-        .bLength                = sizeof(usb_configuration_descriptor.data_2),
-        .bDescriptorType        = usb_descriptor_type_interface,
-        .bInterfaceNumber       = usb_interface_cdc_2 + 1,
-        .bAlternateSetting      = 0,
-        .bNumEndpoints          = 2,
-        .bInterfaceClass        = usb_class_cdc_data,
-        .bInterfaceSubClass     = usb_subclass_cdc_none,
-        .bInterfaceProtocol     = usb_protocol_cdc_none,
-        .iInterface             = usb_string_index_none,
-    },
-    .data_eprx_2 = {
-        .bLength                = sizeof(usb_configuration_descriptor.data_eprx_2),
-        .bDescriptorType        = usb_descriptor_type_endpoint,
-        .bEndpointAddress       = usb_endpoint_direction_out | usb_endpoint_address_cdc_2_data,
-        .bmAttributes           = usb_endpoint_type_bulk,
-        .wMaxPacketSize         = USB_CDC_DATA_2_ENDPOINT_SIZE,
-        .bInterval              = 0,
-    },
-    .data_eptx_2 = {
-        .bLength                = sizeof(usb_configuration_descriptor.data_eptx_2),
-        .bDescriptorType        = usb_descriptor_type_endpoint,
-        .bEndpointAddress       = usb_endpoint_direction_in | usb_endpoint_address_cdc_2_data,
-        .bmAttributes           = usb_endpoint_type_bulk,
-        .wMaxPacketSize         = USB_CDC_DATA_2_ENDPOINT_SIZE,
-        .bInterval              = 0,
-    },
-
 };
diff -urN bluepill-serial-monster/usb_descriptors.h bluepill-dual-cdc/usb_descriptors.h
--- bluepill-serial-monster/usb_descriptors.h	2023-07-02 19:29:23.470152568 +0900
+++ bluepill-dual-cdc/usb_descriptors.h	2023-07-10 06:54:40.691523278 +0900
@@ -27,7 +27,6 @@
     usb_string_index_serial,
     usb_string_index_uart_1_interface_name,
     usb_string_index_uart_2_interface_name,
-    usb_string_index_uart_3_interface_name,
     usb_string_index_last,
 } __attribute__ ((packed)) usb_string_index_t;
 
@@ -41,8 +40,6 @@
     usb_endpoint_address_cdc_0_data         = 0x02,
     usb_endpoint_address_cdc_1_interrupt    = 0x03,
     usb_endpoint_address_cdc_1_data         = 0x04,
-    usb_endpoint_address_cdc_2_interrupt    = 0x05,
-    usb_endpoint_address_cdc_2_data         = 0x06,
     usb_endpoint_address_last
 };
 
@@ -53,7 +50,6 @@
 enum {
     usb_interface_cdc_0 = 0x00,
     usb_interface_cdc_1 = 0x02,
-    usb_interface_cdc_2 = 0x04,
 };
 
 /* Device Descriptor */
@@ -84,16 +80,6 @@
     usb_interface_descriptor_t          data_1;
     usb_endpoint_descriptor_t           data_eprx_1;
     usb_endpoint_descriptor_t           data_eptx_1;
-    usb_iad_descriptor_t                comm_iad_2;
-    usb_interface_descriptor_t          comm_2;
-    usb_cdc_header_desc_t               cdc_hdr_2;
-    usb_cdc_call_mgmt_desc_t            cdc_mgmt_2;
-    usb_cdc_acm_desc_t                  cdc_acm_2;
-    usb_cdc_union_desc_t                cdc_union_2;
-    usb_endpoint_descriptor_t           comm_ep_2;
-    usb_interface_descriptor_t          data_2;
-    usb_endpoint_descriptor_t           data_eprx_2;
-    usb_endpoint_descriptor_t           data_eptx_2;
 } __attribute__((packed)) usb_device_configuration_descriptor_t;
 
 extern const usb_device_configuration_descriptor_t usb_configuration_descriptor;

patchの当て方ですがソースが~/stm32/bluepill-serial-monsterにあり例としてdiffを~/stm32/bp-sm-to-bp-dc.diffとして保存している場合、以下のようにします。
$ cd ~/stm32/bluepill-serial-monster
$ patch -p1 < ../bp-sm-to-bp-dc.diff
patching file device_config.c
patching file Makefile
patching file usb_cdc.c
patching file usb_cdc.h
patching file usb_descriptors.c
patching file usb_descriptors.h
ビルドは ~/stm32/STM32CubeF1にCubeのソースが入っている場合、
export STM32CUBE_PATH=~/stm32/STM32CubeF1
make
でビルドできます。書き込みはlinux環境の場合 stlink-toolsが入っていてstlinkでターゲットが接続されている場合, make flashでOKです。Windows/WSL2の場合はCubeProgrammerなどを使って書き込むとよいと思います。
C6T6を持て余している方?は一度試してみてください。
今回は以上です。それでは。

コメント

このブログの人気の投稿

wsdd を使ってSamba サーバをネットワークに表示

Windows 10のアップデートで、セキュリティー対応のため、smbv1がデフォルトではインストールされなくなり、Samba serverがエクスプローラーのネットワークに表示されなくなってしまいました。そこで、いくつか方法を調べたのですが、linuxでwsdの実装がないか探したところ、 https://github.com/christgau/wsdd が、見つかりましたので、さっそくインストールしてみました。まだパッケージにはないようですが、インストール自身は簡単です。wsdd自体は以下のように取得し、linkを張っておきます。 cd /usr/local/bin/ sudo wget https://raw.githubusercontent.com/christgau/wsdd/master/src/wsdd.py sudo chmod 755 wsdd.py sudo ln -sf wsdd.py wsdd こちらのsambaサーバはDebianなので、/etc/systemd/system/wsdd.serviceは以下のようにしました。 [Unit] Description=Web Services Dynamic Discovery host daemon Requires=network-online.target After=network.target network-online.target multi-user.target [Service] Type=simple ExecStart=/usr/local/bin/wsdd -d MYDOMAIN [Install] WantedBy=multi-user.target wsdd -d MYDOMAINのところを、環境にあわせて書き換えてください。 次に、systemdに登録・起動テストを行います。 systemctl enable wsdd systemctl start wsdd 起動に成功すると、エクスプローラーのネットワークに表示されます。  なおこのwsddはpython3が必要です。一度試してみてください。SMBv1/CIFSを停止していても、大丈夫です。 cで書かれたほかのwsddの実装もあるようなので、いずれパッケージになるかもしれませ

Hyper-V Server2019にワークグループ環境下でWindows10(1809)から接続

Hyper-V server 2019に、ワークグループ環境にてWindows10(1809)から接続してみました。Windows10にHyper-V管理ツールがインストールされていることと、Hyper-V Serverをインストール済であることが前提です。以下、Hyper-V serverは名前がHyperVSV、アドレスは192.168.1.110としています。 まず、Hyper-V server上で、powershellを起動し、以下のコマンドを入力します。 Enable-WSManCredSSP -Role Server -Force 続いて、クライアントのWindows10のpowershell で以下のコマンドを入力します。 winrm quickconfig -Force Enable-WSManCredSSP -Role Client -DelegateComputer * -Force さらに、クライアントマシンで、gpedit(グループポリシーエディタ)を起動し、以下の要領でポリシーを設定します。 a. [コンピューターの構成]->[管理テンプレート]->[システム]->[資格情報の委任]->[NTLMのみのサーバー認証で新しい資格情報の委任を許可する] を有効にし、サーバを一覧に追加[表示...]ボタンをクリックして、「WSMAN/*」を追加 b. [コンピューターの構成]->[管理テンプレート]->[システム]->[資格情報の委任]->[NTLM のみのサーバー認証で保存された資格情報の委任を許可する] を有効にし、サーバを一覧に追加[表示...]ボタンをクリックして、「*」を追加 また、名前解決できるように、(notepadを管理者権限で実行し)C:\Windows\System32\Drivers\etc\hostsにサーバ名とIPアドレスの対を追加。 192.168.1.110 HyperVSV 最後に、Hyper-Vマネージャーを起動し、Windows10からHyper-V サーバに接続します。手順は以下の通りです。 「サーバーに接続」->コンピュータの選択->別のコンピューターに[HyperVSV]と入力し、[別のユーザーとして接続する

フレッツ光クロス:MAP-E ROUTER by Debian Box (iptables)

フレッツ光クロスがようやく開通したので、Debianにてrouterを構成し接続してみました。なお、プロバイダーを選ぶにあたっては、IPoE方式がそれぞれ異なるため検討したところ、IPoEでは、MAP-Eでもv6plusとocnバーチャルコネクトがあり、前者がポート数240なのに対し、後者は約4倍のポート数が使えるようなネットの情報をみて、OCNバーチャルコネクトを選択しました。(プロバイダーとしてはぷららです。なおDS-LiteはCE側でのNATではないので今回は見送りました。)そこで、OCN バーチャルコネクトをDebian(iptables)で実現するとどうなるかと思い、ネットの情報を頼りにしつつ、設定した次第です。 実際に試した結果、とりあえず通信できていますが、MAP-Eは本来マッピングルールをマップサーバから取得するはずなので、今回のやり方が正解とはいえませんし、仕様変更されると通信できなくなる可能性があります。あくまでも参考程度ですが、本稿をUPしてみました。 2023/03/16追記: こちら にゲームコンソールNAT越え(Nintendo Switch ナットタイプ A判定)対応版を投稿しました。 2023/03/28追記:※1の記述および3行無効化によりNAT越え(Nintendo Switch ナットタイプ B判定)できるようになりました。 構成は以下の通りです。 ルーターがDebianで回線がOCNバーチャルコネクトであること以外はなにも特別なところはない構成です。 さて、いきなり設定ですが、まず、割り当てられたプレフィックスを確認します。 確認は、 dhclient -6 -d -P enp2s0 とします。出力の中に 前略 RCV: | | X-- IAPREFIX 2400:4050:5c71:af00::/56 後略 このようにプレフィックスが表示されるので、その確認したプレフィックスを書き留めておきます。これを こちらで 入力します。すると、 CE: 2400:4050:5c71:af00:99:f171:c600:2f00 IPv4 アドレス: 153.241.113.198 ポート番号:(1776-1791 2800-2815 3824-3839) 4848-4863 5872-5887 6896-