Repository navigation
Conversation
copy_raw() kept its 4 KB sector buffer and the uzlib state on its stack. Addressing them there, past the reach of the stack-relative loads and stores, takes more code than addressing a global. They are now globals, as buffer2 and gzip_dict already are. Both are written before they are read, so the uncleared BSS does not matter. The sector-0 image goes from 3488 to 3280 bytes (3288 of its 4096 with elf2bin's trailer).
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
copy_raw()kept its 4 KB sector buffer and the uzlib state (about1.3 KB) on its stack. With a frame that large, the compiler needs more
instructions to address them than it needs for a global. This change makes
bufferandm_uncompglobals, likebuffer2andgzip_dict..text.rodataThe image is 208 bytes smaller. That leaves room in sector 0 for other
work, such as a copy that survives a power cut (#9354).
The 5.3 KB moves from the stack into BSS (
buffer4096 bytes,m_uncomp1284 bytes), after the 41 KB of globals that eboot already has in DRAM.
That DRAM is free while eboot runs, and the sketch reclaims it when it
starts. eboot does not clear its BSS, and does not need to: the code writes
both buffers before it reads them, as it did on the stack. Behaviour does
not change: the same code runs on the same data, now at a fixed address.
Testing
eboot.elfwas rebuilt with the toolchain thattools/get.pyinstalls,and
tests/ci/eboot_test.shpasses. In an emulator(bekensim, ESP8266
mode, booting the flash through the ROM), a sketch gave eboot an update as
Updaterdoes: a raw image (75 sectors) and two gzip images (75 sectorsfrom about 230 KB, and 160 sectors from about 490 KB, copied over their own
source). Each copy left the flash byte for byte equal to the update, and
the new sketch started. Each copy also made the same erases and programs as
master's eboot, at the same addresses and in the same order (148, 148 and
318).