-
Notifications
You must be signed in to change notification settings - Fork 404
Better Android support, plus a bit of improvements #517
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
base: main
Are you sure you want to change the base?
Conversation
71bdb96
to
23a12f5
Compare
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.
Thanks a lot for working on this! I have already pushed 5 of your commits that look good to me. Please rebase to drop them from the branch.
I haven't fully understood the "big picture" here. Could you maybe add a short "design document" to Documentation/android.md
(or something like this) and describe:
- Motivation (Boot Android with mainline through lk2nd)
- How to set this up (flash lk2nd to both boot and recovery)
- How do the expected flows look like? Android sets up the recovery message, reboots to recovery, the stock bootloader reads the recovery message, boots the recovery partition (= lk2nd) and then lk2nd does the same again?
I think understanding this better would help me to review the rest of the changes.
boot_into_recovery = 1; | ||
} | ||
|
||
#if !ABOOT_STANDALONE |
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.
Have you tried
if (IS_ENABLED(ABOOT_STANDALONE))
goto out;
(Not sure if that code causes compile errors...)
Rule of thumb: Avoid macros where possible, this improves compile testing. I'm not saying goto
is great, but the jump label is there already, so not our fault. >:D
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.
yep, some of those code should cause compilation errors...
as far as I can see, reset_device_info()
and set_device_root()
functions are already excluded by macro !ABOOT_STANDALONE
in commit app: aboot: Avoid using special partitions using ABOOT_STANDALONE=1
, and those code is calling that two functions
Sorry, I'm unlikely able to write a decent document, but I can explain my "big picture" to you: Honestly, I have to use lk2nd only because of the mainline kernel ports relies on it. Integrating lk2nd in Android and inserting lk2nd to the boot flow is breaking Android standards and is making the things a bit complicated. I'm trying to make lk2nd transparent to the end user. Ideally, the end user doesn't have to worry about the existence of lk2nd. In my own Android device tree configuration, I have added build rules to build lk2nd inline, and have overridden boot.img build rule to have it placing lk2nd.img at 0 offset and the real Android boot.img at 512KB offset. lk2nd is integrated into recovery.img too, in the same way as boot.img. When booting into recovery, the boot flow is: stock bootloader detects boot mode is recovery -> stock bootloader boots recovery partition at 0 offset -> lk2nd is loaded because it's at 0 offset -> lk2nd keeps detecting boot mode is recovery -> lk2nd boots the virtual partition named "recovery" which is actually 512KB offset of the real recovery partition -> Android recovery image is loaded There's two ways to set the boot mode for the next boot: writing string to misc partition (standard Android way), and the stuff inside When the users wants to install android with mainline kernel, they could either get partition images for flashing with fastboot, or standard Android OTA package for flashing in recovery mode, either ones have {boot,recovery}.img with lk2nd embedded in. The only things that still haven't got dealt are:
|
Useful for Android recovery that runs mainline kernel
If it's not detecting boot image header at 512 KiB offset, try booting from 0 offset. Useful when lk2nd boots the recovery partition, at least.
Android could run on mainline kernel... Fix up some logic and code style in `_emmc_recovery_init()` while at it.
This is solely used for Android OS, but shouldn't cause any problem to Linux OS. This may cause problem for devices that was launched with Android 9 and earlier and wants to boot Android from lk2nd. I'll mitigate this in the following commits.
For Linux OS, this has no use. For custom Android OS, the developers are used to make changes on the source files directly, rather than relying on this logic. Additionally, the changes that it make are most likely deprecated on newer Android versions or newer kernel versions. Stock Android OS may rely on it though, but the purpose of lk2nd is likely never used to be booting stock Android OS... Change-Id: Ia0f331dc60c7d2c023c0d79e531e801bc6193d55
Code copied from boot_linux_from_mmc() Change-Id: I8c6dd64eabd264f42e13e443bceae6e5cc525a38
Please check out each commits for details.