Skip to content

Commit

Permalink
0.1.16 test with ota-repo switchover routine and log tuning
Browse files Browse the repository at this point in the history
continuation from 0.1.15
  • Loading branch information
HomeACcessoryKid committed Dec 22, 2018
1 parent 4d7b998 commit 153d35c
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 27 deletions.
28 changes: 14 additions & 14 deletions deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ cd life-cycle-manager

#create/update the file versions/latest-pre-release but no new-line
```
echo -n 0.1.15 > versions/latest-pre-release
mkdir versions/0.1.15v
cp versions/certs.sector versions/0.1.15v
echo -n 0.1.16 > versions/latest-pre-release
mkdir versions/0.1.16v
cp versions/certs.sector versions/0.1.16v
```
#set local.mk to the ota-main program
```
make -j6 rebuild OTAVERSION=0.1.15
mv firmware/otamain.bin versions/0.1.15v
make -j6 rebuild OTAVERSION=0.1.16
mv firmware/otamain.bin versions/0.1.16v
```
#set local.mk back to ota-boot program
```
make -j6 rebuild OTAVERSION=0.1.15
mv firmware/otaboot.bin versions/0.1.15v
make -j6 rebuild OTAVERSION=0.1.15 OTABETA=1
cp firmware/otaboot.bin versions/0.1.15v/otabootbeta.bin
make -j6 rebuild OTAVERSION=0.1.16
mv firmware/otaboot.bin versions/0.1.16v
make -j6 rebuild OTAVERSION=0.1.16 OTABETA=1
cp firmware/otaboot.bin versions/0.1.16v/otabootbeta.bin
```

#remove the older versions files

#commit this as version 0.1.15
#set up a new github release 0.1.15 as a pre-release using the just commited master...
#commit this as version 0.1.16
#set up a new github release 0.1.16 as a pre-release using the just commited master...
#upload the certs and binaries to the pre-release assets on github

