Skip to content

Commit d129476

Browse files
Add documentation for compressed OTA, fix bug
Fixes #6923 Documents the user steps needed to do a compressed upload, and notes the 2-step process needed for deploying compressed uploads to the field for the first time. Fixes a bug in serial output formatting discovered by @AdrianEddy. Adds additional contributors for uzlib, per @pfalcon.
1 parent 1d0bc5e commit d129476

File tree

4 files changed

+36
-5
lines changed

4 files changed

+36
-5
lines changed

Diff for: README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,11 @@ ESP8266 core files are licensed under LGPL.
124124

125125
[LittleFS](https://github.com/ARMmbed/littlefs) library written by ARM Limited and released under the [BSD 3-clause license](https://github.com/ARMmbed/littlefs/blob/master/LICENSE.md).
126126

127-
[uzlib](https://github.com/pfalcon/uzlib) library written and (c) 2014-2018 Paul Sokolovsky, licensed under the ZLib license (https://www.zlib.net/zlib_license.html).
127+
[uzlib](https://github.com/pfalcon/uzlib) library written and (c) 2014-2018 Paul Sokolovsky, licensed under the ZLib license (https://www.zlib.net/zlib_license.html). uzlib is based on:
128+
* tinf library by Joergen Ibsen (Deflate decompression)
129+
* Deflate Static Huffman tree routines by Simon Tatham
130+
* LZ77 compressor by Paul Sokolovsky
131+
* Library integrated and maintained by Paul Sokolovsky.
128132

129133
### Other useful links ###
130134

Diff for: bootloaders/eboot/eboot.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ int print_version(const uint32_t flash_addr)
2727
if (SPIRead(flash_addr + APP_START_OFFSET + sizeof(image_header_t) + sizeof(section_header_t), &ver, sizeof(ver))) {
2828
return 1;
2929
}
30-
char fmt[16];
30+
char fmt[7];
3131
fmt[0] = 'v';
3232
fmt[1] = '%';
3333
fmt[2] = '0';
3434
fmt[3] = '8';
3535
fmt[4] = 'x';
3636
fmt[5] = '\n';
37-
fmt[6] = '0';
37+
fmt[6] = 0;
3838
ets_printf((const char*) fmt, ver);
3939
return 0;
4040
}

Diff for: bootloaders/eboot/eboot.elf

-36 Bytes
Binary file not shown.

Diff for: doc/ota_updates/readme.rst

+29-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ Compile the sketch normally and, once a `.bin` file is available, sign it using
123123

124124
.. code:: bash
125125
126-
<ESP8266ArduioPath>/tools/signing.py --mode sign --privatekey <path-to-private.key> --bin <path-to-unsigned-bin> --out <path-to-signed-binary>
126+
<ESP8266ArduinoPath>/tools/signing.py --mode sign --privatekey <path-to-private.key> --bin <path-to-unsigned-bin> --out <path-to-signed-binary>
127127
128128
Old And New Signature Formats
129129
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -134,7 +134,34 @@ To create a legacy signature, call the signing script with --legacy:
134134

135135
.. code:: bash
136136
137-
<ESP8266ArduioPath>/tools/signing.py --mode sign --privatekey <path-to-private.key> --bin <path-to-unsigned-bin> --out <path-to-signed-binary> --legacy <path-to-legacy-file>
137+
<ESP8266ArduinoPath>/tools/signing.py --mode sign --privatekey <path-to-private.key> --bin <path-to-unsigned-bin> --out <path-to-signed-binary> --legacy <path-to-legacy-file>
138+
139+
140+
Compression
141+
-----------
142+
143+
The eboot bootloader incorporates a GZIP decompressor, built for very low code requirements. For applications, this optional decompression is completely transparent. For uploading compressed filesystems, the application must be built with `ATOMIC_FS_UPDATE` defined because, otherwise, eboot will not be involved in writing the filesystem.
144+
145+
No changes to the application are required. The `Updater` class and `eboot` bootloader (which performs actual application overwriting on update) automatically search for the `gzip` header in the uploaded binary, and if found, handle it.
146+
147+
Compress an application `.bin` file or filesystem package using any `gzip` available, at any desired compression level (`gzip -9` is recommended because it provides the maximum compression and uncompresses as fast as any other compressino level). For example:
148+
149+
.. code:: bash
150+
151+
gzip -9 sketch.bin # Maximum compression, output sketch.bin.gz
152+
<Upload the resultant sketch.bin.gz>
153+
154+
If signing is desired, sign the gzip compressed file *after* compression.
155+
156+
.. code:: bash
157+
158+
gzip -9 sketch.bin
159+
<ESP8266ArduinoPath>/tools/signing.py --mode sign --privatekey <path-to-private.key> --bin sketch.bin.gz --out sketch.bin.gz.signed
160+
161+
Updating apps in the field to support compression
162+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
163+
164+
If you have applications deployed in the field and wish to update them to support compressed OTA uploads, you will need to first recompile the application, then _upload the uncompressed `.bin` file once_. Attempting to upload a `gzip` compressed binary to a legacy app will result in the Updater rejecting the upload as it does not understand the `gzip` format. After this initial upload, which will include the new bootloader and `Updater` class with compression support, compressed updates can then be used.
138165

139166

140167
Safety

0 commit comments

Comments
 (0)