adl_wdRearmAppWd Resets the Application


#1

We are trying to use Application Watchdog, even though we can active the watchdog, when we try to deactivate or rearm the Watchdog timer, watchdog reset occurs:

Code to activate the timer

s32 sReturn;
    sReturn = adl_wdActiveAppWd(ADL_TMR_S_TO_TICK(60));
    TRACE((25,"WD Activate: %d", sReturn));
    rStartTimer = adl_tmrSubscribe(TRUE, 150, ADL_TMR_TYPE_100MS, (adl_tmrHandler_t) WDTimer);
    if (rStartTimer > 0)
    {
        TRACE ((25, "WDTimer OK"));
    }

void WDTimer(u8 ID)
{
	s32 sReturn;
	TRACE((25,"Rearming"));
	sReturn = adl_wdDeActiveAppWd();
	TRACE((25,"Rearm result: %d", sReturn));
}

And this is what I get on TRACE:


#2

I’m pretty sure that timer handler prototype differs from that one you used. Check it and provide your timer subscription with valid handler function.


#3

It does!

And remove the typecast - it just masks errors like this!


#4

Maybe not. For old API versions (latest FW 6.57 for Q24PL modules) its OK.


#5

I don’t think that this issue is about the Timer, I have used timers just like this without any problem. But I agree you on fixing these workarounds so I updated the code to this:

adl_tmr_t *rWDTimer;

void WDTimer(u8 ID, void * Context)
{
	s32 sReturn;
	TRACE((25,"Rearming"));
	sReturn = adl_wdRearmAppWd();
	TRACE((25,"Aktif Eylendi: %d", sReturn));
}

void adl_main(adl_InitType_e InitType)
{
.
.
.
    s32 sReturn;
    sReturn = adl_wdActiveAppWd(ADL_TMR_S_TO_TICK(60));
    TRACE((25,"WD Activate: %d", sReturn));
    rWDTimer = adl_tmrSubscribe(TRUE, 150, ADL_TMR_TYPE_100MS, WDTimer);
    if (rWDTimer > 0)
    {
        TRACE ((25, "WDTimer OK"));
    }
}

This code still resets the Application just after the “Rearming” Trace in WDTimer. So this issue looks like it’s about the adl_wdRearmAppWd() function.

I also wanted to ask if there is a limit for the count of timers on an application.


#6

There is a per-task limit, and a total-application limit - see the ADL User Guide!


#7

Now I don’t know how to fix this problem… Try to increase stack size, remove trace after watchdog rearming, check whether your watchdog facility is activated with WCFM command.


#8

It’s not about the Timer count too:


#9

I also tried the Appli_WD sample provided with Developer Studio and it is working so it’s also not an hardware issue. Regarding the stack size, how do we define the stack size? What is the optimal value?


#10

There’s plenty of stack setting in the examples e.g.
const u16 wm_apmCustomStackSize = 1024*3;

Optimal size? Depends on how limited you are in RAM. Just try increasing it and see if it helps, if not put it back to the normal.

Which system are you unsing this on? The WD is enabled by default in my setups, I have to switch it off for a few operations I do, but this is on a time-out, it then restarts.


#11

We have AirPrime Q2687,

I think it was set to 1024 but I went up to 1024 * 4 and nothing changed.


#12

Are you re-arming the WD every 15 seconds, but running a 1 second watchdog?

EDIT: No - sorry, 60 sec watchdog. Just taking a look during compiles!


#13

It is not about the code either,

I tried the same code on a clean Project and it worked. So I presume It has to conflict with the rest of the code.

This is going to be hard. Do you have any advice for me?


#14

Try running it all faster?


#15

Since your code works on a clean project you should add your existing code part by part and see when and where it starts crashing. It still could be a stack size issue - your stack is big enough for a small code size in a clean project, but small for your final code.
How to increase your stack size: if you are using developer studio, open generated.c in your project, set your application settings to writable, set stack size to 16536, rebuild your project. Also try to set ISR stack sizes to 1024.
If you are not using DS - read forum for instructions.


#16

I don’t think that this is practical since the Application code has ~5000 lines.

I don’t have a “generated.c” file on my project. It is “main.c” but I have this line on the code;

const u16 wm_apmCustomStackSize = 16536;

Shouldn’t this be enough?

(by the way the application was working fine with “1024” before watchdog why do I have to increase stack size 16 times to just enable the watchdog?)

Could you please give me some details on how to do this?


#17

It is a good way to divide code on parts and modules which can be included or excluded independently. It is just an advise for a future refactoring. :slight_smile:

It may work or not. I think it should work if placed just after including adl_global.h. But to avoid problems your better install newest developer studio, create new project and port your application in it. You will have new application settings in it.

Application was working with 1024 when it was Visual Studio project with old SDK. Since M2M studio reserved stack size is actually 3 times smaller than it is supposed by programmer. Well it is enough to set your stack size to 4096 by my application was crashing on this setting… But worked well on 81024 and 161024 (and actually on 3*1024).
Watchdog feature is provided with new SDK, so it is better to use new application settings with it.

With developer studio you will find how to do it easily.