-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
IAR CMake native support #2376
IAR CMake native support #2376
Conversation
hw/bsp/family_support.cmake
Outdated
@@ -367,7 +373,7 @@ function(family_flash_jlink TARGET) | |||
endif () | |||
|
|||
file(GENERATE | |||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.jlink | |||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${TARGET}.jlink |
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.
does IAR has 1 config per folder within the build dir. Normally clion has 1 build dir per config. If possible, change it to {TARGET}_$<CONFIG>.jlink
would be better.
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.
Yes each binary has it's own folder.
$ ls
audio_4_channel_mic_Debug.jlink build.ninja build-RelWithDebInfo.ninja CMakeFiles/ RelWithDebInfo/
audio_4_channel_mic_Release.jlink build-Debug.ninja cmake_install.cmake Debug/ tinyusb/
audio_4_channel_mic_RelWithDebInfo.jlink build-Release.ninja CMakeCache.txt Release/
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 see, for clion, I typically use one build dir per config.
$ ls
audio_test.elf audio_test.elf.map audio_test.jlink CMakeFiles cmake_install.cmake tinyusb
I think maybe we can use $<TARGET_FILE_DIR:${TARGET}>
instead of of ${CMAKE_CURRENT_BINARY_DIR}
for the flash target as below, please try to see if that work for you. It should expand to parent folder of the exe file (within each config for IAR)
function(family_flash_jlink TARGET)
if (NOT DEFINED JLINKEXE)
set(JLINKEXE JLinkExe)
endif ()
file(GENERATE
OUTPUT $<TARGET_FILE_DIR:${TARGET}>/${TARGET}.jlink
CONTENT "halt
loadfile $<TARGET_FILE:${TARGET}>
r
go
exit"
)
add_custom_target(${TARGET}-jlink
DEPENDS ${TARGET}
COMMAND ${JLINKEXE} -device ${JLINK_DEVICE} -if swd -JTAGConf -1,-1 -speed auto -CommandFile $<TARGET_FILE_DIR:${TARGET}>/${TARGET}.jlink
)
endfunction()
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.
It gives something like this:
.
├── build.ninja
├── build-Debug.ninja
├── build-Release.ninja
├── build-RelWithDebInfo.ninja
├── cmake_install.cmake
├── CMakeCache.txt
├── CMakeFiles
│ └──...
├── Debug
│ ├── audio_4_channel_mic.elf
│ ├── audio_4_channel_mic.elf.map
│ ├── audio_4_channel_mic.jlink
│ └── libboard_stm32f439nucleo.a
├── Release
│ ├── audio_4_channel_mic.elf
│ ├── audio_4_channel_mic.elf.map
│ ├── audio_4_channel_mic.jlink
│ └── libboard_stm32f439nucleo.a
├── RelWithDebInfo
│ ├── audio_4_channel_mic.elf
│ ├── audio_4_channel_mic.elf.map
│ ├── audio_4_channel_mic.jlink
│ └── libboard_stm32f439nucleo.a
└── tinyusb
├── cmake_install.cmake
├── CMakeFiles
│ └──...
├── Debug
│ └── libaudio_4_channel_mic-tinyusb.a
├── Release
│ └── libaudio_4_channel_mic-tinyusb.a
└── RelWithDebInfo
└── libaudio_4_channel_mic-tinyusb.a
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.
perfect, it is what we want the .jlink file in the same folder of the elf for both IAR Workbecnh and clion. Not sure if IAR can execute the -jlink target, if it does, it should be able to flash your board with correct elf.
Please push the update, it is all good now.
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.
Done.
Currently CMake support is pretty primitive, it defaults to Ninja multi config generator and there is no option for pre/post build actions. And I had multiple crashes modifying CMake file.
I'm going to give them some feedbacks.
hw/bsp/family_support.cmake
Outdated
@@ -377,7 +383,7 @@ exit" | |||
|
|||
add_custom_target(${TARGET}-jlink | |||
DEPENDS ${TARGET} | |||
COMMAND ${JLINKEXE} -device ${JLINK_DEVICE} -if swd -JTAGConf -1,-1 -speed auto -CommandFile ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.jlink | |||
COMMAND ${JLINKEXE} -device ${JLINK_DEVICE} -if swd -JTAGConf -1,-1 -speed auto -CommandFile ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${TARGET}.jlink |
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.
need to change as well, though please try the new $<TARGET_FILE_DIR:${TARGET}>
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.
perfect, thank you
Describe the PR
size.exe
optional