Installing the STM32 USB Bootloader, Easily!

Installing the STM32 USB Bootloader, Easily!

Hello everyone, welcome to my channel. I’m Caleb and I’m going to show you how
to delete your System 32… er, wait… that’s not right [papers shuffle, confusion in background] Ok sorry, I meant upload the USB bootloader
to the STM32. Just a quick note, if you want to skip this
short introduction and get right into the meat and potatoes, go to this timestamp. I would recommend watching the entire video
because there is useful information interspersed throughout, but you should be able to get
it up and running faster if you skip ahead. And now, time for the introduction. I’m like any other hobbyist, which means
I love arduinos. However, the Arduino Nano clones weren’t
cutting it for me anymore. My search for a better board lead to the cheap
and feature-rich STM32. When I first bought one of these boards, I
tried to plug it into my computer. However, the COM port that normally appears
with Arduinos never showed up. After some research, I found out that these
STM32 boards don’t ship with a USB bootloader. Instead they ship with a serial bootloader. To upload code, you need one of these knockoff
FTDI breakout boards/serial adapters. If you’ve ever worked with a chinese clone
of the Pro Mini, you should have one of these lying around. If not, they only cost a few bucks. If you need to pick one up, the links are,
as always, in the description down below. While the lack of USB support may seem like
a hindrance, it can actually be a benefit. The USB bootloader uses 20KB of the 64KB available. However, it is severely inconvenient to use
the serial adapter, and I’ve never had a project surpass the ATmega328’s 32KB anyway. The reason I am making this video is that
I wasn’t able to easily find information on how to add USB bootloader support. I have compiled my findings and hopefully
you will find this very easy. Now, fasten your seat belts, and let’s get
started! First, get your serial adapter (knockoff or
otherwise) and set it to 3.3V. If you don’t change the voltage, you will
definitely release the magic smoke. Unfortunately, they don’t sell magic smoke
refilling tools anymore, so you will have effectively destroyed your precious board. Grab your STM32 and adapter board and connect
the GND lines of the two boards together. If you want to, you can connect the 3.3V rail
of the boards together to avoid two simultaneous USB Cords. However, double check with a multimeter that
the VCC of the adapter board is outputting 3.3v. The safer option is to leave it unconnected
and just use two USB cords. The next step is to connect the TX of the
adapter board to A10 of the STM32, and RX to A9. Finally move the Boot Zero jumper to the 1
position and connect the USB, (or USB’s,) to your computer. If you want to just upload a simple sketch,
now is the time to try it. I would recommend the standard blink program
as a good test. However, you may need to replace “LED_BUILTIN”
with your LED’s pin ID. In my case the LED’s pin was PC13. To send the code, make sure that you install
the STM32F1xx boards package, and select “Generic STM32F103C Series” and upload method “Serial”
in the Tools menu. Finally, click the upload button. The LED should start blinking (obviously.) If this isn’t the case, now is the time
to check your wiring, the Boot Zero jumper, and COM ports. Moving on, go to the links in the description
and download the Flasher Loader Demo from the ST website. We also need to tell the computer how to interact
with the STM32. Download the drivers from the link in the
description. To install these drivers, run the install_drivers.bat
and follow the instructions provided. If the device ever starts acting up, which
can happen due to windows updates or anything similar, reinstall these drivers and unplug/replug
the STM32. An example of one of these issues is the uploader
getting stuck on “Searching for DFU device [1EAF:0003]…” and then erroring. Only one more download to go! Navigate to the binaries link and download
the correct version of the bootloader for your board. You can tell which version is correct by checking
which pin is connected to the LED. My board has the pin on PC13 so I choose the
generic_boot20_pc13.bin file. And now for the bootloader install. Make sure the Boot Zero jumper on the STM32
is set to 1, make sure your serial adapter is connected, and run “STMFlashLoader Demo.exe”. Note: I had to navigate to my program files
x86, and I found it in the STMicroelectronics directory. Select the correct port and click next. If the program freezes or doesn’t work immediately
check that your serial adapter is connected correctly and that boot zero is set correctly. Unplug and replug your boards and try again. You should now see a green stoplight that
says target is readable. This page also tells you the flash size. Click next. This screen shows all of the memory pages
and their read-write protection status. They should all be unlocked. Click next. Select the “Download to device” radio
button and click the three dots “…” next to the “Download from file” text box. Navigate to the bin file that you downloaded
(in my case “generic_boot20_pc13.bin”) and select it. You may have to change the file type to .bin
in the navigation menu on the bottom right. You shouldn’t have to change anything else
on this screen once the file has been selected. Hit next and wait for the flash to be updated. Close out of the program. BEFORE YOU REMOVE THE POWER FROM THE BOARD
to go back through and reupload the .bin with Flash Loader Demonstrator again. You should be done! If all went correctly you can now unplug your
serial adapter from the board and plug in a micro-USB. Open up the standard Arduino blink program. Go to tools and change your build settings
to the following. Board: “Generic STM32F103c series”. Upload Method: “STM32duino bootloader” Everything else should already be set correctly. Select the right serial port (mine was listed
as Maple Mini, COM4) and click upload. If everything was completed correctly, you
should see the built in LED start blinking. If the board throws an error and complains
about the DFU device not being detected or something. Install the drivers mentioned above again
and restart the program, and your computer. If that doesn’t help, it could be an issue
with your resistor. The boards should have a value of 1.5k for
R10 but instead, most have a 10k resistor. For most computers/boards, this is not an
issue. However, this can cause issues in the long
run. I’ve never had a problem with it, but that
doesn’t stop you from having a problem with it. There is a potential workaround listed in
a few seconds that may help if this happens to you. Having successfully completed your STM32 USB
bootloader install, here are a few other getting started tips. You may want to resolder the micro-USB connections
because they are usually poorly soldered from the factory. Great Scott did a great video on the stm32
and I would highly recommend it. Click the card that should have just appeared
somewhere to check his video out. We used Boot Zero for uploading the firmware
to the STM32. However, we never touched Boot One. Now, with the USB Bootloader, Boot One places
the board into perpetual DFU mode. This allows us to upload code even if the
Arduino IDE can’t place the board into DFU mode, and could potentially be a workaround
if your R10 is causing issues. Thanks everybody for watching this video. I hope this was helpful and I look forward
to seeing your success stories in the comments. Hopefully this simplified and/or conglomerated
the information out there into something useful. I’m thinking about creating a mini series
with the STM32, comparing it to other arduinos and doing some stress testing. Tell me if that would be something exciting
to watch! That’s all for now. I’ll see you all next time, thanks and bye
bye! [Song: Prototyperaptor – Awe]

