# Forum: ARM programming with GCC/GNU tools Migrating from Keil to GCC

 Author: Trevor J. (trevor_j) Posted on: 2011-01-15 05:32

Rate this post
 0 ▲ useful ▼ not useful
I just recently switched my development environment to Linux and am
wanting to use gcc as my toolchain from now on but have a few questions.

Notably Keil's toolchain is ELF however I see that everyone seems to be
using EABI. I understand the ELF layout but their is not as much info on
EABI. What is the benefits of this new format?

I have used CodeSourcery Lite to compile some test apps and I have also
built my own arm-none-eabi toolchain tailored to my Cortex-M3 and I know
both work but I am wondering for the standard c library does
CodeSourcery install its own support libraries or does it use the system
version of stdint.h? I'm somewhat new to where everything is placed in
the Linux file system. Ideally I would have the entire toolchain in one
self contained directory.

Debugging is a huge difference between Keil's uVision4 and Insight/DDD
or even Eclipse. I am considering writing a plugin to give the same
Peripheral overview as uVision as this is a nice way to check the setup
otherwise you need to probe around in memory and check bit values with a
1000page datasheet.

Does anybody know a walkthrough on setting up Eclipse for CodeSourcery
with debugging and everything?

ITM/ETM, I use ITM extensively thought my programs and uVision4 handled
this automatically with its debug terminal. How do I use this feature
through the command line tools such as GDB/Insignt or even Eclipse?

 Author: Martin Thomas (mthomas) (Moderator) Posted on: 2011-01-15 16:36

Rate this post
 0 ▲ useful ▼ not useful
Trevor J. wrote:
> I just recently switched my development environment to Linux and am
> wanting to use gcc as my toolchain from now on but have a few questions.
>
> Notably Keil's toolchain is ELF however I see that everyone seems to be
> using EABI. I understand the ELF layout but their is not as much info on
> EABI. What is the benefits of this new format?

compare the "elf-File" with the "axf-File" generated by the Realview
tools (IRC the internal Format is at least similar).

The Binary-Interface is something different. Realview uses the EABI. The
GNU tools can be configured for the "old"-ABI or EABI (see
configurationen parameter target).

> I have used CodeSourcery Lite to compile some test apps and I have also
> built my own arm-none-eabi toolchain tailored to my Cortex-M3 and I know
> both work but I am wondering for the standard c library does
> CodeSourcery install its own support libraries or does it use the system
> version of stdint.h?

CS G++ lite comes with a libc. It's the newlib, see libc.pdf in the
documentation installed be CS G++ and/or visit
http://sourceware.org/newlib/

> I'm somewhat new to where everything is placed in
> the Linux file system. Ideally I would have the entire toolchain in one
> self contained directory.

As far as I know CS G++ lite for ARM-EABI and Linux hosts comes with a
small install-script which installs the cross tool-chain, it's libraries
(libc, libgcc) and the header-files in a subdirectory of /opt. You may
use CS's structure as template.

> Debugging is a huge difference between Keil's uVision4 and Insight/DDD
> or even Eclipse. I am considering writing a plugin to give the same
> Peripheral overview as uVision as this is a nice way to check the setup
> otherwise you need to probe around in memory and check bit values with a
> 1000page datasheet.
>
> Does anybody know a walkthrough on setting up Eclipse for CodeSourcery
> with debugging and everything?

The is a special functions register view plugin for Eclipse on sf.net
but I have not played with it so far.

> ITM/ETM, I use ITM extensively thought my programs and uVision4 handled
> this automatically with its debug terminal. How do I use this feature
> through the command line tools such as GDB/Insignt or even Eclipse?

If you need something like a "printf via JTAG-interface" (DCC): OpenOCD
supports  the reception of characters "sent" through the
debug-data-register (see OpenOCD manual: target_request debugmsgs

 Author: Trevor J. (trevor_j) Posted on: 2011-01-15 19:24

Rate this post
 0 ▲ useful ▼ not useful
Thanks for the answers!

Wiki does not have the best answers on ELF and EABI but I am fimilar
with ELF and its organization makes since to me. EABI appears to be very
similar to ELF except that it also defines call and memory structures.
Can you link ELF's output from two different compilers? EABI apparently
can and thats handy when you have dynamic libs on the system.

Reilview outputs EABI? when converting the axf to a hex file for
programming the documentation says its converting from ELF.

I looked up 'target_request debugmsgs' in the OpenOCD manual and boy
theirs not much of a description in there. In uVision I had to connect
via SWO and not JTAG and then enable TRACE_IOEN in the DBGMCU_CR to
start receiving via ITM. Is their a better description of how to
actually go about setting this up via OpenOCD?

 Author: Martin Thomas (mthomas) (Moderator) Posted on: 2011-01-15 21:22

Rate this post
 0 ▲ useful ▼ not useful
Trevor J. wrote:
> Wiki does not have the best answers on ELF and EABI but I am fimilar
> with ELF and its organization makes since to me. EABI appears to be very
> similar to ELF except that it also defines call and memory structures.

Why do you try to compare a binary-interface (like "old" ABI or EABI)
with an output-format of a linking (like ELF)?

> Can you link ELF's output from two different compilers? EABI apparently
> can and thats handy when you have dynamic libs on the system.

As far as I know object-code using EABI from different compilers can be

> Reilview outputs EABI? when converting the axf to a hex file for
> programming the documentation says its converting from ELF.

The usual file-extension used for outputs of Realview's Linker is axf.
The usual file-extension when using GNU tools is elf. But these are just
file-extensions, I expect internally both files are in ELF maybe with a
few more/less sections. The forum on keil.com might be a better place to
ask internal and technical questions on Realview and µVision.

> I looked up 'target_request debugmsgs' in the OpenOCD manual and boy
> theirs not much of a description in there. In uVision I had to connect
> via SWO and not JTAG and then enable TRACE_IOEN in the DBGMCU_CR to
> start receiving via ITM. Is their a better description of how to
> actually go about setting this up via OpenOCD?

OpenOCD and "printf" via debug-interface:
http://repo.or.cz/w/openocd.git/tree/master:/contrib/libdcc . For
further information you may also ask in the OpenOCD-forum at sparkfun or
in the OpenOCD developer mailing list.

 Author: Trevor J. (trevor_j) Posted on: 2011-01-16 05:05

Rate this post
 0 ▲ useful ▼ not useful
Martin Thomas wrote:
> OpenOCD and "printf" via debug-interface:
> http://repo.or.cz/w/openocd.git/tree/master:/contrib/libdcc . For
> further information you may also ask in the OpenOCD-forum at sparkfun or
> in the OpenOCD developer mailing list.

Fantastic! Thats even easier to use than uVisions version as you must
manually retarget putc() to print to the ITM registers and set up those
registers correctly.

Thanks for the help!

 Author: Spencer Oliver (ntfreak) Posted on: 2011-04-05 23:36

Rate this post
 0 ▲ useful ▼ not useful
Just thought i would mention another possibility when using codesourcery
toolchain.

Codesourcery as Martin has already mentioned is based on newlib.

However they also have there own lib (cs3) layer that can also be used
for semi-hosting. If you link with libcs3hosted.a rather than
libcs3unhosted.a you are able to use this with openocd.

for this to work enable with:
arm semihosting enable

Not only can you do normal things like printf to console, but you can
also open/read/write files on your local pc - great for logging without
having to write a filesystem etc.

Cheers
Spen

• $formula (LaTeX syntax)$