“static clustering” option on IAR optimization causes hard fault

Hello all… I am using STM32L151 family with IAR 6.21 on my FreeRTOS project and I have encountered some problems with “xQueueSend” and “xQueueSendFromISR” functions. When using these functions from my tasks, it causes the CPU generate a “hard fault” interrupt. I traced the problem to the function that copies the data to the queue( where the number of bytes to copy is messed up). After a lot of debugging time, I have found that when I un-check the box of “static clustering” option on IAR optimizer, the program runs fine without the “hard fault”. So, I have a few qeustions regarding this phenomena. Have anyone encountered a similar problem? Anyone knows what is “static clustering” option on IAR optimizer (I have looked on IAR documentation but the explanation is hardly satisfaing)? And the most important, what can I do to make it work? Assume I want to keep the level of optimization as high as possible. Thank you. Itay

“static clustering” option on IAR optimization causes hard fault

This is a known thing, and is ‘normally’ the case. Generally in EWARM you can set optimisaiton to maximum, then manually uncheck the static clustering option. I have never worked out why, and, as you say, the documentation on what static clustering does is not informative (just something like “makes statics cluster”, or “clusters statics when turned on”, …). I would guess it was doing something to place certain variables near each other for faster access, but it is a guess. All demos are tested with zero, maximum speed and maximum code size optimisations, and this one option (specific to IAR) is the only one we are aware of that causes an issue. Regards.

“static clustering” option on IAR optimization causes hard fault

Thank you very much for the quick response. Itay.

“static clustering” option on IAR optimization causes hard fault

Does anyone know if this is still an issue? I noticed that in a later release of IAR, V7.10 2014-02-21, an issue with this optimization was addressed: In a very rare situation, related to static clustering, incorrect code might be generated. [EW24464]

“static clustering” option on IAR optimization causes hard fault

I’ve not explicitly tried it for a while but normally test with full optimisation, and if that turns static clustering in then I guess it must be ok. Easy to try though.

“static clustering” option on IAR optimization causes hard fault

I was just going by the prevous resonpse
All demos are tested with zero, maximum speed and maximum code size optimisations, and this one option (specific to IAR) is the only one we are aware of that causes an issue.
If you could test this, i’d apreciate it.