2×1=10

because numbers are people, too
Persönliches
Fotografie
Programmierung
    • Embedded CLion EAP: forcing arm-eabi-gcc onto cmake on Windows

      While CLion may become a good IDE for embedded development, it really struggles with non conformant build scenarios at the time being. As far as building on Windows is concerned, you may either chose a MinGW- or cygwin-based toolchain and that’s it.

      CMake, however, being the underlying build system, supports the notion of externally defined toolchains (-D CMAKE_TOOLCHAIN_FILE=...), which may be used to trick CLion into cross-compiling when it really doesn’t want to.

      Note that this is merely a hack to get you starting and by no means a full-fledged solution. (Side note: Please share your insights.)

      As for my system, I finally went with MinGW (mingw-base 2013072200) as this solution handles paths Windows-like, i.e. without cygwin’s /cygdrive/ mangling; I also installed arm-none-eabi-gcc 4.9.2. Note also that installing the arm-gcc toolchain within cygwin might be an easier solution in the long run.

      First, we create a toolchain – in this case for a Cortex-M0+ – like follows:

      include(CMakeForceCompiler)
      set(CMAKE_SYSTEM_NAME Generic)
      set(CMAKE_SYSTEM_PROCESSOR cortex-m0plus)
      
      find_program(ARM_CC arm-eabi-gcc
          ${TOOLCHAIN_DIR}/bin
          )
      find_program(ARM_CXX arm-eabi-g++
          ${TOOLCHAIN_DIR}/bin
          )
      find_program(ARM_OBJCOPY arm-eabi-objcopy
          ${TOOLCHAIN_DIR}/bin
          )
      find_program(ARM_SIZE_TOOL arm-eabi-size
          ${TOOLCHAIN_DIR}/bin)
      
      CMAKE_FORCE_C_COMPILER(${ARM_CC} GNU)
      CMAKE_FORCE_CXX_COMPILER(${ARM_CXX} GNU)
      
      set(CMAKE_C_FLAGS
        "${CMAKE_C_FLAGS}"
        "-fno-common -ffunction-sections -fdata-sections"
      )
      
      if (CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m0plus")
      
        set(CMAKE_C_FLAGS
          "${CMAKE_C_FLAGS}"
          "-mcpu=cortex-m0plus -mthumb"
        )
      
      else ()
        message(WARNING
          "Processor not recognised in toolchain file, "
          "compiler flags not configured."
        )
      endif ()
      
      # fix long strings (CMake appends semicolons)
      string(REGEX REPLACE ";" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
      
      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "")
      
      set(BUILD_SHARED_LIBS OFF)
      

      In CLion’s Build, Execution, Deployment > CMake settings we then set the CMake Generation options with

      -DTOOLCHAIN_DIR:PATH=c:/path/to/arm-eabi/ 
      -DCMAKE_TOOLCHAIN_FILE=toolchain-gcc-arm-eabi.cmake
      

      as can be seen in the following image.

      CLion CMake generation options

      If we weren’t using MinGW but cygwin, CMake would be unable to find the executables given a MinGW-style path (e.g. c:/some/thing); a cygwin-style path (e.g. /cygdrive/c/some/thing) would then have to be used here. However, when the cygwin toolchain is selected in CLion, all source file paths are also presented cygwin-style, which obviously can’t be accessed from a non-cygwin application. Long story short: Know your tools, I didn’t.

      Using Help > Show Generated CMake Files in Explorer you can see the generated project files.

      CLion Show Generated Files

      Deleting this folder forces a full invalidation of CMake’s generated cache, which might otherwise not happen.

      CLion Generated Files in Explorer

      Afterwards you can trigger a regeneration of the cache by using the Reload CMake Project button in the CMake Problem pane.

      CLion regenerate CMake project

      Now the CMake Cache should show the correct paths.

      CLion CMake cache

      If you then build your project, CMake will use the crosscompiler and place the binaries in the folder you deleted earlier.

      Februar 12th, 2015 GMT +1 von
      Markus
      2015-02-12T06:21:21+01:00 2015-07-3T11:34:09+01:00 · 6 Kommentare
      Windows IDE CLion MinGW cygwin
      Allgemein Embedded

      6 Kommentare auf „Embedded CLion EAP: forcing arm-eabi-gcc onto cmake on Windows“

      1. Andrey sagt:
        Freitag, April 3rd, 2015 04:42 pm GMT +1 um 16:42

        Hello, what exactly config must be use on Build, Execution, Deployment > ToolChain settings ?

        Antworten
      2. Nate sagt:
        Sonntag, Juni 14th, 2015 03:54 pm GMT +1 um 15:54

        Thanks for this writeup. This was the cross-compilation strategy that I used as well, and so far it seems to be working alright.

        Antworten
      3. Alexander sagt:
        Mittwoch, August 26th, 2015 09:33 pm GMT +1 um 21:33

        Hello, is it possible to debug remotely with arm-eabi-gdb / gdb-server?

        Antworten
      4. SparkBuzz sagt:
        Dienstag, September 29th, 2015 12:27 pm GMT +1 um 12:27

        I’d also like to know if debugging is possible?

        Antworten
      5. Markus sagt:
        Freitag, Dezember 4th, 2015 01:17 pm GMT +1 um 13:17

        About the (remote) debugging: I have no idea. It’s what I need as well.

        Antworten
      6. Mark sagt:
        Donnerstag, Mai 5th, 2016 02:20 am GMT +1 um 02:20

        „Help > Show Generated CMake Files in Explorer“ appears to have moved to the „Tools > CMake“ menu.

        Antworten

      Hinterlasse einen Kommentar

      Hier klicken, um das Antworten abzubrechen.

    1. « newer
    2. 1
    3. …
    4. 8
    5. 9
    6. 10
    7. 11
    8. 12
    9. 13
    10. 14
    11. …
    12. 39
    13. older »
    • Kategorien

      • .NET
        • ASP.NET
        • Core
        • DNX
      • Allgemein
      • Android
      • Embedded
      • FPGA
      • Humor
      • Image Processing
      • Kalman Filter
      • Machine Learning
        • Caffe
        • Hidden Markov Models
        • Neural Networks
        • TensorFlow
      • Mapping
      • MATLAB
      • Robotik
      • Rust
      • Signal Processing
      • Tutorial
      • Version Control
    • Neueste Beiträge

      • Getting an image into and out of TensorFlow
      • Dockerized .NET Core 1.0.1 and .NET Framework on Mono 4.7
      • Building Caffe on Windows using Visual Studio 201…3
      • Rust: adding arbitrary things
      • „Compiler crashed with code 1“ on Mono
    • Kategorien

      .NET Allgemein Android ASP.NET Caffe Core DNX Embedded FPGA Hidden Markov Models Humor Image Processing Kalman Filter Machine Learning Mapping MATLAB Neural Networks Robotik Rust Signal Processing TensorFlow Tutorial Version Control
    • Tags

      .NET Accelerometer Bitmap Bug Canvas CLR Curve Fitting docker FPGA FRDM-KL25Z FRDM-KL26Z Freescale git Gyroscope Integration Drift Intent J-Link Linear Programming Linux Magnetometer Matlab Mono Naismith Open Intents OpenSDA Pipistrello Player/Stage PWM Sensor Fusion Simulink Spartan 6 svn tensorflow Tilt Compensation Tobler Tranter Trekking TRIAD ubuntu Windows Xilinx Xilinx SDK ZedBoard ZYBO Zynq
    • Letzte Kommetare

      • Bernardo bei Frequency-variable PWM generator in Simulink
      • Canberk bei Frequency-variable PWM generator in Simulink
      • Mark bei Embedded CLion EAP: forcing arm-eabi-gcc onto cmake on Windows
      • santhan bei Frequency-variable PWM generator in Simulink
      • Markus bei Embedded CLion EAP: forcing arm-eabi-gcc onto cmake on Windows
    • Blog durchsuchen

    • Februar 2015
      M D M D F S S
      « Sep   Mrz »
       1
      2345678
      9101112131415
      16171819202122
      232425262728  
    • Self

      • Find me on GitHub
      • Google+
      • Me on StackExchange
      • Ye olde blog
    • Meta

      • Anmelden
      • Beitrags-Feed (RSS)
      • Kommentare als RSS
      • WordPress.org
    (Generiert in 1,049 Sekunden)

    Zurück nach oben.