Skip to content

Enchan1207/cmake-avr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cmake-avr

Overview

CMake toolchain for AVR microcontroller

Requirements

Usage

  1. Clone this repository.

    git clone https://github.com/Enchan1207/cmake-avr
  2. Set environment variable AVR_SDK_PATH to it.

    export AVR_SDK_PATH='/path/to/cmake-avr'
  3. Configure CMakePresets.json .

    {
        "version": 10,
        "cmakeMinimumRequired": {
            "major": 3,
            "minor": 12,
            "patch": 0
        },
        "configurePresets": [
            {
                "name": "target",
                "generator": "Ninja",
                "binaryDir": "${sourceDir}/build/${presetName}",
                "cacheVariables": {
                    "AVR_MCU": "attiny85",
                    "AVR_FCPU": "8000000"
                },
                "toolchainFile": "$env{AVR_SDK_PATH}/cmake/avr_toolchain.cmake"
            }
        ],
        "buildPresets": [
            {
                "name": "target",
                "configurePreset": "target"
            }
        ]
    }
  4. (optional) Add target_configure_for_avr for your target in CMakeLists.txt. it provides memory-usage and .hex file output to specified target.

    add_executable(main_target)
    
    # some configuration...
    
    target_configure_for_avr(main_target)

Configuration options

This toolchain provides options: AVR_MCU and AVR_FCPU. It will be passed to commands and can be set at configure (cmake ...) or at CMakePresets.json.

Appendix: How to install a compiler

AVR compilers can be installed from microchip or HomeBrew.

License

This repository is published under MIT License.

About

CMake toolchain for AVR microcontroller

Resources

License

Stars

Watchers

Forks

Contributors

Languages