OTA 3G REPROGRAMMING ERROR

Using OTA functions with Waspmote
agualdron
Posts: 19
Joined: Mon Apr 18, 2016 7:07 pm

Re: OTA 3G REPROGRAMMING ERROR

Post by agualdron » Wed Jun 22, 2016 11:10 pm

Hello,

After some time I'm back to face the OTA - REPROGRAMMING ERROR...

This time I use the GPRS (Not 3G) for the OTA, thus I'm calling the
GPRS_Pro.requestOTA() function, as shown in the example.

The API version is the v023.

For testing purposes I'm Using the libeluim FTP that you provided before.

The memory I'm using is 2GB in FAT and shows the 1.86GB as described in the Over the Air Programming guide.

After running the program, if I inspect the memory, I find the 2 files "UPGRADE.TXT" and the binary file, which in my case is "OTA_HEL"

the contents of the UPGRADE.TXT is the following:

Code: Select all

FILE:OTA_HEL
PATH:/
SIZE:16884
VERSION:11

and the USB-serial output in GPRS debug mode is the following:

*Note: for easy reading I placed "..." instead of repeated information.

Code: Select all

E#
**************************
---Config APN v23 internal
APN: internet.movistar.com.co
LOGIN: movistar
PASSWORD: movistar
**************************
RESTARTING
Program version: 10
Debug mode 1
not_ready: 1
not_ready: 1
not_ready: 0
Send command with 1 answer: AT+CMEE=1
Answer: 1
Send command with 1 answer: ATE0
Answer: 1
Send command with 1 answer: AT+CSCLK=0
Answer: 1
Send command with 2 answers: AT+CFUN=1
Answer: 1
GPRS_Pro module ready...
Connecting to the network
Send command with 1 answer: AT+CREG?
Answer: 1
Network status: 1
GPRS_Pro module connected to the network
Starting OTA process
Send command with 1 answer: AT+SAPBR=3,1,"CONTYPE","GPRS"
Answer: 1
Send command with 1 answer: AT+SAPBR=3,1,"APN","internet.movistar.com.co"
Answer: 1
Send command with 1 answer: AT+SAPBR=3,1,"USER","movistar"
Answer: 1
Send command with 1 answer: AT+SAPBR=3,1,"PWD","movistar"
Answer: 1
Send command with 1 answer: AT+SAPBR=5,1
Answer: 1
Downloading OTA VER FILE
Send command with 1 answer: AT+CGREG?
Answer: 1
...
GPRS status: 1
Send command with 2 answers: AT+SAPBR=1,1
Answer: 1
Send command with 1 answer: AT+SAPBR=2,1
Answer: 1
Send command with 2 answers: AT+FTPCID=1
Answer: 1
Send command with 2 answers: AT+FTPMODE=1
Answer: 1
Send command with 2 answers: AT+FTPTYPE="I"
Answer: 1
Send command with 2 answers: AT+FTPSERV="pruebas.libelium.com"
Answer: 1
Send command with 2 answers: AT+FTPPORT=21
Answer: 1
Send command with 2 answers: AT+FTPUN="t3g@libelium.com"
Answer: 1
Send command with 2 answers: AT+FTPPW="ftp1234"
Answer: 1
Inside readDataFTP
FTP file: /UPGRADE.TXT
SD file:/UPGRADE.TXT
Send command with 2 answers: AT+FTPSTATE
Answer: 1
Inside FTPsize
Send command with 2 answers: AT+FTPSTATE
Answer: 1
Send command with 2 answers: AT+FTPGETNAME="/UPGRADE.TXT"
Answer: 1
Send command with 2 answers: AT+FTPGETPATH="/"
Answer: 1
Send command with 2 answers: AT+FTPSIZE
Answer: 1
Size in FTP: 45
Send command with 2 answers: AT+FTPGETNAME="/UPGRADE.TXT"
Answer: 1
Send command with 2 answers: AT+FTPGETPATH="/"
Answer: 1
Send command with 2 answers: AT+FTPGET=1
Answer: 1
Send command with 2 answers: AT+FTPGET=2,250
Answer: 1
FTP data: 45
Bytes stored: 45/45
Send command with 2 answers: AT+FTPGET=2,250
Answer: 1
FTP data: 0
Inside FTPsize
Send command with 2 answers: AT+FTPSTATE
Answer: 1
Send command with 2 answers: AT+FTPGETNAME="/UPGRADE.TXT"
Answer: 1
Send command with 2 answers: AT+FTPGETPATH="/"
Answer: 1
Send command with 2 answers: AT+FTPSIZE
Answer: 1
Size in FTP: 45
Return from readDataFTP: 1
ftp_size: 45
ftp_retries: 3
file size SD: 45
Send command with 2 answers: AT+SAPBR=0,1
Answer: 1
OTA file: OTA_HEL
File path: /
Version: 11
Downloading OTA FILE
Send command with 1 answer: AT+CGREG?
Answer: 1
GPRS status: 1
Send command with 2 answers: AT+SAPBR=1,1
Answer: 1
Send command with 1 answer: AT+SAPBR=2,1
Answer: 1
Send command with 2 answers: AT+FTPCID=1
Answer: 1
Send command with 2 answers: AT+FTPMODE=1
Answer: 1
Send command with 2 answers: AT+FTPTYPE="I"
Answer: 1
Send command with 2 answers: AT+FTPSERV="pruebas.libelium.com"
Answer: 1
Send command with 2 answers: AT+FTPPORT=21
Answer: 1
Send command with 2 answers: AT+FTPUN="t3g@libelium.com"
Answer: 1
Send command with 2 answers: AT+FTPPW="ftp1234"
Answer: 1
Inside readDataFTP
FTP file: //OTA_HEL
SD file:OTA_HEL
Send command with 2 answers: AT+FTPSTATE
Answer: 1
Inside FTPsize
Send command with 2 answers: AT+FTPSTATE
Answer: 1
Send command with 2 answers: AT+FTPGETNAME="/OTA_HEL"
Answer: 1
Send command with 2 answers: AT+FTPGETPATH="/"
Answer: 1
Send command with 2 answers: AT+FTPSIZE
Answer: 1
Size in FTP: 16894
Send command with 2 answers: AT+FTPGETNAME="/OTA_HEL"
Answer: 1
Send command with 2 answers: AT+FTPGETPATH="/"
Answer: 1
Send command with 2 answers: AT+FTPGET=1
Answer: 1
Send command with 2 answers: AT+FTPGET=2,250
special error3
Answer: 2
Inside FTPsize
Send command with 2 answers: AT+FTPSTATE
Answer: 1
Send command with 2 answers: AT+FTPSTATE
Answer: 1
...
Send command with 2 answers: AT+FTPGETNAME="/OTA_HEL"
Answer: 1
Send command with 2 answers: AT+FTPGETPATH="/"
Answer: 1
Send command with 2 answers: AT+FTPSIZE
Answer: 1
Size in FTP: 16894
Return from readDataFTP: -51
ftp_size: 16894
ftp_retries: 3
file size SD: 0
Inside readDataFTP
FTP file: //OTA_HEL
SD file:OTA_HEL
Send command with 2 answers: AT+FTPSTATE
Answer: 1
Inside FTPsize
Send command with 2 answers: AT+FTPSTATE
Answer: 1
Send command with 2 answers: AT+FTPGETNAME="/OTA_HEL"
Answer: 1
Send command with 2 answers: AT+FTPGETPATH="/"
Answer: 1
Send command with 2 answers: AT+FTPSIZE
Answer: 1
Size in FTP: 16894
Send command with 2 answers: AT+FTPGETNAME="/OTA_HEL"
Answer: 1
Send command with 2 answers: AT+FTPGETPATH="/"
Answer: 1
Send command with 2 answers: AT+FTPGET=1
Answer: 1
Send command with 2 answers: AT+FTPGET=2,250
Answer: 1
FTP data: 250
Bytes stored: 250/16894
Send command with 2 answers: AT+FTPGET=2,250
Answer: 1
FTP data: 250
Bytes stored: 500/16894
...
Send command with 2 answers: AT+FTPGET=2,250
Answer: 1
FTP data: 144
Bytes stored: 16894/16894
Send command with 2 answers: AT+FTPGET=2,250
Answer: 1
FTP data: 0
Inside FTPsize
Send command with 2 answers: AT+FTPSTATE
Answer: 1
Send command with 2 answers: AT+FTPGETNAME="/OTA_HEL"
Answer: 1
Send command with 2 answers: AT+FTPGETPATH="/"
Answer: 1
Send command with 2 answers: AT+FTPSIZE
Answer: 1
Size in FTP: 16894
Return from readDataFTP: 1
ftp_size: 16894
ftp_retries: 2
file size SD: 16894
Send command with 2 answers: AT+SAPBR=0,1
Answer: 1
UPGRADE.TXT    45
OTA_HEL        16894
E#
**************************
---Config APN v23 internal
APN: internet.movistar.com.co
LOGIN: movistar
PASSWORD: movistar
**************************
REPROGRAMMING ERROR
Program version: 10
Debug mode 1

