2x1=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 embed­ded devel­op­ment, it real­ly strug­gles with non con­for­mant build sce­nar­ios at the time being. As far as build­ing on Win­dows is con­cerned, you may either chose a MinGW- or cyg­win-based tool­chain and that’s it.

      CMake, how­ev­er, being the under­ly­ing build sys­tem, sup­ports the notion of exter­nal­ly defined tool­chains (-D CMAKE_TOOLCHAIN_FILE=...), which may be used to trick CLion into cross-com­pil­ing when it real­ly doesn’t want to.

      Note that this is mere­ly a hack to get you start­ing and by no means a full-fledged solu­tion. (Side note: Please share your insights.)

      As for my sys­tem, I final­ly went with MinGW (mingw-base 2013072200) as this solu­tion han­dles paths Win­dows-like, i.e. with­out cygwin’s /cygdrive/ man­gling; I also installed arm-none-eabi-gcc 4.9.2. Note also that installing the arm-gcc tool­chain with­in cyg­win might be an eas­i­er solu­tion in the long run.

      First, we cre­ate a tool­chain — in this case for a Cor­tex-M0+ — like fol­lows:

      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 set­tings we then set the CMake Gen­er­a­tion options with

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

      as can be seen in the fol­low­ing image.

      CLion CMake generation options

      If we weren’t using MinGW but cyg­win, CMake would be unable to find the exe­cuta­bles giv­en a MinGW-style path (e.g. c:/some/thing); a cyg­win-style path (e.g. /cygdrive/c/some/thing) would then have to be used here. How­ev­er, when the cyg­win tool­chain is select­ed in CLion, all source file paths are also pre­sent­ed cyg­win-style, which obvi­ous­ly can’t be accessed from a non-cyg­win appli­ca­tion. Long sto­ry short: Know your tools, I didn’t.

      Using Help > Show Generated CMake Files in Explorer you can see the gen­er­at­ed project files.

      CLion Show Generated Files

      Delet­ing this fold­er forces a full inval­i­da­tion of CMake’s gen­er­at­ed cache, which might oth­er­wise not hap­pen.

      CLion Generated Files in Explorer

      After­wards you can trig­ger a regen­er­a­tion of the cache by using the Reload CMake Project but­ton in the CMake Prob­lem pane.

      CLion regenerate CMake project

      Now the CMake Cache should show the cor­rect paths.

      CLion CMake cache

      If you then build your project, CMake will use the cross­com­pil­er and place the bina­ries in the fold­er you delet­ed ear­li­er.

      Februar 12th, 2015 GMT +2 von
      Markus
      2015-02-12T06:21:21+02:00 2015-07-3T11:34:09+02: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 +2 um 16:42 Uhr

        Hel­lo, what exact­ly con­fig must be use on Build, Exe­cu­tion, Deploy­ment > Tool­Chain set­tings ?

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

        Thanks for this write­up. This was the cross-com­pi­la­tion strat­e­gy that I used as well, and so far it seems to be work­ing alright.

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

        Hel­lo, is it pos­si­ble to debug remote­ly with arm-eabi-gdb / gdb-serv­er?

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

        I’d also like to know if debug­ging is pos­si­ble?

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

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

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

        “Help > Show Gen­er­at­ed CMake Files in Explor­er” 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. 12
    5. 13
    6. 14
    7. 15
    8. 16
    9. 17
    10. 18
    11. …
    12. 43
    13. older »
    • Kategorien

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

      • Summarized: The E-Dimension — Why Machine Learning Doesn’t Work Well for Some Problems?
      • Use your conda environment in Jupyter Notebooks
      • Building OpenCV for Anaconda Python 3
      • Using TensorFlow’s Supervisor with TensorBoard summary groups
      • Getting an image into and out of TensorFlow
    • Kategorien

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

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

      • Lecke Mio bei Frequency-variable PWM generator in Simulink
      • Vaibhav bei Use your conda environment in Jupyter Notebooks
      • newbee bei Frequency-variable PWM generator in Simulink
      • Markus bei Using TensorFlow’s Supervisor with TensorBoard summary groups
      • Toke bei Using TensorFlow’s Supervisor with TensorBoard summary groups
    • 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 Stack­Ex­change
      • Ye olde blog
    • Meta

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

    Zurück nach oben.