Conversation
hw/bsp/family_support.cmake
Outdated
|
|
||
| file(GENERATE | ||
| OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.jlink | ||
| OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${TARGET}.jlink |
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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
| 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.
need to change as well, though please try the new $<TARGET_FILE_DIR:${TARGET}>
Describe the PR
size.exeoptional