# WP85 ULPM App automatically get removed after 4 Boot cycles

**URL:** <https://mangoh.discourse.group/t/wp85-ulpm-app-automatically-get-removed-after-4-boot-cycles/787>\
**Category:** Uncategorized\
**Created:** [October 5, 2017, 11:37am UTC](https://mangoh.discourse.group/t/wp85-ulpm-app-automatically-get-removed-after-4-boot-cycles/787 "2017-10-05T11:37:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jaison\_Ollukkaran](https://avatars.discourse-cdn.com/v4/letter/j/f1d935/32.png) [@Jaison\_Ollukkaran](https://mangoh.discourse.group/u/Jaison_Ollukkaran)\
**Post date:** [October 5, 2017, 11:37am UTC](https://mangoh.discourse.group/t/wp85-ulpm-app-automatically-get-removed-after-4-boot-cycles/787/1 "2017-10-05T11:37:14Z")

</div>

I had created an app to test ULPM with wake up on timer. I am using WP8548. Its working fine for 4 cycles of Shutdown and reboot. afterwards on 5th cycle boot up my app automatically got removed.The figure show my app running as ULP\_testing\_1. Also when I try to remove other 3 user apps,Its automatically getting reinstalled on the 5th cycle of ULPM boot up

 ![Form pic](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/1X/df5b33cea7f3acbd0284d572ed5360878a66719b.PNG)

Here is my Code…

#include “legato.h”  
#include “interfaces.h”

//--------------------------------------------------------------------------  
/\*\*

- Function Prototype  
\*/  
//--------------------------------------------------------------------------

void SwitchToLowPowerMode(void);

//--------------------------------------------------------------------------  
/\*\*

- Variables Declarations  
\*/  
//--------------------------------------------------------------------------

le\_timer\_Ref\_t ULPStartTimerRef = NULL;

//--------------------------------------------------------------------------  
/\*\*

- ULP mode entering- system live delay timer Handler  
\*/  
//--------------------------------------------------------------------------

static void ULPSwitchingTimerHandler(le\_timer\_Ref\_t timerRef){

```
LE_INFO("------------> Activating Ultra Low Power Mode<--------------");
SwitchToLowPowerMode();

//le_ulpm_BootOnTimer(60);
//le_ulpm_ShutDown();

```

}

//--------------------------------------------------------------------------  
/\*\*

- ULP mode Function  
\*/  
//--------------------------------------------------------------------------

void SwitchToLowPowerMode(void)  
{

```
char version[LE_ULPM_MAX_VERS_LEN+1];

  // Get ultra low power manager firmware version
LE_FATAL_IF(le_ulpm_GetFirmwareVersion(version, sizeof(version)) != LE_OK,"Failed to get ultra low power firmware version");
LE_INFO("Ultra Low Power Manager Firmware version: %s", version);

// Boot after 1000 second of shutdown.
LE_ERROR_IF(le_ulpm_BootOnTimer(60) != LE_OK, "Can't set timer as boot source");
// Initiate shutdown.
LE_ERROR_IF(le_ulpm_ShutDown() != LE_OK, "Can't initiate shutdown");

```

}

//--------------------------------------------------------------------------  
/\*\*

- ULP mode entering- system live timer  
\*/  
//--------------------------------------------------------------------------

static void SetupModbusPollingTimer()  
{  
ULPStartTimerRef = le\_timer\_Create(“ULPStartTimer”); //create timer  
le\_clk\_Time\_t interval = { 60, 0 }; //update every 60 seconds  
le\_timer\_SetInterval(ULPStartTimerRef, interval); //Set delay  
le\_timer\_SetRepeat(ULPStartTimerRef, 0); //set repeat to always  
le\_timer\_SetHandler(ULPStartTimerRef, ULPSwitchingTimerHandler); //set callback function to handle timer expiration event  
le\_timer\_Start(ULPStartTimerRef); //start timer  
}

// Start App from here.

COMPONENT\_INIT  
{

```
LE_INFO("Ultra Low Power Testing.");

// Now check whether boot was due to timer expiry.
if (le_bootReason_WasTimer())
{
	LE_INFO("ULPM: Booted from timer.");
}
else{

	LE_INFO("ULPM: Booted from other reason.");
}

SetupModbusPollingTimer();

```

}

---

<div class="post-metadata">

**Author:** ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)\
**Post date:** [October 5, 2017, 3:20pm UTC](https://mangoh.discourse.group/t/wp85-ulpm-app-automatically-get-removed-after-4-boot-cycles/787/2 "2017-10-05T15:20:34Z")

</div>

I believe that the Legato system is rolling back because it thinks that the system is in a boot loop. Personally, I’m not a fan of this behavior because I think it does more harm than good. Please [file a bug in the legato application framework](https://github.com/legatoproject/legato-af/issues).

---

<div class="post-metadata">

**Author:** ![daav](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/daav/32/79_2.png) [@daav](https://mangoh.discourse.group/u/daav)\
**Post date:** [October 6, 2017, 4:41pm UTC](https://mangoh.discourse.group/t/wp85-ulpm-app-automatically-get-removed-after-4-boot-cycles/787/3 "2017-10-06T16:41:51Z")

</div>

Hi,

This roolback mechanism is indeed happening if the device resets too often during a probation period (which is several minutes by default). The probation period starts as soon as a new app/system is installed.  
To workaround that you can:

- install the **devMode** app, that reduces the probation period to 5s. You should have a DS notification for that when you connect to your device.
- use the target **update** tool ([http://legato.io/legato-docs/latest/toolsTarget\_update.html](http://legato.io/legato-docs/latest/toolsTarget_update.html)) to mark the system “as good” after your app install. This will end the probation period.

---

<div class="post-metadata">

**Author:** ![Jaison\_Ollukkaran](https://avatars.discourse-cdn.com/v4/letter/j/f1d935/32.png) [@Jaison\_Ollukkaran](https://mangoh.discourse.group/u/Jaison_Ollukkaran)\
**Post date:** [October 9, 2017, 7:05am UTC](https://mangoh.discourse.group/t/wp85-ulpm-app-automatically-get-removed-after-4-boot-cycles/787/4 "2017-10-09T07:05:46Z")

</div>

System roll back on boot loop was the issue.  
I tried update tool (update --mark-good) to end probation period, as per daav’s suggestion and it was a success.  
now my ULP mode test App is running without any problems.

Thank you daav and dfrey.
