Skip to content

Commit

Permalink
0.9.0 ready for stability testing before 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HomeACcessoryKid committed Dec 23, 2018
1 parent 7c28563 commit 84e640b
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 76 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.17 > versions/latest-pre-release
mkdir versions/0.1.17v
cp versions/certs.sector versions/0.1.17v
echo -n 0.9.0 > versions/latest-pre-release
mkdir versions/0.9.0v
cp versions/certs.sector* versions/0.9.0v
```
#set local.mk to the ota-main program
```
make -j6 rebuild OTAVERSION=0.1.17
mv firmware/otamain.bin versions/0.1.17v
make -j6 rebuild OTAVERSION=0.9.0
mv firmware/otamain.bin versions/0.9.0v
```
#set local.mk back to ota-boot program
```
make -j6 rebuild OTAVERSION=0.1.17
mv firmware/otaboot.bin versions/0.1.17v
make -j6 rebuild OTAVERSION=0.1.17 OTABETA=1
cp firmware/otaboot.bin versions/0.1.17v/otabootbeta.bin
make -j6 rebuild OTAVERSION=0.9.0
mv firmware/otaboot.bin versions/0.9.0v
make -j6 rebuild OTAVERSION=0.9.0 OTABETA=1
cp firmware/otaboot.bin versions/0.9.0v/otabootbeta.bin
```

#remove the older versions files

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

#upload the file versions/latest-pre-release to the 'latest release' assets on github
Expand Down
24 changes: 12 additions & 12 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* use local.mk to turn it into the LCM otamain.bin app or the otaboot.bin app
*/

#include <stdlib.h> //for UDPLOG and free
#include <stdlib.h> //for UDPLGP and free
#include <stdio.h>
#include <esp/uart.h>
#include <esp8266.h>
Expand Down Expand Up @@ -33,7 +33,7 @@ void ota_task(void *arg) {
int keyid,foundkey=0;
char keyname[KEYNAMELEN];

if (ota_boot()) UDPLOG("OTABOOT "); else UDPLOG("OTAMAIN ");
if (ota_boot()) UDPLGP("OTABOOT "); else UDPLGP("OTAMAIN ");
UDPLGP("VERSION: %s\n",OTAVERSION); //including the compile time makes comparing binaries impossible, so don't

ota_init();
Expand All @@ -50,7 +50,7 @@ void ota_task(void *arg) {

if (!ota_get_privkey()) { //have private key
have_private_key=1;
UDPLOG("have private key\n");
UDPLGP("have private key\n");
if (ota_verify_pubkey()) ota_sign(active_cert_sector,file_size, &signature, "pub-1.key");//use this (old) privkey to sign the (new) pubkey
}

Expand All @@ -59,8 +59,8 @@ void ota_task(void *arg) {
//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)
UDPLOG("--- entering the loop\n");
//UDPLOG("%d\n",sdk_system_get_time()/1000);
UDPLGP("--- entering the loop\n");
//UDPLGP("%d\n",sdk_system_get_time()/1000);
//need for a protection against an electricity outage recovery storm
vTaskDelay(holdoff_time*(1000/portTICK_PERIOD_MS));
holdoff_time*=HOLDOFF_MULTIPLIER; holdoff_time=(holdoff_time<HOLDOFF_MAX) ? holdoff_time : HOLDOFF_MAX;
Expand Down Expand Up @@ -147,12 +147,12 @@ void ota_task(void *arg) {
}
} //now file is here for sure and matches hash
//when switching to LCM we need to introduce the latest public key as used by LCM
ota_get_file(LCMREPO,lcm_version,CERTFILE,backup_cert_sector);
ota_get_pubkey(backup_cert_sector);
//ota_get_file(LCMREPO,lcm_version,CERTFILE,backup_cert_sector);
//ota_get_pubkey(backup_cert_sector);
if (ota_verify_signature(&signature)) continue; //this should never happen
ota_temp_boot(); //launches the ota software in bootsector 1
} else { //running ota-main software now
UDPLOG("--- running ota-main software\n");
UDPLGP("--- running ota-main software\n");
//if there is a newer version of ota-main...
if (ota_compare(ota_version,OTAVERSION)>0) { //set OTAVERSION when running make and match with github
ota_get_hash(OTAREPO, ota_version, BOOTFILE, &signature);
Expand All @@ -166,7 +166,7 @@ void ota_task(void *arg) {
if (new_version) free(new_version);
new_version=ota_get_version(user_repo);
if (ota_compare(new_version,user_version)>0) { //can only upgrade
UDPLOG("user_repo=\'%s\' new_version=\'%s\' user_file=\'%s\'\n",user_repo,new_version,user_file);
UDPLGP("user_repo=\'%s\' new_version=\'%s\' user_file=\'%s\'\n",user_repo,new_version,user_file);
ota_get_hash(user_repo, new_version, user_file, &signature);
file_size=ota_get_file(user_repo,new_version,user_file,BOOT0SECTOR);
if (file_size<=0 || ota_verify_hash(BOOT0SECTOR,&signature)) continue; //something went wrong, but now boot0 is broken so start over
Expand All @@ -184,14 +184,14 @@ void ota_task(void *arg) {
void on_wifi_ready() {
xTaskCreate(udplog_send, "logsend", 256, NULL, 4, NULL);
xTaskCreate(ota_task,"ota",4096,NULL,1,NULL);
UDPLOG("wifiready-done\n");
UDPLGP("wifiready-done\n");
}

void user_init(void) {
UDPLOG("\n\n\n\n\n\n\nuser-init-start\n");
UDPLGP("\n\n\n\n\n\n\nuser-init-start\n");
// uart_set_baud(0, 74880);
uart_set_baud(0, 115200);

wifi_config_init("LCM", NULL, on_wifi_ready); //expanded it with setting repo-details
UDPLOG("user-init-done\n");
UDPLGP("user-init-done\n");
}
Loading

0 comments on commit 84e640b

Please sign in to comment.