I did some additional experimentation both with the Freescale KDS toolchain, and the GNU Tools for ARM Embedded Processors (https://launchpad.net/gcc-arm-embedded). I changed the stack and heap settings, and I think I've ruled that out.
It looks like the hard fault when running the KDS toolchain occurs in:
rt_List.c
void rt_put_rdy_first (P_TCB p_task)
While looking at the disassembly view, it looked like one of the registers (R3) was populated with a real value (0x1fff04b0) when running the GNU Arm toolchain, but it was zero (showed 0x0) when using the KDS toolchain.
If R3 is 0x0, it looks like this assembly command may be trying to load a value into address 0x4, which is a read-only memory location?
str r2, [r3, #4]
See attached debugger screen shots for more detail.
One other thing I checked was the value in the Configurable Fault Status Register (0xE000ED29). Prior to the hardfault, it looks like this register is set to 0b010, indicating IMPRECISERR - Imprecise data bus error:
1 = a data bus error has occurred, but the return address in the stack frame is not related to the instruction that caused the error.
When the processor sets this bit to 1, it does not write a fault address to the BFAR.
This is an asynchronous fault. Therefore, if it is detected when the priority of the current process is higher than the BusFault priority, the BusFault becomes pending and becomes active only when the processor returns from all higher priority processes. If a precise fault occurs before the processor enters the handler for the imprecise BusFault, the handler detects both IMPRECISERR set to 1 and one of the precise fault status bits set to 1.
I noticed that I got a significantly different .map file from each linker and have attached those as well.
The only difference between the working and non-working configurations in KDS, was the toolchain, and the linker flags that had to be different between the two tool chains: -specs=nano.specs -specs=nosys.specs for the GCC Arm toolchain and -nanolibc for the KDS toolchain.
Any ideas? Linker configuration error, or linker bug, perhaps?
KDS toolchain just before hard fault:
GCC Arm toolchain at the same location, no fault:
To get the combined benefits of the FRDM-64F platform, the mbed libraries, and the KDS IDE, I created the following KDS project that compiles, and allows for step-by-step debugging of mbed applications, including step through of mbed source code.
https://github.com/bundgus/K64F-mbed-KDS-Template
Thanks to everyone in the mbed community for your contributions, hopefully this will be useful to you. I'm sure there are many improvements to be made. Feel free to fork this configuration, and let me know if you have any suggestions.
The sample application in this template project is the K64F Disco Blinky application.
-Mark