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
Miao Wei, deputy director of the Economic Committ...
At this year's two sessions, the top leadersh...
Gigsgigscloud recently launched the Los Angeles L...
5G is the latest generation of cellular network t...
Iperf test: Use udp to set the bandwidth to 2M, 5...
[51CTO.com original article] During the 4th Globa...
Friendhosting is a Bulgarian hosting company esta...
In a recent blog post, Stefan Pongratz, vice pres...
Recently, the central government has clearly inst...
A major shift is happening with IoT devices that ...
[Original article from 51CTO.com] In 2019, Shenzh...
[51CTO.com original article] With the continuous ...
Recently, CloudCone has released information abou...
[51CTO.com original article] In order to pay trib...
In the digital age where seamless connectivity an...