
Flash STM32 firmware from a web browser via USB serial, using a checksum and optional encryption, with HTML interfaces and the JavaScript Web Serial API.
Encrypt and rename the firmware binary with version information, then use a web interface to initiate a flash upgrade that erases, writes, and reboots between the bootloader and main application.
Use STM32 cube IDE to write code and perform read, write, flash, and reboot operations, with notepad plus plus for firmware editing and web browser testing via Web Serial API.
Configure stm32 for usb connectivity by creating a CubeIDE project for stm32 f103 microcontroller, enabling external clock and usb peripheral, and selecting the cdc middleware.
Learn to receive data from a microcontroller using JavaScript and the Web Serial API by building a simple html interface that displays received bytes in hexadecimal and decimal.
Send data to the Stm32 over usb serial from a web browser using JavaScript, then multiply the received byte by two and return it.
Trigger usb re-enumeration without unplugging by pulsing the stm32 f103 usb d+ pin low for 100 ms using hal gpio initialization, configuring a12 as gpio output to reset the pin.
Learn how the STM32 bootloader identifies devices and reports firmware version using a four-byte response scheme in a custom protocol, including a command 0x01 workflow and web-based testing.
Explore how command 0x02 reads a 32-bit word from flash memory by parsing four reverse-order address bytes in hexadecimal and assembling the result for a web interface.
Implement command 0x03 to erase main application flash region, returning a single byte hex response; test this via a web browser application and verify 0x01 and 0x02.
Implement command 0x04 to write a 32-bit data word to flash by parsing two parameters (address and word) in lsb order, validating eight bytes, and testing with a web interface.
Command 0x05 switches to the main application by resetting the microcontroller; the bootloader checks the backup register and returns a one-byte hex response, similar to 0x03 erase flash.
read flash memory from the stm32 bootloader by sending four-byte address blocks and assembling the results into a JavaScript array, then save as firmware.bin via an html interface.
Erase 64kB of undocumented flash on stm32 f103; bootloader memory remains. Verify the erase with stm32 cube programmer and implement a web interface erase flash button using zero three command.
Write to STM32 flash memory using a web-based bootloader. Send erase and write commands, format data into four-byte blocks, and verify with STM32 cube programmer.
Place the main application at a different flash address by editing the linker script and system stm32 file, and verify with a PC13 LED blink on the blue pill.
Implement a bootloader that uses backup registers and the system reset; set boot flag values like 5555 to stay in bootloader or zero to load the main application after reset.
Add a CRC-32 checksum feature to the bootloader by implementing a Crc32 function and a lookup table, with per-byte updates and an initial CRC value, and validate using command 0x06.
Enhance the stm32 bootloader protocol to read larger data chunks over usb by adding a read n parameter to command zero two, enabling 1–255 byte reads and faster flash access.
Modify the bootloader protocol to write 128-byte chunks using the 0x04 flash write command, updating the HTML interface and STM32 code with a chunk size, data slicing, and address increment.
Add a crc32 checksum field to read commands and extend responses; calculate and verify data checksums in C and JavaScript, and validate flash data with cube programmer.
Add a 32-bit CRC32 checksum to the STM32 write command, sending four lsb-first bytes and validating the checksum on the host and STM32 before flashing.
Enable protection of stm32 firmware binaries by creating a web-based tool that loads a file, encrypts it with a 16-byte key in CBC mode, and saves encrypted file for download.
Integrate AES decryption into the STM32 bootloader to decrypt encrypted binaries using the same key and a CBC mode, then decrypt before writing to flash.
Enable read out protection on STM32 by issuing command 07 to set the option bytes, protecting the flash and enabling the two protection levels.
Enable write protection for the bootloader using command zero eight to guard the first 64 kB of flash, and verify the change with the stm32 cube programmer.
Learn how the STM32 bootloader validates the main application at boot with a crc32 checksum and a 5555 marker, enabling secure firmware upgrade via USB.
Activate the bootloader via power-on and reset checks with gpio inputs or a serial command within a short window, then jump to the main application only if the checksum passes.
Thank you for taking the STM32 Bootloader course! I hope you enjoyed the Web Serial API approach—flashing via a browser makes things so much easier. If you have questions, just drop them in the Q&A or message me directly. Happy coding!
Note: This course currently only supports the STM32F1 series (Blue Pill boards with STM32F103C8T6).
This course focuses on USB-based firmware upgrades (wired connection) using Web Serial API – not internet/Wi-Fi updates.
This course is for developers who want to watch code being written line-by-line. I explain concepts slowly and clearly, but the screen recordings are intentionally sped up 2x to save time. If you want to code along with every example (great for learning!), you'll need to pause and rewind frequently.
That's it – no diagrams or deep dives into flash memory theory. We'll modify STM32 and HTML code bit by bit and immediately test how it works. The screen is always split:
• Left side: Web browser + IDE (live coding)
• Right side: Slides (key concepts)
Take this course if you're into STM32 HAL and want to build a reliable, production-ready bootloader. While we focus on USB CDC and Web Serial API, the core concepts can easily adapt to UART-based bootloaders or EXE flasher utilities.
To simplify things, I've prepared helper functions for Web Serial API and STM32 USB-CDC (see myserial.js and usb_serial.c).
The course won’t explain the internals – experienced developers will quickly grasp how they work (the code is minimal)
Beginners: Try using them as-is first, but ask me if you get stuck adapting them to your projects