Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 97f13258 authored by Chen, ZhiminX's avatar Chen, ZhiminX Committed by Xihua Chen
Browse files

Add a recovery ACPIO section to boot image

For non-A/B devices, the recovery partition should be
self-sufficient and not depend on any other partition.
Since recovery may need load ACPIO before access to devices,
we need to make sure that the the recovery image also contains
the information from the ACPIO image.

Test: can generate image with acpio/acpi
Fixes: 111871613

Change-Id: I77b95a4c78a7e967f5e682ba7053f9d03f4ca51c
parent 3da42a6c
Loading
Loading
Loading
Loading
+18 −17
Original line number Original line Diff line number Diff line
@@ -110,25 +110,25 @@ typedef struct boot_img_hdr_v0 boot_img_hdr;
 */
 */


struct boot_img_hdr_v1 : public boot_img_hdr_v0 {
struct boot_img_hdr_v1 : public boot_img_hdr_v0 {
    uint32_t recovery_dtbo_size;   /* size in bytes for recovery DTBO image */
    uint32_t recovery_dtbo_size;   /* size in bytes for recovery DTBO/ACPIO image */
    uint64_t recovery_dtbo_offset; /* offset to recovery dtbo in boot image */
    uint64_t recovery_dtbo_offset; /* offset to recovery dtbo/acpio in boot image */
    uint32_t header_size;
    uint32_t header_size;
} __attribute__((packed));
} __attribute__((packed));


/* When the boot image header has a version of 1, the structure of the boot
/* When the boot image header has a version of 1, the structure of the boot
 * image is as follows:
 * image is as follows:
 *
 *
 * +-----------------+
 * +---------------------+
 * | boot header         | 1 page
 * | boot header         | 1 page
 * +-----------------+
 * +---------------------+
 * | kernel              | n pages
 * | kernel              | n pages
 * +-----------------+
 * +---------------------+
 * | ramdisk             | m pages
 * | ramdisk             | m pages
 * +-----------------+
 * +---------------------+
 * | second stage        | o pages
 * | second stage        | o pages
 * +-----------------+
 * +---------------------+
 * | recovery dtbo   | p pages
 * | recovery dtbo/acpio | p pages
 * +-----------------+
 * +---------------------+
 * n = (kernel_size + page_size - 1) / page_size
 * n = (kernel_size + page_size - 1) / page_size
 * m = (ramdisk_size + page_size - 1) / page_size
 * m = (ramdisk_size + page_size - 1) / page_size
 * o = (second_size + page_size - 1) / page_size
 * o = (second_size + page_size - 1) / page_size
@@ -136,13 +136,14 @@ struct boot_img_hdr_v1 : public boot_img_hdr_v0 {
 *
 *
 * 0. all entities are page_size aligned in flash
 * 0. all entities are page_size aligned in flash
 * 1. kernel and ramdisk are required (size != 0)
 * 1. kernel and ramdisk are required (size != 0)
 * 2. recovery_dtbo is required for recovery.img in non-A/B devices(recovery_dtbo_size != 0)
 * 2. recovery_dtbo/recovery_acpio is required for recovery.img in non-A/B
 *    devices(recovery_dtbo_size != 0)
 * 3. second is optional (second_size == 0 -> no second)
 * 3. second is optional (second_size == 0 -> no second)
 * 4. load each element (kernel, ramdisk, second) at
 * 4. load each element (kernel, ramdisk, second) at
 *    the specified physical address (kernel_addr, etc)
 *    the specified physical address (kernel_addr, etc)
 * 5. If booting to recovery mode in a non-A/B device, extract recovery dtbo and
 * 5. If booting to recovery mode in a non-A/B device, extract recovery
 *    apply the correct set of overlays on the base device tree depending on the
 *    dtbo/acpio and apply the correct set of overlays on the base device tree
 *    hardware/product revision.
 *    depending on the hardware/product revision.
 * 6. prepare tags at tag_addr.  kernel_args[] is
 * 6. prepare tags at tag_addr.  kernel_args[] is
 *    appended to the kernel commandline in the tags.
 *    appended to the kernel commandline in the tags.
 * 7. r0 = 0, r1 = MACHINE_TYPE, r2 = tags_addr
 * 7. r0 = 0, r1 = MACHINE_TYPE, r2 = tags_addr
+4 −1
Original line number Original line Diff line number Diff line
@@ -161,7 +161,10 @@ def parse_cmdline():
                        required=True)
                        required=True)
    parser.add_argument('--ramdisk', help='path to the ramdisk', type=FileType('rb'))
    parser.add_argument('--ramdisk', help='path to the ramdisk', type=FileType('rb'))
    parser.add_argument('--second', help='path to the 2nd bootloader', type=FileType('rb'))
    parser.add_argument('--second', help='path to the 2nd bootloader', type=FileType('rb'))
    parser.add_argument('--recovery_dtbo', help='path to the recovery DTBO', type=FileType('rb'))
    recovery_dtbo_group = parser.add_mutually_exclusive_group()
    recovery_dtbo_group.add_argument('--recovery_dtbo', help='path to the recovery DTBO', type=FileType('rb'))
    recovery_dtbo_group.add_argument('--recovery_acpio', help='path to the recovery ACPIO',
                                     type=FileType('rb'), metavar='RECOVERY_ACPIO', dest='recovery_dtbo')
    parser.add_argument('--cmdline', help='extra arguments to be passed on the '
    parser.add_argument('--cmdline', help='extra arguments to be passed on the '
                        'kernel command line', default='', action=ValidateStrLenAction, maxlen=1536)
                        'kernel command line', default='', action=ValidateStrLenAction, maxlen=1536)
    parser.add_argument('--base', help='base address', type=parse_int, default=0x10000000)
    parser.add_argument('--base', help='base address', type=parse_int, default=0x10000000)