STM32 + HAL + FreeRTOS Part IV: IDE (Eclipse) setup

Maybe I should've started with this a bit earlier, but IMO getting project to build from Eclipse is pretty straight forward - just import project as a Makefile project. Despite the fact, that it can't resolve some symbols, make is aware of them and compiles just fine.

So, for starters you'll need Eclipse itself, which is available on their downloads page. What you'll need is "Eclipse IDE for C/C++ developers". I have an old Mars2 version, but it shouldn't matter that much.

To run Eclipse, you also need Java Runtime (JRE) for your system available. JRE has to be with the same architecture (x86, x64) as Eclipse itself (and preferably OS).

Once installed and started up, you have to set up your workspace (directory, where it'll store all the project-related data). It does not have to be your projects folder, I prefer to keep it separately from actual code I commit, to avoid cluttering. Existing code can be easily imported afterwards.

Once workspace is set up, all you have to do is import Makefile project by clicking File/New/Makefile project with Existing code. Click Browse... and browse into the directory with our project source code, where the Makefile is located. It should fill project name based on the folder name. Toolchain selection can be left as <none> for now. Click finish and enjoy your project.

It should be able to build as-is now. Open Src/main.c file in project explorer and hit CTRL+B. If you see .hex and .bin file names in output console, you're dandy.


Now there are some issues with unresolved symbols (which annoyingly get reported as bugs). Let's try to fix that.

The following steps configure the CDT build output parser to automatically discover symbols, include paths and compiler settings based on the output produced by the Makefile.
  • Right-click on project Project Properties/C/C++/Preprocessor Include Paths,etc./Providers to open configuration window we're interested in
  • Click on CDT GCC Build Output Parser and change the compiler command pattern from (gcc)|([gc]\+\+)|(clang) to (.*gcc)|(.*[gc]\+\+) then apply changes.
  • Click on CDT Built-in Compiler Settings and replace ${COMMAND} with $toolchain-path\arm-none-eabi-gcc and click Apply. Here $toolchain-path is path to the toolchain binary folder:
    # Windows
    C:\tools\arm-gcc\7-2017-q4-major\bin\arm-none-eabi-gcc ${FLAGS} -E -P -v -dD "${INPUTS}"
    
    # Linux
    ~/tools/arm-gcc/7-2017-q4-major/bin/arm-none-eabi-gcc ${FLAGS} -E -P -v -dD "${INPUTS}"
    
Note, that  full path to the toolchain is needed only if you don't have it in system PATH.

Now do Project/Clean and then rebuild the project, so that Indexer can read the console output and add index everything mentioned there. Most of the warnings should go away now.

You can ignore make errors on performing make clean, it's usually Windows complaining that it can't find .dep directory. It should still clean up build.

Debugging STM32 applications with Eclipse via ST-Link is a bit more convoluted setup, so that will be reviewed some other time.

No comments:

Post a Comment