Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Allow compressed flash updates#6820

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
earlephilhower merged 6 commits intoesp8266:masterfromearlephilhower:eboot-to-O2
Dec 18, 2019

Conversation

@earlephilhower
Copy link
Collaborator

As part of the compressed OTA image work, we will need to be able to
build the bootloader using -O2 to minimize code size for the
decompressor.

It was as -O0 which does no code optimization whatsoever because there
was a bit of quasi-assembly that was optimized out with any other
setting. Building uzlib with -O0 is probably a bad thing and will wind
up much larger than with -O2.

Rewrite the jump-to-app code in pure ASM to avoid the optimization
issue.

Add -Wall and clean up warnings it generates.

Remove call to esptool-ck and generation of unused eboot.bin application
image since it is not used by the Arduino core.

d-a-v, pfeerick, and mcspr reacted with rocket emoji
@earlephilhowerearlephilhowerforce-pushed theeboot-to-O2 branch 2 times, most recently from8ebe220 to83adc5dCompareNovember 26, 2019 01:33
@earlephilhowerearlephilhower changed the titleWIP - Allow eboot to be built with -O2, clean up warningsWIP - Allow compressed flash updatesNov 26, 2019
@earlephilhower
Copy link
CollaboratorAuthor

This PR can now automatically decompress GZIP'd .BIN files and run them.

Prior versions had an incorrectly low code size due to me forgetting to set the "use gzip" flag. D'oh.

Real memory usage is 0xee0, leaving ~260 bytes free in the 4K sector.

