# SL6087 reset randomly

**URL:** <https://forum.sierrawireless.com/t/sl6087-reset-randomly/5608>\
**Category:** Open AT\
**Created:** [May 17, 2012, 11:44am UTC](https://forum.sierrawireless.com/t/sl6087-reset-randomly/5608 "2012-05-17T11:44:18Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jitendrak](https://avatars.discourse-cdn.com/v4/letter/j/e19adc/32.png) [@jitendrak](https://forum.sierrawireless.com/u/jitendrak)\
**Post date:** [May 17, 2012, 11:44am UTC](https://forum.sierrawireless.com/t/sl6087-reset-randomly/5608/1 "2012-05-17T11:44:18Z")

</div>

Hi

I am working on Sierra Wireless AirPrime SL6087 module and using firmware 7.46.0, OS-6.36.0. I have written an AT application, which creates 4 task,

GPRS Task (Priority - 4) – Creates Message Queue to Transfer data between GPRS\_Task and other Tasks, It does the GPRS connection, opens one TCP-Client Socket to connect to Remote Sever, that remains open for entire session, it is used to receive data from Remote Server. It also, creates one more TCP-Client Socket [when the Uart\_Task has data to be transferred to Sever] to transfer data to remote sever and when all data is transferred, this connection is closed. The Uart\_Task, invokes the GPRS\_Task using Message Queue, when it has Data to send. The GPRS\_Task also creates a periodic timer of 1min, that checks the if any data received from Remote Sever for processing, and raises query for Signal Strength using ‘at+csq’.

Uart\_Task (Priority - 3), Uart\_task, opens the comm-port 2 in Data mode to communicate to external world, and when it has data from external world, sends a Message to GPRS\_Task to send it to remote sever, otherwise, it is blocked on Semaphore and released only when Uart Receive Event handler has received data to Process. i also releases semaphore for SMS\_Task, if data requires SMS to be send.

NMS\_Task (Priority - 2): NMS\_Task is blocked on Semaphore, which is released when the 2nd TCP-Client Socket is created by GPRS\_TASK on Uart\_Task request, and WIP\_WRITE event is received by the socket handler. Once released, it reads the buffer address from FIFO, and sends the data to remote sever using wip\_write, and request to GPRS\_Task, to close the Channel using Message Queue. And, again get blocked on semaphore.

SMS\_Task (Priority - 1): SMS\_Task is blocked on semaphore, which released when Uart Task has data to be send as SMS, other wise it is blocked on semaphore.

The address of buffer, which holds the data received by Uart\_task, is communicated between task using adl\_queue (QUEUE\_ORDER). Three FIFOs have been created. First, between Uart\_Receive\_Event\_handler & and Uart\_Task, to hold address of buffer received by Uart\_Receive\_Event\_handler and to be processed by Uart\_Task. Second, between Uart\_Task and NMS\_Task, to hold address of buffer holding processed data to be send to remote server. And third, between, SMS\_Task and Uart\_task, to hold address of buffer holding processed Data to be send as SMS.

The AT application works as expected, randomly but it is getting the system getting reset.  
To check the cause of reset, I used adl\_InitGetType, it returns ‘0’ .i.e. ‘ADL\_INIT\_POWER\_ON’.  
I also subscribed, to ‘adl\_errSubscribe’ but the error handler is never getting invoked. I am not getting any reason behind the reset.

Is there any way to detect the memory corruption? And, if the reset is happening because of memory corruption, what will be the return value of ‘adl\_InitGetType’?

What may be the other possible reason of reboot?

Thanks in advance.

Jitendra

---

<div class="post-metadata">

**Author:** ![jitendrak](https://avatars.discourse-cdn.com/v4/letter/j/e19adc/32.png) [@jitendrak](https://forum.sierrawireless.com/u/jitendrak)\
**Post date:** [May 18, 2012, 9:59am UTC](https://forum.sierrawireless.com/t/sl6087-reset-randomly/5608/2 "2012-05-18T09:59:42Z")

</div>

Hi,

In the same query, if the wip channel handle for created tcp-client connection is stored in to ‘client\_socket’ (wip\_channel\_t type) variable. And, in Socket Event Handler, void cbSocketevh(wip\_event\_t \*ev, void \*ctx), the wip channel is being referred using ‘client\_socket’ (used to store socket handle) instead of ev-\>channel. will this may result in to socket handle corruption and reset of application?

Also, is it necessary for event handler to be re-entrant, because, in socket event handler, few global variables and semaphore have been accessed. Is it safe to access the global variables and release the semaphore (only if acquired) in event handler?

Please, clear my doubts.

Thanks in advance.

Jitendra

---

<div class="post-metadata">

**Author:** ![pjc50](https://avatars.discourse-cdn.com/v4/letter/p/f9ae1b/32.png) [@pjc50](https://forum.sierrawireless.com/u/pjc50)\
**Post date:** [May 24, 2012, 4:01pm UTC](https://forum.sierrawireless.com/t/sl6087-reset-randomly/5608/3 "2012-05-24T16:01:11Z")

</div>

Storing the wip channel is safe. The event handler need not be re-entrant, because event handlers are actually driven by message passing to a hidden outer loop around each thread.

There are a couple of things I found from experience that cause problems:

- the watchdog timer triggers after 5 seconds if the module is not idle. Having threads blocked on semaphores may not count as “idle”.

- I tried the “block thread on semaphore” design pattern and couldn’t get it to work. This may well be the source of your crashes. Semaphores only seem to work if used for critical section exclusion, not blocking threads for a long time.

- have you looked for backtraces in Developer Studio? (You may need to get the app to clear backtraces on startup)

- The WIP library is only safe from the thread in which it’s initialised.

It might be safer to simply restructure the whole application into one thread that does everything in event handlers. I think this is the way you’re “supposed” to write applications in OpenAT. In particular, all API functions are nonblocking. So if you write short functions they will all execute in a short time.

---

<div class="post-metadata">

**Author:** ![jitendrak](https://avatars.discourse-cdn.com/v4/letter/j/e19adc/32.png) [@jitendrak](https://forum.sierrawireless.com/u/jitendrak)\
**Post date:** [May 25, 2012, 6:12am UTC](https://forum.sierrawireless.com/t/sl6087-reset-randomly/5608/4 "2012-05-25T06:12:19Z")

</div>

Thanks, the explanation given is very useful. I have some quick questions with respect to back-traces and watchdog.

If the reboot is due to watchdog (I assume it to be hardware watchdog), then, what will be the return value of [i]adl\_InitGetType/i. Will it be ADL\_INIT\_POWER\_ON or ADL\_INIT\_REBOOT\_FROM\_EXCEPTION?

As you have mentioned about back-traces, I registered the Error Event Handler via [i]adl\_errSubscribe/i and returning the TRUE from Error Event Handler. But, the Error Event handler is never got invoked when reset occurs (I have used TRACE to print ErrorID). As soon as the module resets, it goes to production mode, and traces only get printed after it has been again switched to development mode. Do I need to use Back-trace Analysis function to get back-traces after reset?

How, to get backtraces in Developer Studio (2.0)? I have read the doc How to Configure Developer Studio and GDB Stub. As it says, in Debug configuration use ‘Open AT GDB Target’ to configure GDB, but, there is no option like ‘Open AT GDB Target’ as mentioned in the doc. How should I configure GDB in Developer Studio.

Thanks  
Jitendra

---

<div class="post-metadata">

**Author:** ![cjmeyer](https://avatars.discourse-cdn.com/v4/letter/c/d07c76/32.png) [@cjmeyer](https://forum.sierrawireless.com/u/cjmeyer)\
**Post date:** [May 28, 2012, 3:02pm UTC](https://forum.sierrawireless.com/t/sl6087-reset-randomly/5608/5 "2012-05-28T15:02:07Z")

</div>

> [@jitendrak](#):
>
> If the reboot is due to watchdog (I assume it to be hardware watchdog), then, what will be the return value of [i]adl\_InitGetType/i. Will it be ADL\_INIT\_POWER\_ON or ADL\_INIT\_REBOOT\_FROM\_EXCEPTION?

Cant answer the other questions but for the watchdog it definitely returns ADL\_INIT\_REBOOT\_FROM\_EXCEPTION  
and the backtrace will look something like this:

```auto
Watch dog reset. Tsk 31
	Unknown function (0)
	Unknown function (0)
```

---

<div class="post-metadata">

**Author:** ![jitendrak](https://avatars.discourse-cdn.com/v4/letter/j/e19adc/32.png) [@jitendrak](https://forum.sierrawireless.com/u/jitendrak)\
**Post date:** [May 29, 2012, 5:38am UTC](https://forum.sierrawireless.com/t/sl6087-reset-randomly/5608/6 "2012-05-29T05:38:07Z")

</div>

But, the return value of adl\_InitGetType() reported is ADL\_INIT\_POWER\_ON instead of ADL\_INIT\_REBOOT\_FROM\_EXCEPTION. Also the back-trace collected from developer studio

```auto
Watch dog reset. Tsk 36
	_rand_init+0
	_rand_init+0
Watch dog reset. Tsk 36
	_rand_init+0
	_rand_init+0
Watch dog reset. Tsk 36
	_rand_init+0
	_rand_init+0
Watch dog reset. Tsk 36
	_rand_init+0
	_rand_init+0
Watch dog reset. Tsk 36
	_rand_init+0
	_rand_init+0
Watch dog reset. Tsk 36
	_rand_init+0
	_rand_init+0
Watch dog reset. Tsk 36
	_rand_init+0
	_rand_init+0
Watch dog reset. Tsk 36
	_rand_init+0
	_rand_init+0
Watch dog reset. Tsk 36
	_rand_init+0
	_rand_init+0
Watch dog reset. Tsk 12
	_rand_init+0
	_rand_init+0
Watch dog reset. Tsk 36
	_rand_init+0
	_rand_init+0
Watch dog reset. Tsk 29
	_rand_init+0
	_rand_init+0
Watch dog reset. Tsk 36
	_rand_init+0
	_rand_init+0
```

---

<div class="post-metadata">

**Author:** ![jitendrak](https://avatars.discourse-cdn.com/v4/letter/j/e19adc/32.png) [@jitendrak](https://forum.sierrawireless.com/u/jitendrak)\
**Post date:** [July 11, 2012, 6:29am UTC](https://forum.sierrawireless.com/t/sl6087-reset-randomly/5608/7 "2012-07-11T06:29:07Z")

</div>

Please, some one explain me the internal implementation of wip\_TCPClientCreate() function and wip\_close() function.  
Because with my further debugging, I figure out that after these two API’s have been invoked successfully, some time SL6087 module resets.

In case of wip\_TCPClientCreate() API, WIP\_OPEN event is expected, but some time, instead of the WIP\_OPEN event, the SL6087 resets.

Same way when wip\_close () API is called, the socket\_finalize r function is getting invoked successfully, once the controls returns out this function, some time the SL6087 resets.

In both cases the adl\_InitGetType() returns ADL\_INIT\_POWER\_ON instead of ADL\_INIT\_REBOOT\_FROM\_EXCEPTION.

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [July 11, 2012, 10:37pm UTC](https://forum.sierrawireless.com/t/sl6087-reset-randomly/5608/8 "2012-07-11T22:37:25Z")

</div>

Have you tried increasing stack size ❓

---

<div class="post-metadata">

**Author:** ![jitendrak](https://avatars.discourse-cdn.com/v4/letter/j/e19adc/32.png) [@jitendrak](https://forum.sierrawireless.com/u/jitendrak)\
**Post date:** [July 12, 2012, 5:54am UTC](https://forum.sierrawireless.com/t/sl6087-reset-randomly/5608/9 "2012-07-12T05:54:54Z")

</div>

I have not yet increased the stack size.  
Please let me know, how should I calculate the required stack size.

---

<div class="post-metadata">

**Author:** ![jitendrak](https://avatars.discourse-cdn.com/v4/letter/j/e19adc/32.png) [@jitendrak](https://forum.sierrawireless.com/u/jitendrak)\
**Post date:** [January 9, 2013, 11:24am UTC](https://forum.sierrawireless.com/t/sl6087-reset-randomly/5608/10 "2013-01-09T11:24:37Z")

</div>

After export task to message handler using FIFO to transfer data between the message handler and message queue synchronize and control the execution of message handler.  
Now, I am not seeing the Sl6087 Reset issue.

What really fixed the issue I don’t know. 🙂
