Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the relation of cmake-avr and avrdude? #25

Open
IJkb opened this issue Feb 14, 2022 · 2 comments
Open

What is the relation of cmake-avr and avrdude? #25

IJkb opened this issue Feb 14, 2022 · 2 comments

Comments

@IJkb
Copy link

IJkb commented Feb 14, 2022

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?

@mkleemann
Copy link
Owner

mkleemann commented Feb 14, 2022

The custom targets execute avrdude as defined in the scripts. You just have to specify the target you want to run in your call of cmake, like "cmake [...] get_fuses". In your case it is something like upload, I believe. Sorry, it's been a while I used it actively and I have to look too :)

Avr_dude is just the programming tool I used. Setting up another programmer with its settings is also possible.

I hope that helps a bit.

@mkleemann
Copy link
Owner

"make help" shows you all the possible targets. So, it's not cmake, but make you call with the target.

As I said, it's been a while.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants