blob: dba721e452e67d8a3f85fec86e70c7dd06761a35 [file] [log] [blame]
jessica421370d2012-09-21 17:03:38 -07001# 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
18import common
19
20def 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:
jessica5a1ed802012-10-10 15:00:28 -070029 radio_img = info.input_zip.read("RADIO/radio.raw")
jessica421370d2012-09-21 17:03:38 -070030 except KeyError:
jessica5a1ed802012-10-10 15:00:28 -070031 print "no radio.raw in target_files; skipping install"
jessica421370d2012-09-21 17:03:38 -070032 else:
33 WriteRadio(info, radio_img)
34
35
36def IncrementalOTA_InstallEnd(info):
37 try:
38 target_bootloader_bin = info.target_zip.read("RADIO/bootloader.raw")
39 try:
40 source_bootloader_bin = info.source_zip.read("RADIO/bootloader.raw")
41 except KeyError:
42 source_bootloader_bin = None
43
44 if source_bootloader_bin == target_bootloader_bin:
45 print "bootloader unchanged; skipping"
46 else:
47 WriteBootloader(info, target_bootloader_bin)
48 except KeyError:
49 print "no bootloader.raw in target target_files; skipping install"
50
51 try:
jessica5a1ed802012-10-10 15:00:28 -070052 target_radio_img = info.target_zip.read("RADIO/radio.raw")
jessica421370d2012-09-21 17:03:38 -070053 try:
jessica5a1ed802012-10-10 15:00:28 -070054 source_radio_img = info.source_zip.read("RADIO/radio.raw")
jessica421370d2012-09-21 17:03:38 -070055 except KeyError:
56 source_radio_img = None
57
58 if source_radio_img == target_radio_img:
59 print "radio image unchanged; skipping"
60 else:
61 WriteRadio(info, target_radio_img)
62 except KeyError:
jessica5a1ed802012-10-10 15:00:28 -070063 print "no radio.raw in target_files; skipping install"
jessica421370d2012-09-21 17:03:38 -070064
65
66def WriteBootloader(info, bootloader_bin):
67 common.ZipWriteStr(info.output_zip, "bootloader.raw", bootloader_bin)
68 fstab = info.info_dict["fstab"]
69
70 info.script.Print("Writing bootloader...")
71
72 info.script.AppendExtra('''package_extract_file("bootloader.raw", "%s");''' %
73 (fstab["/staging"].device,))
74
75def WriteRadio(info, radio_img):
jessica5a1ed802012-10-10 15:00:28 -070076 common.ZipWriteStr(info.output_zip, "radio.raw", radio_img)
jessica421370d2012-09-21 17:03:38 -070077 fstab = info.info_dict["fstab"]
78
79 info.script.Print("Writing radio...")
jessica5a1ed802012-10-10 15:00:28 -070080
81 info.script.AppendExtra("""assert(package_extract_file("radio.raw", "%s"),
82 mount("ext4", "EMMC", "%s", "/radio"),
83 bach.update_modem("/radio/SAM_6260_ALL.fls"),
84 unmount("/radio"));""" %
85 (fstab["/radio"].device, fstab["/radio"].device))