-
Notifications
You must be signed in to change notification settings - Fork 37
Problem: No AVR support and path issues on windows #5
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
9a8b9d3
b685908
eaa8a0f
7026d51
b5d985a
79d74e6
b39c388
9a9b22b
3a83f6a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#============================================================================= | ||
# Copyright 2016 Sam Hanes | ||
# | ||
# Distributed under the OSI-approved BSD License (the "License"); | ||
# see accompanying file COPYING.txt for details. | ||
# | ||
# This software is distributed WITHOUT ANY WARRANTY; without even the | ||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
# See the License for more information. | ||
#============================================================================= | ||
# (To distribute this file outside of CMake-Microchip, | ||
# substitute the full License text for the above reference.) | ||
|
||
|
||
function(avr_obj2hex target) | ||
find_program(AVR_OBJ2HEX | ||
NAMES ${_CMAKE_TOOLCHAIN_PREFIX}avr-objcopy avr-objcopy | ||
HINTS ${_CMAKE_TOOLCHAIN_LOCATION} | ||
) | ||
|
||
if(NOT AVR_OBJ2HEX) | ||
message(SEND_ERROR "No avr-objcopy program was found") | ||
endif() | ||
|
||
function(get_target_property_fallback var target) | ||
set(result NOTFOUND) | ||
foreach(property ${ARGN}) | ||
get_target_property(result ${target} ${property}) | ||
if(result) | ||
break() | ||
endif() | ||
endforeach() | ||
set(${var} ${result} PARENT_SCOPE) | ||
endfunction() | ||
|
||
get_target_property_fallback(in_f ${target} | ||
RUNTIME_OUTPUT_NAME | ||
OUTPUT_NAME | ||
NAME | ||
) | ||
|
||
get_target_property_fallback(dir ${target} | ||
RUNTIME_OUTPUT_DIRECTORY | ||
BINARY_DIR | ||
) | ||
|
||
get_filename_component(out_f ${in_f} NAME_WE) | ||
set(out_f "${out_f}$<$<CONFIG:DEBUG>:${CMAKE_DEBUG_POSTFIX}>.hex") | ||
|
||
add_custom_command( | ||
TARGET ${target} POST_BUILD | ||
WORKING_DIRECTORY ${dir}/$<CONFIG> | ||
COMMAND "${AVR_OBJ2HEX}" -O ihex "${in_f}$<$<CONFIG:DEBUG>:${CMAKE_DEBUG_POSTFIX}>.elf" "${out_f}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To make it easier to customize consider adding a variable AVR_OBJCOPY_FLAGS (AVR_OBJ2HEX_FLAGS) and maybe appropriate target property for more complex projects. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Uff, feel free ;) This is behind my knowladge of AVR_OBJCOPY ;) |
||
BYPRODUCTS ${dir}/$<CONFIG>/${out_f} | ||
VERBATIM | ||
) | ||
|
||
set_property(DIRECTORY APPEND | ||
PROPERTY ADDITIONAL_MAKE_CLEAN_FILES | ||
${dir}/${out_f} | ||
) | ||
endfunction() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,12 +56,13 @@ set(MICROCHIP_MCU "${MICROCHIP_MCU}" | |
CACHE STRING "full model number of the target Microchip MCU" | ||
) | ||
|
||
|
||
# known 8-bit MCU families | ||
list(APPEND MICROCHIP_FAMILIES_8 | ||
PIC12F | ||
PIC16F | ||
PIC18F | ||
ATtiny | ||
ATxmega | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about ATmega parts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not have any test hardware for ATmega. I can add it, but untested. |
||
) | ||
|
||
# known 16-bit MCU families | ||
|
@@ -112,6 +113,17 @@ elseif(MICROCHIP_MCU MATCHES "^(dsPIC|PIC)(32M[XZ]|[0-9]+[A-Z])([A-Z0-9]+)$") | |
"Unsupported MCU family '${MICROCHIP_MCU_FAMILY}'." | ||
) | ||
endif() | ||
|
||
elseif(MICROCHIP_MCU MATCHES "^(AT)(tiny|xmega)([a-zA-Z0-9]+)$") | ||
set(MICROCHIP_MCU_FAMILY "${CMAKE_MATCH_1}${CMAKE_MATCH_2}") | ||
set(MICROCHIP_MCU_MODEL "${MICROCHIP_MCU}") | ||
if(MICROCHIP_MCU_FAMILY IN_LIST MICROCHIP_FAMILIES_8) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Building a test program to check if the compiler actually supports the CPU would make error messages nicer - i.e. a descriptive error during configure instead of during compile (though still descriptive). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This idea sounds good. but as above: feel free :) |
||
set(CMAKE_SYSTEM_PROCESSOR "AVR") | ||
else() | ||
message(FATAL_ERROR | ||
"Unsupported MCU family '${MICROCHIP_MCU_FAMILY}'." | ||
) | ||
endif() | ||
|
||
else() | ||
message(FATAL_ERROR | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to name it AVR_OBJCOPY as it's more descriptive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, since there is already a MicrochipBin2Hex.cmake it feels for me more suitable.
On the other hand, since I do not develop our MCU software, but manage the CI and test final hardware, this naming is a little helper, that this function gives the files for program the device ;) I know... weak arguments ^^
OBJCOPY directly fits to the called avr program, so there is a better connection for typical developer...
At the end, I found this cmake file once somewhere, it is from the owner of this Repository, and I think it would be nice, if we can discuss the naming with him (and hopefully also other users)