<commit_before># USB Firmware Upgrade Project

This project implements a firmware upgrade (bootloader) solution using the USB *Device Firmware Upgrade Class* (DFU), which provides an interface to up- and download (executable) images to the device memory. The project implements the same DFU functionality as the **System Memory Boot mode** permanently programmed in all USB capable STM32 devices, therefore the following guide applies to DFU firmware upgrade in general for the STM32 family.

The project is provided with a number of Board Support Packages, which extend the applicability of the project ~~over the whole supported product range.~~ (The flash interface is not delivered on all device lines yet.)

## Project structure

The project uses the XPD drivers that belong to the selected STM32 line (e.g. for the STM32F3-Discovery the [STM32F3_XPD](https://github.com/IntergatedCircuits/STM32_XPD/tree/master/STM32F3_XPD) and its dependencies in [CMSIS](https://github.com/IntergatedCircuits/STM32_XPD/tree/master/CMSIS)). The STMicroelectronics provided (but slightly improved) [STM32_USB_Device_Library](https://github.com/IntergatedCircuits/STM32_XPD/tree/master/Middlewares/STM32_USB_Device_Library) is used as the USB Core and DFU class stack.

The **App** folder contains the project-specific USB configuration, as well as the embedded flash media interface (*usb_dfu_flash.c*).

The **BSP_{X}** folders each contain a Board Support Package which make the project out-of-the-box evaluatable for the given STM32 kit. This code also gives insight into how to efficiently separate the device-specific configuration from the application-specific peripheral handling.

## Drivers and Software

The STM32 devices DFU driver package – the [DfuSe](http://www.st.com/en/development-tools/stsw-stm32080.html) – contains not only the necessary drivers, but also a freely modifiable software toolkit for simple device flashing using the USB interface. This includes DFU file generator and DFU flasher GUI and command line applications.

### Firmware Upgrade Procedure

1. Start the *DfuSeDemo.exe* application. It automatically detects when a DFU device is connected to the computer, and displays device information.
2. Open the DFU File Manager (*DfuFileMgr.exe*) application and select **GENERATE**.
3. The device data shall be copied from the device information displayed on the DfuSeDemo as well as the *Target ID*. The result of a built firmware should be *.hex* or *.bin* file, which have to be injected here. A descriptive *Target Name* can also be specified.
4. Press *Generate* and save the *.dfu* file.
5. In the DfuSeDemo, choose the previously created *.dfu* file in the *Upgrade or Verify Action* section, then press **Upgrade**, and wait for the procedure to be completed.<commit_msg>Readme updated: full support of flash operations<commit_after># USB Firmware Upgrade Project

This project implements a firmware upgrade (bootloader) solution using the USB *Device Firmware Upgrade Class* (DFU), which provides an interface to up- and download (executable) images to the device memory. The project implements the same DFU functionality as the **System Memory Boot mode** permanently programmed in all USB capable STM32 devices, therefore the following guide applies to DFU firmware upgrade in general for the STM32 family.

The project is provided with a number of Board Support Packages, which extend the applicability of the project over the whole supported product range.

## Project structure

The project uses the XPD drivers that belong to the selected STM32 line (e.g. for the STM32F3-Discovery the [STM32F3_XPD](https://github.com/IntergatedCircuits/STM32_XPD/tree/master/STM32F3_XPD) and its dependencies in [CMSIS](https://github.com/IntergatedCircuits/STM32_XPD/tree/master/CMSIS)). The STMicroelectronics provided (but slightly improved) [STM32_USB_Device_Library](https://github.com/IntergatedCircuits/STM32_XPD/tree/master/Middlewares/STM32_USB_Device_Library) is used as the USB Core and DFU class stack.

The **App** folder contains the project-specific USB configuration, as well as the embedded flash media interface (*usb_dfu_flash.c*).

The **BSP_{X}** folders each contain a Board Support Package which make the project out-of-the-box evaluatable for the given STM32 kit. This code also gives insight into how to efficiently separate the device-specific configuration from the application-specific peripheral handling.

## Drivers and Software

The STM32 devices DFU driver package – the [DfuSe](http://www.st.com/en/development-tools/stsw-stm32080.html) – contains not only the necessary drivers, but also a freely modifiable software toolkit for simple device flashing using the USB interface. This includes DFU file generator and DFU flasher GUI and command line applications.

### Firmware Upgrade Procedure

1. Start the *DfuSeDemo.exe* application. It automatically detects when a DFU device is connected to the computer, and displays device information.
2. Open the DFU File Manager (*DfuFileMgr.exe*) application and select **GENERATE**.
3. The device data shall be copied from the device information displayed on the DfuSeDemo as well as the *Target ID*. The result of a built firmware should be *.hex* or *.bin* file, which have to be injected here. A descriptive *Target Name* can also be specified.
4. Press *Generate* and save the *.dfu* file.
5. In the DfuSeDemo, choose the previously created *.dfu* file in the *Upgrade or Verify Action* section, then press **Upgrade**, and wait for the procedure to be completed.
{'fraction_non_alphanumeric': 0.06538530626908569, 'fraction_numerical': 0.014011137057661218, 'mean_word_length': 5.125412541254126, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5091659', 'n_tokens_mistral': 1531, 'n_tokens_neox': 1397, 'n_words': 732}