diff options
author | mohamed.khadri <mohamed.khadri@lge.com> | 2015-08-06 17:36:13 -0700 |
---|---|---|
committer | Vineeta Srivastava <vsrivastava@google.com> | 2015-08-19 23:26:58 -0700 |
commit | d9beaf6a2c7833809a2464cbb7ba3f32a8a3be23 (patch) | |
tree | 6308267da500fcfa03a5ed6051ca3a9e6bbc9239 /releasetools.py | |
parent | dc7b5b6ba84cfeb98eb872a383d0c0765110eaa4 (diff) | |
download | bullhead-d9beaf6a2c7833809a2464cbb7ba3f32a8a3be23.tar.gz |
bullhead: edify script for safe updates of primary/backup partitions
- Flash backup partitions
- patch secondary pte's to swap primary/backup,enable secondary gpt
- Flash psuedo-backup partions, effectively flashing primary
- restore secondary pte's and restore primary gpt
- Flash all other non backup partitions
Change-Id: Iac7e96ebfef64911d690966471b990c67c32fb9e
Signed-off-by: Mohamed Khadri <mohamed.khadri@lge.com>
Diffstat (limited to 'releasetools.py')
-rw-r--r-- | releasetools.py | 62 |
1 files changed, 48 insertions, 14 deletions
diff --git a/releasetools.py b/releasetools.py index d19fe65..fb6291f 100644 --- a/releasetools.py +++ b/releasetools.py @@ -128,10 +128,10 @@ def WriteRadio(info, radio_img): # bullhead also has 8 backup partitions: # sbl1, tz, rpm, aboot, pmic, hyp, keymaster, cmnlib # - -release_partitions = "sbl1 tz rpm aboot sdi imgdata pmic hyp sec keymaster cmnlib" -debug_partitions = "sbl1 tz rpm aboot sdi imgdata pmic hyp sec keymaster cmnlib" -backup_partitions = "sbl1 tz rpm aboot pmic hyp keymaster cmnlib" +release_backup_partitions = "sbl1 tz rpm aboot pmic hyp keymaster cmnlib" +debug_backup_partitions = "sbl1 tz rpm aboot pmic hyp keymaster cmnlib" +release_nobackup_partitions = "sdi imgdata sec" +debug_nobackup_partitions = "sdi imgdata sec" def WriteBootloader(info, bootloader): info.script.Print("Writing bootloader...") @@ -169,13 +169,55 @@ def WriteBootloader(info, bootloader): 'package_extract_file("bootloader-flag.txt", "%s");' % (misc_device,)) + # failed sbl updates, may render the handset unusable/unrestorable. + # Hence adopt below strategy for updates,enabling restore at all times. + # 1. Flash backup partitions + # 2. patch secondary pte's to swap primary/backup, and enable secondary gpt + # 3. Flash psuedo-backup partions, effectively flashing primary partitions + # 4. restore secondary pte's and restore primary gpt + # 5. Flash all other non backup partitions + # # Depending on the build fingerprint, we can decide which partitions # to update. fp = info.info_dict["build.prop"]["ro.build.fingerprint"] if "release-keys" in fp: - to_flash = release_partitions.split() + to_bkp_flash = release_backup_partitions.split() + to_flash = release_nobackup_partitions.split() else: - to_flash = debug_partitions.split() + to_bkp_flash = debug_backup_partitions.split() + to_flash = debug_nobackup_partitions.split() + + # Write the images to separate files in the OTA package + # and flash backup partitions + for i in to_bkp_flash: + try: + _, device = common.GetTypeAndDevice("/"+i+"bak", info.info_dict) + except KeyError: + print "skipping flash of %s; not in recovery.fstab" % (i,) + continue + common.ZipWriteStr(info.output_zip, "bootloader.%s.img" % (i,), + bootloader[imgs[i][0]:imgs[i][0]+imgs[i][1]]) + + info.script.AppendExtra('package_extract_file("bootloader.%s.img", "%s");' % + (i, device)) + + target_device = info.info_dict["build.prop"]["ro.product.device"] + # swap ptes in secondary and force secondary gpt + info.script.AppendExtra("lge_"+target_device+"_update_gpt();") + + # flash again after swap, effectively flashing primary + # pte's are not re-read, hence primary is psuedo-secondary + for i in to_bkp_flash: + try: + _, device = common.GetTypeAndDevice("/"+i, info.info_dict) + except KeyError: + print "skipping flash of %s; not in recovery.fstab" % (i,) + continue + info.script.AppendExtra('package_extract_file("bootloader.%s.img", "%s");' % + (i, device)) + + # restore secondary gpt for correct mappings and enable primary gpt + info.script.AppendExtra("lge_"+target_device+"_recover_gpt();") # Write the images to separate files in the OTA package for i in to_flash: @@ -194,14 +236,6 @@ def WriteBootloader(info, bootloader): 'package_extract_file("bootloader-flag-clear.txt", "%s");' % (misc_device,)) - try: - for i in backup_partitions.split(): - _, device = common.GetTypeAndDevice("/"+i+"bak", info.info_dict) - info.script.AppendExtra( - 'package_extract_file("bootloader.%s.img", "%s");' % (i, device)) - except KeyError: - pass - def trunc_to_null(s): if '\0' in s: |