jessica | 421370d | 2012-09-21 17:03:38 -0700 | [diff] [blame] | 1 | # Copyright (C) 2012 The Android Open Source Project |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | """Emit extra commands needed for Group during OTA installation |
| 16 | (installing the bootloader).""" |
| 17 | |
| 18 | import common |
| 19 | |
| 20 | def FullOTA_InstallEnd(info): |
| 21 | try: |
| 22 | bootloader_bin = info.input_zip.read("RADIO/bootloader.raw") |
| 23 | except KeyError: |
| 24 | print "no bootloader.raw in target_files; skipping install" |
| 25 | else: |
| 26 | WriteBootloader(info, bootloader_bin) |
| 27 | |
| 28 | try: |
jessica | 5a1ed80 | 2012-10-10 15:00:28 -0700 | [diff] [blame] | 29 | radio_img = info.input_zip.read("RADIO/radio.raw") |
jessica | 421370d | 2012-09-21 17:03:38 -0700 | [diff] [blame] | 30 | except KeyError: |
jessica | 5a1ed80 | 2012-10-10 15:00:28 -0700 | [diff] [blame] | 31 | print "no radio.raw in target_files; skipping install" |
jessica | 421370d | 2012-09-21 17:03:38 -0700 | [diff] [blame] | 32 | else: |
| 33 | WriteRadio(info, radio_img) |
| 34 | |
JP Abgrall | 2f96dbf | 2014-11-25 15:32:50 -0800 | [diff] [blame] | 35 | def IncrementalOTA_InstallBegin(info): |
| 36 | info.script.Unmount("/system") |
| 37 | info.script.TunePartition("/system", "-O", "^has_journal") |
| 38 | info.script.Mount("/system") |
jessica | 421370d | 2012-09-21 17:03:38 -0700 | [diff] [blame] | 39 | |
| 40 | def IncrementalOTA_InstallEnd(info): |
| 41 | try: |
| 42 | target_bootloader_bin = info.target_zip.read("RADIO/bootloader.raw") |
| 43 | try: |
| 44 | source_bootloader_bin = info.source_zip.read("RADIO/bootloader.raw") |
| 45 | except KeyError: |
| 46 | source_bootloader_bin = None |
| 47 | |
| 48 | if source_bootloader_bin == target_bootloader_bin: |
| 49 | print "bootloader unchanged; skipping" |
| 50 | else: |
| 51 | WriteBootloader(info, target_bootloader_bin) |
| 52 | except KeyError: |
| 53 | print "no bootloader.raw in target target_files; skipping install" |
| 54 | |
| 55 | try: |
jessica | 5a1ed80 | 2012-10-10 15:00:28 -0700 | [diff] [blame] | 56 | target_radio_img = info.target_zip.read("RADIO/radio.raw") |
jessica | 421370d | 2012-09-21 17:03:38 -0700 | [diff] [blame] | 57 | try: |
jessica | 5a1ed80 | 2012-10-10 15:00:28 -0700 | [diff] [blame] | 58 | source_radio_img = info.source_zip.read("RADIO/radio.raw") |
jessica | 421370d | 2012-09-21 17:03:38 -0700 | [diff] [blame] | 59 | except KeyError: |
| 60 | source_radio_img = None |
| 61 | |
| 62 | if source_radio_img == target_radio_img: |
| 63 | print "radio image unchanged; skipping" |
| 64 | else: |
| 65 | WriteRadio(info, target_radio_img) |
| 66 | except KeyError: |
jessica | 5a1ed80 | 2012-10-10 15:00:28 -0700 | [diff] [blame] | 67 | print "no radio.raw in target_files; skipping install" |
jessica | 421370d | 2012-09-21 17:03:38 -0700 | [diff] [blame] | 68 | |
| 69 | |
| 70 | def WriteBootloader(info, bootloader_bin): |
| 71 | common.ZipWriteStr(info.output_zip, "bootloader.raw", bootloader_bin) |
| 72 | fstab = info.info_dict["fstab"] |
| 73 | |
| 74 | info.script.Print("Writing bootloader...") |
| 75 | |
| 76 | info.script.AppendExtra('''package_extract_file("bootloader.raw", "%s");''' % |
| 77 | (fstab["/staging"].device,)) |
| 78 | |
| 79 | def WriteRadio(info, radio_img): |
jessica | 5a1ed80 | 2012-10-10 15:00:28 -0700 | [diff] [blame] | 80 | common.ZipWriteStr(info.output_zip, "radio.raw", radio_img) |
jessica | 421370d | 2012-09-21 17:03:38 -0700 | [diff] [blame] | 81 | fstab = info.info_dict["fstab"] |
| 82 | |
| 83 | info.script.Print("Writing radio...") |
jessica | 5a1ed80 | 2012-10-10 15:00:28 -0700 | [diff] [blame] | 84 | |
| 85 | info.script.AppendExtra("""assert(package_extract_file("radio.raw", "%s"), |
| 86 | mount("ext4", "EMMC", "%s", "/radio"), |
| 87 | bach.update_modem("/radio/SAM_6260_ALL.fls"), |
| 88 | unmount("/radio"));""" % |
| 89 | (fstab["/radio"].device, fstab["/radio"].device)) |