-
Notifications
You must be signed in to change notification settings - Fork 35
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
Problem: No AVR support and path issues on windows #5
Open
argltuc
wants to merge
9
commits into
Elemecca:master
Choose a base branch
from
valofly:AVRSupport
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9a8b9d3
Add AVR support (currently limmited to ATtiny / ATxmega) and Multi-Co…
b685908
update AVR hex-file install handling / revert PIC hex-file handling
eaa8a0f
add ATmega support (untested)
7026d51
add avr-gcc support since it is part of XC8 compiler package
b5d985a
extend avr-gcc support to c++
79d74e6
optional arguments for AVR Obj2Hex
b39c388
change minimal cmake version
9a9b22b
add support for AVR DA family (XC8-CC >= 2.30 necessary)
3a83f6a
add build for AVR eeprom hex files
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#============================================================================= | ||
# 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_eeprom2hex target) | ||
find_program(AVR_EEPROM2HEX | ||
NAMES ${_CMAKE_TOOLCHAIN_PREFIX}avr-objcopy avr-objcopy | ||
HINTS ${_CMAKE_TOOLCHAIN_LOCATION} | ||
) | ||
|
||
if(NOT AVR_EEPROM2HEX) | ||
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}>.eep") | ||
|
||
add_custom_command( | ||
TARGET ${target} POST_BUILD | ||
WORKING_DIRECTORY ${dir}/$<CONFIG> | ||
COMMAND "${AVR_EEPROM2HEX}" -j .eeprom --set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings ${ARGN} -O ihex "${in_f}$<$<CONFIG:DEBUG>:${CMAKE_DEBUG_POSTFIX}>.elf" "${out_f}" | ||
BYPRODUCTS ${dir}/$<CONFIG>/${out_f} | ||
VERBATIM | ||
) | ||
|
||
set_property(DIRECTORY APPEND | ||
PROPERTY ADDITIONAL_MAKE_CLEAN_FILES | ||
${dir}/$<CONFIG>/${out_f} | ||
) | ||
|
||
install(FILES ${dir}/$<CONFIG>/${out_f} TYPE BIN) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#============================================================================= | ||
# 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 ${ARGN} "${in_f}$<$<CONFIG:DEBUG>:${CMAKE_DEBUG_POSTFIX}>.elf" "${out_f}" | ||
BYPRODUCTS ${dir}/$<CONFIG>/${out_f} | ||
VERBATIM | ||
) | ||
|
||
set_property(DIRECTORY APPEND | ||
PROPERTY ADDITIONAL_MAKE_CLEAN_FILES | ||
${dir}/$<CONFIG>/${out_f} | ||
) | ||
|
||
install(FILES ${dir}/$<CONFIG>/${out_f} TYPE BIN) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#============================================================================= | ||
# Copyright 2019 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.) | ||
|
||
# called by `CMakeCInformation` | ||
# to configure the AVR GCC compiler interface for C files | ||
|
||
string(TOLOWER ${MICROCHIP_MCU_MODEL} MMCU) | ||
|
||
string(APPEND CMAKE_C_FLAGS_INIT | ||
# build for the configured MCU model | ||
" -mmcu=${MMCU}" | ||
) | ||
|
||
set(CMAKE_C_OUTPUT_EXTENSION ".p1") | ||
set(CMAKE_EXECUTABLE_SUFFIX ".elf") | ||
|
||
set(CMAKE_C_COMPILE_OBJECT) | ||
string(APPEND CMAKE_C_COMPILE_OBJECT | ||
"<CMAKE_C_COMPILER> <FLAGS> <DEFINES> <INCLUDES>" | ||
" -o <OBJECT> -c <SOURCE>" | ||
) | ||
|
||
set(CMAKE_C_LINK_EXECUTABLE) | ||
string(APPEND CMAKE_C_LINK_EXECUTABLE | ||
"<CMAKE_C_COMPILER> <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS>" | ||
" <OBJECTS> <LINK_LIBRARIES>" | ||
" -o <TARGET>" | ||
) | ||
|
||
set(CMAKE_C_CREATE_STATIC_LIBRARY) | ||
string(APPEND CMAKE_C_CREATE_STATIC_LIBRARY | ||
"<CMAKE_AR> -r <TARGET>" | ||
" <OBJECTS> <LINK_LIBRARIES>" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#============================================================================= | ||
# Copyright 2019 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.) | ||
|
||
# called by `CMakeCInformation` | ||
# to configure the AVR GCC compiler interface for C files | ||
|
||
string(TOLOWER ${MICROCHIP_MCU_MODEL} MMCU) | ||
|
||
string(APPEND CMAKE_CXX_FLAGS_INIT | ||
# build for the configured MCU model | ||
" -mmcu=${MMCU}" | ||
) | ||
|
||
set(CMAKE_CXX_OUTPUT_EXTENSION ".p1") | ||
set(CMAKE_EXECUTABLE_SUFFIX ".elf") | ||
|
||
set(CMAKE_CXX_COMPILE_OBJECT) | ||
string(APPEND CMAKE_CXX_COMPILE_OBJECT | ||
"<CMAKE_CXX_COMPILER> <FLAGS> <DEFINES> <INCLUDES>" | ||
" -o <OBJECT> -c <SOURCE>" | ||
) | ||
|
||
set(CMAKE_CXX_LINK_EXECUTABLE) | ||
string(APPEND CMAKE_CXX_LINK_EXECUTABLE | ||
"<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS>" | ||
" <OBJECTS> <LINK_LIBRARIES>" | ||
" -o <TARGET>" | ||
) | ||
|
||
set(CMAKE_CXX_CREATE_STATIC_LIBRARY) | ||
string(APPEND CMAKE_CXX_CREATE_STATIC_LIBRARY | ||
"<CMAKE_AR> -r <TARGET>" | ||
" <OBJECTS> <LINK_LIBRARIES>" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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)