I would like to use a STM32F105xx to build my own computer keyboard. That MCU has support to USB OTG (FS). So, I have 2 questions:

  1. Can I flash microcontroller with usb or I need a external programer?
  2. How to do the computer recognize stm32 as a keyboard?

1 Answer 1


The STM32F105xx series is not yet supported by either Arduino core (STM32 core or maple core) and neither mbed-os.

The chip is still usable with the STM32 provided framework, the STM32HAL, (e.g. through STM32CubeMX). There you can select your chip and generate a template project. The program lets you easily configure the chip for "USB Device" role and HID (Human-Interface-Device) class.


Note that from a hardware side, you must provide the chip with an external crystal oscilator (usually 8MHz) so that the HSE+PLL can generate the 48MHz USB clock. This will not work on the internal HSI clock due to low precision. Activate the HSE Crystal in the RCC section of CubeMX and see the clock configuration tab.

From there on you'll have to read the STM32F1 HAL documentation to figure out how to send keystrokes. There are also external resources here and here.

Programming the board via USB is possible. Just set the BOOT0 and BOOT1 pins accordingly and reset the board to get into bootloader mode. It will then appear as a USB device which is flashable by given tools. See e.g. here. The more direct way is to buy a cheap STLinkv2 and program it via the SWD pins (SWDIO + SWCLK), which also enables debugging, which USB flashing does not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.