Monday, October 29, 2012

Prepare GNUARM compiler toolchain for Windows

Copied verbatim from http://winarm.scienceprog.com/winarm-tools/prepare-gnuarm-compiler-toolchain-for-windows.html

Look at the date. I'll update and modify this posting when/if I get around to it.

Prepare GNUARM compiler toolchain for Windows

GNUARM is a toolchain for developing ARM microcontroller projects based on open source compiler GCC.
GNUARM logo
GNUARM works on windows (requires Cygwin), Linux and MacOS. GNUARM doesn't have any GUI, but you can adapt any GUI that supports commands from command line. One of good project is WinARM where you get all tools needed in one package. Thiswill be discussed later.
GNUARM package consists of the GNU binutils, GCC compiler set and debugger (Insight for Windows and Linux, GDB only for MacOS). Newlib is used for the C library. With GNUARM yo uhave ability compile C and C++ programs.
Let's set up toolchain for windows environment. First of all download compiled toolset fromhttp://www.gnuarm.com:
Download the newest GNUARM stabile compilation:
Then start installation:
  • Start window:
Gnuarm start install 
  • Accept license agreement:
Gnuarm license 
  • Select folder where do you want GNUARM to be installed. I recommend to select C:/GNUARM:
Gnu arm install location 
  •  Select the components. You can select all of them:
Gnuarm components 
  • Chose Start menu folder name:
Start menu of Gnuarm 
  • Select desktop shortcut to be placed. I highly recommend to check Cygwin DLL:
Gnuarm installation tasks
  • And press install..
  • Select checkbox in order to create system variable: PATH=c:\gnuarm\bin:
Gnuarm PAHT 
After we have GNUARM installed, download binutils from http://optimize.ath.cx/ARM7/src/utils.zip. Download this archive and unpack all contents to c:\gnuarm\bin folder. Also You can downloadhttp://optimize.ath.cx/ARM7/src/cygncurses-8.dll and put it in c:\gnuarm\bin folder if there is no any. Now we are ready to start building projects.
Lets try some test compilation. Just example download LPC2214 project package fromhttp://optimize.ath.cx/ARM7/src/lpc2214_blink.zip and extract in any folder. In the package you’ll find following files:
  • lpc2214.h LPC2214 header. You can also download header files from www.gnuarm.com
  • blink.c LED blink example routine.
  • boot.s The startup routine which is first executed after the CPU is reset. After it main function is called.
  • Makfile makefile
  • lpc2214-rom.ld The script file which used by linker. The start address size and the ROM/RAM is described. If there is needed - ROM binary is built.
  • setenv.cmd Configuration file, where you have to show path to C:\GNUARM\bin and bin C:\GNUARM\bin\utils
  • jtag_flash.exe The tool, which writes the flash by JTAG and executes on demand.
  • jtag_stub.exe The JTAG debugger for GDB/Insight.
Because setenv.cmd is used to show path to C: when GCC is installed in different location, you have to edit it. If you left default settings, then don’t edit this file.
Lets try to compile this program. Start DOS console window (Start->Run and type CMD):
Lets compile project to hex file. Leave make file not edited as it is ready for this. So I will have to use commands: make and once again make hex.
making ARM project with GNUARM 
That’s it hex is built and placed in project directory. It can be uploaded ARM MCU.
Here is a table with most common make commands:
Command Target (function)
  • Make Compiling, linking and forming the elf file;
  • Make clean Clearing compiled o, lst, elf, hex and bin files;
  • Make hex forming the hex file;
  • Make bin forming Bin file;
  • Make lst Listing (assembling) file formation;
  • Make run Compiling, linking and it writing in to the flash after this execution starts;
  • Make debug Compiling, linking and writing in to the flash after building start Insight/GDB.
So if you already have programmer adapter connected, you can flash you ARM microcontroller with only one command - make run.

Saturday, October 13, 2012

Flashing an ARM7 Board with USB-to-Serial Converter


A simple flashing method for UNO32 (data dump via UART0)

This document will show you how to use the UART0 of the UNO32 to perform some simple flashing.
As the UART0 is used for ISP download at NXP chip, UART0 will reserved for those application that don't need two UART and don't need all GPIO.

Setup

At UNO32 development, your development PC will connect to UNO32 via the on-board USB to Serial adapter at most time, to download your code to UNO32. So, the idea is we use this already connected channel to dump some information to help us to debug our program. Below is the block diagram.
Connection
The USB connection will form a virtual Serial port at the PC, the actual UART signal is connected to the MCU's ISP port. To perform ISP, there are four signals used.
1) TXD (PC to MCU, for data transfer)
2) RXD (MCU to PC, for data transfer)
3) DTR (PC to MCU, to reset MCU)
4) RTS (PC to MCU, connected to ISP pin)
When programming MCU, the FlashMagic will control the DTR and RTS to make the MCU enter ISP mode. Then use TXD/RXD to transfer data.
If we want to use this Serial port, we need to make the correct state on DTR and RTS. Otherwise, the MCU cannot enter your code correctly.
Basically, any PC serial terminal program that has a function for you to control DTR/RTS can do the job. For myself, I use Termite to do it. So, I just show you how to config Termite here.
TermiteConfig
At the port config, select the port of the Virtual Serial port created by UNO32. The rest is show above (115200 N81). Then, at the Plug-ins, enable the Status LEDs. This will make Termite display all line status as a LEDs, and you can control RTS/DTR by click their LED.
Click [OK] to leave the port setting, you will connected to UNO32 and see those LEDs. To make the UNO32 not enter ISP, you need to turn off RTS all the time. For DTR, turn it on will reset the MCU. So, I will turn the DTR on, then off once to reset UNO32 to enter my code. When I need to download a new code, click the top-left button to release the Serial port. After download, click it again to get the port.
Termite
Here is the procedures
1) Use FlashMagic to download you code.
2) Use Termite get the serial port. Then reset the UNO32 via the DTR LED and test my code.
3) Modify my code and genertate a new HEX.
4) Release port at Termite.
5) Repeat step 1 until my code work.


Reference: