1#!/bin/bash
2#
3# Copyright (C) 2023 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17set -e
18
19readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
20
21BOOT_A_NAME="boot_a"
22BOOT_A_SIZE_KB="8"
23BOOT_A_PART_FILE="${SCRIPT_DIR}/${BOOT_A_NAME}.bin"
24
25BOOT_B_NAME="boot_b"
26BOOT_B_SIZE_KB="12"
27BOOT_B_PART_FILE="${SCRIPT_DIR}/${BOOT_B_NAME}.bin"
28
29dd if=/dev/urandom bs=1024 count=${BOOT_A_SIZE_KB} > ${BOOT_A_PART_FILE}
30dd if=/dev/urandom bs=1024 count=${BOOT_B_SIZE_KB} > ${BOOT_B_PART_FILE}
31
32python3 ${SCRIPT_DIR}/../../tools/gen_gpt_disk.py ${SCRIPT_DIR}/gpt_test_1.bin 64K \
33    --partition "${BOOT_A_NAME},${BOOT_A_SIZE_KB}k,${BOOT_A_PART_FILE}" \
34    --partition "${BOOT_B_NAME},${BOOT_B_SIZE_KB}k,${BOOT_B_PART_FILE}"
35
36
37VENDOR_BOOT_A_NAME="vendor_boot_a"
38VENDOR_BOOT_A_SIZE_KB="4"
39VENDOR_BOOT_A_PART_FILE="${SCRIPT_DIR}/${VENDOR_BOOT_A_NAME}.bin"
40
41VENDOR_BOOT_B_NAME="vendor_boot_b"
42VENDOR_BOOT_B_SIZE_KB="6"
43VENDOR_BOOT_B_PART_FILE="${SCRIPT_DIR}/${VENDOR_BOOT_B_NAME}.bin"
44
45dd if=/dev/urandom bs=1024 count=${VENDOR_BOOT_A_SIZE_KB} > ${VENDOR_BOOT_A_PART_FILE}
46dd if=/dev/urandom bs=1024 count=${VENDOR_BOOT_B_SIZE_KB} > ${VENDOR_BOOT_B_PART_FILE}
47
48python3 ${SCRIPT_DIR}/../../tools/gen_gpt_disk.py ${SCRIPT_DIR}/gpt_test_2.bin 128K \
49    --partition "${VENDOR_BOOT_A_NAME},${VENDOR_BOOT_A_SIZE_KB}k,${VENDOR_BOOT_A_PART_FILE}" \
50    --partition "${VENDOR_BOOT_B_NAME},${VENDOR_BOOT_B_SIZE_KB}k,${VENDOR_BOOT_B_PART_FILE}"
51