-
Notifications
You must be signed in to change notification settings - Fork 63
Add support for Microchip XC32 toolchain in the CMSIS toolbox #2310
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: main
Are you sure you want to change the base?
Changes from all commits
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,133 @@ | ||||||||||||||||||||||
| # This file maps the CMSIS project options to toolchain settings. | ||||||||||||||||||||||
| # | ||||||||||||||||||||||
| # - Applies to toolchain: Microchip XC32 Compiler version 5.0.0 and greater | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| set(AS "xc32-gcc") | ||||||||||||||||||||||
| set(CC "xc32-gcc") | ||||||||||||||||||||||
| set(CPP "xc32-gcc") | ||||||||||||||||||||||
| set(CXX "xc32-g++") | ||||||||||||||||||||||
| set(OC "xc32-objcopy") | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| set(TOOLCHAIN_ROOT "${REGISTERED_TOOLCHAIN_ROOT}") | ||||||||||||||||||||||
| set(TOOLCHAIN_VERSION "${REGISTERED_TOOLCHAIN_VERSION}") | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if(DEFINED TOOLCHAIN_ROOT) | ||||||||||||||||||||||
| set(PREFIX) | ||||||||||||||||||||||
| set(EXT) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| set(AS ${TOOLCHAIN_ROOT}/${PREFIX}${AS}${EXT}) | ||||||||||||||||||||||
| set(CC ${TOOLCHAIN_ROOT}/${PREFIX}${CC}${EXT}) | ||||||||||||||||||||||
| set(CPP ${TOOLCHAIN_ROOT}/${PREFIX}${CPP}${EXT}) | ||||||||||||||||||||||
| set(CXX ${TOOLCHAIN_ROOT}/${PREFIX}${CXX}${EXT}) | ||||||||||||||||||||||
| set(OC ${TOOLCHAIN_ROOT}/${PREFIX}${OC}${EXT}) | ||||||||||||||||||||||
| endif() | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Environment variables | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if(NOT DEFINED ENV{DEVICE_ID}) | ||||||||||||||||||||||
|
Collaborator
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. How is the environment variable |
||||||||||||||||||||||
| message(FATAL_ERROR "Environment variable DEVICE_ID not defined!") | ||||||||||||||||||||||
| endif() | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if(NOT DEFINED ENV{DFP_PATH}) | ||||||||||||||||||||||
| message(FATAL_ERROR "Environment variable DFP_PATH not defined!") | ||||||||||||||||||||||
|
Comment on lines
+28
to
+32
|
||||||||||||||||||||||
| message(FATAL_ERROR "Environment variable DEVICE_ID not defined!") | |
| endif() | |
| if(NOT DEFINED ENV{DFP_PATH}) | |
| message(FATAL_ERROR "Environment variable DFP_PATH not defined!") | |
| message(FATAL_ERROR "Environment variable DEVICE_ID not defined. Set DEVICE_ID to specify the target Microchip device (e.g., export DEVICE_ID=PIC32MX795F512L).") | |
| endif() | |
| if(NOT DEFINED ENV{DFP_PATH}) | |
| message(FATAL_ERROR "Environment variable DFP_PATH not defined. Set DFP_PATH to the path of the Device Family Pack for the selected device (e.g., export DFP_PATH=/path/to/dfp).") |
Copilot
AI
Dec 15, 2025
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.
The linker script path is constructed without verifying that the file exists. If the path is incorrect or the file is missing, the linker will fail with an unclear error. Add a check using if(NOT EXISTS "${LINKER_SCRIPT}") and provide a clear error message before attempting to use it in CMAKE_EXE_LINKER_FLAGS.
| set(LINKER_SCRIPT "${DFP_PATH}/xc32/${DEVICE_ID}/${DEVICE_ID}.ld") | |
| set(LINKER_SCRIPT "${DFP_PATH}/xc32/${DEVICE_ID}/${DEVICE_ID}.ld") | |
| if(NOT EXISTS "${LINKER_SCRIPT}") | |
| message(FATAL_ERROR "Linker script not found: ${LINKER_SCRIPT}. Please check that DFP_PATH and DEVICE_ID are set correctly and the linker script exists.") | |
| endif() |
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.
Referencing a file from a read-only location as the linker script sounds unconventional.
All files coming from a DFP should be handled via packs, including device header files and start-up components, for proper semantic versioning and componentization.
It shouldn't be necessary things like DFP_PATH and LINKER_SCRIPT here.
In addition I would strongly recommend to add a default linker script gcc_xc_linker_script.ld.src into the templates folder.
More info:
https://open-cmsis-pack.github.io/cmsis-toolbox/YML-Input-Format/#linker
https://open-cmsis-pack.github.io/cmsis-toolbox/CreateApplications/#configure-linker-scripts
Copilot
AI
Dec 15, 2025
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.
Corrected spelling of 'unkown' to 'unknown'.
| message(FATAL_ERROR "unkown '${_option}' value '${value}' !") | |
| message(FATAL_ERROR "unknown '${_option}' value '${value}' !") |
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.
Being XC32 a GCC variant and following the suggested name convention #1887 (comment)
<common compiler name>_<variant id>, in this case I would propose to name itGCC_XCorGCC_XC32.Uh oh!
There was an error while loading. Please reload this page.
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.
The Microchip XC32 compiler is already in PACK.xsd since 2020 as
XC.Though, it may be rarely used in
Tcompilerconditions for compiler dependent components, such as RTX5 or CMSIS-Compiler.