#erase the flash and upload the privatekey
Expand All @@ -41,15 +41,15 @@ esptool.py -p /dev/cu.usbserial-* --baud 230400 write_flash 0xf5000 privatekey.d
```
#upload the ota-boot BETA program to the device that contains the private key
```
make flash OTAVERSION=0.1.15 OTABETA=1
make flash OTAVERSION=0.1.16 OTABETA=1
```
#power cycle to prevent the bug for software reset after flash
#setup wifi and select the ota-demo repo without pre-release checkbox
#create the 3 signature files next to the bin file and upload to github one by one
#verify the hashes on the computer
```
openssl sha384 versions/0.1.15v/otamain.bin
xxd versions/0.1.15v/otamain.bin.sig
openssl sha384 versions/0.1.16v/otamain.bin
xxd versions/0.1.16v/otamain.bin.sig
```

#upload the file versions/latest-pre-release to the 'latest release' assets on github
Expand Down
1 change: 1 addition & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ void ota_task(void *arg) {
ota_finalize_file(active_cert_sector);
}
UDPLGP("active_cert_sector: 0x%05x\n",active_cert_sector);
ota_get_pubkey(active_cert_sector); //TODO test if this works multiple times and remove after test
file_size=ota_get_pubkey(active_cert_sector);

if (!ota_get_privkey()) { //have private key
Expand Down
24 changes: 12 additions & 12 deletions ota.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,18 +234,18 @@ int ota_compare(char* newv, char* oldv) { //(if equal,0) (if newer,1) (if pre-re
strncpy(old,oldv,MAXVERSIONLEN-1);
if ((dot=strchr(new,'.'))) {dot[0]=0; valuen=atoi(new); new=dot+1;}
if ((dot=strchr(old,'.'))) {dot[0]=0; valueo=atoi(old); old=dot+1;}
UDPLOG("%d-%d,%s-%s\n",valuen,valueo,new,old);
printf("%d-%d,%s-%s\n",valuen,valueo,new,old);
if (valuen>valueo) result=1;
if (valuen<valueo) result=-1;
valuen=valueo=0;
if ((dot=strchr(new,'.'))) {dot[0]=0; valuen=atoi(new); new=dot+1;}
if ((dot=strchr(old,'.'))) {dot[0]=0; valueo=atoi(old); old=dot+1;}
UDPLOG("%d-%d,%s-%s\n",valuen,valueo,new,old);
printf("%d-%d,%s-%s\n",valuen,valueo,new,old);
if (valuen>valueo) result=1;
if (valuen<valueo) result=-1;
valuen=atoi(new);
valueo=atoi(old);
UDPLOG("%d-%d\n",valuen,valueo);
printf("%d-%d\n",valuen,valueo);
if (valuen>valueo) result=1;
if (valuen<valueo) result=-1;
} //they are equal
Expand All @@ -254,7 +254,7 @@ int ota_compare(char* newv, char* oldv) { //(if equal,0) (if newer,1) (if pre-re
}

static int ota_connect(char* host, int port, int *socket, WOLFSSL** ssl) {
UDPLGP("--- ota_connect LocalPort=");
UDPLGP("--- ota_connect LocalPort=");
int ret;
int delay=1;
ip_addr_t target_ip;
Expand Down Expand Up @@ -289,7 +289,7 @@ static int ota_connect(char* host, int port, int *socket, WOLFSSL** ssl) {
return -3;
}

UDPLGP("local...");
UDPLGP("local..");
memset(&sock_addr, 0, sizeof(sock_addr));
sock_addr.sin_family = AF_INET;
sock_addr.sin_addr.s_addr = 0;
Expand All @@ -302,7 +302,7 @@ static int ota_connect(char* host, int port, int *socket, WOLFSSL** ssl) {
}
UDPLGP("OK ");

UDPLGP("remote...");
UDPLGP("remote..");
memset(&sock_addr, 0, sizeof(sock_addr));
sock_addr.sin_family = AF_INET;
sock_addr.sin_addr.s_addr = target_ip.addr;
Expand All @@ -314,7 +314,7 @@ static int ota_connect(char* host, int port, int *socket, WOLFSSL** ssl) {
}
UDPLGP("OK ");

UDPLGP("SSL...");
UDPLGP("SSL..");
*ssl = wolfSSL_new(ctx);
if (!*ssl) {
printf(FAILED);
Expand All @@ -329,7 +329,7 @@ static int ota_connect(char* host, int port, int *socket, WOLFSSL** ssl) {
if (verify) ret=wolfSSL_check_domain_name(*ssl, host);
//wolfSSL_Debugging_OFF();

UDPLGP("to %s port %d...", host, port);
UDPLGP("to %s port %d..", host, port);
ret = wolfSSL_connect(*ssl);
if (ret != SSL_SUCCESS) {
printf("failed, return [-0x%x]\n", -ret);
Expand Down Expand Up @@ -434,7 +434,7 @@ char* ota_get_version(char * repo) {
UDPLGP("%s",recv_buf);
ret = wolfSSL_write(ssl, recv_buf, send_bytes);
if (ret > 0) {
UDPLGP("sent OK\n");
printf("sent OK\n");

//wolfSSL_shutdown(ssl); //by shutting down the connection before even reading, we reduce the payload to the minimum
ret = wolfSSL_peek(ssl, recv_buf, RECV_BUF_LEN - 1);
Expand Down Expand Up @@ -586,7 +586,6 @@ int ota_get_file_ex(char * repo, char * version, char * file, int sector, byte
strcpy(getlinestart,location);
//UDPLOG("request:\n%s\n",getlinestart);
//if (!retc) {
UDPLGP("Collecting %d bytes\n",length);
while (collected<length) {
sprintf(recv_buf,"%s%d-%d%s",getlinestart,collected,collected+4095,CRLFCRLF);
send_bytes=strlen(recv_buf);
Expand Down Expand Up @@ -617,12 +616,13 @@ int ota_get_file_ex(char * repo, char * version, char * file, int sector, byte
location+=21; //flush Content-Range: bytes //
location=strstr(location,"/"); location++; //flush /
length=atoi(location);
UDPLGP("start@ 0x%5x collecting %6d bytes\n",sector,length);
//verify if last bytes are crlfcrlf else header=1
} else {
recv_bytes += ret;
if (sector) { //write to flash
if (writespace<ret) {
printf("erasing@0x%05x\n", sector+collected);
printf("erasing@0x%05x>", sector+collected);
if (!spiflash_erase_sector(sector+collected)) return -6; //erase error
writespace+=SECTORSIZE;
}
Expand Down Expand Up @@ -652,7 +652,7 @@ int ota_get_file_ex(char * repo, char * version, char * file, int sector, byte
header=0; //move to header section itself
} while(recv_bytes<clength);
printf(" so far collected %d bytes\n", collected);
UDPLOG("\rerased %x collected %d bytes", sector+collected, collected);
UDPLOG("\rerased 0x%5x collected %6d bytes", sector+collected, collected);
} else {
printf("failed, return [-0x%x]\n", -ret);
ret=wolfSSL_get_error(ssl,ret);
Expand Down
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion versions/latest-pre-release
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.15
0.1.16

0 comments on commit 153d35c

Please sign in to comment.