How do I add an MCU target to an imported CMake project?
I've inherited an existing project. It's got STM HAL / auto-generated code. It's set up with CMake to be compiled at the command line. I've imported it into STM32CubeIDE and it builds.
I have an STM32F407G-DISC1 board (MB997D). Using a hack, I've managed to get my .elf loading onto the discovery board and running, but it's a hack (and the paths to source code are obviously incorrect, so debugging doesn't bring up source code files).
Here's the hack:
- build a new project for the discovery board from scratch, or, import the STM32F4-DISC demo project
- create a run/debug configuration for this project, verify that source-level debugging works (STM32 Cortex-M C/C++ Application type)
- go to Debug Configurations... => right click on the working debug configuration => Duplicate => give the duplicated configuration a new name
- In the duplicated debug configuration, change the C/C++ Application from the .elf of the working project to the .elf of the inherited project
- Change nothing else!
- Apply => Debug
This successfully loads my project's .elf onto the discovery board and it appears to run, verified via halting the running code every so often and it claims it's in routines from my project that don't exist in the working project the debug configuration was duplicated from.
This is progress; previously I wasn't able to get debugging working at all. In that question (I was using a different development board but I don't think that changes anything) @Pavel A. suggests "transplanting the target MCU info from a working project".
How do I do that?
I haven't found anything in STM32CubeIDE's (v1.4.2) UI that allows me to add a target MCU to my CMake imported project.
I see in the .cproject file of the working project some XML relating to the STM32F407 MCU as a target. I could cut and paste that directly, but I'm not sure which parts of the XML are relevant and I can't find any documentation about it.
Corollary question:
Shouldn't the CMake generate the target MCU information in the .cproject?
I wasn't able to find anything on that, although that would probably be STM32CubeIDE-specific and not part of the general Eclipse CDT 4 generator.
