Skip to content

Commit bff6b52

Browse files
2.2.6 overclocking and fix in version string processing
- overclock in ota_set_verify=ON fixes tighter timeout applied by GitHub - version string malloc was 1 byte short - keyid now uint16_t
1 parent 1d87872 commit bff6b52

File tree

12 files changed

+53
-28
lines changed

12 files changed

+53
-28
lines changed

Changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 2.2.6 overclocking and fix in version string processing
4+
- overclock in ota_set_verify=ON fixes tighter timeout applied by GitHub
5+
- version string malloc was 1 byte short
6+
- keyid now uint16_t
7+
38
## 2.2.5 updated certificates to be identical across all versions
49
- contains DigiCertGlobalRootCA and DigiCertHighAssuranceEVRootCA
510
- EC support put back in place

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Life-Cycle-Manager (LCM)
22
Initial install, WiFi settings and over the air firmware upgrades for any esp-open-rtos repository on GitHub
3-
(c) 2018-2022 HomeAccessoryKid
3+
(c) 2018-2024 HomeAccessoryKid
4+
5+
## Update December 2023
6+
It looks like GitHub has put a 10s timeout on their TLS stack.
7+
When verifying the server certificate, we take >15s and the server finishes the connection.
8+
Version 2.2.6 tries to fix this by using overclock during this phase.
49

510
## Update season 16 April 2022
611
After 14 months, version 2.1.2 will get upgraded to version 2.2.5. So be aware your own app update will take extra long.

deploy.md

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(c) 2018-2022 HomeAccessoryKid
1+
(c) 2018-2024 HomeAccessoryKid
22

33
### Instructions for end users:
44
TBD
@@ -10,33 +10,42 @@ cd life-cycle-manager
1010
- initial steps to be expanded
1111

1212
#### These are the steps if not introducing a new key pair
13-
- create/update the file versions1/latest-pre-release without new-line and setup 2.2.5 version folder
13+
- create/update the file versions1/latest-pre-release without new-line and setup 2.2.6 version folder
1414
```
15-
mkdir versions1/2.2.5v
16-
echo -n 2.2.5 > versions1/2.2.5v/latest-pre-release
17-
cp versions1/certs.sector versions1/certs.sector.sig versions1/2.2.5v
18-
cp versions1/public*key* versions1/2.2.5v
15+
mkdir versions1/2.2.6v
16+
echo -n 2.2.6 > versions1/2.2.6v/latest-pre-release
17+
cp versions1/certs.sector versions1/certs.sector.sig versions1/2.2.6v
18+
cp versions1/public*key* versions1/2.2.6v
1919
```
2020
- set local.mk to the ota-main program
2121
```
22-
make -j6 rebuild OTAVERSION=2.2.5
23-
mv firmware/otamain.bin versions1/2.2.5v
22+
make -j6 rebuild OTAVERSION=2.2.6
23+
mv firmware/otamain.bin versions1/2.2.6v
2424
```
2525
- set local.mk back to ota-boot program
2626
```
27-
make -j6 rebuild OTAVERSION=2.2.5
28-
mv firmware/otaboot.bin versions1/2.2.5v
29-
make -j6 rebuild OTAVERSION=2.2.5 OTABETA=1
30-
cp firmware/otaboot.bin versions1/2.2.5v/otabootbeta.bin
27+
make -j6 rebuild OTAVERSION=2.2.6
28+
mv firmware/otaboot.bin versions1/2.2.6v
29+
make -j6 rebuild OTAVERSION=2.2.6 OTABETA=1
30+
cp firmware/otaboot.bin versions1/2.2.6v/otabootbeta.bin
3131
```
3232
- remove the older version files
3333
#
3434
- update Changelog
3535
- if you can sign the binaries locally, do so, else follow later steps
36+
```
37+
~/bin/ecc_signer otaboot.bin ../secp384r1prv.der ../secp384r1pub.der
38+
printf "%08x" `cat otaboot.bin | wc -c`| xxd -r -p > len
39+
cat hash len sign > otaboot.bin.sig
40+
~/bin/ecc_signer otamain.bin ../secp384r1prv.der ../secp384r1pub.der
41+
printf "%08x" `cat otamain.bin | wc -c`| xxd -r -p > len
42+
cat hash len sign > otamain.bin.sig
43+
rm hash len sign
44+
```
3645
- test otaboot for basic behaviour
3746
- commit and sync submodules
38-
- commit and sync this as version 2.2.5
39-
- set up a new github release 2.2.5 as a pre-release using the just commited master...
47+
- commit and sync this as version 2.2.6
48+
- set up a new github release 2.2.6 as a pre-release using the just commited master...
4049
- upload the certs and binaries to the pre-release assets on github
4150
#
4251
- erase the flash and upload the privatekey
@@ -46,18 +55,18 @@ esptool.py -p /dev/cu.usbserial-* --baud 230400 write_flash 0xf9000 versions1-pr
4655
```
4756
- upload the ota-boot BETA program to the device that contains the private key
4857
```
49-
make flash OTAVERSION=2.2.5 OTABETA=1
58+
make flash OTAVERSION=2.2.6 OTABETA=1
5059
```
5160
- power cycle to prevent the bug for software reset after flash
5261
- setup wifi and select the ota-demo repo without pre-release checkbox
5362
- create the 2 signature files next to the bin file and upload to github one by one
5463
- verify the hashes on the computer
5564
```
56-
openssl sha384 versions1/2.2.5v/otamain.bin
57-
xxd versions1/2.2.5v/otamain.bin.sig
65+
openssl sha384 versions1/2.2.6v/otamain.bin
66+
xxd versions1/2.2.6v/otamain.bin.sig
5867
```
5968

60-
- upload the file versions1/2.2.5v/latest-pre-release to the 'latest release' assets on github
69+
- upload the file versions1/2.2.6v/latest-pre-release to the 'latest release' assets on github
6170

6271
#### Testing
6372

@@ -110,14 +119,14 @@ esptool.py -p /dev/cu.usbserial-* --baud 230400 write_flash 0xf9000 versionsN-1-
110119
```
111120
- collect public-1.key.sig and store it in the new version folder and copy it to versions1
112121
```
113-
cp versions1/2.2.5v/public-1.key.sig versions1
122+
cp versions1/2.2.6v/public-1.key.sig versions1
114123
```
115124
- then flash the new private key
116125
```
117126
esptool.py -p /dev/cu.usbserial-* --baud 230400 write_flash 0xf9000 versions1-privatekey.der
118127
```
119128
- collect cert.sector.sig and store it in the new version folder and copy it to versions1
120129
```
121-
cp versions1/2.2.5v/certs.sector.sig versions1
130+
cp versions1/2.2.6v/certs.sector.sig versions1
122131
```
123132
- continue with a normal deployment to create the 2 signature files next to the bin files

