Skip to content

Commit

Permalink
0.1.14 fix otabeta=0 bug, now for real and log tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
HomeACcessoryKid committed Dec 22, 2018
1 parent a883a2e commit 5ad47a8
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 41 deletions.
29 changes: 15 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.13 > versions/latest-pre-release
mkdir versions/0.1.13v
cp versions/certs.sector versions/0.1.13v
echo -n 0.1.14 > versions/latest-pre-release
mkdir versions/0.1.14v
cp versions/certs.sector versions/0.1.14v
```
#set local.mk to the ota-main program
```
make -j6 rebuild OTAVERSION=0.1.13
mv firmware/otamain.bin versions/0.1.13v
make -j6 rebuild OTAVERSION=0.1.14
mv firmware/otamain.bin versions/0.1.14v
```
#set local.mk back to ota-boot program
```
make -j6 rebuild OTAVERSION=0.1.13
mv firmware/otaboot.bin versions/0.1.13v
make -j6 rebuild OTAVERSION=0.1.13 OTABETA=1
cp firmware/otaboot.bin versions/0.1.13v/otabootbeta.bin
make -j6 rebuild OTAVERSION=0.1.14
mv firmware/otaboot.bin versions/0.1.14v
make -j6 rebuild OTAVERSION=0.1.14 OTABETA=1
cp firmware/otaboot.bin versions/0.1.14v/otabootbeta.bin
```

#remove the older versions files

#commit this as version 0.1.13
#set up a new github release 0.1.13 as a pre-release using the just commited master...
#commit this as version 0.1.14
#set up a new github release 0.1.14 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,14 +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.13 OTABETA=1
make flash OTAVERSION=0.1.14 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.13v/otamain.bin
xxd versions/0.1.13v/otamain.bin.sig
openssl sha384 versions/0.1.14v/otamain.bin
xxd versions/0.1.14v/otamain.bin.sig
```

#upload the file versions/latest-pre-release to the 'latest release' assets on github
Expand Down
2 changes: 1 addition & 1 deletion esp-wifi-config
1 change: 0 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ void ota_task(void *arg) {

if (ota_boot()) ota_write_status("0.0.0"); //we will have to get user code from scratch if running ota_boot
if ( !ota_load_user_app(&user_repo, &user_version, &user_file)) { //repo/version/file must be configured
UDPLOG("user_repo=\'%s\' user_version=\'%s\' user_file=\'%s\'\n",user_repo,user_version,user_file);
//new_version=ota_get_version(user_repo); //consider that if here version is equal, we end it already
//if (!ota_compare(new_version,user_version)) { //allows a denial of update so not doing it for now
for (;;) { //escape from this loop by continue (try again) or break (boots into slot 0)
Expand Down
49 changes: 25 additions & 24 deletions ota.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ int ota_get_pubkey(int sector) { //get the ecdsa key from the indicated sector,
if (buffer[20]!=0x03 || buffer[21]!=0x62 || buffer[22]!=0x00) return -2; //not a valid keyformat
length=97;

int idx; for (idx=0;idx<length;idx++) UDPLOG(" %02x",buffer[idx+23]);
int idx; for (idx=0;idx<length;idx++) printf(" %02x",buffer[idx+23]);
wc_ecc_init(&pubecckey);
ret=wc_ecc_import_x963_ex(buffer+23,length,&pubecckey,ECC_SECP384R1);
UDPLOG("\nret: %d\n",ret);
printf("\nret: %d\n",ret);

if (!ret)return PKEYSIZE; else return ret;
}
Expand Down Expand Up @@ -361,7 +361,7 @@ int ota_load_user_app(char * *repo, char * *version, char * *file) {
*file=value;
} else return -1;

UDPLOG("ota_repo=\'%s\' ota_version=\'%s\' ota_file=\'%s\'\n",*repo,*version,*file);
UDPLGP("user_repo=\'%s\' user_version=\'%s\' user_file=\'%s\'\n",*repo,*version,*file);
return 0;
}

Expand Down Expand Up @@ -449,16 +449,16 @@ char* ota_get_version(char * repo) {
location=strstr(location,"tag/");
version=malloc(strlen(location+4));
strcpy(version,location+4);
UDPLGP("%s@version:\"%s\"\n",repo,version);
printf("%s@version:\"%s\"\n",repo,version);
} else {
UDPLOG("failed, return [-0x%x]\n", -ret);
UDPLGP("failed, return [-0x%x]\n", -ret);
ret=wolfSSL_get_error(ssl,ret);
UDPLOG("wolfSSL_send error = %d\n", ret);
UDPLGP("wolfSSL_send error = %d\n", ret);
}
} else {
UDPLOG("failed, return [-0x%x]\n", -ret);
UDPLGP("failed, return [-0x%x]\n", -ret);
ret=wolfSSL_get_error(ssl,ret);
UDPLOG("wolfSSL_send error = %d\n", ret);
UDPLGP("wolfSSL_send error = %d\n", ret);
}
}
switch (retc) {
Expand Down Expand Up @@ -490,7 +490,6 @@ char* ota_get_version(char * repo) {
}

UDPLGP("%s@version:\"%s\"\n",repo,version);
printf("--- end_get_version\n");
return version;
}