objdump -t eboot.elf  | sort -k100000000 l    d  .comment00000000 .comment00000000 l    d  .debug_abbrev00000000 .debug_abbrev00000000 l    d  .debug_aranges00000000 .debug_aranges00000000 l    d  .debug_frame00000000 .debug_frame00000000 l    d  .debug_info00000000 .debug_info00000000 l    d  .debug_line00000000 .debug_line00000000 l    d  .debug_loc00000000 .debug_loc00000000 l    d  .debug_ranges00000000 .debug_ranges00000000 l    d  .debug_str00000000 .debug_str00000000 l    df *ABS*00000000 eboot.c00000000 l    df *ABS*00000000 eboot_command.c00000000 l    df *ABS*00000000 tinfgzip.c00000000 l    df *ABS*00000000 tinflate.c00000000 l    d  .xtensa.info00000000 .xtensa.info00000110 g       *ABS*00000000 _memmap_cacheattr_wb_base00000110 g       *ABS*00000000 _memmap_cacheattr_wt_base00000220 g       *ABS*00000000 _memmap_cacheattr_bp_base22222112 g       *ABS*00000000 _memmap_cacheattr_wb_allvalid22222112 g       *ABS*00000000 _memmap_cacheattr_wt_allvalid2222211f g       *ABS*00000000 _memmap_cacheattr_wba_trapnull2222211f g       *ABS*00000000 _memmap_cacheattr_wbna_trapnull2222211f g       *ABS*00000000 _memmap_cacheattr_wb_trapnull2222211f g       *ABS*00000000 _memmap_cacheattr_wt_trapnull22222222 g       *ABS*00000000 _memmap_cacheattr_bp_allvalid2222222f g       *ABS*00000000 _memmap_cacheattr_bp_trapnull3ff00000 g       *ABS*00000000 _dport0_data_end3ff00000 g       *ABS*00000000 _dport0_data_start3ff00000 g       *ABS*00000000 _dport0_literal_end3ff00000 g       *ABS*00000000 _dport0_literal_start3ff00000 g       *ABS*00000000 _dport0_rodata_end3ff00000 g       *ABS*00000000 _dport0_rodata_start3ffe8000 g     O .data00008000 gzip_dict3ffe8000 l    d  .data00000000 .data3fff0000 g     O .data00001000 uzlib_flash_read_cb_buff3fff1000 g     O .data00000004 uzlib_flash_read_cb_addr3fff1004 g     O .data0000001e length_bits3fff1024 g     O .data00000013 clcidx3fff1038 g     O .data0000003c length_base3fff1074 g     O .data0000001e dist_bits3fff1094 g     O .data0000003c dist_base3fff10d0 g       *ABS*00000000 _heap_start400024cc g       *ABS*00000000 ets_printf40002be8 g       *ABS*00000000 ets_putc40002fa0 g       *ABS*00000000 ets_wdt_enable400030f0 g       *ABS*00000000 ets_wdt_disable40004a00 g       *ABS*00000000 SPIEraseSector40004a4c g       *ABS*00000000 SPIWrite40004b1c g       *ABS*00000000 SPIRead4000dc88 g       *ABS*00000000 __divsi34010f000 g       *ABS*00000000 _text_start4010f000 g       .text00000000 _stext4010f000 l    d  .text00000000 .text4010f090 g     F .text0000003f uzlib_flash_read_cb4010f0d0 g     F .text00000041 print_version4010f114 g     F .text000000ad load_app_from_flash_raw4010f1c4 g     F .text00000312 copy_raw4010f4d8 g     F .text000000fe main4010f5d8 g     F .text00000041 crc_update4010f61c g     F .text00000052 eboot_command_read4010f670 g     F .text00000014 eboot_command_clear4010f684 l     F .text0000008d tinf_build_bits_base4010f714 l     F .text00000033 tinf_getbit4010f748 l     F .text00000047 tinf_read_bits4010f790 l     F .text0000005e tinf_decode_symbol4010f7f0 l     F .text0000013b tinf_decode_trees4010f92c g     F .text0000009f uzlib_init4010f9cc g     F .text0000033c uzlib_uncompress4010fd08 g     F .text0000002c tinf_get_uint164010fd34 g     F .text000000b6 uzlib_gzip_parse_header4010fdec l     F .text0000007b tinf_build_tree4010fe68 g     F .text00000041 uzlib_get_byte4010feac g     F .text0000001a uzlib_uncompress_init4010fec6 g       *ABS*00000000 _text_end4010fec6 g       .text00000000 _etext4010fec8 g       *ABS*00000000 _data_end4010fec8 g       *ABS*00000000 _data_start4010fec8 g       *ABS*00000000 _rodata_start4010fed1 g       *ABS*00000000 __XT_EXCEPTION_DESCS__4010fed1 g       *ABS*00000000 __XT_EXCEPTION_DESCS_END__4010fed1 g       *ABS*00000000 __XT_EXCEPTION_TABLE__4010fed4 g       *ABS*00000000 _bss_table_start4010fedc g       *ABS*00000000 _bss_table_end4010fedc g       *ABS*00000000 _rodata_end4010fee0 g       *ABS*00000000 _bss_end4010fee0 g       *ABS*00000000 _bss_start4010fee0 g       *ABS*00000000 _lit4_end4010fee0 g       *ABS*00000000 _lit4_start40240000 g       *ABS*00000000 _irom0_text_end40240000 g       *ABS*00000000 _irom0_text_starteboot.elf:     file format elf32-littlefffff00f g       *ABS*00000000 _memmap_cacheattr_unused_maskfffff11f g       *ABS*00000000 _memmap_cacheattr_wb_strictfffff11f g       *ABS*00000000 _memmap_cacheattr_wt_strictfffff22f g       *ABS*00000000 _memmap_cacheattr_bp_strictSYMBOL TABLE:

