This article is reprinted from the WeChat public account "Mantan Embedded", written by Vinson. Please contact the Mantan Embedded public account to reprint this article. What is DFU?DFU, or Device Firmware Upgrade, is also a USB protocol. It is mainly used for device upgrades and is commonly used in mobile phones (IOS, Android) and TV boxes. Compared with CDC serial ports or RNDIS, it is a faster USB transmission method. DFU: Need to enter USB DFU mode, suitable for upgrading at the bootloader stage. CDC OTA: Can be used as a composite device and run together. The disadvantage is that the transmission speed may be limited by bandwidth. How to use?
dfu-util cross-compilationdfu-util is a host-side implementation of the USB Forum's DFU 1.0 and DFU 1.1 specifications. DFU is designed to download and upload firmware to and from devices connected via USB. It ranges from small devices like microcontroller boards to mobile phones. This article mainly introduces cross-compilation on Windows and Linux platforms. You can directly refer to the official website. It is not very difficult. There are currently two approaches to cross-compiling for Windows:
Prepare
Project Engineering Adjustment1. Adjust the project file to VS 2019 2. Modify the solution file, dfu-util_2019.sln, and adjust it to 2019 You can see that by default libusb and dfu-uilt are in the same directory. You can also combine libusb into the dfu-util project, but you need to modify the related header files. I recommend that you do not modify the project reference path for the first compilation. 3. libusb project 4. Open dfu-util_2019.sln with vs 2019 5. Modify external references Compile error fix1. off_t error Solution: Right click project->Properties->Configuration Properties->C/C++->Preprocessor->Preprocessor Macro Definition->Edit, add _OFF_T_DEFINED macro definition 2. Error 2: ssize_t is undefined Solution: Include libusb.h 3. Eliminate warnings Solution: Same as error 1, define the macro _CRT_NONSTDC_NO_DEPRECATE 4. Error 3: SSIZE_MAX is not defined SSIZE_MAX is defined under POSIX and is modified as follows: 5. Error 4: Unable to parse header file Solution: Include the correct header file directory 6. Compilation successful Compilation Summary Unified environment: The library downloaded from git is a vs 2010 project. You need to modify it to your own vs version first, specifically the moderator version. You can create a new empty project to view it. External reference dependency: After changing the project name, there may be problems with the reference relationship between projects. In this case, you need to remove it and then add the reference again correctly. The header files are correctly included: mainly libusb.h and getopt.h Compilation error: Higher versions of IDE may have stronger syntax checking, so if you encounter errors and warnings, don't panic, just solve them patiently. For getopt and libusb, you only need to compile them once and use them directly afterwards. After successful compilation, we can migrate the console program to the graphical interface as needed, and a basic DFU host upgrade tool will be created. SummarizeThis article briefly introduces what DFU is, and also introduces in detail how to use VS + MSVC to compile dfu-util, and records the entire debugging process. I have to say that compiling under Linux is much more convenient. Different VS may have some differences. Friends who are doing USB DFU can refer to it. |
>>: Front-end 100 Questions: The Seven-layer Network Model and the Evolution of HTTP
Over the past century, as the country has become ...
The Wi-Fi industry is currently developing rapidl...
Strategy Analytics predicts that the number of Wi...
Amazon, Microsoft and Google account for more tha...
The energy of digital technologies represented by...
Nanotechnology, transportation, cybersecurity and...
At the beginning of last month, we purchased the ...
There is no shortage of newcomers in the network ...
[51CTO.com original article] As the most importan...
Since the beginning of this year, South Korea, Ja...
[[267345]] 5G has become a hot topic among people...
This year marks the sixth year of the implementat...
The epidemic has interrupted the construction pro...
Let me share some information about HostYun's...
1.SPI hardware SPI: Serial Peripheral Interface, ...