Expand Down Expand Up @@ -548,14 +547,14 @@ int ota_get_file_ex(char * repo, char * version, char * file, int sector, byte
location+=18; //flush Location: https://
//UDPLOG("%s\n",location);
} else {
UDPLOG("failed, return [-0x%x]\n", -ret);
printf("failed, return [-0x%x]\n", -ret);
ret=wolfSSL_get_error(ssl,ret);
UDPLOG("wolfSSL_send error = %d\n", ret);
printf("wolfSSL_send error = %d\n", ret);
}
} else {
UDPLOG("failed, return [-0x%x]\n", -ret);
printf("failed, return [-0x%x]\n", -ret);
ret=wolfSSL_get_error(ssl,ret);
UDPLOG("wolfSSL_send error = %d\n", ret);
printf("wolfSSL_send error = %d\n", ret);
}
}
switch (retc) {
Expand Down Expand Up @@ -593,11 +592,11 @@ int ota_get_file_ex(char * repo, char * version, char * file, int sector, byte
sprintf(recv_buf,"%s%d-%d%s",getlinestart,collected,collected+4095,CRLFCRLF);
send_bytes=strlen(recv_buf);
//UDPLOG("request:\n%s\n",recv_buf);
UDPLOG("send request......");
printf("send request......");
ret = wolfSSL_write(ssl, recv_buf, send_bytes);
recv_bytes=0;
if (ret > 0) {
UDPLOG("OK\n");
printf("OK\n");

header=1;
memset(recv_buf,0,RECV_BUF_LEN);
Expand All @@ -624,7 +623,7 @@ int ota_get_file_ex(char * repo, char * version, char * file, int sector, byte
recv_bytes += ret;
if (sector) { //write to flash
if (writespace<ret) {
UDPLOG("erasing@0x%05x\n", sector+collected);
printf("erasing@0x%05x\n", sector+collected);
if (!spiflash_erase_sector(sector+collected)) return -6; //erase error
writespace+=SECTORSIZE;
}
Expand All @@ -641,30 +640,32 @@ int ota_get_file_ex(char * repo, char * version, char * file, int sector, byte
}
collected+=ret;
int i;
for (i=0;i<3;i++) UDPLOG("%02x", recv_buf[i]);
UDPLOG("...");
for (i=3;i>0;i--) UDPLOG("%02x", recv_buf[ret-i]);
UDPLOG(" ");
for (i=0;i<3;i++) printf("%02x", recv_buf[i]);
printf("...");
for (i=3;i>0;i--) printf("%02x", recv_buf[ret-i]);
printf(" ");
}
} else {
if (ret) {ret=wolfSSL_get_error(ssl,ret); UDPLOG("error %d\n",ret);}
if (ret) {ret=wolfSSL_get_error(ssl,ret); printf("error %d\n",ret);}
if (!ret && collected<length) retc = ota_connect(host2, HTTPS_PORT, &socket, &ssl); //memory leak?
break;
}
header=0; //move to header section itself
} while(recv_bytes<clength);
UDPLOG(" so far collected %d bytes\n", collected);
printf(" so far collected %d bytes\n", collected);
UDPLOG("%d bytes\r", collected);
} else {
UDPLOG("failed, return [-0x%x]\n", -ret);
printf("failed, return [-0x%x]\n", -ret);
ret=wolfSSL_get_error(ssl,ret);
UDPLOG("wolfSSL_send error = %d\n", ret);
printf("wolfSSL_send error = %d\n", ret);
if (ret==-308) {
retc = ota_connect(host2, HTTPS_PORT, &socket, &ssl); //dangerous for eternal connecting? memory leak?
} else {
break; //give up?
}
}
}
UDPLOG("\n");
switch (retc) {
case 0:
case -1:
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.13
0.1.14

0 comments on commit 5ad47a8

Please sign in to comment.