This is the code For the OTA:

Code: Select all

#include <WaspGPRS_Pro.h>
int answer, counter;

char apn[]      = "internet.movistar.com.co";
char login[]    = "movistar";
char password[] = "movistar";

char FTP_address[]    = "pruebas.libelium.com";
char FTP_port[]       = "21";
char FTP_user_name[]  = "t3g@libelium.com";
char FTP_password[]   = "ftp1234";

void setup(){
    Utils.setProgramVersion(10);
    USB.println(F("**************************"));
    // 1. sets operator parameters
    GPRS_Pro.set_APN(apn, login, password);
    // And shows them
    GPRS_Pro.show_APN();
    USB.println(F("**************************"));
    
    Utils.setAuthKey("LIBELIUM");
    Utils.setID("WASPMOTE00000001");
  
    //Check if the program has been programmed succesfully
    answer = Utils.checkNewProgram();    
    switch(answer)
    {
        case 0:
            USB.println(F("REPROGRAMMING ERROR"));
            break;    
        case  1:
            USB.println(F("REPROGRAMMING OK"));
            break;    
        default:
            USB.println(F("RESTARTING"));
    }
    USB.print(F("Program version: "));
    USB.println(Utils.getProgramVersion(), DEC);
}

void loop(){
    //Starts the GPRS_Pro module
    answer = GPRS_Pro.ON();
    
    //Checks the start sequence: 1 for correct start and -3 for correct start with low battery level
    if ((answer == 1) || (answer == -3))
    {
        USB.println(F("GPRS_Pro module ready..."));
        USB.println(F("Connecting to the network")); 
        
        answer = GPRS_Pro.check(60);
        
        if (answer == 1)
        {              
            USB.println(F("GPRS_Pro module connected to the network")); 
            USB.println(F("Starting OTA process")); 
            
            answer = GPRS_Pro.requestOTA(FTP_address, FTP_port, FTP_user_name, FTP_password);
            
            // If OTA process fails, show the error code
            USB.print(F("Error code:"));
            USB.println( answer, DEC);
        }
        else
        {
            USB.println(F("Error connecting to the network"));                
        }
    }
    else
    {
        USB.println(F("Error starting the GPRS_Pro module"));        
    }
        
    GPRS_Pro.OFF();
}
This is the code in the server (To be uploaded during the OTA process)