100 thoughts to “Installing the STM32 USB Bootloader, Easily!”

  1. great video! , Caleb Marting. I struggled a lot to install the USB bootloader a few months ago but I failed. I will differently try this tomorrow. Please do the mini-series on STM32. It would be a great resource for beginners. cheers !

  2. The stm32 comes with a usb bootloader from the factory, what it doesnt come with as the ARDUINO bootloader. With a St-link programmer ($5.00) instead of the FTDI thingy you have debug capabilities, you can step through your code while its running live line by line so having serial (SWD) is still very useful, of course you'd have to upgrade your IDEfrom the Arduino and go for something like KEIL or SystemWorkbench or Truestudio which is for stm32 which is now also free like the rest. And once you upgrade IDE you are not stuck using just the STM32F103 you can use any stm32 chip, some have dual cores one core runing bluetooth and thus eliminate those huge bluetooth dongles etc. And if you dont like to open the datasheet and learn how to program the chip you can use STM32Cube and just call functions that do everything for you, Arduino style, you dont learn much but you get things done quickly so for hobbyists its perfect.

  3. After bad (native usb port) experiences with Arduino SAMD21 MINI, I have decided to switch to STM32. I have ordered a couple different model of STM32 boards from China and was searching some sources to learn how to get it working with Arduino IDE. This is the best what I found so far… Now, I beleive that I am ready to work with STM32 boards when they arrive. You saved my days… Thanks a lot.

  4. Thanks for the video. I'm just getting started with this and after my initial research I decided to buy some stm32 boards. Never used any Arduinos, but these stm32s seemed much more capable and so cheap, I didnt see a reason to start with the actual Arduinos. Any more videos on this subject would be appreciated for us newbs. =)

  5. For everybody who is missing the information: To load the compiled sketch to the STM32 you should set the program jumper to 1 like shown THEN press the reset button. You have to do this everytime you want to upload a new sketch. Once it is loaded it will imidiatly start. If you diconnect power you set the jumper back to 0 and the program starts to run.
    Some Knockoffs may want to have the LED_BUILTIN renamed to PC13. However mine worked also with LED_BUILTIN and also when I mixed both pin named up and used them together 😂

    Also mine worked fine when I accidently connected the VCC from the FTDI board to the 5Volt Pin of the STM32

  6. i encounterd problem on "FDU error", pretty sure it's because of the wrong resistor value. So, when should i change the value of the resistor? Is it after i burn the custom bootloader?

  7. The PA9 and the PA10 pins are 5 volt tolerant. You can check the FT values from this table:

  8. Hi Caleb,
    1)This worked for me,but i wish to put back the original serial UART bootloader.Will the same procedure work ?
     2) Any idea where I could download the .bin file for the originl bootloader ? I could not find it online or maybe not looking in the proper places.
     3) How does the flash loader know where to place the .bin file for the bootloader or the user application in the device memory ?

  9. Hello. I have the same exact hardware you are using in this video. However, I am stuck at 2:52 with the bootloader. The version you show is not available. The one that I was able to find was Arduino STM32F4. Any way you could make it available for dl?

  10. At 2:33 you tell us to take the (boot 0) jumper and place it to 1 position. But right at 3:09 both jumpers come to 0 positions. Why is it so . And according to some links online putting jumpers according to 2:33 puts the board in serial mode . I tried uploading the code , it worked , great . But the moment i try to re-upload the code the board no longer accepts the new code by overwriting the previous code just like normal arduinos do . It only accepts the new code when i press the reset button (which erases everything ) why is it so can you explain .

  11. @2:35 are you showing people how to power up the device : powering up the board holding it with conductive tweezer shorting across a bunch of resistors???

  12. Yes more STM32 videos. I am learning this too, from standard 8-bit Arduino. I like the uarts and hardware interrupts, for projects like closed loop motor control with encoders.

  13. I created a Discord for this community. Please join if you want quick and easy access to other like-minded STM32 developers.

  14. Looking seriously at STM32F4 board for just over AUD$10. 168Mhz, FPU, 1MB flash, 192K + 4K SRAM, heaps of I/O on a neat board.

    Currently use an Arduino Due that's great… but… but hate the default headers and well… 168Mhz and 192K is better than 84Mhz and 96K for a board that's ~60% of the price. Was looking at Teensy but not enough I/O for my project unless muck around with solder pads etc. I use Visual Micro under Visual Studio… and seems to install and compile. No point ordering a board if don't have means to compile… and as I just found out need a boot loader.

  15. I wonder if there is a way to use a Arduino Uno as a USB to TTL converter to program the STM… Should be possible right? Afaik when you connect reset to ground you can use the rx and tx pins as serial throughput

  16. When uploading the blink sketch, I get this: "EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000007110b5db, pid=7876, tid=2940" from the maple loader. IDK how to fix it…

  17. "Error downloading"
    IDK why this happened but I manually download the and put it in Arduinohardware. It needs to be like hardwarestm32f1STM32F1 and cores,libraries,boards.txt in it.
    "exec: "/bin/arm-none-eabi-g++": file does not exist"
    After some search work I figured out that I need to download "Arduino SAM" in board manager. Would've be better if you mentioned that in the clip :/

  18. Could I do this install on a windows machine then use the STM32 with Arduino IDE on a Mac or would I still have to use windows to use it?

  19. Nice but if ever I need all the 64kb of memory how do I remove the bootloader?…..thanks in advance for what you did future reply

  20. if you have an ESP8266 laying around – you can flash & debug your STM32 via SWD via WiFi:

  21. A USB-MSD loader can be seen here: (download from )

  22. Thanks a lot Caleb. I get it!!! Now, i can program my bluepills through USB and use Serial Port Monitor. Only a question. I need to press the reset button after upload a program. Upload works fine, but before press the reset button, the COM port apears disabled. After pressing the reset button, the Serial Port Monitor and COM Port works fine. Both jumpers on 0 position.

  23. Great information! Just a heads-up, you have to register an e-mail address to download the flasher software. If your programming computer doesn't have an e-mail client (for verification) like mine, getting the flasher software will be problematic.

  24. TIL! Thnx for the info!

    Are there any disadvantages to using the serial port method (apart from inconvenience)?
    Because I might need that extra 20kb of space.

    Great video thnx!

  25. Try it: (new) generic_boot20_pc13_fastboot.bin

  26. If you have only 5V serial converter, you can use it also. Just do not power board from serials 5v, but power board via usb and keep GND connected. A9 and A10 pins are 5V tolerant.

  27. I was about to toss my SMT32 in the trash but your amazingly useful video saved it. Thank you!

  28. Good God! You said "easily". Was all that necessary to prepare the board for its intended purpose? Or– was it a hack? If it's a hack– it may be well worth doing. If this is what you have to do in order to have a board ready to do what it was intended to do– shame on the manufacturer. Why should the consumer have to do all this?

  29. the driver was the issue then yissssssssss I actually have a jtag but usb is just more easy 😛

    Thanks 🙂

  30. Everyone do yourself a favor and get rid of the Arduino IDE. Calling itself an IDE is an insult to actual IDEs.
    At least get something like atom and platformio. It can be used to write Arduino code (or better go C/C++ without the Arduino bulk), and
    supports tons of different micro controllers.

    Also an st-link programmer clone costs something like 2$ and makes programming STM32 so much more comfortable. No need for the serial bootloader or USB bootloader, no need to change jumpers all the time.

  31. Thank you so much for the video! One question, I can undo the bootloader by flashing a random program via serial I assume? Like loading the blink program via arduino serial?

  32. Mine didn't work, device manager doesn't see stm32 at a com port! Already put 3 hours into this. wondering if anyone else has similar issues, I am using a clone

  33. @2:35 I hope you didn't really have the other end of that USB cable plugged in, while the metal tweezers shorted those resistors/capacitors???? If you short out your USB cable, on recent model motherboards, the internal USB hub will just turn off, and won't come back until you remove power entirely and turn it back on. Best case, you'll have to turn off your computer and restart it to keep working. But there's always the chance of permanent damage when you use conductive tools on a powered circuit.

  34. hey man tremendous video, can you make a tutorial on how to make the stm32 simulate a usb Keyboard?. can it be done with arduino programming? or do you have to use the st-link thingy?

  35. I'm getting this error. I have two boards and still this happens in both

    maple_loader v0.1

    Resetting to bootloader via DTR pulse

    Searching for DFU device [1EAF:0003]…

    Found it!

    Opening USB Device 0x1eaf:0x0003…

    Found Runtime: [0x1eaf:0x0003] devnum=1, cfg=0, intf=0, alt=2, name="STM32duino bootloader v1.0 Upload to Flash 0x8002000"

    Setting Configuration 1…

    Claiming USB DFU Interface…

    Setting Alternate Setting …

    Determining device status: state = dfuIDLE, status = 0

    dfuIDLE, continuing

    Transfer Size = 0x0400


    Starting download: [##################################################] finished!

    state(8) = dfuMANIFEST-WAIT-RESET, status(0) = No error condition is present


    error resetting after download: usb_reset: could not reset device, win error: A device which does not exist was specified.

    Resetting USB to switch back to runtime mode

  36. some boards have the 100kohm R3 resistor that connect BOOT0 header to mcu. In my case, when BOOT0 jumper is on 1 position, the pin on mcu only pulled up to 1 volt, which had me failed to flash the firmware. you might need to replace R3 with 10k. i just replaced it with a 2.2k smd resistor i had and it worked.

  37. plz help me i don't know why the flash loader freeze after doing next then don't respond, all my connector are connect perfectly plz help

  38. Good day. Very useful video!

    I need your help. I use a board like this:
    Device Diagram::
    PA12 is pulled to power through a 10k resistor. The LED is connected to pc13.

    I installed different bootloaders. These came up: dso138_boot20.bin, generic_boot20_pc13.bin and naze32_boot20.bin. But there is one difficulty: for flashing the sketch I need to press the RESET button. Is there any way to do an automatic reboot? Could it be possible to somehow modify the bootloader, or add a circuit for a hardwar reset?

  39. Can we use this bootloader without using arduino ? I ask because I prefer Keil. I just want the support for the USB port in the STM32

Leave a Reply

Your email address will not be published. Required fields are marked *