Sunday, June 26, 2011

STM32F GCC IDE on Windows(1)

You can easily build a GCC IDE for Cortex-M3 using a open source IDE.  If you are not a big fan of Eclipse like me, you will probably like CodeLite or Geany. Both programs are cross platform, open source, and light-weight. Geany is more minimalistic of two. If you are familiar with Visual Studio, you will find CodeLite is more comfortable.

I'm going to use the following programs:


GCC and Make
For the CSG++ Lite, be sure to download the installer version(EABI). Install is straight forward. You don't have to change any settings. After install, you should add the following directory to your PATH.

> C:\Program Files\CodeSourcery\Sourcery G++ Lite\bin

You can verify that your PATH is set up correctly by running

> arm-none-eabi-gcc -v

on your console window.
Other than the compiler collection, you may need at least GNU make utility. You can install Cygwin for the make utility. But the simplest way is using GnuWin32. Download and install the GnuWin32 make package. You also have to add its bin directory to you PATH. You can install as many GnuWin32 packages as you need.

> C:\Program Files\GnuWin32\bin

STM32F Library and CodeLite Project
Download the library(stm32f10x_stdperiph_lib.zip) and extract it on your work directory. Then install CodeLite and fire it up to create initial workspace and project. For convenience, create a Codelite workspace under the STM32F library directory. (Workspace->New Workspace)


By selecting the workspace name and path as shown and deselecting the "Create the workspace under a separate directory" check box, you can use the STM32F library project directory as your workspace. But it is only for convenience sake. You can choose your workspace anywhere you like.

Now create a new project.(Workspace->New Project)


For the Categories, choose "Others" then you can select "Custom Makefile" type for the template. Type in your project name. And select compiler type. Compiler type here is not important because you will use your own build and compile command strings. Resulting directory structure would be



For now, there is no file under GpioTest directory except the CodeLite project file.

After the  project creation, go to the project settings by right click on the project "GpioTest" and select the last menu item.


Go to "Customize" on the left, then check "Enable custom build". You want  change "Working Directory" from $(WorkspacePath) to $(ProjectPath) where you have your own Makefile. Now fill in the Build Command with "make" and the Clean Command with "make clean". In this way, you can use your Makefile to build your project instead of CodeLite's own makefile.

1 comment:

  1. Hi thanks fot that !
    Very clear !

    I'd need to rebuild some code written for STM32F103 to STM32F107.

    I see nowhere how to change the target in my codelite, nor in my source code nor in my makefile.

    Any Idea ?

    Pit

    ReplyDelete