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

Improvements and fix bug #1

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
be0ef3e
mejorado soporte de pic32
juanAngel Jun 30, 2017
cef304d
XC32 working on windows.
Oct 3, 2017
de389e7
Added bin2hex.
Oct 5, 2017
8685588
CXX
Oct 6, 2017
947ffd9
Override Release and Debug flags.
Nov 17, 2017
999477b
agregado soporte para generacion de MAP
juanAngel Jun 30, 2017
08b38f9
corregido README y agregada explicacion de variables nuevas
juanAngel Jun 30, 2017
8896436
agregado soporte premilimar para objetivos deploit y run
juanAngel Jul 7, 2017
27c9cee
mejorado soporte de herramientas mplabx
juanAngel Jul 7, 2017
8905536
corregido objetivo run
juanAngel Jul 10, 2017
301c5d3
fix syntax error
juanAngel Jun 30, 2017
1b1fed4
Merge branch 'master' of git://github.com/juanAngel/cmake-microchip
juanAngel Jul 11, 2017
c90ecc6
add gitignore
juanAngel Jul 11, 2017
5a3295d
Merge ../Rexlab-emulate/external/cmake-microchip
juanAngel Jul 11, 2017
e15e89a
permite la deteccion de la familia y modelo configurados por parte de…
juanAngel Aug 25, 2017
50d81f8
agregado soporte para ensamblaor
juanAngel Aug 28, 2017
bc6beae
eliminado error
juanAngel Aug 28, 2017
6098b80
Mejorado soporte para ensamblador
juanAngel Sep 20, 2017
a643a9a
corregidos errores ocasionales de funciones no encontradas
juanAngel Sep 26, 2017
05b8434
Eliminada advertencia
juanAngel Oct 4, 2017
d706773
Corregido error en la generacion de los flag del compilador
juanAngel Oct 11, 2017
568ae06
cambiado mensaje para indicar el soporte de XC32
juanAngel Oct 17, 2017
caef8de
Merge https://github.com/raitraak-rrk/cmake-microchip
juanAngel Nov 24, 2017
c20f61a
Merge https://github.com/raitraak-rrk/cmake-microchip
juanAngel Nov 24, 2017
ce3e02b
fix error
juanAngel Dec 19, 2017
19a3754
fix include errors
juanAngel Dec 21, 2017
32b3ac6
Agregado soporte para diferentes programadores
juanAngel Oct 3, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*
21 changes: 17 additions & 4 deletions Modules/MicrochipBin2Hex.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
# substitute the full License text for the above reference.)


function(bin2hex target)
function(add_bin2hex_target target)
find_program(MICROCHIP_BIN2HEX
NAMES ${_CMAKE_TOOLCHAIN_PREFIX}bin2hex bin2hex
HINTS ${_CMAKE_TOOLCHAIN_LOCATION}
)

if(NOT MICROCHIP_BIN2HEX)
message(SEND_ERROR "No bin2hex program was found")
message(SEND_ERROR "No bin2hex program was found. _CMAKE_TOOLCHAIN_PREFIX=${_CMAKE_TOOLCHAIN_PREFIX}")
endif()

function(get_target_property_fallback var target)
Expand Down Expand Up @@ -48,12 +48,25 @@ function(bin2hex target)
set(out_f "${out_f}.hex")

add_custom_command(
TARGET ${target} POST_BUILD
#TARGET ${target} POST_BUILD
OUTPUT ${dir}/${out_f}
DEPENDS ${target}
WORKING_DIRECTORY ${dir}
COMMAND "${MICROCHIP_BIN2HEX}" "${in_f}"
BYPRODUCTS ${dir}/${out_f}
VERBATIM
)
add_custom_target(bin2hex_${target}
DEPENDS ${dir}/${out_f}
)

if(NOT TARGET bin2hex)
add_custom_target(bin2hex ALL)
#message(STATUS "bin2hex not exits")
endif()

add_dependencies(bin2hex
bin2hex_${target}
)

