2024-06-14 22:02:44 +00:00
|
|
|
# ###############################
|
|
|
|
# AVR-GCC toolchain file
|
|
|
|
# ###############################
|
|
|
|
|
|
|
|
# Specify the cross-compiler
|
|
|
|
set(CMAKE_SYSTEM_NAME Generic)
|
|
|
|
set(CMAKE_SYSTEM_VERSION 1)
|
|
|
|
set(CMAKE_SYSTEM_PROCESSOR avr)
|
|
|
|
|
|
|
|
# Specify the compiler and linker
|
|
|
|
set(AVR_MCU atmega328p) # The old Classic
|
|
|
|
#set(AVR_MCU attiny85) # The older ATtiny series, avr25
|
|
|
|
#set(AVR_MCU attiny404) # this is the avrxmega3 series
|
|
|
|
#set(AVR_MCU avr64dd28) # Newer DX series, avrxmega2
|
|
|
|
|
|
|
|
# The default frequency of an 328p devboard using the external crystal.
|
2024-06-14 23:07:10 +00:00
|
|
|
set(F_CPU 16000000UL)
|
2024-06-14 22:02:44 +00:00
|
|
|
#set(F_CPU 8000000)
|
2024-06-14 23:07:10 +00:00
|
|
|
add_compile_definitions(F_CPU=${F_CPU})
|
2024-06-14 22:02:44 +00:00
|
|
|
# add_compile_definitions(MCU=atmega328p)
|
|
|
|
add_compile_definitions(__AVR_ATmega328P__)
|
|
|
|
|
2024-06-14 23:07:10 +00:00
|
|
|
# Set up the programmer for it
|
|
|
|
#set(PROGRAMMER usbasp-clone)
|
|
|
|
set(PROGRAMMER arduino)
|
|
|
|
|
|
|
|
# Set the Port for the programmer
|
|
|
|
set(PORT /dev/ttyUSB0)
|
|
|
|
|
|
|
|
|
2024-06-14 22:02:44 +00:00
|
|
|
# Define the toolchain executables
|
|
|
|
set(CMAKE_C_COMPILER avr-gcc)
|
|
|
|
set(CMAKE_CXX_COMPILER avr-g++)
|
|
|
|
set(CMAKE_ASM_COMPILER avr-gcc)
|
|
|
|
set(CMAKE_LINKER avr-ld)
|
|
|
|
set(CMAKE_OBJCOPY avr-objcopy)
|
|
|
|
set(CMAKE_SIZE avr-size)
|
|
|
|
|
|
|
|
|
|
|
|
# Define compile options
|
|
|
|
#set(CMAKE_C_FLAGS_INIT "-mmcu=${AVR_MCU} -DF_CPU=16000000UL")
|
|
|
|
#set(CMAKE_CXX_FLAGS_INIT "-mmcu=${AVR_MCU} -DF_CPU=16000000UL")
|
|
|
|
#set(CMAKE_EXE_LINKER_FLAGS_INIT "-mmcu=${AVR_MCU}")
|
2024-06-14 23:07:10 +00:00
|
|
|
set(CMAKE_C_FLAGS " -Os -mmcu=${AVR_MCU} -DF_CPU=${F_CPU}")
|
|
|
|
set(CMAKE_CXX_FLAGS "-mmcu=${AVR_MCU} -DF_CPU=${F_CPU}")
|
2024-06-14 22:02:44 +00:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS_INIT "-mmcu=${AVR_MCU}")
|
|
|
|
|
|
|
|
|
|
|
|
# Define the archiver and other tools
|
|
|
|
set(CMAKE_AR avr-ar)
|
|
|
|
set(CMAKE_RANLIB avr-ranlib)
|
|
|
|
|