[BC660K] DFOTA after upgrading

Hello,

We are developing an FW using QuecOpen and FreeRTOS provided by the SDK.

About the DFOTA upgrade, we did some tests and it seems that we do not have able time to catch the result of the DFOTA SUCCESS return, that is, the module reboots immediately after the SUCCESS of installing the new firmware.

Here is the logs:

AT+QFOTADL="http://xxx.xxx.xxx.xxx:yyy/firmware_old1-TO-firmware_new.zip"
OK
L +QIND: "FOTA","HTTPSTART"
L +QIND: "FOTA","DOWNLOADING",57%
L +QIND: "FOTA","DOWNLOADING",100%
+QIND: "FOTA","HTTPEND",0

��x��������������x������x<� [ dummy messages .... ]
READY P

So, the READY P message comes from the Ql_GetWakeUpReason() API, where we simply assign a char to be printable, and we can see what was the restart cause.

However, the Ql_GetWakeUpReason() is either limited (because it has jus a few restart reasons, 6 to be precise), or we are doing it wrong.

What we would expect is that Ql_GetWakeUpReason() could return some more specific reason rather than a simple QL_POWERON, which is too generic. Something more specific like QL_FOTAUPGRADE or so would be more reasonable.

The possible values defined at ql_power.h are:


/* This enum defines the power on reason. */
typedef enum {
	/* First power on or hardware reset */
	QL_POWERON               = 0,  
	/*  software reset */
	QL_SOFT_RESET		     = 1,
	/* Wake up by RTC timer from deep sleep. TAU/ALARM(oc,onet)/USER RTC */
	QL_RTCWAKEUP			 = 2,
	/* Wake up by UART0-RXD from deep sleep */
	QL_RXD_WAKEUP	         = 3,	
	/* Wake up by PSM_EINT0 from deep sleep */
	QL_PSM_EINT0_WAKEUP	     = 4,
	/* Wake up by PSM_EINT1 from deep sleep */
	QL_PSM_EINT1_WAKEUP	     = 5,
	
    /* others reset */
    QL_UNKNOWN_PWRON,
}  Enum_WakeUp_Reason;

So, the core question here is: how do we get the proper restart reason after a SUCCESSFULLY firmware upgrade from DFOTA?

P.S.: I am not sure yet if these dummy messages is because we use a different baudrate or what.

UPDATE 1:
By checking the Datasheet of DFOTA, after reboot it prints the URC: +QIND: "FOTA","END",<upgrade_result>, but since we are using QuecOpen and FreeRTOS, I am not sure if we are able to catch that message (if the message is really thrown).

UPDATE 2:
We are using BC660K module.

Did some more investigation and it seems that in the very last state of the DFOTA update there is no chance to safely store the upgrade status.

For example, when running the QFOTADL command, it will print the following URCs (in my case):

+QIND: "FOTA","HTTPSTART"
+QIND: "FOTA","DOWNLOADING",57%
+QIND: "FOTA","DOWNLOADING",100%
+QIND: "FOTA","HTTPEND",0
+QIND: "FOTA","START"

# [ then reboots ]

So, I did a parser to check these incoming URCs, and tried to write to a file the status on each step to log some status messages.

Although the URCs generated (or expected) from the DFOTA are these:

HTTPSTART
DOWNLOADING
HTTPEND
START
UPDATING 
END

my code is able to write up to START state, after that, I believe the QFOTADL executes so fast that there is no time to write to a file.

I do not know if is possible to reach the END with an <upgrade_result> != 0 that causes the module to restart?!?!? If that is the case, then the error will be silent and we will not be able to handle such a case.

On the HTTPEND state I am able to create situations where the <download_result> returns values different than 0, so I can create error handling cases.
But, for the END, I am not sure if the error handling that I wrote will work or not because of the reasons I just mentioned previously.