@earlephilhowerearlephilhower changed the titleWIP - Allow compressed flash updatesAllow compressed flash updatesNov 27, 2019
Modified the bootloader to be able to take stored updates in compressedGZIP format (i.e. the output of "gzip -9 xxx.bin") and decompress themon-the-fly to their final destination.  This can work for apps and forfilesystems (when used with the 2-step update option).Allow eboot to be built using -Os/2 optimizations by fixing some portionswhich failed when any optimizations were used.  Add -Wall and use dataand function sections to reduce size.  Use -Os to minimize size.Remove obsolete esptool-ck calls to build a .ROM image, we don't use it.Move all uninitted variables to RAM from IRAM, allowing 8-bit access.Hook in@d-a-v and@pfalcon's uzlib port to actually do thedecompression.  Do not use any CRC checking which saves space.  Since wehave overwritten all of flash by the time we know id the CRC matches,there's nothing we could have done anyway.Adjust the Updater class to support GZIP files and not attempt to patchthem.Bootloader builds to 0xd90 out of 0xfff bytes.
@earlephilhower
Copy link
CollaboratorAuthor

Fixes#6614

Copy link
Collaborator

@d-a-vd-a-v left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This gives a 🚀 bright future 🚀 for esp8285 and more generally 1M or 2M setups

I tested with the ESP8266HttpUpdate library (with the below changes) and it works very well.

Thanks alot@earlephilhower !

--- a/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp+++ b/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp@@ -370,7 +370,7 @@ HTTPUpdateResultESP8266HTTPUpdate::handleUpdate(HTTPClient& http,const String&                     }// check for valid first magic byte-if(buf[0] !=0xE9) {+if(buf[0] !=0xE9 && buf[0] !=0x1f) {DEBUG_HTTP_UPDATE("[httpUpdate] Magic header does not start with 0xE9\n");_setLastError(HTTP_UE_BIN_VERIFY_HEADER_FAILED);                         http.end();@@ -378,14 +378,16 @@ HTTPUpdateResultESP8266HTTPUpdate::handleUpdate(HTTPClient& http,const String&                      } -uint32_t bin_flash_size = ESP.magicFlashChipSize((buf[3] &0xf0) >>4);+if (buf[0] ==0xe9) {+uint32_t bin_flash_size = ESP.magicFlashChipSize((buf[3] &0xf0) >>4); -// check if new bin fits to SPI flash-if(bin_flash_size > ESP.getFlashChipRealSize()) {-DEBUG_HTTP_UPDATE("[httpUpdate] New binary does not fit SPI Flash size\n");-_setLastError(HTTP_UE_BIN_FOR_WRONG_FLASH);-                        http.end();-return HTTP_UPDATE_FAILED;+// check if new bin fits to SPI flash+if(bin_flash_size > ESP.getFlashChipRealSize()) {+DEBUG_HTTP_UPDATE("[httpUpdate] New binary does not fit SPI Flash size\n");+_setLastError(HTTP_UE_BIN_FOR_WRONG_FLASH);+                            http.end();+return HTTP_UPDATE_FAILED;+                        }                     }                 }if(runUpdate(*tcp, len, http.header("x-MD5"), command)) {

@earlephilhower
Copy link
CollaboratorAuthor

Thanks,@d-a-v. I tried the httpupdateserver, not the httpupdate path and I'll be sure to include your patch in the next push.

@TD-er
Copy link
Contributor

Just curious, how should the bin be compressed in order to be uncompressed with this bootloader?
Any specific gzip flags needed?

@earlephilhower
Copy link
CollaboratorAuthor

It should be able to parse any valid gzip file. I just usegzip sketch.elf.binand upload thesketch.elf.bin.gz file.-9 might make sense since every byte counts and images are <16MB by definition.

For now, because there are some self-test failures with@d-a-v's esp8266branch (whose cool new features we don't actually use in eboot now)start with pfalcon's 2.9 release and add the 2 patches (clcidx to codefrom IRAM/RODATA, and the Windows test file renaming) needed to buildand run successfully.
@csgregg
Copy link

Are there any working examples of compressed for file system update (LittleFS) OTA using ESP8266httpUpdate? I can't seem to find any.
I can successfully OTA update a compressed program image but it fails with a compressed file system image.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@d-a-vd-a-vd-a-v approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@earlephilhower@TD-er@csgregg@d-a-v

[8]ページ先頭

©2009-2025 Movatter.jp