第 2 節

ARM Keil MDK (ARM Microcontroller Environment Setup)

0瀏覽次數0訪問次數--跳出率--平均停留

Introduction and Environment Recommendations

  1. Keil MDK is the official software from ARM. It is the most mainstream IDE for microcontroller development, bar none.
  2. Recommended version:
    1. Beginner: Blindly Follow ARM Keil MDK 5 + CubeMX (In the early stages, beginners are only allowed to install ARM Keil MDK 5 first, and are not allowed to use CubeMX)
    2. Veteran: No-brainer VSCode + CMake + CubeMX

Introduction

  1. The most mainstream development environment (despite having many fatal flaws), bar none. Beginners should use it without overthinking—this is the solution they must use to develop STM32.
  2. The drawbacks are obvious: an outdated interface, outdated code completion, only supports Windows, and is available only in the 32-bit X86 version.

Windows

https://www.bilibili.com/video/BV18T411r7Yu

How to obtain the required files:

  1. The club's USB drive (direct copy)
  2. Official website:
    1. MDK5 official website: https://www.keil.com/demo/eval/arm.htm
    2. MDK5 FW firmware download link: https://www.keil.arm.com/devices/
    3. ARM compiler download link:
      1. ARMCC(AC5) must be downloaded: https://developer.arm.com/downloads/view/ACOMP5?revision=r5p6-07rel1
      2. ARMCLANG (AC6) is generally included with the latest version of MDK5, no need to download: https://developer.arm.com/downloads/view/ACOMPE
      3. AC5 vs. AC6 Comparison (generally not needed): https://developer.arm.com/Tools and Software/Arm Compiler for Embedded FuSa#Editions

    4. Keil MDK 5 crack keygen (please disable antivirus software before downloading): keygen.iso or https://www.duote.com/soft/907739.html
    5. Java_JRE Download (generally download Windows Offline (64-bit), JRE installation is required to open CubeMX): https://www.java.com/en/download/manual.jsp
    6. CubeMX official website: https://www.st.com.cn/zh/development-tools/stm32cubemx.html
    7. ALIENTEK supporting materials 1 (Drive A materials F1): http://www.openedv.com/docs/boards/stm32/zdyz\_stm32f103\_warshipV4.html
    8. ALIENTEK supporting materials 2 (Drive A materials F4): http://www.openedv.com/docs/boards/stm32/zdyz\_stm32f407\_explorerV3.html

Introduction

  1. This approach is a compromise, falling somewhere between MDK5 and MDK6, and can avoid some of MDK5's shortcomings. (However, because the C/C++ plugin is too poor, it is not recommended.)

Windows

Configuration Tutorial:

Quick configuration video:

https://www.bilibili.com/video/BV18e4y1H7xX

If you encounter any issues, please refer to the video below:

https://www.bilibili.com/video/BV19V411g7gD/

  1. Please install software such as MDK5, CubeMX, VScode, etc.
  2. Install VScode plugins

  1. Configure Keil Assistant
    1. Click on extension settings.

    1. Find the path to MDK5

    1. Copy the path.

    1. Paste the path you just copied.

  1. Open an MDK5 project with VSCode
    1. Open the project.



  2. Then you can edit the source code using VSCode.

Notes (Must Read):
Notes
  1. This approach is merely a compromise solution — slightly better than using MDK5 alone, but far less convenient than MDK6.
  2. VScode is only responsible for code editing (it is recommended not to use features like compilation in Keil Assistant).
  3. MDK5 is responsible for compiling, downloading, debugging, adding source files, header files, and all other operations.
  4. Advantages: Resolves the issue of the "go to definition" feature failing in the AC6 compiler (AC6 has all advantages, this is its only drawback); addresses the eye-strain problem of MDK5's outdated interface; fixes MDK5's poor code suggestions; allows the use of various VSCode extensions to improve editing efficiency.
  5. Disadvantages: You need to keep both VSCode and MDK5 open at the same time, each handling its own tasks, which is not unified. Although the code suggestions from the C/C++ plugin are better than those in MDK5, they are still quite poor (far inferior to MDK6 + Clangd).
The text 🦟 has encoding issues.
  1. The issue is as follows:

  1. Manually change the encoding (click UTF-8 in the bottom right corner; it's recommended to use the plugin below for a more convenient solution than manual changes):

  1. Plugins (The hallmark of VSCode is its abundance of plugins; using VSCode without plugins strips it of its soul).

This plugin will automatically alert you that the current encoding is problematic, guess the correct encoding, and clicking "yes" will automatically fix it.

False positive error

Don't worry about it, just make sure MDK5 compiles without errors.

Unable to go to definition

(Only do this if there is an issue; if there is no issue, leave it alone.)

Add the following inside the box below: (After adding, there may still be false error reports, but go to definition should work normally.)

..\**

Or change all absolute paths in the Include Path field to relative paths (only a portion is listed below):

..\applications\Inc
..\bsp\boards\Inc

Introduction

  1. Advantages: It improves virtually all known shortcomings of MDK5, making it a true blessing for developers.
  2. Disadvantages: High learning curve; not manageable without a certain level of computer literacy.
  3. Currently, it is not highly recommended for standalone use, because even if you know how to use it, your teammates may not, making the project incompatible. However, if you have the ability and really want to use MDK6, feel free to do so—the main thing is to use what works best for you.
  4. However, it is highly recommended to use them together, MDK6 in conjunction with MDK5. Use MDK5 to add source files, header files, and perform other operations (don't forget to compile with MDK5 after adding source and header files); use MDK6 to convert the MDK5 project just created, then proceed with source code editing, compilation, debugging, and other operations. (This way, whether your teammates use MDK5 or MDK6, they can open your project and use it directly.) (If you don't understand this, ask your senior.)

Windows && Linux

ARM Keil MDK6 Tutorial

(It feels quite comfortable to develop with so far. If the electrical control team leader finds it useful in the future, the IDE can be standardized.)

Currently, there are three widely used compilers.

armclang (AC6): Compiles extremely fast with minimal overhead. (Both compilation speed and resource usage are excellent.)

armcc (AC5): Compilation is extremely slow, but overhead is very small. (Just small overhead.)

armgcc: Compiles faster, with slightly higher overhead. (Only faster for compilation.)

So ARM GCC doesn't have that much of an advantage, but it's still acceptable.

The main difference is that ARMCC and ARMCLANG are commercial compilers, while ARMGCC is an open-source compiler. This allows ARMGCC to be used with tools like CMake and Makefile for better project management, and it also supports all platforms (Windows, Linux, MacOS, etc.).

Detailed tutorial STM32+CMake Project Deployment

音乐页