Using IAR ARM Compiler with Visual Studio and VisualGDB

This tutorial shows how to configure VisualGDB to use the IAR ARM compiler instead of the GCC compiler. We will create a basic project from scratch and will show how to configure various parameters of it. For detailed instructions on importing existing projects, follow our IAR project importing tutorial instead.

Before you begin, install VisualGDB 5.5 or later.

  1. Start Visual Studio and open the VisualGDB Embedded Project Wizard:
  2. Specify the location and name for the created project:
  3. On the first page proceed with the default “Create a new project -> Embedded Binary -> MSBuild” option:VisualGDB can also create GNU Make-based projects using the IAR compiler, however we recommend using MSBuild due to better performance and deeper integration into Visual Studio.
  4. On the next page select the IAR toolchain from the list. VisualGDB will automatically scan it for supported devices and allow simply choosing one from list. Select your device and press “Next” to go to the next page of the wizard:
  5. If the IAR compiler is not found, locate and open the <VisualGDB Directory>\Rules\KnownToolchains.xml file. It contains the rules used by VisualGDB to locate the toolchains. E.g. for IAR the following rules will be used:
    	  <PathDetectionKey>SOFTWARE\IAR Systems\Embedded Workbench\*\EWARM\InstallPath</PathDetectionKey>

    Then verify that your registry contains the path of the IAR compiler as shown below:If you are using a custom build of IAR that has a different registry path, simply contact our support with more details and we will update the rule file shipped with VisualGDB to locate it as well.

  6. As the IAR compiler itself does not provide any project samples, the sample selection page of the wizard will be empty. Simply click “Next” to go to the final page:
  7. Connect your JTAG/SWD debugger to your computer and ensure VisualGDB detects it. Then, click “Finish” to complete the wizard and generate the project:
  8. As the created project is initially empty, building it will result in an error:
  9. Use the Add->New Item context menu command to add a new source file:
  10. Add the following contents to the newly added file:
    int main()

    The project will now build successfully:

  11. If the linking fails due to the unsupported “–text_out” parameter, you are likely using an older IAR version that does not support it yet. The parameter is controlled by theĀ  Linker -> Output -> Output File Encoding setting under Visual Studio Project Properties:If your IAR compiler does not support it, simply clearing the setting for both configurations will resolve the issue.
  12. Set a breakpoint in main() and press F5 to start debugging the project. VisualGDB will automatically connect to the target, program it and the breakpoint will trigger:
  13. Although IAR produces complex multi-line error messages, VisualGDB can properly recognize them and display the relevant information. E.g. try replacing the code in the main source file with this in order to trigger a template instantiation error:
    template <class _Type>
    class Demo
        void func()
            typename _Type::bad var;
    int main()
        Demo<int> inst;
  14. Try building the project. See how VisualGDB automatically extracts the ‘required from <…>’ line and displays it under the error text:
  15. Right-click on any error and choose “Go to build log”. This will automatically navigate to the corresponding part of the build log, letting you see even more details:
  16. Right-click on the project in Solution Explorer and select “Properties”. This will open the regular Visual Studio property page window for the project. Note how VisualGDB automatically translated IAR-specific parameters to easily editable MSBuild settings:You can set various properties for any subsets of projects, files or configurations, just like for regular Visual C++-based projects.

Now that you got a basic project to build and debug, you can import your existing IAR projects into VisualGDB by following this tutorial. Ensure you select the IAR compiler in the wizard while importing the project, as otherwise VisualGDB will use the GCC compiler instead of IAR.