Code: Select all

#include <WaspGPRS_Pro.h>
int answer, counter;

void setup(){
    Utils.setProgramVersion(11);
    //Check if the program has been programmed succesfully
    answer = Utils.checkNewProgram();    
    switch(answer)
    {
        case 0:
            USB.println(F("REPROGRAMMING ERROR"));
            break;    
        case  1:
            USB.println(F("REPROGRAMMING OK"));
            break;    
        default:
            USB.println(F("RESTARTING"));
    }
    USB.print(F("Program version: "));
    USB.println(Utils.getProgramVersion(), DEC);
}

void loop(){
    // put your main code here, to run repeatedly:
    USB.println("Hello im Alive!!!!");
    delay(3000);
}

agualdron
Posts: 19
Joined: Mon Apr 18, 2016 7:07 pm

Re: OTA 3G REPROGRAMMING ERROR

Post by agualdron » Thu Jun 23, 2016 2:11 am

Hello,

I did some other test, to undestand whats going on...

I tryed this code:

Code: Select all

void setup(){
    USB.print(F("Program version: \n"));
    USB.println(Utils.getProgramVersion(), DEC);
    
    USB.print(F("Boot version: \n"));
    USB.println(Utils.getBootVersion(), DEC);
    
    USB.print(F("Program ID: \n"));
    Utils.getProgramID(buffer);
    USB.println(buffer);
    
    USB.print(F("Mote ID: \n"));
    Utils.getProgramID(buffer);
    USB.println(buffer);

	// Buffer OTA
	USB.println("\n\nBuffer OTA:\n");
    for (int k=0; k<32; k++)
    {
		USB.print(Utils.readEEPROM((k+2)));
	}
	// Current ID
	USB.println("\n\nCurrent ID:\n");
	for (int k=0; k<32; k++)
    {
		USB.println((unsigned char)Utils.readEEPROM((k+34)), DEC);
	}
	
	USB.println("\n\nCurrent ID Backup:\n");
	for (int k=0; k<32; k++)
    {
		USB.println((unsigned char)Utils.readEEPROM((k+66)), DEC);
	}
    
    //Check if the program has been programmed succesfully    
    answer = Utils.checkNewProgram();    
    switch(answer)
    {
        case 0:
            USB.println(F("REPROGRAMMING ERROR"));
            break;    
        case  1:
            USB.println(F("REPROGRAMMING OK"));
            break;    
        default:
            USB.println(F("RESTARTING"));
    }
    USB.print(F("Program version: "));
    USB.println(Utils.getProgramVersion(), DEC);
    
    USB.println(F("**************************"));
    // 1. sets operator parameters
    GPRS_Pro.set_APN(apn, login, password);
    // And shows them
    GPRS_Pro.show_APN();
    USB.println(F("**************************"));
    
    Utils.setAuthKey("LIBELIUM");
    Utils.setID("WASPMOTE00000001");
    
    // put your setup code here, to run once:
    
}
And this was the result:

Code: Select all

E#
Program version: 
10
Boot version: 
69
Program ID: 
OTA_HEL
Mote ID: 
OTA_HEL


Buffer OTA:

OTA_HEL*************************

Current ID:

10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10


Current ID Backup:

10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
RESTARTING
Program version: 10
**************************
---Config APN v23 internal
APN: internet.movistar.com.co
LOGIN: movistar
PASSWORD: movistar
**************************

The ID (address +34) seems to be always d10 ('LF'), and that could be reason I always read 10 from the readProgramVersion function. Is it ok? do you think it is related with OTA problem? How can I fix this?

Hope we can fix the OTA problem...

Thank you

agualdron
Posts: 19
Joined: Mon Apr 18, 2016 7:07 pm

Re: OTA 3G REPROGRAMMING ERROR

Post by agualdron » Fri Jun 24, 2016 6:06 pm

Finilly it works...


I forgot (but is not evident from the OTAP guide) to format the SD with the SD Format example before attempting to do OTA.

After formatting the SD, the requestOTA worked as expected.

I'm still using GPRS, later I will try 3G again.

Hope this help other users.

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: OTA 3G REPROGRAMMING ERROR

Post by libelium-dev » Mon Jun 27, 2016 8:56 am

Glad to hear finally works!

Please don't hesitate to ask if you have more problem with 3g.

