Skip to content

Merge AndroidEfiLoaderCompositeDiskConfig with AndroidCompositeDiskConfig#2254

Open
Databean wants to merge 3 commits intogoogle:mainfrom
Databean:merge_android_efi
Open

Merge AndroidEfiLoaderCompositeDiskConfig with AndroidCompositeDiskConfig#2254
Databean wants to merge 3 commits intogoogle:mainfrom
Databean:merge_android_efi

Conversation

@Databean
Copy link
Member

We now have the ImageFile mechanism where partitions can be supplied dynamically. Since the main contribution of AndroidEfiLoaderCompositeDiskConfig, this can go through the ImageFile logic instead.

Tested with a build fetched using --android_efi_loader_build=aosp_uefi-gbl-mainline/gbl_efi_dist_and_test.

Bug: b/491903055

@Databean Databean requested a review from cjreynol March 11, 2026 22:00
Copy link
Collaborator

@cjreynol cjreynol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw you came up with a test case, but consider checking with Dmitrii or Ram if there are any other cases to check? I am just ignorant to how disruptive a breakage here might be and am defaulting towards greater caution.

Result<std::string> Path() const override;

private:
static constexpr std::string_view kName = "android_esp";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, not a request for change:

Any reason to make this a class member rather than a static variable declared in the source file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No good reason, copied the class definition from another place that did need to expose it, while this one didn't. I moved it to private but it might as well be only in the .cc file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to the source file.

@Databean Databean requested a review from dimorinny March 12, 2026 20:44
@Databean
Copy link
Member Author

FYI @dimorinny

@Databean
Copy link
Member Author

Databean commented Mar 12, 2026

Looks like this "happens to work" in an unintuitive way. There's a comment in the code from before this CL saying

Cuttlefish uboot EFI bootflow by default looks at the first partition for EFI application. Thus we put "android_esp" at the beginning.

As written here, the partitions are put in a std::map keyed by partition name, and android_esp happens to be first because std::map uses a tree sorted on keys to store entries. I tried renaming the partition so it would be sorted later, and confirmed that u-boot will not find it when it is later in the GPT.

Copy link
Collaborator

@cjreynol cjreynol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the latest comment about this not necessarily working except in certain cases.

The ImageFile mechanism is already dynamic in which partitions are
added, and the only contribution of AndroidEfiLoaderCompositeDisk was to
add another partition.

Bug: b/491903055
@Databean Databean force-pushed the merge_android_efi branch from 34fd5ed to 18da0b1 Compare March 14, 2026 00:27
@Databean
Copy link
Member Author

The "insert at the beginning" logic is now more explicit.

@Databean Databean requested a review from cjreynol March 14, 2026 00:28

// Cuttlefish uboot EFI bootflow by default looks at the first partition
// for EFI application. Thus we put "android_esp" at the beginning.
std::vector<ImagePartition>::iterator insert_location =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The requirement to strictly keep the ESP partition first is a bit annoying to maintain (especially once you merge it into the main android_composite_disk_config).

I played around with the U-Boot environment, and I think we can get rid of this requirement by relying on the partition name instead. For example, we could extend the WriteEFIEnvironment logic by adding a command to obtain a partition index by its name, so it would look something like this:

part number virtio 0 android_esp devplist && load virtio 0:${devplist} ${loadaddr} efi/boot/bootaa64.efi && bootefi ${loadaddr} ${fdtcontroladdr};

According to my local experiments, it should work:

=> part number virtio 0 android_esp PART_NUM
=> printenv PART_NUM
PART_NUM=0x1

Both are part of assembly_cvd, so I don't think we will have any compatibility problems with that approach.


This would be slightly outside the scope of the initial proposal, so if you prefer, I can create a separate bug and address it. Please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants