I created hex-files with the help of this great repository, thanks already for this very helpful project! Now I want to upload my code to a MCU (using avrdude!?) But I haven't really exactly figured out how this would work. There seems to be some connection between cmake and avrdude, is that correct? For example there are some things set in the CMakeLists.txt like
set(AVR_UPLOADTOOL avrdude) set(AVR_PROGRAMMER avrispmkII) set(AVR_UPLOADTOOL_PORT usb)
later in the "generic-gcc-avr.cmake", these definitions are used for add_custom_target()-functions:
`
##########################################################################
avr_target_compile_definitions
Calls target_compile_definitions with AVR target names
##########################################################################
function(avr_target_compile_definitions EXECUTABLE_TARGET)
if(NOT ARGN)
message(FATAL_ERROR "No compile definitions to add to ${EXECUTABLE_TARGET}.")
endif()
get_target_property(TARGET_LIST ${EXECUTABLE_TARGET} OUTPUT_NAME)
set(extra_args ${ARGN})
target_compile_definitions(${TARGET_LIST} ${extra_args})
endfunction()
function(avr_generate_fixed_targets)
get status
add_custom_target(
get_status
${AVR_UPLOADTOOL} ${AVR_UPLOADTOOL_BASE_OPTIONS} -P ${AVR_UPLOADTOOL_PORT} -n -v
COMMENT "Get status from ${AVR_MCU}"
)
get fuses
add_custom_target(
get_fuses
${AVR_UPLOADTOOL} ${AVR_UPLOADTOOL_BASE_OPTIONS} -P ${AVR_UPLOADTOOL_PORT} -n
-U lfuse:r:-:b
-U hfuse:r:-:b
COMMENT "Get fuses from ${AVR_MCU}"
)
set fuses
add_custom_target(
set_fuses
${AVR_UPLOADTOOL} ${AVR_UPLOADTOOL_BASE_OPTIONS} -P ${AVR_UPLOADTOOL_PORT}
-U lfuse:w:${AVR_L_FUSE}:m
-U hfuse:w:${AVR_H_FUSE}:m
COMMENT "Setup: High Fuse: ${AVR_H_FUSE} Low Fuse: ${AVR_L_FUSE}"
)
get oscillator calibration
add_custom_target(
get_calibration
${AVR_UPLOADTOOL} ${AVR_UPLOADTOOL_BASE_OPTIONS} -P ${AVR_UPLOADTOOL_PORT}
-U calibration:r:${AVR_MCU}_calib.tmp:r
COMMENT "Write calibration status of internal oscillator to ${AVR_MCU}_calib.tmp."
)
set oscillator calibration
add_custom_target(
set_calibration
${AVR_UPLOADTOOL} ${AVR_UPLOADTOOL_BASE_OPTIONS} -P ${AVR_UPLOADTOOL_PORT}
-U calibration:w:${AVR_MCU}_calib.hex
COMMENT "Program calibration status of internal oscillator from ${AVR_MCU}_calib.hex."
)
endfunction()
`
but what is happening here exactly? Could anyone elaborate or point me to to the documentation for these details? Also, as stated in the topic, how does this cmake-avr interact with avrdude or some other mechanisms to upload the code to my mcu?
I created hex-files with the help of this great repository, thanks already for this very helpful project! Now I want to upload my code to a MCU (using avrdude!?) But I haven't really exactly figured out how this would work. There seems to be some connection between cmake and avrdude, is that correct? For example there are some things set in the CMakeLists.txt like
set(AVR_UPLOADTOOL avrdude) set(AVR_PROGRAMMER avrispmkII) set(AVR_UPLOADTOOL_PORT usb)later in the "generic-gcc-avr.cmake", these definitions are used for add_custom_target()-functions:
`
##########################################################################
avr_target_compile_definitions
Calls target_compile_definitions with AVR target names
##########################################################################
function(avr_target_compile_definitions EXECUTABLE_TARGET)
if(NOT ARGN)
message(FATAL_ERROR "No compile definitions to add to ${EXECUTABLE_TARGET}.")
endif()
target_compile_definitions(${TARGET_LIST} ${extra_args})
endfunction()
function(avr_generate_fixed_targets)
get status
add_custom_target(
get_status
${AVR_UPLOADTOOL} ${AVR_UPLOADTOOL_BASE_OPTIONS} -P ${AVR_UPLOADTOOL_PORT} -n -v
COMMENT "Get status from ${AVR_MCU}"
)
get fuses
add_custom_target(
get_fuses
${AVR_UPLOADTOOL} ${AVR_UPLOADTOOL_BASE_OPTIONS} -P ${AVR_UPLOADTOOL_PORT} -n
-U lfuse:r:-:b
-U hfuse:r:-:b
COMMENT "Get fuses from ${AVR_MCU}"
)
set fuses
add_custom_target(
set_fuses
${AVR_UPLOADTOOL} ${AVR_UPLOADTOOL_BASE_OPTIONS} -P ${AVR_UPLOADTOOL_PORT}
-U lfuse:w:${AVR_L_FUSE}:m
-U hfuse:w:${AVR_H_FUSE}:m
COMMENT "Setup: High Fuse: ${AVR_H_FUSE} Low Fuse: ${AVR_L_FUSE}"
)
get oscillator calibration
add_custom_target(
get_calibration
${AVR_UPLOADTOOL} ${AVR_UPLOADTOOL_BASE_OPTIONS} -P ${AVR_UPLOADTOOL_PORT}
-U calibration:r:${AVR_MCU}_calib.tmp:r
COMMENT "Write calibration status of internal oscillator to ${AVR_MCU}_calib.tmp."
)
set oscillator calibration
add_custom_target(
set_calibration
${AVR_UPLOADTOOL} ${AVR_UPLOADTOOL_BASE_OPTIONS} -P ${AVR_UPLOADTOOL_PORT}
-U calibration:w:${AVR_MCU}_calib.hex
COMMENT "Program calibration status of internal oscillator from ${AVR_MCU}_calib.hex."
)
endfunction()
`
but what is happening here exactly? Could anyone elaborate or point me to to the documentation for these details? Also, as stated in the topic, how does this cmake-avr interact with avrdude or some other mechanisms to upload the code to my mcu?