1// Copyright (C) 2021 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 15package { 16 default_applicable_licenses: ["Android-Apache-2.0"], 17} 18 19python_binary_host { 20 name: "fastboot_gen_rand", 21 visibility: [":__subpackages__"], 22 srcs: ["fastboot_gen_rand.py"], 23} 24 25genrule_defaults { 26 name: "fastboot_test_data_gen_defaults", 27 visibility: ["//system/core/fastboot"], 28 tools: [ 29 "fastboot_gen_rand", 30 ], 31} 32 33// Genrules for components of test vendor boot image. 34 35// Fake dtb image. 36genrule { 37 name: "fastboot_test_dtb", 38 defaults: ["fastboot_test_data_gen_defaults"], 39 out: ["test_dtb.img"], 40 cmd: "$(location fastboot_gen_rand) --seed dtb --length 1024 > $(out)", 41} 42 43// Fake dtb image for replacement. 44genrule { 45 name: "fastboot_test_dtb_replace", 46 defaults: ["fastboot_test_data_gen_defaults"], 47 out: ["dtb_replace.img"], 48 cmd: "$(location fastboot_gen_rand) --seed dtb --length 2048 > $(out)", 49} 50 51// Fake bootconfig image. 52genrule { 53 name: "fastboot_test_bootconfig", 54 defaults: ["fastboot_test_data_gen_defaults"], 55 out: ["test_bootconfig.img"], 56 cmd: "$(location fastboot_gen_rand) --seed bootconfig --length 1024 > $(out)", 57} 58 59// Fake vendor ramdisk with type "none". 60genrule { 61 name: "fastboot_test_vendor_ramdisk_none", 62 defaults: ["fastboot_test_data_gen_defaults"], 63 out: ["test_vendor_ramdisk_none.img"], 64 cmd: "$(location fastboot_gen_rand) --seed vendor_ramdisk_none --length 1024 > $(out)", 65} 66 67// Fake vendor ramdisk with type "platform". 68genrule { 69 name: "fastboot_test_vendor_ramdisk_platform", 70 defaults: ["fastboot_test_data_gen_defaults"], 71 out: ["test_vendor_ramdisk_platform.img"], 72 cmd: "$(location fastboot_gen_rand) --seed vendor_ramdisk_platform --length 1024 > $(out)", 73} 74 75// Fake replacement ramdisk. 76genrule { 77 name: "fastboot_test_vendor_ramdisk_replace", 78 defaults: ["fastboot_test_data_gen_defaults"], 79 out: ["test_vendor_ramdisk_replace.img"], 80 cmd: "$(location fastboot_gen_rand) --seed replace --length 3072 > $(out)", 81} 82 83// Genrules for test vendor boot images. 84 85fastboot_sign_test_image = "$(location avbtool) add_hash_footer --salt 00 --image $(out) " + 86 "--partition_name vendor_boot --partition_size $$(( 1 * 1024 * 1024 ))" 87 88genrule_defaults { 89 name: "fastboot_test_vendor_boot_gen_defaults", 90 defaults: ["fastboot_test_data_gen_defaults"], 91 tools: [ 92 "avbtool", 93 "mkbootimg", 94 ], 95} 96 97genrule { 98 name: "fastboot_test_vendor_boot_v3", 99 defaults: ["fastboot_test_vendor_boot_gen_defaults"], 100 out: ["vendor_boot_v3.img"], 101 srcs: [ 102 ":fastboot_test_dtb", 103 ":fastboot_test_vendor_ramdisk_none", 104 ], 105 cmd: "$(location mkbootimg) --header_version 3 " + 106 "--vendor_ramdisk $(location :fastboot_test_vendor_ramdisk_none) " + 107 "--dtb $(location :fastboot_test_dtb) " + 108 "--vendor_boot $(out) && " + 109 fastboot_sign_test_image, 110} 111 112genrule { 113 name: "fastboot_test_vendor_boot_v4_without_frag", 114 defaults: ["fastboot_test_vendor_boot_gen_defaults"], 115 out: ["vendor_boot_v4_without_frag.img"], 116 srcs: [ 117 ":fastboot_test_dtb", 118 ":fastboot_test_vendor_ramdisk_none", 119 ":fastboot_test_bootconfig", 120 ], 121 cmd: "$(location mkbootimg) --header_version 4 " + 122 "--vendor_ramdisk $(location :fastboot_test_vendor_ramdisk_none) " + 123 "--dtb $(location :fastboot_test_dtb) " + 124 "--vendor_bootconfig $(location :fastboot_test_bootconfig) " + 125 "--vendor_boot $(out) && " + 126 fastboot_sign_test_image, 127} 128 129genrule { 130 name: "fastboot_test_vendor_boot_v4_with_frag", 131 defaults: ["fastboot_test_vendor_boot_gen_defaults"], 132 out: ["vendor_boot_v4_with_frag.img"], 133 srcs: [ 134 ":fastboot_test_dtb", 135 ":fastboot_test_vendor_ramdisk_none", 136 ":fastboot_test_vendor_ramdisk_platform", 137 ":fastboot_test_bootconfig", 138 ], 139 cmd: "$(location mkbootimg) --header_version 4 " + 140 "--dtb $(location :fastboot_test_dtb) " + 141 "--vendor_bootconfig $(location :fastboot_test_bootconfig) " + 142 "--ramdisk_type none --ramdisk_name none_ramdisk " + 143 "--vendor_ramdisk_fragment $(location :fastboot_test_vendor_ramdisk_none) " + 144 "--ramdisk_type platform --ramdisk_name platform_ramdisk " + 145 "--vendor_ramdisk_fragment $(location :fastboot_test_vendor_ramdisk_platform) " + 146 "--vendor_boot $(out) && " + 147 fastboot_sign_test_image, 148} 149