/clion-avr-c-demo

Demo project CLion + Arduino Mega2560 + AVR-GCC compiler

Primary LanguageCMakeThe UnlicenseUnlicense

Demo project CLion + Arduino Uno + AVR-GCC compiler

Note Debug is not supported yet

Prerequirements

Hardware

All platforms(MAC, Linux, Windows)

Windows only

HOWTO

Use the project

  • Open the project with CLion
  • Setup a new CLion Toolchain (i.e. set compilators and debugger location) with your AVR8 GNU installation (Settings -> Build, Execution, Deployment -> Toolchains). You may use either avr-gdb-py or avr-gdb. First one is better but requires Python to be installed.
Screenshot 1

CLion Settings Part I

  • Use the toolchain for the project (Settings -> Build, Execution, Deployment -> CMake -> Toolchain:)
Screenshot 2

CLion Settings Part II

  • Adjust CMakeLists.txt settings, such as avrdude location and actual COM port
  • Select FLASH run configuration
  • Build it. Arduino yellow LED should start blinking about 1Hz

Use simulator(simavr)

Screenshot 3

CLion Run Configuration

  • Set a breakpoint somewhere in your main()
  • Select SIMAVR Run Configuaration
  • Click Debug
  • Enjoj!

Diagnose problems

  • Uncomment avrdude verbose switch

Use another AVR-based board

  • Check if this repository contains a branch dedicated to your CPU
  • Clone this project
  • Make adjustments as in "Use the project"
  • Open the project with CLion
  • Correct CMakeLists.txt
    • Project name in add_executable() clause
    • List of source files in add_executable clause
    • add include_directories() clause(s) if needed
    • TARGET_CPU
    • FLASH custom target command line to reflect another hardware