Skip to content

Commit

Permalink
0.1.11 introduced 'latest-pre-release' concept
Browse files Browse the repository at this point in the history
  • Loading branch information
HomeACcessoryKid committed Dec 15, 2018
1 parent b220d62 commit c85af54
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 14 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ ifdef OTAVERSION
EXTRA_CFLAGS += -DOTAVERSION=\"$(OTAVERSION)\"
endif

ifdef OTABETA
EXTRA_CFLAGS += -DOTABETA
endif

include $(SDK_PATH)/common.mk

monitor:
Expand Down
35 changes: 23 additions & 12 deletions deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,43 @@ cd life-cycle-manager
```
#initial steps to be expanded

mkdir versions/0.1.10v
cp versions/certs.sector versions/0.1.10v
#create/update a file versions/latest-pre-release with this version, but no new-line
mkdir versions/0.1.11v
cp versions/certs.sector versions/0.1.11v
#set local.mk to the ota-main program
make -j6 rebuild OTAVERSION=0.1.10
mv firmware/otamain.bin versions/0.1.10v
make -j6 rebuild OTAVERSION=0.1.11
mv firmware/otamain.bin versions/0.1.11v
#set local.mk back to ota-boot program
make -j6 rebuild OTAVERSION=0.1.10
cp firmware/otaboot.bin versions/0.1.10v
make -j6 rebuild OTAVERSION=0.1.11
mv firmware/otaboot.bin versions/0.1.11v
make -j6 rebuild OTAVERSION=0.1.11 OTABETA=1
cp firmware/otaboot.bin versions/0.1.11v/otabootbeta.bin

#remove the older versions files

#commit this as version 0.1.10
#set up a new github release 0.1.10 as a pre-release using the just commited master...
#commit this as version 0.1.11
#set up a new github release 0.1.11 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
```
esptool.py -p /dev/cu.usbserial-* --baud 230400 erase_flash
esptool.py -p /dev/cu.usbserial-* --baud 230400 write_flash 0xf5000 privatekey.der
```
#upload the ota-boot program to the device that contains the private key
make flash OTAVERSION=0.1.10
#upload the ota-boot BETA program to the device that contains the private key
make flash OTAVERSION=0.1.11 OTABETA=1
#power cycle to prevent the bug for software reset after flash
#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.10v/otamain.bin
xxd versions/0.1.10v/otamain.bin.sig
openssl sha384 versions/0.1.11v/otamain.bin
xxd versions/0.1.11v/otamain.bin.sig

#upload the file versions/latest-pre-release to the 'latest release' assets on github

#test the release with several devices that have the beta flag set
#if bugs are found, leave this release at pre-release and start a new version

#if the results are 100% stable
#make the release a production release on github
#remove the private key
```
Expand Down
2 changes: 1 addition & 1 deletion esp-wifi-config
30 changes: 29 additions & 1 deletion ota.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,21 @@ void MyLoggingCallback(const int logLevel, const char* const logMessage) {
}
#endif

bool userbeta=0;
bool otabeta=0;

void ota_init() {
UDPLGP("--- ota_init\n");

//using beta = pre-releases?
#ifdef OTABETA
sysparam_set_bool("ota_self-use_pre-release", 1);
#endif
sysparam_get_bool("ota_self-use_pre-release", &otabeta);
sysparam_get_bool("ota_use_pre-release", &userbeta);

UDPLGP("userbeta=\'%d\' otabeta=\'%d\'\n",userbeta,otabeta);

//rboot setup
rboot_config conf;
conf=rboot_get_config();
Expand Down Expand Up @@ -396,10 +408,12 @@ void ota_set_verify(int onoff) {
printf("--- end_set_verify...\n");
}

int ota_get_file_ex(char * repo, char * version, char * file, int sector, byte * buffer, int bufsz); //prototype needed
char* ota_get_version(char * repo) {
UDPLGP("--- ota_get_version\n");

char* version=NULL;
char prerelease[64];
int retc, ret=0;
WOLFSSL* ssl;
int socket;
Expand Down Expand Up @@ -434,7 +448,7 @@ char* ota_get_version(char * repo) {
location=strstr(location,"tag/");
version=malloc(strlen(location+4));
strcpy(version,location+4);
UDPLOG("%s@version:\"%s\"\n",repo,version);
UDPLGP("%s@version:\"%s\"\n",repo,version);
} else {
UDPLOG("failed, return [-0x%x]\n", -ret);
ret=wolfSSL_get_error(ssl,ret);
Expand All @@ -461,6 +475,20 @@ char* ota_get_version(char * repo) {
// if (ret <= 0) return ret;

if (ota_boot() && ota_compare(version,OTAVERSION)<0) strcpy(version,OTAVERSION);

//find latest-pre-release if joined beta program
if ( (userbeta && strcmp(OTAREPO,repo)) || (otabeta && !strcmp(OTAREPO,repo)) ) {
prerelease[63]=0;
ret=ota_get_file_ex(repo,version,"latest-pre-release",0,(byte *)prerelease,63);
if (ret>0) {
prerelease[ret]=0;
free(version);
version=malloc(strlen(prerelease)+1);
strcpy(version,prerelease);
}
}

UDPLGP("%s@version:\"%s\"\n",repo,version);
printf("--- end_get_version\n");
return version;
}
Expand Down
File renamed without changes.
Binary file not shown.
Binary file added versions/0.1.11v/otabootbeta.bin
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions versions/latest-pre-release
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.11

0 comments on commit c85af54

Please sign in to comment.