add upload target to toolchain

master
Julian Daube 4 years ago committed by Julian Daube
parent abb58843cf
commit e0a68445e3

@ -14,6 +14,34 @@ SET(CMAKE_C_COMPILER ${AVR_CC})
SET(CMAKE_CXX_COMPILER ${AVR_CXX})
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS)
if(NOT AVR_UPLOADTOOL)
set(
AVR_UPLOADTOOL avrdude
CACHE STRING "Set default upload tool: avrdude"
)
find_program(AVR_UPLOADTOOL avrdude)
endif(NOT AVR_UPLOADTOOL)
# default upload tool port
if(NOT AVR_UPLOADTOOL_PORT)
set(
AVR_UPLOADTOOL_PORT usb
CACHE STRING "Set default upload tool port: usb"
)
endif(NOT AVR_UPLOADTOOL_PORT)
# default programmer (hardware)
if(NOT AVR_PROGRAMMER)
set(
AVR_PROGRAMMER atmelice_isp
CACHE STRING "Set default programmer hardware model: avrispmkII"
)
endif(NOT AVR_PROGRAMMER)
# prepare base flags for upload tool
set(AVR_UPLOADTOOL_BASE_OPTIONS -p ${AVR_MCU} -c ${AVR_PROGRAMMER} -B5)
add_definitions(-mmcu=${AVR_MCU} -D__${AVR_MCU}__ -DF_CPU=8000000 --std=c99)
function(add_avr_executable EXECUTABLE_NAME)
@ -77,6 +105,16 @@ function(add_avr_executable EXECUTABLE_NAME)
OUTPUT_NAME "${elf_file}"
)
# upload - with avrdude
add_custom_target(
upload_${EXECUTABLE_NAME}
${AVR_UPLOADTOOL} ${AVR_UPLOADTOOL_BASE_OPTIONS} ${AVR_UPLOADTOOL_OPTIONS}
-U flash:w:${hex_file}
-P ${AVR_UPLOADTOOL_PORT}
DEPENDS ${hex_file}
COMMENT "Uploading ${hex_file} to ${AVR_MCU} using ${AVR_PROGRAMMER}"
)
# clean
get_directory_property(clean_files ADDITIONAL_MAKE_CLEAN_FILES)
set_directory_properties(

Loading…
Cancel
Save