Importing projects from CooCox CoIDE to Visual Studio

This tutorial shows how to import an embedded project from Eclipse-based CooCox CoIDE to Visual Studio, build and debug it with VisualGDB. We will import a project created for the STM32F4Discovery board and show how to setup build and use the peripheral driver libraries provided by ST.

  1. Create a project with CooCox CoIDE, add references to the GPIO module and put the following code into the main source file:

  2. Run the “tree /f” command from the project directory to get an overview of the source files included in the project:01a-treeThe most important about the file layout is that the header files are located in cmsis, cmsis_boot and cmsis_lib/include subdirectories. We will need to specify this later when we get the project to build under Visual Studio.
  3. Launch Visual Studio and start the VisualGDB Embedded Project Wizard: 02-embwiz
  4. Select “Import a project built with command-line tools -> Generate a Makefile”:03-import
  5. Select your ARM toolchain and pick the device from the list:04-device
  6. Specify the directory with your CoIDE project so that VisualGDB can import files from it:05-dir
  7. Select OpenOCD as the debug method. If your Discovery board is plugged in, VisualGDB will detect it automatically. Otherwise, select the programming interface from the list or press “Detect” to try detecting it again:06-ocd
  8. Press Finish to create the project. By default it will use the new STM32 HAL library. As the CoIDE projects include the files from the ST libraries, this would cause a conflict. To avoid it, open VisualGDB Project Properties, go to the Embedded Frameworks page and remove references to all frameworks:07-refs
  9. Go to the Makefile settings page and specify the relative paths to the directories containing .h files in the Include Directories field:08-includes
  10. Remove the startup file used by VisualGDB as the CoIDE includes its own startup file:09-startup
  11. Try building your project. If VisualGDB shows errors related to the assert function, edit the stm32f4xx.h to include the stm32f4xx_conf.h file:include
  12. Press F10 to step into the main() function:10-bkptOnce the debugging starts, you can step through the function or press F5 to resume debugging.
  13. Once you verify that the program works as expected, stop debugging by pressing Shift-F5. Now we will remove the files that CoIDE copied from the STM32 libraries and replace them with references to the VisualGDB STM32 library. This will ensure that the files will be stored in one central location shared between the projects and that updating them to newer versions automatically affects all related projects. First, remove the files from the cmsis, cmsis_boot and cmsis_lib subdirectories:11-removestartup
  14. Then add a reference to the Legacy Peripheral Library framework via VisualGDB Project Properties:12-system
  15. Finally, clear the Include Directories field on the Makefile Settings page:13-incl
  16. Now you can build your project again. Instead of the files copied by CoIDE, it will use the shared files provided by VisualGDB:14-periph
  17. Press F10 to step into it and then hit F5 to continue debugging and validate that it is working as before:15-main
  18. You can also delete the files in cmsis, cmsis_boot and cmsis_lib directories from the disk, as they do not participate in build anymore:delfiles