HardFault in Tasks.c when using IAR 6.50

tanffn wrote on Thursday, April 23, 2015:

I’ve noticed an “interesting” issue that I am simply unable to trackdown/resolve.

I am working on ST’s example LwIP_UDPTCP_Echo_Server_Netconn_RTOS.
If I compile it using IAR 7.40 everything works fine YET when I compile the same code using IAR 6.50 I get an HardFault.

Using LR (from the stack on HardFault) I’ve been able to track down the problem to a macro in FreeRTOS\tasks.c (which seems to run from memory, hence the address).

Since I can put a breakpoint I added a debug variable to find the problematic line.
If I try to debug further (adding more debug code) the location of the hard-fault changes…
Can’t figure out how to track it down, in the vast RTOS/LwIp code…

Any advice?

Also worth mentioning, the error occurs when I plug the ethernet cable and LwIP low_level_input is constantly being called.

[Relevant code]

listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopReadyPriority ] ) );

(Can’t figure out how to insert code! :confused: )

[Hard fault handler]
R0 = 20008a8a
R1 = fffffff1
R2 = 20000000
R3 = 20009f68
R12 = 1b8049
LR = 20009f70
PC = 1400
PSR = 8004337
BFAR = 1b804d
CFSR = 8200
HFSR = 40000000
DFSR = b
AFSR = 0

rtel wrote on Thursday, April 23, 2015:

We find it extremely difficult to provide free support for lwIP, especially when the integration has been performed by somebody else. That is why we introduced our own TCP/IP stack.

In this case the first thing I suggest you do is a complete rebuild - make sure there are absolutely no object or dependency files created by IAR 7.4 left anywhere before clean building with IAR V6.x.

If that does not help, look through IAR’s change history to see if that provides any clues.

Next try without lwIP being used/called.

If you still have a problem, use IAR V7.4.


davedoors wrote on Thursday, April 23, 2015:

Make sure you use the C start up code and linker script from IAR 6 when using IAR 6 and the same from IAR 7 when using IAR 7.

tanffn wrote on Friday, April 24, 2015:

Not sure why my first replay wasn’t posted… 2nd Try :slight_smile:

Thank you Dave and RTE team for you reply.
I tried another clean build with the startup code from IAR 6.50, exact same failure at the same point.

I was actually considering rewrite my code to use FreeRTOS+TCP/IP stack and and the new FatFS.
I will be happy to port the code for STM32F4* (and their eval board) but someone will need to help me to bridge my current knowledge gap… (with some guidance and technical support).

I need to use 6.50 as that’s the license I own, an upgrade will cost almost as much as a new license which is somethign I cannot afford…
I use size limit license with 7.40 only to test the code provided by ST (removed TCP to squeeze it in :))

tanffn wrote on Sunday, April 26, 2015:

No one? :confused:

rtel wrote on Sunday, April 26, 2015:

It is not easy to support older IAR versions as we cannot run the code.

Did you try running without lwIP and looking through the IAR release notes as previously suggested?

We have FreeRTOS+TCP and FreeRTOS+FAT running on an STM32F4 already, the project needs updating since the last labs release though - it is in line though and will get released as soon as we get the chance.


heinbali01 wrote on Sunday, April 26, 2015:

Hi Ariel,

No one?

I’m afraid that’s a very difficult question you’re asking.

In the past I have seen crashes in all of the FreeRTOS modules: list, tasks, queue.

And that was always my own fault :slight_smile:

In most cases there was some memory corruption, a stack overflow, things like that.

Compiler 6.50 shows a problem and 7.40 works OK. Maybe 6.50 needs just a bit more stack space for some operations.

I will be happy to port the code for STM32F4*

There is a NetworkInterface.c for STM32F407 that works fine.


tanffn wrote on Monday, April 27, 2015:

I did check it and replied to it, on my first iteration :slight_smile:
Without LwIP (/before plugging the Ethernet cable) RTOS is working fine, the Blinky thread, blinks.

Can I get the older, unupdated, version? where can I find it?

tanffn wrote on Monday, April 27, 2015:

Hi Hein,
As fun as it is to blame the compiler it’s undoubtedly my fault. Yet its based on a very basic sample code…

I did try to increase the Stack and Heap. It wasn’t it…

In the package I downloaded F4 wasn’t implemented.
I will look at it again.