set_property(DIRECTORY APPEND
PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
Expand Down
90 changes: 90 additions & 0 deletions Modules/MicrochipIPE.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@

include(MicrochipPathSearch)

find_package(Java COMPONENTS Runtime)


set(PROGRAMER "ICD3" CACHE STRING "programador a utilizar")
set_property(CACHE PROGRAMER PROPERTY STRINGS ICD3 ICD4 PK3 PK4 PM3 PKOB)

#set(IPECMD ${Java_JAVA_EXECUTABLE} -jar "/opt/microchip/mplabx/v3.35/mplab_ipe/ipecmd.jar")
set(IPE_LOG MPLABXLog.xml MPLABXLog.xml.0 MPLABXLog.xml.1 MPLABXLog.xml.2 MPLABXLog.xml.3 MPLABXLog.xml.4 MPLABXLog.xml.5 MPLABXLog.xml.6 MPLABXLog.xml.7)

function(finMPLABX)
MICROCHIP_PATH_SEARCH(MICROCHIP_MPLABX_PATH mplabx
CACHE "the path to a Microchip MPLABX installation"
)


if(NOT MICROCHIP_MPLABX_PATH)
message(FATAL_ERROR
"No Microchip MPLABX was found. Please provide the path"
" to an MPLABX installation on the command line, for example:\n"
"cmake -DMICROCHIP_MPLABX_PATH=/opt/microchip/mplabx/v1.42 ."
)
endif()
endfunction()
function(add_ipe_deploit_target target)

finMPLABX()

find_program(MICROCHIP_IPECMD
NAMES mplab_ipe/ipecmd.jar
HINTS ${MICROCHIP_MPLABX_PATH}
)

if(NOT MICROCHIP_IPECMD)
message(SEND_ERROR "No ipecmd.jar program was found")
endif()
set(IPECMD ${Java_JAVA_EXECUTABLE} -jar ${MICROCHIP_IPECMD})

add_custom_command(
DEPENDS ${target}.hex
COMMAND ${IPECMD} -f${target}.hex -M -P${MICROCHIP_MCU_MODEL} -TP${PROGRAMER} -Y
OUTPUT log.0
BYPRODUCTS ${IPE_LOG}
COMMENT "Deploit to pic32"
VERBATIM
)
add_custom_target(deploit DEPENDS log.0)
endfunction()

function(ipeRestar target)
finMPLABX()

find_program(MICROCHIP_IPECMD
NAMES mplab_ipe/ipecmd.jar
HINTS ${MICROCHIP_MPLABX_PATH}
)

if(NOT MICROCHIP_IPECMD)
message(SEND_ERROR "No ipecmd.jar program was found")
endif()
set(IPECMD ${Java_JAVA_EXECUTABLE} -jar ${MICROCHIP_IPECMD})

add_custom_target(restart DEPENDS deploit
COMMAND ${IPECMD} -f${target}.hex -P${MICROCHIP_MCU_MODEL} -TP${PROGRAMER} -Y
VERBATIM
)
endfunction()

function(ipeRun target device)
finMPLABX()

find_program(MICROCHIP_IPECMD
NAMES mplab_ipe/ipecmd.jar
HINTS ${MICROCHIP_MPLABX_PATH}
)

if(NOT MICROCHIP_IPECMD)
message(SEND_ERROR "No ipecmd.jar program was found")
endif()

set(IPECMD ${Java_JAVA_EXECUTABLE} -jar ${MICROCHIP_IPECMD})

add_custom_target(run DEPENDS deploit
#COMMAND sh -c "cat ${device} | sed '/^\\s*$/d'"
COMMAND sh -c "cat ${device}"
VERBATIM
)
endfunction()
1 change: 1 addition & 0 deletions Modules/MicrochipPathSearch.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# (To distribute this file outside of CMake-Microchip,
# substitute the full License text for the above reference.)

cmake_policy(SET CMP0057 NEW)
function(MICROCHIP_PATH_SEARCH outvar target)
set(options)
list(APPEND oneValueArgs CACHE STORE_VERSION)
Expand Down
102 changes: 94 additions & 8 deletions Modules/Platform/MicrochipMCU-C-XC32.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,46 @@
# to provide information specific to the XC32 compiler

include(MicrochipPathSearch)
MICROCHIP_PATH_SEARCH(MICROCHIP_XC32_PATH xc32
CACHE "the path to a Microchip XC32 installation"
STORE_VERSION MICROCHIP_C_COMPILER_VERSION
)

set(_CMAKE_TOOLCHAIN_PREFIX "xc32-")

if(NOT MICROCHIP_XC32_PATH)
MICROCHIP_PATH_SEARCH(MICROCHIP_XC32_PATH xc32
CACHE "the path to a Microchip XC32 installation"
STORE_VERSION MICROCHIP_C_COMPILER_VERSION
)
endif()


function(_xc32_get_version)
execute_process(
COMMAND "${CMAKE_C_COMPILER}" "--version"
OUTPUT_VARIABLE output
ERROR_VARIABLE output
RESULT_VARIABLE result
)

if(result)
message(FATAL_ERROR
"Calling '${CMAKE_C_COMPILER} --version' failed."
)
endif()

if(output MATCHES "([0-9]+(\.[0-9]+)+).* MPLAB XC32 Compiler .*v([0-9]+(\.[0-9]+)+)")
set(gnu_version ${CMAKE_MATCH_1})
set(xc32_version ${CMAKE_MATCH_3})
else()
message(FATAL_ERROR
"Failed to parse output of '${CMAKE_C_COMPILER} --version'."
)
endif()

string(REPLACE "_" "." gnu_version ${gnu_version})
string(REPLACE "_" "." xc32_version ${xc32_version})

set(CMAKE_C_COMPILER_VERSION ${gnu_version} PARENT_SCOPE)
set(MICROCHIP_C_COMPILER_VERSION ${xc32_version} PARENT_SCOPE)
endfunction()

if(NOT MICROCHIP_XC32_PATH)
message(FATAL_ERROR
Expand All @@ -30,12 +66,62 @@ endif()

set(CMAKE_FIND_ROOT_PATH ${MICROCHIP_XC32_PATH})

set(CMAKE_C_COMPILER xc32-gcc)
find_program(CMAKE_ASM_COMPILER "xc32-gcc")
find_program(CMAKE_C_COMPILER "xc32-gcc")
find_program(CMAKE_CXX_COMPILER "xc32-g++")

set(MICROCHIP_C_COMPILER_ID XC32)

add_compile_options(
"-mprocessor=${MICROCHIP_MCU_MODEL}"
set(CMAKE_C_STANDARD_COMPUTED_DEFAULT 90)
set(CMAKE_CXX_COMPILER_FORCED ON)

if(MICROCHIP_MCU_FAMILY STREQUAL "PIC32MX")
set(lib_directory pic32mx)
else()
set(lib_directory pic32-libs)
endif()
include_directories(SYSTEM ${MICROCHIP_XC32_PATH}/${lib_directory}/include)

set(link_flags "")
set(compile_flags "")

list(APPEND compile_flags
"-mprocessor=${MICROCHIP_MCU_MODEL}"
)
string(APPEND link_flags
" -mprocessor=${MICROCHIP_MCU_MODEL}"
)
if(MICROCHIP_LINK_SCRIPT OR MICROCHIP_MIN_HEAP_SIZE)
string(APPEND link_flags
" -Wl"
)
if(MICROCHIP_LINK_SCRIPT)
string(APPEND link_flags
",--script=\"${MICROCHIP_LINK_SCRIPT}\""
)
endif()
if(MICROCHIP_MIN_HEAP_SIZE)
string(APPEND link_flags
",--defsym=_min_heap_size=${MICROCHIP_MIN_HEAP_SIZE}"
)
endif()
if(MICROCHIP_MAP_FILE)
string(APPEND link_flags
",-Map=\"${MICROCHIP_MAP_FILE}\""
)
set_property(DIRECTORY APPEND
PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
"${MICROCHIP_MAP_FILE}"
)
endif()
endif()
string(APPEND CMAKE_C_LINK_FLAGS
" -mprocessor=${MICROCHIP_MCU_MODEL}"
${link_flags}
)
add_compile_options(
${compile_flags}
)

if(CMAKE_C_COMPILER)
_xc32_get_version()
endif()
46 changes: 46 additions & 0 deletions Modules/Platform/MicrochipMCU-CXX-XC32.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#=============================================================================
# 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.)

# this module is called by `Platform/MicrochipMCU-CXX`
# to provide information specific to the XC32 compiler

include(MicrochipPathSearch)
if(NOT MICROCHIP_XC32_PATH)
MICROCHIP_PATH_SEARCH(MICROCHIP_XC32_PATH xc32
CACHE "the path to a Microchip XC32 installation"
STORE_VERSION MICROCHIP_CXX_COMPILER_VERSION
)
endif()

if(NOT MICROCHIP_XC32_PATH)
message(FATAL_ERROR
"No Microchip XC32 compiler was found. Please provide the path"
" to an XC32 installation on the command line, for example:\n"
"cmake -DMICROCHIP_XC32_PATH=/opt/microchip/xc32/v1.42 ."
)
endif()

set(CMAKE_FIND_ROOT_PATH ${MICROCHIP_XC32_PATH})

set(OS_SUFFIX "")
if(WIN32)
string(APPEND OS_SUFFIX ".exe")
endif()

set(CMAKE_CXX_COMPILER ${MICROCHIP_XC32_PATH}/bin/xc32-g++${OS_SUFFIX} CACHE STRING "" FORCE)
set(MICROCHIP_CXX_COMPILER_ID XC32)

set(CMAKE_CXX_FLAGS "-mprocessor=${MICROCHIP_MCU_MODEL}" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_DEBUG "-g" CACHE STRING "" FORCE)
set(CMAKE_EXECUTABLE_SUFFIX_CXX ".elf" CACHE STRING "" FORCE)
31 changes: 31 additions & 0 deletions Modules/Platform/MicrochipMCU-CXX.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#=============================================================================
# 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.)

# This module is loaded during the search for a CXX compiler
# to provide the information necessary to find one.

if(CMAKE_SYSTEM_PROCESSOR STREQUAL "PIC_32")
include(Platform/MicrochipMCU-CXX-XC32)
else()
message(FATAL_ERROR
"No CXX compiler for '${CMAKE_SYSTEM_PROCESSOR}'"
" is supported yet."
)
endif()

if(MICROCHIP_CXX_COMPILER_ID)
message(STATUS
"Using Microchip CXX compiler ${MICROCHIP_CXX_COMPILER_ID}"
" ${MICROCHIP_CXX_COMPILER_VERSION}"
)
endif()
18 changes: 18 additions & 0 deletions Modules/Platform/MicrochipMCU-GNU-C.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

# for XC16, inject properties that may have been missed
# see `Platform/MicrochipMCU-C-XC16` for explanation

if(MICROCHIP_C_COMPILER_ID STREQUAL "XC16")
if(NOT CMAKE_C_COMPILE_FEATURES)
set(CMAKE_C_COMPILE_FEATURES "c_function_prototypes;c_restrict;c_variadic_macros")
Expand All @@ -32,3 +33,20 @@ if(MICROCHIP_C_COMPILER_ID STREQUAL "XC16")
set(CMAKE_C_COMPILER_ABI ELF)
endif()
endif()

if(MICROCHIP_C_COMPILER_ID STREQUAL "XC32")
if(NOT CMAKE_C_COMPILE_FEATURES)
set(CMAKE_C_COMPILE_FEATURES "c_function_prototypes;c_restrict;c_variadic_macros")
set(CMAKE_C90_COMPILE_FEATURES "c_function_prototypes")
set(CMAKE_C99_COMPILE_FEATURES "c_restrict;c_variadic_macros")
set(CMAKE_C11_COMPILE_FEATURES "")
endif()

if(NOT CMAKE_C_SIZEOF_DATA_PTR)
set(CMAKE_C_SIZEOF_DATA_PTR 4)
endif()

if(NOT CMAKE_C_COMPILER_ABI)
set(CMAKE_C_COMPILER_ABI ELF)
endif()
endif()
Loading