Table of Contents
ARM-CM0 STM32 Nucleo-C071RB STM32CubeIDE
Supported firmware update interfaces
| RS232 | CAN | CAN FD | USB | TCP/IP | SD-card | Modbus RTU |
|---|---|---|---|---|---|---|
| No | No | No | Yes | No | No | No |
Development Environment
This demo is targeted towards the Nucleo-C071RB board, with 128 kB internal Flash EEPROM and 24 kB internal RAM.
To compile the demo programs you can use the STM32CubeIDE development environment. Note the STM32CubeIDE is cross-platform. The information outlined on this page applies to both Microsoft Windows and Linux users.
To program the bootloader into the internal flash, the on-board ST-Link debugger interface was used. Firmware updates via the serial communication port are preconfigured to use the virtual COM-port offered by the ST-Link. This means that no additional hardware is needed, besides a standard micro-USB cable.
USB MSC / DFU / CDC composite device reference demos
By default, the OpenBLT bootloader acts as a USB Bulk device, for performing firmware updates via USB. In this case, the bootloader embeds the XCP communication protocol packets into USB Bulk transfers between the host PC and the bootloader running on the target. This works flawlessly and doesn't require any USB driver installation on the host PC. You can find more details on how this works by looking at one of the board demos that supports this.
Some OpenBLT users asked if it's possible to use a different approach for firmware updates via USB. For example using the USB Device Firmware Upgrade (DFU) class, which is officially supported by the USB specification. With this request in mind, the demo bootloader for this Nucleo-C071RB board showcases how you can realize support for firmware updates via:
- USB Mass Storage Class (MSC)
- USB Device Firmware Upgrade (DFU)
- USB Communications Device Class (CDC)
Once the demo bootloader is programmed the Nucleo-C071RB board and you attached a USB cable between its USER USB connector and your PC, it pops up as three USB devices. In Windows, you can see this in the Device Manager:
You can perform firmware updates via USB using each of these three USB device classes, as explained further down on this page.
Workspace creation in STM32CubeIDE
Two demo projects are included in the OpenBLT bootloader package. One for the bootloader itself and one for the demo user program. This user program is configured such that it can be programmed, into the internal flash memory of the microcontroller, during a firmware update with the bootloader.
The first step in getting the bootloader up-and-running, is the creation of the Eclipse workspace in STM32CubeIDE. After starting STM32CubeIDE, you are prompted to open a workspace. It is easiest to create a new one in the following directory: .\Target\Demo\ARMCM0_STM32C0_Nucleo_C071RB_CubeIDE\
To import the demo programs into the workspace, select File → Import from the program menu. Then select General → Existing Projects into Workspace. On the next screen you select the following directory as the root directory: .\Target\Demo\ARMCM0_STM32C0_Nucleo_C071RB_CubeIDE\. Eclipse will automatically find the Boot and Prog projects and select them:
Click the Finish button to complete the project import operation.
Building and programming the Bootloader
Before the bootloader can be used, it needs to be built and programmed into the STM32C071RB's internal flash memory. The steps in this section only need to be done once.
- Set the project as the active project in Eclipse. This is achieved by clicking the Boot project in the Project Explorer to select it.
- Next, right-click the Boot project in the Project Explorer and select Refresh from the popup menu.
- Finally, right-click the Boot project in the Project Explorer and select Build Project from the popup menu to compile all the bootloader sources and link them together into the final executable.
The bootloader program is now ready to be programmed into the internal flash memory of the STM32C071RB microcontroller. Make sure the Nucleo-C071RB board is connected to your PC via a USB cable. Next, select Run → Debug from the menu to flash the bootloader program. This will launch the Debug perspective in Eclipse. Once done, you can start the bootloader program by selecting Run → Resume from the menu.
Alternatively, you can use your favorite programmer to flash the bootloader using one of the following files, depending on what file type your programmer supports:
- \Target\Demo\ARMCM0_STM32C0_Nucleo_C071RB_CubeIDE\Boot\Debug\openblt_stm32c071.elf
- \Target\Demo\ARMCM0_STM32C0_Nucleo_C071RB_CubeIDE\Boot\Debug\openblt_stm32c071.srec
Building the Demo Program
- Set the project as the active project in Eclipse. This is achieved by clicking the Prog project in the Project Explorer to select it.
- Next, right-click the Prog project in the Project Explorer and select Refresh from the popup menu.
- Finally, right-click the Prog project in the Project Explorer and select Build Project from the popup menu to compile all the user program sources and link them together into the final executable.
The output files are
- \Target\Demo\ARMCM0_STM32C0_Nucleo_C071RB_CubeIDE\Prog\Debug\demoprog_stm32c071.srec
- \Target\Demo\ARMCM0_STM32C0_Nucleo_C071RB_CubeIDE\Prog\Debug\demoprog_stm32c071.bin
Firmware update procedure
The demo bootloader for the Nucleo-C071RB board is configured to override the default timed backdoor. This means that after a power-on or reset event, the bootloader starts the user program right away, unless you explicitly requested the bootloader to stay active. To request the bootloader to stay active, keep the blue pushbutton on the board pressed during a power-on or reset.
This custom implementation of the bootloader backdoor entry was achieved, by setting configuration macro BOOT_BACKDOOR_HOOKS_ENABLE to a value of 1 in “blt_conf.h”. Hook-function BackDoorEntryHook() in “hooks.c” was implemented to return a value of BLT_TRUE if the pushbutton is pressed.
The following sections assume that you already:
- Powered the board.
- Activated the bootloader with the help of the blue pushbutton.
- Attached a USB cable between the board's USER USB connector and your PC.
USB Mass Storage Class
To download the demo program \Target\Demo\ARMCM0_STM32C0_Nucleo_C071RB_CubeIDE\Prog\Debug\demoprog_stm32c071.bin using the bootloader, open you file manager and navigate to the drive with label “OPENBLT”. Next copy the firmware file in the binary format (*.bin) to the root directory on that drive. This starts the firmware update and automatically starts the newly programmed firmware, once done.
USB Device Firmware Upgrade
Firmware updates using USB Device Firmware Upgrade assume that you installed the dfu-util tools on your PC.
To download the demo program \Target\Demo\ARMCM0_STM32C0_Nucleo_C071RB_CubeIDE\Prog\Debug\demoprog_stm32c071.bin using the bootloader, open your terminal in the directory where the firmware file in the binary format (*.bin) is located. Next run the command:
dfu-util -d 16C0 -a 0 -R -D <your-firmware-file>.bin
USB Communications Device Class
Firmware updates using USB Communication Device Class are the same as firmware updates via RS232. Just remember to select the correct COM port in MicroBoot or BootCommander. You can find the COM port in the Windows device manager:
To download the demo program \Target\Demo\ARMCM0_STM32C0_Nucleo_C071RB_CubeIDE\Prog\Debug\demoprog_stm32c071.srec using the bootloader, follow the instructions in the following link:






