• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2015 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"""Add extra commands needed for firmwares update during OTA."""
16
17import common
18
19def FullOTA_InstallEnd(info):
20  # copy the data into the package.
21  try:
22    bootloader_img = info.input_zip.read("RADIO/bootloader.img")
23    ec_img = info.input_zip.read("RADIO/ec.bin")
24  except KeyError:
25    print "no firmware images in target_files; skipping install"
26    return
27  # copy the data into the package.
28  common.ZipWriteStr(info.output_zip, "bootloader.img", bootloader_img)
29  common.ZipWriteStr(info.output_zip, "ec.bin", ec_img)
30
31  # emit the script code to trigger the firmware updater on the device
32  info.script.AppendExtra(
33    """dragon.firmware_update(package_extract_file("bootloader.img"), package_extract_file("ec.bin"));""")
34
35def IncrementalOTA_InstallEnd(info):
36  try:
37    target_bootloader_img = info.target_zip.read("RADIO/bootloader.img")
38    target_ec_img = info.target_zip.read("RADIO/ec.bin")
39  except KeyError:
40    print "no firmware images in target target_files; skipping install"
41    return
42
43  # copy the data into the package irrespective of source and target versions.
44  # If previous OTA missed a firmware update, we can try that again on the next
45  # OTA.
46  common.ZipWriteStr(info.output_zip, "bootloader.img", target_bootloader_img)
47  common.ZipWriteStr(info.output_zip, "ec.bin", target_ec_img)
48
49  # emit the script code to trigger the firmware updater on the device
50  info.script.AppendExtra(
51    """dragon.firmware_update(package_extract_file("bootloader.img"), package_extract_file("ec.bin"));""")
52