This is the first part of a multi-part tutorial on setting up a free and functional GNU gcc + Eclipse + debugger environment for use with the Freescale FRDM-KL25Z board.
List of Tutorials
- Part 1: Setting up ARM GNU tool chain
- Part 2: Setting up Eclipse IDE
- Part 3: Setting up the debugger (P&E and Segger)
- Part 4: Setting up Processor Expert
- Part 5: Setting up FreeRTOS Kernel Awareness
- Part 6: Linux Host Support with OpenOCD and CMSIS-DAP
- Part 7: GNU ARM Eclipse Plugins
- Part 8: Processor Expert with GNU ARM Eclipse Plugins
- Part 9: DIY Free Toolchain for Kinetis: Part 9 – Express Setup in 8 Steps
- Part 10 – Project Creation with GNU ARM Eclipse 2.1.1
In this first part, I’m showing how to install the GNU ARM tool chain to build a ‘blinking LED’ application for the FRDM-KL25Z. With 100% free tools😉
There are many tool chains available for ARM cores, where the Freescale Kinetis is just one in the growing ARM ecosystem. Each ARM licensee as STMicrolectronics, NXP and others are providing Eclipse based development tool chains, and Freescale is no exception with CodeWarrior. And beside of this, there are vendors which give either non-Eclipse tool chains (IAR, Keil) or Eclipse based ones (CodeRed (recently acquired by NXP, CodeSourcery (aquired by Mentor Graphics)) and many more. As you see with the acquisitions, there is a lot of movement in the tools market. Acquisitions typically mean that the tool chain will only support the owners processors (see NXP with CodeRed), or that with the acquisition the tool chain greatness slowly fades away?
What CodeRed basically did (and still does) is to grab a standard Eclipse version, adds in GNU build tools and adds their own extensions plus limitations (e.g. debugger code size limits) to sell their package. There is nothing wrong with charging for something like this (even if it has open source tools), because it is a service to pull everything together, test it and make it easy to use. But there is no magic behind this to do this yourself: combine together what is available as open source tools and build up your own ‘do-it-yourself-toolchain’. It does not come for free: it needs time to set it up. And to do this you need some knowledge, and this is maybe that this kind of ‘do-it-yourself’ tool chain is more of a ‘geeky’ thing?
But if you are willing to read this tutorial, and to spend some time with learning and doing your own reasearch, then you have your free open source based tool chain
The other thing is: I can get access to the latest and greatest Eclipse, compiler and debugger versions, and do not have to wait for the silicon vendor to release his customized version.
I’m using a Windows 7 64bit machine with the FRDM-KL25Z board. I hope this tutorial is generic enough so it works for other host platforms.
💡 See the comment from Georg in the comments section below how to do things for Linux/Ubuntu.
ARM Build Tools
To compiler and link my sources, I need a tool chain. I’m using the following:
GNU Tools for ARM Embedded Processors
- Go to https://launchpad.net/gcc-arm-embedded and download the installer. At the time writing this, the latest version is gcc-arm-none-eabi-4_7-2013q2-20130614-win32.exe
- Run the setup/installer. Things are very intuitive. But one important thing: at the end make sure you add the path to the environment variable:
❗ Adding the path to the GNU tools to the environment variable simplifies things a lot. BUT: if you are using multiple GNU based tool chains, this might cause confusion or problems. If so, you still can go into your Windows system settings and change the PATH settings.
To verify proper operation, open a command prompt (Windows+R, then type ‘cmd’) and run the following command
This should report this:
This means that gcc is working properly
The option -v shows the version information. Because I have added the path to the GNU tools in my PATH environment variables, I can execute it from everywhere. It is now a good time to check the PATH variable. For this I enter this in my command prompt
Which shows me what I have in the PATH variable:
❗ You might need to clean up your PATH variable. Be careful with this as this might have an impact on other tools installed.
The next step is to install ‘make’. With make I can run make files to build my application. Make is used as well in Eclipse (see this post) which is subject of another part of this tutorial.
- Go http://gnuwin32.sourceforge.net/packages/make.htm
- We download *not* the setup, but the zip file. Because of this, we need two parts: the ‘Binaries‘ and the ‘Dependencies‘. They are located in the Download section if you scroll down on above page:
- In the make-xxx-bin.zip, locate the make.exe in the bin folder. Copy that file into the same directory where you have installed the GNU gcc binaries (which is “C:\Program Files (x86)\GNU Tools ARM Embedded\4.7 2013q2\bin” for me). Copying the make to that folder ensure that we can call it from everywhere, as this path is part of the PATH environment variable.
- Do the same for the libiconv2.dll and libintl3.dll inside the make-xxx-dep.zip. These DLL’s are required by the make.exe. Place them as the make.exe into the bin folder of the ARM gcc tools.
To test if make is properly installed, run
on the command prompt. This should report the make version number:
This means that the make utility is working too
Building with Make
The next step is make and build a simple application which toggles the red LED on the FRDM-KL25Z board.
The first step is to create a ‘workspace’ for a project, e.g. in “c:\projects\workspace”. I have prepared a simple project for the KL25Z toggling an LED here.
💡 That project is on GitHub here.
Download the .zip file and extract it into your workspace folder.
Open a command prompt and CD to the workspace directory you have created, into the project folder so you are on the same level than the makefile.
Here I execute the
command. This will build the application:
Downloading the Application
Another way to try the application: I can use the MSD Bootloader (see this post). To load the MSD bootloader:
- Press the Reset button on the board while powering it up
- Copy the MSD-FRDM-KL25Z_Pemicro_v10.9.SDA to the device
- Re-Power the board
Then you can copy the generated .hex (S19) file to the device. Reset the board, and you should see the red RGB LED blinking.
Make Clean Command
To clean up the generated files, use the
Congratulations! You just built your first program for the FRDM-KL25Z with open source build tools.
Using the ARM GNU gcc tool chain is not hard at all. All what I need is the ARM tool chain plus the make utility. Then I can build my application using make files. Writing make files is not subject of this tutorial: you can find plenty of tutorials and examples if you search the web. As a starting point you can use the make file used in this tutorial.
To edit the source files, you can use any editor, including Notepad. In the next tutorial I’ll show how to use a standard version of Eclipse: Part 2: Setting up Eclipse IDE
Happy Making it Do-It-Yourself