Setting up a GCC Development Environment for the Cortex M0/M3
Tutorial on installing all everything needed to create a basic GCC build environment in Windows
One of the biggest challenges for many people who wish to develop embedded software with GCC for ARM is simply installing and properly configuring the toolchain, particularly in a non-Linux environment. This tutorial will guide you through the process of setting up an entire open source GCC-based development environment, including the main cross-compiler and toolchain (Yagarto 4.5.0), a graphical development environment (CodeLite), as well as Subversion to be able to download the latest version of the LPC1343 Code Base.
While there are many toolchains and open-source development tools available for ARM, the LPC1343 Code Base has been developped with the tools and software packages listed below. These tools have been selected for their ease of use, and for the minimal amount of effort required to install them in a Windows environment. While these tools are also available for Linux and Mac, the installation process for these operating systems is not covered here.
Install Yagarto 4.5.0 Tools and Toolchain for ARM
Yagarto 4.5.0 provides a complete, easy-to-install, pre-compiled ARM toolchain that supports the new Cortex M0 and M3 cores (as well as ARM7, ARM9, etc.). The latest package available at the time that this tutorial was written was 20100703, with the toolchain based on GCC 4.5.0. It can be downloaded as a 32-bit Windows installer using the link in the table above, and the installer will add the appropriate directories to the Windows "path" environment so that the various gcc binaries (for example, "arm-none-eabi-gcc") can be called from any standard command prompt. The Integrated Development Environment is not required since we will be using a different IDE named CodeLite, which will be installed below.
Yagarto Tools and Toolchain Paths
To avoid any problems with spaces in path names, you should change the destination folder for both Yagarto Tools and Yagarto Toolchain to the directories below:
Yagarto Tools: C:\yagarto\yagarto-tools-20100703
Yagarto Toolchain: C:\yagarto
You can test if the installation was successful by going into the standard Windows command line, and entering the following command, which should show the version and some basic build information on GCC:
Install the CodeLite Open-Source IDE
While you can certainly build your code using only Yagarto and a simple command prompt, it's a far more pleasant process working with an integrated development environment (IDE) like CodeLite. CodeLite will highlight any error messages generated during compilation, allows easy integration with subversion (to be able to work with popular code hosting sites like Google Code), and removes the need to drop down to a command-line every time you want to build your project.
The LPC1343 Code Base includes pre-configured project files for CodeLite, allowing you to get started right away. You can open the appropriate workspace by clicking on the Workspace > Switch to Workspace ... menu item and loading the "LPC1343.workspace" file that is included in the LPC1343 Code Base.
If Yagarto Tools and the Yagarto Toolchain is properly configured (which it should be if you installed using the installer, though you may need to reset for the paths to take effect), you should be able to right-click on the project in the Workspace window and select 'Build' and 'Clean' to automatically build the code, removing the need to go into the command-prompt every time and manually run make. If you have any problems, feel free to consult our tutorials on Using CodeLite with the LPC1343.
Note: If you are unable to build and see and error message relating to make.exe, you may need to go into the Settings > Build Settings menu and under the Build Systems tab change Build Tool to make.exe.
CodeLite has built-in support for Subversion, though you will still need to install the Subversion binaries (see below for more information on this) and download the source code to your computer once from the command prompt. Once the source code has been downloaded locally, though, CodeLite allows you to easily check in and checkout files during the development process, and see which files have been modifed by you since the last checkout.
CodeLite also has a number of useful features such as code completion, an excellent text editor, easy error reporting during the build process, etc., making it a pleasure to work with when developping software. It may not offer the same rich debugging toolset as a commercial GCC-based solution like Rowley Associate's Crossworks for ARM, but it's probably the best open source IDEs we've come across so far, and feels far more modern than most Eclipse-based solutions we've tried. Hopefully, some of the features of CodeLite will be explored in more detail in future tutorials, but you should be able to pick up the basics just by exploring the IDE a bit and examining all the different context menus available ... it's worth the effort of exploring.
For more information
on using CodeLite with the LPC1343 Code Base, have a look at our two part tutorial: Using CodeLite with the LPC1343
. Amongst other things, it explains how to use the USB bootloader on the LPC1343, and how a Segger J-Link for ARM can be used to automatically deploy your compiled code to the board without having to leave the development environment.
(Optional) Install Subversion and the LPC1343 Code Base
Subversion is a widely used source-control package that allows you to download the latest version of your software package from a central repository and collaborate with other developpers during development. The latest development version of the LPC1343 Code Base is available through Google Code, for example, where it is hosted in a publicly accessible Subversion repository.
The easiest way to add command-line support for Subversion in Windows is with a precompiled package, such as the one available in the link at the beginning of this tutorial. This will allow you to run Subversion ("svn") from any command-prompt, and quickly retrieve the source code you wish to use. After installing Subversion, for example, you can retrieve the latest version of the LPC1343 Code Base using the following command, which will create a read-only copy of the LPC1343 Code Base in the folder "lpc1343codebase":
svn checkout http://lpc1343codebase.googlecode.com/svn/trunk/ lpc1343codebase
If you have already installed Yagarto Tools and Toolchain, you can now compile the code from the command-prompt using the following command (make sure that you are in the 'lpc1343codebase' root folder that was created during the checkout process above, which can be entered via "cd lpc1343codebase"):
You can clean up all the temporary files created by the compiler with the following command:
If you don't wish to install Subversion, you can also download an archived version
of the LPC1343 Code Base directly from this website.
Frequently Asked Questions
The GNU GCC compiler provides very good compiled code quality, and has seen a lot of improvements in recent years in code optimisation, etc., making it an excellent choice for developping with ARM. Setting up a working environment can still be a non-trivial process, however, whether on Windows, Linux or another operating system. These FAQs will try to address some the main problems you may face building the LPC1343 Code Base, as shown in the tutorial above.
Why am I getting the following error when I try to build using the makefile: "<PATH>/arm-none-eabi/bin/ld.exe:lpc1xxx/memory.ld:1: syntax error"
In order to keep the makefile as generic as possible (to allow people to easily reuse it in any LPC11xx or LPC13xx project), some linker files are dynamically generating during the build process using the echo statement. Unfortunately, Windows handles the 'echo' command very differently than most other operating systems. Windows will include the outer double-quotes in the output that Linux would use to indicate the contents of the echo, and multi-line support is handled quite differently.
While it will require installing an additional package, the best way to work around this (and a number of other incompatibilities between the Linux and Windows shell) is to install MinGW and MSYS, and add the following directory to your Windows PATH environment variable (which may vary if you installed MSYS in a different location):
This should solve the problems caused by echo, and allow you to build on Windows, Linux or Mac OS X using the same makefile. For details on downloading and installing MinGW and MSYS, as well as adding the directory to your PATH environment variable, please see step one and five the following tutorial: Building a GCC Toolchain from Source