-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Add configurable EFI partition alignment to support UFS devices #8053
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe changes modify the Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
lib/functions/image/partitioning.sh (2)
95-95
: Configurable EFI Partition Alignment VariableThe addition of the line:
UEFI_PART_ALIGN=${UEFI_PART_ALIGN:-512}
ensures that the EFI partition alignment is configurable while retaining backward compatibility. This default allows the system to use the standard 512-byte alignment unless overridden (for example, to 4096 bytes for Qualcomm UFS devices). Please ensure that this new configuration option is clearly documented so that users know when and how to adjust it for UFS devices.
347-347
: Integration of Custom Alignment in Filesystem CreationThe updated command:
run_host_command_logged mkfs.fat -F32 -S "${UEFI_PART_ALIGN}" -n "${UEFI_FS_LABEL^^}" ${LOOP}p${uefipart} 2>&1now passes the
UEFI_PART_ALIGN
variable via the-S
option to set the FAT sector size during formatting. This change appears to correctly support dynamic alignment configuration. Please verify that the value provided (e.g., 4096 when required) meets the expectations of themkfs.fat
utility and that any potential edge cases (such as non-numeric or out-of-range values) are handled or documented.
Is this confirmed working? This would probably also fix #7942 |
its works on rb5 |
@igorpecovnik Hi, Which document should I add it to? |
Interesting question. This seems a board or family level configuration variable but I don't think a documentation for that exists already? |
My proposal for this is to add a simple extension UFS.sh that has |
This might be a common variable—at least for UFS devices, it's needed for 4K alignment. |
This only applies to UFS devices booting with EFI. If Qualcomm uses ABL for boot, this is useless. I'm not sure this extension is needed |
Mediatek Genio can boot via EMMC/SD (512 alignment) or integrated UFS, that's why I was saying that. |
@FantasyGmm how did you make the rootfs 4k aligned? Just using this PR branch + setting UEFI_PART_ALIGN=4096 still gives me: |
Okay maybe this just means that for Mediatek Genio Family at least alignment isn't enough but the sector size needs to be 4096. (Btw which tool is that in the screenshot?) |
On Mediatek Genio we can just flash directly to UFS via fastboot: |
Probably means we still need the newest sfdisk from util-linux =>2.41 to make actual 4096 sector size images instead of this workaround that is not quite ready without it. |
That is very hacky to be merged imo. We should focus on having fully working image files out of the builder and not do additional modifications |
It looks like you might need to change the GPT partition table, I only changed the parameters for the efi partition, which will be 4096 aligned when making the filesystem, but inside the partition table it's still 512 aligned, which causes you to not be able to boot because you're flashing in a full image, whereas I'm separating and flushing it in. |
I can't write the entire image because abl checks for the rootfs partition name and if it doesn't exist it will refuse to boot to uboot. If it's possible to boot into uboot inside xbl then I can bypass that as well, I'll try to go XBL boot next week and try to flash a whole image into lun0 |
It looks like we need to upgrade utils-linux to 24.1Compiled version 2.41 of util-linux and built it without docker, and it's generating a 4096 gpt partition tableThe image can be successfully generated, but I'm not sure if flashing it directly will workAfter booting through XBL's Uboot, I can just dd the full image to lun0 (enable ums in uboot) and then I can just boot it |
Thanks for testing it out. |
845a39b
to
e320152
Compare
Can the image compiled from the new commit be boot on nio? |
Yes this works on Nio-12L. While we cannot merge this as is since it would fail on sfdisk versions before 2.41 a simple version. Here is a patch for build/main that integrates a version check.
|
Thanks for the code, I'll rebase it later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way it keeps functionality on util-linux 2.41< and allows for sector size setting on >2.41 hosts (Like Debian Trixie)
We need sfdisk that is not a part of Ubuntu Noble to make this work? |
https://answers.launchpad.net/ubuntu/+source/util-linux/+question/821212 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose copy/pasting info here: https://docs.armbian.com/Developer-Guide_Build-Switches/#advanced
done |
Description
Default EFI partition uses 512B alignment, which fails on Qualcomm UFS (4K-aligned) devices. This change introduces a variable to optionally enforce 4K alignment while maintaining backward compatibility.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Please also note any relevant details for your test configuration.
Checklist:
Please delete options that are not relevant.