on 2022-11-14 05:58 AM
Every STM32 MCU comes pre-programmed with a system memory bootloader stored in the internal boot ROM (system memory). Its main purpose is to download the application program to the internal Flash memory through one of the available serial peripherals on the target device (e.g. USART, CAN, USB DFU, I2C, and SPI). To verify which peripheral interfaces support the activation of the bootloader, the communication protocols and respective command set and sequence, please review AN2606 (STM32 Microcontroller System Memory Boot Mode).
STM32CubeProgrammer is an all-in-one software tool for programming STM32 products, compatible across multiple operating systems and available in both Graphical User Interface (GUI) and Command Line Interface (CLI) versions. It’s an easy to use and efficient application for reading, writing, and verifying device memory through both the JTAG and SWD debug interfaces and bootloader interfaces (e.g. USART, CAN, USB DFU, I2C, and SPI). It is recommended to always keep up to date with the latest version of STM32CubeProgrammer.
You can find the latest version of STM32CubeProgrammer on st.com. See the relevant documentation and links section at the end of this article for direct link to STM32CubeProgrammer’s landing page.
On the other hand, if you already have STM32CubeProgrammer installed on your system you can refer to the steps below to check your current STM32CubeProgrammer version, and if there are any updates available.
In the bottom left-hand corner of the screen, select the ‘?’ icon. Then select the ‘Software Update’ option.
Note that the contents of this window may differ, depending on the current version of STM32CubeProgrammer you are running. If you have any updates to make, please follow the pop-up window’s on-screen prompts.
The STLINK-V3SET is a stand-alone modular debugger and programming probe for the STM8 and STM32 microcontrollers. It is composed of the main module and complementary adapter board. The STLINK-V3SET provides a proprietary USB interface allowing communication with any STM8 or STM32 target with several protocols: SPI, I2C, CAN, UART and GPIOs. This interface may be used to communicate with the target’s bootloader, which we will be demonstrating in this article.
I2C signals are available on MB1440 CN7 and CN9. The adapter module also provides optional 680-ohm pull-ups, which can be activated by closing JP10 jumpers. In this case, the T_VCC target voltage must be provided to any of the MB1440 connectors accepting it (e.g., CN1, CN2, CN6 or JP10 jumpers).
Locate your STM32 device in AN2606. This section will reveal the activation pattern you need to apply. In addition, provides the various available bootloader interfaces for your device, and even more importantly, the hardware resources required by the bootloader.
In this example, we will select activation pattern 11, row 2. However, feel free in your application to select any of the available activation patterns listed.
After connecting your target MCU board to STM32CubeProgrammer, on the left-hand side of the GUI select the “OB” tab and expand the “User Configuration” tab. Verify that Nucleo-G071RB’s option bytes bits nBoot1 = 1 and nBOOT0_SEL = 0.
Once disconnected from STM32CubeProgrammer, connect PA14 (BOOT 0 pin) to VDD
In this example, we will select I2C1 as our I2C bootloader entry point:
MB1441 attached/mounted to MB1440B via CN1, CN3 and CN4 connectors
Connection Established | Nucleo-G071RB | STLINK-V3 Set |
GND | JP5 | CN6 – Pin 3 |
T_VCC (Target Voltage) | CN7 – Pin 5 | CN6 – Pin 1 |
I2C1_SCL (I2C Clock) | CN10 – Pin 24, PB6 | CN9 – Pin 7 |
I2C1_SDA (I2C Data) | CN7 - Pin 21, PB7 | CN9 – Pin 10 |
You will then need to power the Nucleo-G071RB board through the STLINK USB connector, and the STLINK-V3SET through CN5, the USB-Micro B connector.
Congratulations! We have successfully used STM32CubeProgrammer and STLINK-V3SET to launch ST’s internal I2C bootloader on the Nucleo-G071RB board. The STM32CubeProgrammer GUI has various applications that can help you with your project. Some of the things you can do include but are not limited to reading from / writing to flash memory and RAM, reading / programming the device option bytes, and checking CPU register contents.
Our example here, we will use the Nucleo-G071RB as our STM32 reference board along with the STLINK-V3SET to show you how to leverage the STM32CubeProgrammer GUI to access the target’s I2C bootloader.
@Laura C. Is there a CAN / CAN-FD bus equivalent document for this? Thanks
I have a situation where I have one ST MCU, a G474RE, that I communicate with via USB. I have about a dozen other MCUs in the system (either a G041 or G030) that are controlled by the 474 master over I2C. I'd like to be able to update the code on each of the other MCU's by sending the hex file thru the 474 master. Is this possible and where would I find information on how to do it?
Thanks,
Charles
Read and implement the protocol described in AN4221 ?
If they all respond to the same address that might be a challenge. Can you hold each selectively in reset?
Or facilitate the update method with some of your own code in each of the MCU?
@Tesla DeLorean thank you for the reply. I'm fairly new to using MCU's. Does the bootloader already exist in the G0 device or do I need to find it somewhere? Also, can I use any of the I2C ports on the G0 and any pin? Where do I find the details of the physical layer?
Ok, digging into this a bit more thoroughly, I might have answered some of my questions. It would appear that an 2606 gives the hardware configuration for my parts in Table 89:
Is there any example code that would show how to take an elf file, send it over USB, then download it to the G0? My G474 code already has USB comms working. I can easily get the data sent over but I'm struggling to understand what to do with the ELF file and where to start writing the data, understanding if erasing the full user mem is required, etc... I greatly appreciate any help you can provide.