(Procedure)
 
(12 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[category: ARM Tutorials]]
+
[[category: LPC1768 Tutorials]]
[[User:Vaibhav Katkar|Vaibhav Katkar]] ([[User talk:Vaibhav Katkar|talk]]) 15:20, 4 December 2015 (IST)
+
In this tutorial we will see how to setup ARM GCC Tool Chain to generate .hex and .bin file for LPC1768.<br>
----
+
To start with you will require ARM GCC, winAvr and make utility, download all the software's from following links.<br><br>
=Introduction=
+
 
In this tutorial we will compile a project on LPC 1768 through command line using ARM GCC and make utility. The best part of it is we don't need any IDE to compile the program, a simple makefile will do job for you. To start with you will require ARM GCC and make utility, download both from following links.
+
 
 
=Downloads=
 
=Downloads=
[https://launchpad.net/gcc-arm-embedded ARM GCC]
+
[https://launchpad.net/gcc-arm-embedded ARM GCC]<br>
 +
[https://sourceforge.net/projects/winavr/files/ WinAvr]<br>
 +
[http://gnuwin32.sourceforge.net/packages/make.htm Make Utility]<br>
 +
[https://codeload.github.com/ExploreEmbedded/LedBlinkingWithArmGcc/zip/master Led Blinking Project]<br><br><br>
 +
 
 +
=Installing ARM GCC=
 +
Once ARM GCC is downloaded install it on your machine. At the End of the installation do select the option '''Add path to environment variable''' as shown below.
 +
[[File:ARM_GCC_01.PNG]]
 +
 
 +
 
 +
 
 +
To test the ARM GCC open the command line and use command <b>arm-none-eabi-gcc --version</b>, which will give the version information as shown below.
 +
[[File:ARM GCC 00.PNG]]
 +
<br><br><br><br>
  
[http://gnuwin32.sourceforge.net/packages/make.htm Make Utility]
+
=Installing WinAvr=
 +
Run the winavr installer and follow the steps to set the default configuration.
 +
<br><br><br><br>
  
=Setting Environment=
+
=Installing Make Utility=
#Once ARM GCC is downloaded install it on your machine. While installing do select the option '''Add path to environment variable''' as shown below
+
Finally install the make utility. Make utility will not update the path variables and it needs to be done manually.<br>
 +
Add the Make Utility path to the environment path.
  
[[File:GCC1.PNG|x480px|center]]
+
Now type the command <b>make -v</b> to verify the path. <br>
 +
Output of the command should be the version number of make file as shown in below image.
 +
[[File:ARM GCC 02.PNG]]
 +
<br><br><br>
  
#To test the ARM GCC open the command line and use command '''arm-none-eabi-gcc -v''', which will give the version information.
+
=Compilation=
#After installing ARM GCC install make utility by following the instructions
+
We will compile a simple Led Blinking program for LPC1768 using ARM GCC using following procedure<br>
 +
There are different ways to access your files depending on the makefile. We can write makefile as per folder structure.<br>
 +
To keep things simple we will be storing all the files in the same folder as shown in below image.
 +
[[File:ARM GCC 03.PNG]]
 +
Along with the source files we need core files<b>core_cm3.c, core_cm3.h, core_cm3.o,system_LPC17xx.c, system_LPC17xx.h, lpc17xx.h and startup_LPC17xx.c </b>.<br>
 +
Finally we need a linker file for setting up the RAM, ROM size and start address.<br>
 +
You can get all these files from [https://codeload.github.com/ExploreEmbedded/LedBlinkingWithArmGcc/zip/master Github]
  
==Procedure==
 
We will compile a simple Led Blinking program for LPC 1768 using ARM GCC using following procedure
 
#There are different ways to access your files depending on the makefile. We can write makefile as per our folder structure and where we are storing different files. As per the makefile we are using make one folder in your local directory where you will store all your source and header files
 
#Along with the makefile, main and all other library files, keep all following files in this folder
 
          Core Support: core_cm3.c, core_cm3.h, core_cm3.o
 
  
          Device Support: system_LPC17xx.c, system_LPC17xx.h, lpc17xx.h
 
  
          Startup file: startup_LPC17xx.c
+
After that open command line in your project directory and compile program by using <b>make Clean</b> followed by <b>make all</b> command as shown below.<br>
 +
[[File:ARM GCC 05.PNG]]<br><br>
  
          Linker Script: LPC17xx.ld
+
In case you are getting the below error <b>child 2300(0x14C) died before initialization with status code 0xC0000142</b>, then replace the <b>msys-1.0.dll</b> file from the folder C:\WinAVR-20100110\utils\bin with this
#You can get all these files from [https://github.com/ExploreEmbedded/Explore-Cortex-M3-LPC1768-DVB-14001/tree/master/Code/ARM_GCC/Led_Blinking_GCC Github]
+
[http://www.madwizard.org/download/electronics/msys-1.0-vista64.zip msys-1.0.dll] file.
 +
[[File:ARM GCC 04.PNG]]<br><br>
  
 +
Try compiling again and this time it should be successfully compiled.
 +
[[File:ARM GCC 05.PNG]]
  
#After that open command line in your local directoty and compile program by using '''make all''' command
 
  
[[File:GCC2.PNG|x480px|center]]
+
After successful compilation, <b>.hex</b> and <b>.bin</b> files will be generated in the same project directory.
 +
[[File:ARM GCC 06.PNG]]<br><br>
  
#After compilation is over hex and bin file gets generated which can be flashed to our LPC 1768 board directly.
+
=Linker Setting=
 +
Start address of the application can be changed in the linker file as shown in the below image.
 +
#In case your are using the <b>.hex</b> with flash magic then the start address should be 0x0000.
 +
#For using the <b>.bin</b> file with  Secondary bootloader, the start address should be 0x2000.
 +
[[File:ARM GCC 07.PNG]]
  
 
{{DISQUS}}
 
{{DISQUS}}

Latest revision as of 11:50, 4 July 2016

In this tutorial we will see how to setup ARM GCC Tool Chain to generate .hex and .bin file for LPC1768.
To start with you will require ARM GCC, winAvr and make utility, download all the software's from following links.


Downloads

ARM GCC
WinAvr
Make Utility
Led Blinking Project


Installing ARM GCC

Once ARM GCC is downloaded install it on your machine. At the End of the installation do select the option Add path to environment variable as shown below. ARM GCC 01.PNG


To test the ARM GCC open the command line and use command arm-none-eabi-gcc --version, which will give the version information as shown below. ARM GCC 00.PNG



Installing WinAvr

Run the winavr installer and follow the steps to set the default configuration.



Installing Make Utility

Finally install the make utility. Make utility will not update the path variables and it needs to be done manually.
Add the Make Utility path to the environment path.

Now type the command make -v to verify the path.
Output of the command should be the version number of make file as shown in below image. ARM GCC 02.PNG


Compilation

We will compile a simple Led Blinking program for LPC1768 using ARM GCC using following procedure
There are different ways to access your files depending on the makefile. We can write makefile as per folder structure.
To keep things simple we will be storing all the files in the same folder as shown in below image. ARM GCC 03.PNG Along with the source files we need core filescore_cm3.c, core_cm3.h, core_cm3.o,system_LPC17xx.c, system_LPC17xx.h, lpc17xx.h and startup_LPC17xx.c .
Finally we need a linker file for setting up the RAM, ROM size and start address.
You can get all these files from Github


After that open command line in your project directory and compile program by using make Clean followed by make all command as shown below.
ARM GCC 05.PNG

In case you are getting the below error child 2300(0x14C) died before initialization with status code 0xC0000142, then replace the msys-1.0.dll file from the folder C:\WinAVR-20100110\utils\bin with this msys-1.0.dll file. ARM GCC 04.PNG

Try compiling again and this time it should be successfully compiled. ARM GCC 05.PNG


After successful compilation, .hex and .bin files will be generated in the same project directory. ARM GCC 06.PNG

Linker Setting

Start address of the application can be changed in the linker file as shown in the below image.

  1. In case your are using the .hex with flash magic then the start address should be 0x0000.
  2. For using the .bin file with Secondary bootloader, the start address should be 0x2000.

ARM GCC 07.PNG