Regards

MaticS
Posts: 119
Joined: Mon Jun 02, 2014 11:31 am

Re: OTA 3G REPROGRAMMING ERROR

Post by MaticS » Thu Sep 22, 2016 5:29 pm

Hi libelium-dev, I have a silly question. We tested "just in case" the over the air update for 2 times in a row.

The 1st time, update worked. The 2nd time, it did not.
We can see that the UPGRADE.TXT and the OTA image downloaded well, as they are on the SD card. File sizes and names fit.

We had identical sketch for the 3 times (initial upload, first OTA, second OTA), just one variable - the version - was changed in the sketch.

So we flashed a sketch and had it running for a few days.
Then we compiled identical sketch with version +1, created UPGRADE.TXT, and uploaded both files to FTP.
Then we triggered OTA. It worked. New version was on the node.
Then we just changed the variable which holds the version in the sketch, and changed version for +1 in UPGRADE.TXT, and uploaded both files to server.
Then we did OTA. The OTA downloaded both files and rebooted the node after a while.
It didn't change the version in sketch (so new sketch didn't install), neither give any error.
Then we erased an SD card, to make sure no files are on SD card.
Then we triggered OTA again.
The OTA started, downloaded both files, and rebooted.
There was still an old version of image, but both files (UPGRADE.TXT and OTA file) were on SD card, so they were downloaded successfully.

Any suggestions what may be the case? Does OTA have any registers that get filled after it's executed, and preventing 2nd run of OTA with the same named files or something like that?

Thanks!

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: OTA 3G REPROGRAMMING ERROR

Post by libelium-dev » Fri Sep 23, 2016 2:52 pm

Hi Matic,

Could you share the code of your tests?

Regards

MaticS
Posts: 119
Joined: Mon Jun 02, 2014 11:31 am

Re: OTA 3G REPROGRAMMING ERROR

Post by MaticS » Tue Sep 27, 2016 9:03 am

Hi libelium-dev,

we resolved the issue by trying. We are using a standard OTA procedure.

So, to sum up the issue from before:
Node flash worked
Node update 1 worked
Node update 2 didn't work.


What we did between Node update 1 and Node update 2 was changing the file on the server and changing the version in the UPGRADE.TXT. The filename stayed the same, as we understand from the documentation should be the case.
But finally, we were trying things and found out that we necessarily had to change the file name as well (not just version in UPGRADE.TXT). When we changed the file name, also the 2nd update did work.

As I understand, this is a bit contrary to the OTAP documentation which says on the page 45 that
VERSION: identifies the program version. It must be defined as a 1-unsigned-byte number (range: from 0 to 255). This label must be used by the user so as to validate new program versions when the file name specified in FILE does not change. Thus, Waspmote will know if the same program has changed its version and if it is necessary to download it or not.
Either we don't get it well, either there is an issue in the actual implementation? The Waspmote did download the new version, but didn't flash it. But when we changed the file name, both download and flash did happen.

Best regards,
Matic

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: OTA 3G REPROGRAMMING ERROR

Post by libelium-dev » Tue Sep 27, 2016 3:05 pm

Hi,

Glad to hear you solved the issue! We will do some tests to check it.

Thank you for sharing your solution, it will help other users if they have the same problem.

Regards.

MaticS
Posts: 119
Joined: Mon Jun 02, 2014 11:31 am

Re: OTA 3G REPROGRAMMING ERROR

Post by MaticS » Wed Sep 28, 2016 10:42 am

Hi, no prob. Looking forwards!

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: OTA 3G REPROGRAMMING ERROR

Post by libelium-dev » Wed Sep 28, 2016 4:54 pm

Hi,

We did some tests following the same procedure as you. We uploaded UPGRADE.TXT with version +1, without changing the name of the compiled file. OTA worked properly.

In order to see if the issue is in your server setting, you can test with our FTP server
pruebas.libelium.com
user: t3g@libelium.com
port: 21
pass: ftp1234
Regards

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest