Commit graph

27 commits

Author SHA1 Message Date
Tianjie Xu
ebe39a096a Fix print error of numbers of blocks
The total number of blocks to pack as new data was printed incorrectly.
Fix printing.

Change-Id: I6a6bb8dd6682d9c57943ceb1a728995f9529e2fd
2016-01-14 19:13:21 -08:00
Tianjie Xu
bb86e1d9c2 Adjust the size limit for splitting large files
Modify the number of max blocks per transfer to reduce splitting of
large files during patch generation. This will reduce the size of
final incremental OTA updater package. In specific, the size limit
for each file to transfer is set to 1/8 cachesize instead of a fix
number.

Bug: 26472126

Change-Id: Iffb135e378c4c7a91640f2fc4c40e9e93d1fe4bb
2016-01-13 18:21:26 -08:00
Tao Bao
eba409c4da Bump up the BBOTA version to 4.
To accommodate new changes (such as error correction in [1]) to BBOTA
in N release. We bump up the version to keep the OTA script backward
compatible.

Needs the matching CL in commit
1fdec8685af858c5ff4f45d2e3059186ab5ed2ab.

[1]: commit 0a7b47397db3648afe6f3aeb2abb175934c2cbca

Change-Id: Ib9158b455cd5905fe2d4742ce81feb1b7583054f
2015-10-23 10:45:36 -07:00
Tao Bao
db08d835d0 Merge "Fix calculation of stashed blocks." 2015-10-22 18:57:42 +00:00
caozhiyuan
21b37d83eb Fix calculation of stashed blocks.
Change-Id: Ic3d607cb6691fc58e189a54a7244942cf3f3c387
Signed-off-by: caozhiyuan <cao.zhiyuan@zte.com.cn>
2015-10-22 09:57:10 +08:00
Tao Bao
4fcb77e4e3 blockimgdiff.py: Fix the script error for BBOTA v1.
CL in [1] added an assertion to make sure an empty RangeSet cannot call
RangeSet.to_raw_string(). However, we may unintentionally hit that when
generating BBOTA v1 script (e.g. for "new" commands that always have
empty src_ranges).

[1] commit e8f756137c

Change-Id: I1723606967f354ace9286d2b888fdbc80ba10e39
2015-10-21 17:03:18 -07:00
Tao Bao
b32d56ea8c releasetools: Fix the expected total blocks.
With the change in [1], it zeroes out extra blocks that might be read
by dm-verity. We should update the expected number of blocks that get
touched.

[1] commit e9b619108d.

Bug: 23786644
Change-Id: I7a7c3531e5af6bf381d3a14832e77abfa9a8efce
2015-09-09 11:56:58 -07:00
Tao Bao
42206c3f2f releasetools: Don't write empty groups.
For a DataImage, we may have no mapping of ZERO or NONZERO blocks. Don't
write those groups if they are empty.

Bug: 19024504
Change-Id: I1e921effcdbf0661d4f4b541c104dd456ac0c582
2015-09-08 14:06:08 -07:00
Tao Bao
7589e961a7 releasetools: Always write the last block if it's padded.
In BBOTAs if the last block of a DataImage is padded, we should always
write the whole block even for incremental OTAs. Because otherwise the
last block may be skipped if unchanged, but would fail the post-install
verification if it has non-zero contents in the padding bytes.

Bug: 23828506
Change-Id: I4b0af7344d18261258cd48d18c029c089d6ff365
2015-09-05 20:54:55 -07:00
Tao Bao
9a5caf2c30 Split large files for BBOTA v3.
For BBOTA v3, we need to stash source blocks to support resumable
feature. However, with the growth of file size and the shrink of the
cache size, source blocks that represent a file are too large to be
stashed as a whole. CL in [1] solves the issue by replacing the diff
command with a "new" command. However, it may increase the generated
package size substantially (e.g. from ~100MB to ~400MB).

With this CL, if a file spans too many blocks, we split it into smaller
pieces by generating multiple commands. For the same case above, it
reduces the package size to ~150MB.

One potential downside is that after splitting, files like .jar,
.apk and .zip can no longer use imgdiff. We may lose the potential
benefit of using imgdiff for patch size reduction.

[1] commit 82c47981bd

Bug: 22430577
Change-Id: I5684fab0ac41c8d94fe18f52a34cef77e06f741c
2015-08-26 10:50:11 -07:00
Tao Bao
82c47981bd Revise stash for BBOTAs when needed.
When generating incremental BBOTAs (v2 and above), we need to ensure
that the needed runtime stash is below the given threshold. If it's
running out of space on /cache, we replace the command that uses a
stash with a "new" command instead.

This may increase the OTA package size, since it is carrying more full
blocks instead of patches. It gets even worse for large files that span
a number of blocks, because currently we will store all the blocks for
the file as "new" blocks if stashing cannot be satisfied. We may further
optimize by splitting them into smaller chunks so that most of them can
still be stashed.

Bug: 22430577
Change-Id: I5a49e361adc7d3d41de2e9c08ee9b08c1e6c091a
2015-08-17 10:21:49 -07:00
Tao Bao
bb625d2099 Free the stash after its use in BBOTA v2.
In BBOTA v2, the stash size computation is inaccurate. A stash will be
used only once, so we deduct its size from stashed_blocks right after
its use. However, the stash doesn't actually get freed until being
overwritten by another stash or destroyed at the end of an update. This
leads to OTA failures due to insufficient space on /cache. This CL
changes the BBOTA v2 script to generate an explicit free right after
its use.

Bug: 23119955
Change-Id: Icdd8352bb0ff778945937c870990a888c7a4d38b
2015-08-13 14:44:38 -07:00
Tao Bao
575d68a48e Change the cache partition size check into warnings.
For some old builds, we may not define cache partition size. Change the
exception into a warning to make the script backward compatible.

Change-Id: Ie94c7fbb1a9f3a7db3f16e8d845e493a534aac5b
2015-08-07 19:49:45 -07:00
Tao Bao
8dcf738234 Assert the stash size when generating OTAs.
With block-based OTA v2 and v3, it requires stash space on the /cache
partition to back up blocks during an update. We need to ensure that
it doesn't exceed the partition size. Since there might be other files
on /cache as well, we use cache_size * threshold as the maximum allowed
size. The threshold defaults to 0.8, which can be overridden by command
line option '--stash_threshold'.

Change-Id: I5c2e353ea4716328d6cdc6a7f758520de8d88b8e
(cherry picked from commit 23ac404212)
2015-07-14 13:36:50 -07:00
Tao Bao
e9b619108d Zero out blocks that may be touched by dm-verity.
dm-verity may touch some blocks that are not in the care_map due to
block device read-ahead. It will fail if such blocks contain
non-zeroes. As a workaround, we mark them as extended blocks and
zero out explicitly to avoid dm-verity failures.

Bug: 20881595
Change-Id: Id097138bfd065c84eac088b3ad49758010b2927b
(cherry picked from commit 2fd2c9bfd6)
2015-07-10 13:50:24 -07:00
Tao Bao
68658c0f4f Add post-install verification for BBOTAs
Similar to the assertations in file-based OTA, we perform verification
for block-based OTAs (BBOTAs) after updating a partition, for both of
the incremental and full OTAs. It increases the update time (~20s on
Nexus 6), but will capture unnoticed errors right away.

Bug: 21500869
Change-Id: I89ac8fe623b855721b7affd07cf9426a23433ab0
2015-06-01 15:00:30 -07:00
Tao Bao
ff7778166b Add support for clobbered blocks
In ext4 filesystems, some blocks might be changed even being mounted
R/O, such as the superblock (block 0). We need to exclude such blocks
from integrity verification. Plus such blocks should always be
written to the target by copying instead of patching.

Bug: http://b/20939131
Change-Id: I991169ec307dfb231b2fe8908a0668595ecb2060
2015-05-13 11:19:39 -07:00
Sami Tolvanen
29f529f33e Calculate max_stashed_blocks correctly for block OTA v3
The updater automatically stashes overlapping source blocks to
make it possible to resume if the command performing the update
is interrupted. However, blockimgdiff.py does not take this into
account and therefore, max_stashed_blocks indicates only the
number of explicitly stashed blocks. Change blockimgdiff.py to
correctly calculate the maximum used stash space, including any
automatically stashed blocks.

Bug: 20309033
Change-Id: Ibf5cb1abc38c54e60a6ad3ce4cbce43556b08ac2
2015-04-17 16:28:08 +01:00
Dan Albert
8b72aefb5a Make releasetools pylint clean.
This caught a few bugs/syntax errors (a few character classes were not
escaped properly in regex patterns, some indentation was illegal,
etc).

Change-Id: I50637607524e68c4fb9cad7167f58a46b8d26b2c
2015-03-24 11:05:16 -07:00
Tao Bao
b8c8717191 Make the generated OTAs repeatable
The generated OTAs are supposed to be repeatable. The use of dict in
blockimgdiff.py breaks the assumption for block-based OTAs. Fixed by
using OrderedDict instead.

Change-Id: I945bdc879912ba174ca330c152b1f8fc7ed211ac
2015-03-19 19:42:12 -07:00
Jesse Zhao
7b985f6aed Fix the error that free_string is not defined.
Change-Id: I7490a91ea930daaf194dad0c8b3a3357558b4770
Bug:19573713
(cherry picked from commit 7ca20d1a1c)
2015-03-11 17:22:43 +00:00
Sami Tolvanen
dd67a295cc Change transfer list format to include block hashes
Add source and target block hashes as parameters to transfer list
commands that copy or patch data to a partition. This allows the
updater to verify the status of each command in the transfer list
and makes resuming block based OTAs possible. Due to the changes,
update the transfer list version to 3.

Needs matching changes from
  I1e752464134aeb2d396946348e6041acabe13942

Bug: 18262110
Change-Id: Ia5c56379f570047f10f0aa7373a1025439495c98
(cherry picked from commit cac671a9d1)
2015-03-11 17:22:06 +00:00
Doug Zongker
e985f6f4d8 fix transfer list for full OTAs
The erase command we insert at the top for full OTAs was getting
inserted in the wrong place for version 2.

Change-Id: I9caf03a40efbdba79f3428f73e50d4319d9ba371
2014-09-25 16:39:45 -07:00
Doug Zongker
623381880a generate version 2 blockimgdiff files
Generate version 2 of the block_image_update transfer list format.
This improves patch size by a different strategy for dealing with
out-of-order transfers.  If transfer A must be done before transfer B
due to B overwriting A's source but we want to do B before A, we
resolve the conflict by:

  - before B is executed, we save ("stash") the overlapping region (ie
    the blocks B will overwrite that A wants to read)

  - when A is executed, it will read those parts of source data from
    the stash rather than from the image.

This reverses the ordering constraint; with these additions now B
*must* go before A.  The implementation of the stash is left up to the
code that executes the transfer list to apply the patch; it could hold
stashed data in RAM or on a scratch disk such as /cache, if available.

The code retains the ability to build a version 1 block image patch;
it's needed for processing older target-files.

Change-Id: Ia9aa0bd45d5dc3ef7c5835e483b1b2ead10135fe
2014-09-25 16:39:14 -07:00
Doug Zongker
424296a4e8 add missing AOSP copyright notices
Change-Id: Idc812db30b259a55702f8728197f957f2d24d978
2014-09-02 08:53:09 -07:00
Doug Zongker
ab7ca1d286 refactor BlockDifference into common
Move BlockDifference into common and make its script generation code
more complete, so that it can be use by releasetools.py to do diffs on
baseband images.

Bug: 16984795
Change-Id: Iba9afc1c7755458ce47468b5170672612b2cb4b3
2014-08-26 13:12:11 -07:00
Doug Zongker
fc44a515d4 new block OTA system tools
Replace the xdelta/xz-based block OTA generation with a new system
based on the existing bsdiff/imgdiff tools.

Bug: 16984795
Change-Id: Ia9732516ffdfc12be86260b2cc4b1dd2d210e886
2014-08-26 13:10:25 -07:00