Overwriting Symbols in the GNU Linker File

I start liking the GNU linker (ld) more and more. Yes, that linker command file syntax needs some time to learn, but it is very powerful. I stumbled over an interesting way how to define linker symbols:

/* Linker file for GNU C Compiler */

/* Entry Point */
ENTRY(Reset_Handler)

HEAP_SIZE  = DEFINED(__heap_size__)  ? __heap_size__  : 0x00000400;
STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x00000400;

The interesting part is how the HEAP_SIZE and STACK_SIZE symbols are defined.

It checks if e.g. __heap_size__ is DEFINED, and if so, it uses that symbol, otherwise it is using 0x400. Very similar to the C/C++ ‘?’ operator. So I can overwrite the default of 0x400 with my value or symbol. The questions is: from where does the symbol come from?

Continue reading

Listing Code and Data Size for each Source File with GNU and Eclipse

I have used the ‘classic’ CodeWarrior IDE for years, before I moved over to Eclipse some years ago. And as with any IDE or tool switch, things are different in the ‘new world’. In summary, I don’t want to go back anyway, and Eclipse is my development tool of choice now. But from time to time I get challenged about something like “hey, this was possible in the previous tool, so how can I do the same in Eclipse?”. As a fan of Eclipse, this then gets my attention as I feel that Eclipse can do it, and it can do it better. 😉

So what about this one: In CodeWarrior the project view lists code and data size for each source file:

Code And Data Size in CodeWarrior

Code And Data Size in CodeWarrior

Continue reading

Switching ARM GNU Tool Chain and Libraries in Kinetis Design Studio

The Freescale Kinetis Design Studio (KDS) V1.0.1 beta is using a different GNU ARM toolchain than the ARM Inc. supported one on launchpad (GCC ARM Embedded). Additionally, KDS is using newlib 1.19 and newlib-nano 1.0, while there just has been a new release of the GCC ARM Embedded a month ago with the 4.8.4 update 2 release in June this year. So how to upgrade KDS to the latest and greatest GCC ARM Embedded?

Continue reading

printf() and scanf() with GNU ARM Libraries

In “Semihosting with Kinetis Design Studio” I’m using the debugger with semihosting to output text with printf(). But how to use a physical serial connection instead?

printf() and scanf() in action

printf() and scanf() in action

This post is about how to enable and use printf() and scanf() with GNU ARM libraries. I show it both for the Freescale Kinetis Design Studio (KDS) and for stock Eclipse Kepler with the GNU GCC ARM Embedded (launchpad) toolchain and libraries. The principles are the same, just the details are different ;-).

Continue reading

FILLing unused Memory with the GNU Linker

In many of my applications I use a CRC/checksum to verify that the code/flash on the target is not modified. For this, not only the code/data in flash counts, but as well all the unused gaps in the memory map. Instead to leave it up to the flasher/debugger (which usually erases it to 0xFF), I want to fill it with my pattern. The GNU linker is using the pattern 0x00 for unused bytes inside sections. So this post is about to use the GNU linker to ‘fill’ the uninitalized FLASH memory with a pattern.

FLASH with DeadBeef Pattern

FLASH with DeadBeef Pattern

Continue reading

Tutorial: DIY Kinetis SDK Project with Eclipse – Board Configuration

In “Tutorial: DIY Kinetis SDK Project with Eclipse – Startup” I showed how to create a Kinetis SDK project from scratch. In this post it is about adding the board initialization files. With the board initialization the peripheral clocks and pin muxing is configured.

MK64FN1M0VLL12 on FRDM-K64F

MK64FN1M0VLL12 on FRDM-K64F

Continue reading

Semihosting with Kinetis Design Studio

Semihosting is a technique to do printf() debugging through an active debug connection. So instead using a physical connection like RS-232 or USB CDC, the connection to the host machine is through the debugger. This post is about enabling and using semihosting with gcc and newlib/newlib-nano in Freescale Eclipse based Kinetis Design Studio (KDS) using the GNU ARM Eclipse plugins.

Semihosting Console View with output

Semihosting Console View with output

Continue reading

Tutorial: Data Logger with the FRDM-K64F Board

The Freescale FRDM-K64F is a great board for data logger applications: it has a powerful ARM Cortex M4F with 120 MHz, 1 MB Flash and 256 KByte RAM. Best of all: it already has a micro SD card socket on the board :-).

Data Logger with FRDM-K64F

Data Logger with FRDM-K64F

Continue reading

Constructing a Classroom IDE with Eclipse for ARM

For the next semester I will do things differently in my advanced embedded systems programming course (INTRO) at the University of Lucerne: Instead of using the Freescale provided CodeWarrior, we will use a DIY tool chain for ARM with Eclipse Kepler.

Eclipse Kepler Ready for Classroom Usage

Eclipse Kepler Ready for Classroom Usage

That way we we can offer students an open and convenient tool chain for their lab work, course assignments and own projects both at work and at home. So this post is about spending about 30 minutes to build your own tool chain which then can passed to students and coworkers so they have a complete toolchain installed in a few minutes.

Continue reading

GNU ARM Eclipse & Segger J-Link Device Name Settings

Thanks to the GNU ARM Eclipse plugins from Liviu it is easy to build and debug projects for all the different ARM cores. But I need to specify the device name in the debug configuration:

Device Name for Segger GDB Configuration

Device Name for Segger GDB Configuration

There must be an easier way for this? Yes, indeed, there is 🙂

Continue reading