LPC1549 - debugging memory problem

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

LPC1549 - debugging memory problem

跳至解决方案
2,252 次查看
dennis_frie
Contributor II

I've been struggling with a project in MCUXpresso recently, that has started to fail randomly.
I suspect it's a memory problem, but have a hard time narrowing it down.

As an example, one of the problems I've noticed, is the initialization of variables not being done correctly in the ResetISR.

double testFreq = 1000; // Variable used in actual firmware
volatile int32_t debugVar1 = 1234; // Debug purpose
volatile double debugVar2 = 1234; // Debug purpose

Without using the debug variables, I get the following readout when debugging and breaking the code just after the ResetISR routine that copies variables from flash to RAM (note, the testFreq variable is used in the code and should have been initialized):

testFreq = -nan(0xfffffffffffff)
debugVar1 = 33570816
debugVar2 = 9.2732874683871246e-312

Adding the following code to actually use the debug variables and the testFreq is also initialized correctly;

volatile int32_t dummy = (int32_t)debugVar1;
dummy = (int32_t)debugVar2;

This gives the expected initialization;

testFreq = 1000
debugVar1 = 1234
debugVar2 = 1234

It should be noted, that any random changes will cause the testFreq variable to be initialized correctly. However, other random errors or crashes will show.

So - the big question. I suspected the problems was caused by a pointer error or something similar that would corrupt random data. However, as this seems to be something that can be seen already in the ResetISR routine, I'm starting to wonder if where to look. Any good ideas ?

标签 (1)
0 项奖励
回复
1 解答
2,209 次查看
dennis_frie
Contributor II

As the problem seems to be isolated to the specific hardware prototype (the firmware is now tested on a handful of other hardware without problems) I've currently just "left it in a corner". We've used the LPC1549 for years and I've never seen this behavior before, so I'm fine with accepting this is just a device that has been damaged "somehow" after months of use in the RND lab. Unless we see this again, I don't think we will use too much time trying to understand what exactly has been damaged.

在原帖中查看解决方案

0 项奖励
回复
7 回复数
2,231 次查看
frank_m
Senior Contributor III

The first post sounded much like a stack overflow, an out-of-bound access, or a dangling pointer. The SCB fault registers would give you further information.

The second post sounds more like a setup problem. Perhaps the clock/Flash settings are not correct, and you operate the device beyond spec. That would explain the stochastic nature, i.e. some parts fail, some not.

Or, you have some hardware issue, probably related to the power supply.

2,212 次查看
dennis_frie
Contributor II

Well, that was exactly what I expected (problem with pointer or stack overflow). However, stack seemed to be well within limit and RAM usage shouldn't get close. A bad pointer could have explained it, however, as the problem seem to happen even with just the ResetISR routine being executed, that leaves pretty much nothing left to debug.

I guess a bad power-supply could explain it. It's supplied by a simple 3.3V LDO. It does output 3.3V, but I haven't checked with a scope to ensure everything looks good during its boot sequence.

0 项奖励
回复
2,204 次查看
frank_m
Senior Contributor III

> I guess a bad power-supply could explain it. It's supplied by a simple 3.3V LDO. It does output 3.3V, but I haven't checked with a scope to ensure everything looks good during its boot sequence.

Proper buffering capacitors near the MCU are another requirement related to power supply.

However, I would not rule out setup issues. Very few manufacturers can run the Flash on their MCU with full speed, you will need to setup waitstates depending on clock frequency. Exceeding the limits here can create spurious behaviour as you observed, which differs between individual boards. I've got some experience with another vendor's Cortex M MCUs in this regard.

 

0 项奖励
回复
2,200 次查看
dennis_frie
Contributor II

True, but as this error can be seen just after the ResetISR routine, the MCU should be running low clock speed and with flash wait states well within accepted range. With a Microchip MCU I've seen problems with slow ramping supply voltage and MCU clock settings being set before the supply was within specs to run at max frequency - but in this case it already seems to happen before the clock change.

0 项奖励
回复
2,236 次查看
dennis_frie
Contributor II

Well, after days of debugging I finally tried another hardware prototype - and everything just works. I've never seen a MCU fail like this, but guess there's a chance some memory parts has been ESD damaged or something similar? I can't quite explain it, but so far the problem seems to be related to a defective MCU.

Live and learn..

0 项奖励
回复
2,222 次查看
diego_charles
NXP TechSupport
NXP TechSupport

Hi @dennis_frie 

 

This sounds interesting,  as far I understand your variables reside in the .data section.

In the MCU where you had those errors, what happens with the variables placed in the .bss?  Are they initialized with zeros as expected?

Or , what if you place your variables in a custom area and test if they are initialized properly? Here is a tutorial with examples on how to do this using MCUXpresso.

https://community.nxp.com/t5/Kinetis-Design-Studio-Knowledge/Relocating-Code-and-Data-Using-the-MCUX...

Diego.

 

0 项奖励
回复
2,210 次查看
dennis_frie
Contributor II

As the problem seems to be isolated to the specific hardware prototype (the firmware is now tested on a handful of other hardware without problems) I've currently just "left it in a corner". We've used the LPC1549 for years and I've never seen this behavior before, so I'm fine with accepting this is just a device that has been damaged "somehow" after months of use in the RND lab. Unless we see this again, I don't think we will use too much time trying to understand what exactly has been damaged.

0 项奖励
回复