main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ void ota_task(void *arg) {
3535
#ifdef OTABOOT
3636
int have_private_key=0;
3737
#endif
38-
int keyid,foundkey=0;
38+
uint16_t keyid;
39+
int foundkey=0;
3940
char keyname[KEYNAMELEN];
4041

4142
ota_init();

ota.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222

2323
#include <udplogger.h>
2424

25+
#include <FreeRTOS.h>
26+
#include <esplibs/libmain.h> //for overclocking functions
27+
2528
static int verify = 1;
2629
static byte file_first_byte[]={0xff};
2730
ecc_key prvecckey;
@@ -582,12 +585,14 @@ void ota_set_verify(int onoff) {
582585
UDPLGP("TIME: %s", ctime(&ts)); //we need to have the clock right to check certificates
583586

584587
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, NULL);
588+
sdk_system_overclock(); //With verification, we are to slow for the 10s timeout of GitHub (end 2023)
585589
}
586590
} else {
587591
UDPLGP("OFF\n");
588592
if (verify==1) {
589593
verify= 0;
590594
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL);
595+
sdk_system_restoreclock();
591596
}
592597
}
593598
}
@@ -619,7 +624,7 @@ char* ota_get_btl_version() {
619624

620625
spiflash_read(SECTORSIZE-MAXVERSIONLEN, (byte *)versionbuff, MAXVERSIONLEN);
621626
if (versionbuff[0]!=0xff) { //TODO: make this more error resistant
622-
version=malloc(strlen(versionbuff));
627+
version=malloc(strlen(versionbuff)+1);
623628
strcpy(version,versionbuff);
624629
} else {
625630
version=malloc(6);
@@ -696,7 +701,7 @@ char* ota_get_version(char * repo) {
696701
strchr(recv_buf,'\r')[0]=0;
697702
found_ptr=ota_strstr(recv_buf,"releases/tag/");
698703
if (found_ptr[13]=='v' || found_ptr[13]=='V') found_ptr++;
699-
version=malloc(strlen(found_ptr+13));
704+
version=malloc(strlen(found_ptr+13)+1);
700705
strcpy(version,found_ptr+13);
701706
printf("%s@version:\"%s\" according to latest release\n",repo,version);
702707
} else {
@@ -853,7 +858,7 @@ int ota_get_file_ex(char * repo, char * version, char * file, int sector, byte
853858
strcat(found_ptr, REQUESTTAIL);
854859
slash=strchr(found_ptr,'/')-found_ptr;
855860
found_ptr[slash]=0; //cut behind the hostname
856-
char * host2=malloc(strlen(found_ptr));
861+
char * host2=malloc(strlen(found_ptr)+1);
857862
strcpy(host2,found_ptr);
858863
//printf("next host: %s\n",host2);
859864

@@ -862,7 +867,7 @@ int ota_get_file_ex(char * repo, char * version, char * file, int sector, byte
862867
strcat(strcat(found_ptr+slash+1,host2),RANGE); //append hostname and range to URI
863868
found_ptr+=slash-4;
864869
memcpy(found_ptr,REQUESTHEAD,5);
865-
char * getlinestart=malloc(strlen(found_ptr));
870+
char * getlinestart=malloc(strlen(found_ptr)+1);
866871
strcpy(getlinestart,found_ptr);
867872
//printf("request:\n%s\n",getlinestart);
868873
//if (!retc) {

ota.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
#define SIGNSIZE 104 //ECDSA r+s in ASN1 format secP384r1
4343
#define PKEYSIZE 120 //size of a pub key
4444
#define KEYNAME "public-%d.key"
45-
#define KEYNAMELEN 16 //allows for 9999 keys
45+
#define KEYNAMELEN 17 //allows for 65535 keys with uint16_t
4646

4747
typedef unsigned char byte;
4848

versions1/2.2.5v/latest-pre-release

Lines changed: 0 additions & 1 deletion
This file was deleted.
File renamed without changes.

versions1/2.2.6v/latest-pre-release

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.2.6
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)