Preface
I previously sorted out the process of using VSCode to develop APM32F4, and thought there is an vintage IDE - “Eclipse”, so I also checked out how to use Eclipse to develop APM32F4, and here is a brief record of the whole process.
1 Development Environment
Development board: APM32F407IG MINI Development board
Debugger: J-Link V9/V10 or Geehy-Link
OS: WIN10 64-bit OS
IDE:Eclipse IDE for Embedded C/C++ Developers Version: 2022-12 (https://ftp.yz.yamagata-u.ac.jp/pub/eclipse//technology/epp/downloads/release/2022-12/M2/eclipse-embedcpp-2022-12-M2-win32-x86_64.zip) Just download the full size package directly and unzip it.
Cross-compilation chain: xpack-arm-none-eabi-gcc-10.2.1-1.1-win32-x64 (Remember to add Path)
Compilation tool: gnu-mcu-eclipse-windows-build-tools-2.12-20190422-1053-win64 (Remember to add Path)
GDB Server: OpenOCD (Please use the version I shared. openocd-v0.12.0-rc2-2022-11-22-1713.zip (9.96 MB) )/ J-Link GDB Server CL V7.62c (The latest version now supports APM32F4)
We won’t go into the configuration of the development environment here, I believe we all know how to do it. Let’s go straight to the main text.
2 Project Development
2.1 New project
Create a new “Eclipse” folder in the project directory ( please note that the path should be full English ) to save our project files, and copy the startup file ( startup_apm32f40x.S ) and the link script file (APM32F4xxxG_FLASH.ld) that we used in our last development with VSCode.
Open “Eclipse”. You can create a new “C/C++ Project” under “File->New” and select “C Managed Build”.
Enter the Project name and configure the project type. For convenience, it is recommended to place the project in the Project directory. Select the compilation chain as ARM Cross GCC.
If the Eclipse IDE has set the ARM Toolchains Path correctly, the path will be selected here automatically. If the Eclipse IDE has not set the ARM Toolchains Path, you can also select the absolute path to ARM Toolchains here.
Click “Finish” to complete the creation of the Project.
2.2. Create a new project folder and add files
2.2.1 Create a folder and add files manually
Create the virtual folder Application.
Create the CMSIS, Board, and StdPeriphDriver folders in the same way.
Right-click on the “Application” and select the “Import” option to import the file.
Select “File System” for “Import”, select the path of the file you want to import, and check the files you want to import.
Similarly, import the required files into the CMSIS, Board, and StdPeriphDriver folders.
2.3 Project configuration
Right-click the project and select the Project Properties “Properties” option to open it.
2.3.1 Target Processor configuration
Under “C/C++ Build->Settings->Tool Settings->Target Processor”, you can configure it as follows: you can select cortex-m3, cortex-m4, cortex-m23 or cortex-m33 depending on the core of the target chip. Here we select “cortex-m4”.
2.3.2 Optimization configuration
Configure the optimization level in the “C/C++ Build->Settings->Tool Settings->Optimization” option, you can select -O0, -O1, -O2, -O3, -Os, -Ofast, -Og.
2.3.3 GNU Arm Cross C Compiler configuration
Configure Cross C compilation options in the “C/C++ Build->Settings->Tool Settings->GNU Arm Cross C Compiler” option.
In this example, add APM32F10X_HD and APM32F103_MINI precompiled macros in '‘Preprocessor->Defined symbols’' option.
In the “includes->Include paths” option, add the paths to the header files required by the project. You can add the following in this case:
“${ProjDirPath}/../../Include”
“${ProjDirPath}/../../../../../Boards”
“${ProjDirPath}/../../../../../Libraries/APM32F4xx_StdPeriphDriver/inc”
“${ProjDirPath}/../../../../../Libraries/CMSIS/Include”
“${ProjDirPath}/../../../../../Libraries/Device/Geehy/APM32F4xx/Include”
Note: The path to the header file added in this case is a relative path. You can also add absolute paths directly here
2.3.4 GNU Arm Cross C Linker configuration
Configure Cross C linking options in “C/C++ Build->Settings->Tool Settings->GNU Arm Cross C Linker”. In the “General ->Script files” option add:
“${workspace_loc:/${ProjName}/APM32F4xxxG_FLASH.ld}” The link script is responsible for telling the linker how to allocate memory for the compiled executable.
In the Miscellaneous option, check Use newlib-nano and Do not use syscalls (you can optimize the code size)
2.3.5 Build Steps Configuration - Generating bin files
In “C/C++ Build->Settings-> Build Steps” you can add commands to generate bin/hex files.
You can add the following in this case:
arm-none-eabi-objcopy -O binary “Template.elf” “Template.bin”;
arm-none-eabi-objdump -D “Template.elf” > “Template.dump”
Finally we click the “Apply and Close” button to save our configuration.
2.4 Compilation project
Select Project->Build Project to compile the current project.
Note: Build Project is to compile the current project, Build All is to compile all projects in the current workspace.
Note: You need to save the current project before compiling each time, otherwise you will be compiling the previous project. After modifying, please clean the project before building to make sure it is correct.
After compiling, you can see that the corresponding elf, hex and bin files have been generated.
2.5 Downloading and debugging projects using Geehy-Link
2.5.1 Debug configuration interface
In the menu bar, click Run->Debug Configurations to enter the Debug configuration screen.
Use OpenOCD as the GDB Server and the GDB tool in the GCC toolchain as the GDB Client. Double-click GDB OpenOCD Debugging to create a new set of configuration options for OpenOCD.
2.5.2 Main tab
In the Main tab, select the current project and the elf file under the current project will usually be added automatically. If not, you can click Browse to add the elf file manually.
Note: If you have compiled more than one model, you need to select the corresponding executable file.elf. For convenience, you can also create a new set of debug configuration for each model.
2.5.3 Debugger tab
If the OpenOCD path is correctly configured when building the Eclipse environment, it will be automatically recognized here. If not configured correctly before, you can also select the absolute path of OpenOCD in the Executable path field. In the Config options field, fill in the cfg file used. In this case it is:
-f interface/cmsis-dap.cfg -f target/apm32f4x.cfg
The OpenOCD cfg file provides information on debugger, debug protocol, target chip identification and target chip burn-in algorithm selection.
2.5.4 SVD Path tab
2.6 Debug interface
Once Debug Configurations is complete, click Debug to enter the Debug view.
The above is the development process of building Eclipse to develop APM32F4.