mer-hybris / hybris-initrd

initrd generation submodule for flashable Sailfish OS image based boot images and recovery images.
2 stars 17 forks source link

Embed recovery. Fixes MER#1987 #27

Open Thaodan opened 5 years ago

Thaodan commented 5 years ago

Some devices like Sonys X series have no recovery partition on these devices the recovery needs to be inside the regular initramfs.

To do so we check if skip_initramfs hasn't been passed (read line 56) and then start the recovery.

Background: Bootloaders for Android phones pass skip_init_ramfs when the system should be booted normally and don't pass it when the key combination for recovery mode was used. We piggy back on this behavior by using the kernel commandline option is mostly the samen way except that we always use a init-ramfs.

Thaodan commented 5 years ago

How can I default to an alternative value like in shell Scripts with ${too:-bar} ?

About the dependencies , how would you do this with just sed? I'm not sure how to do this in a clean way.

sledges commented 5 years ago

How can I default to an alternative value like in shell Scripts with ${too:-bar} ?

%{?foo}%{!?foo:bar}, e.g. %{?embed_recovery}%{!?embed_recovery:0}

About the dependencies , how would you do this with just sed? I'm not sure how to do this in a clean way.

sed "s/@EMBED_RECOVERY@/%{?embed_recovery}%{!?embed_recovery:0}/g" -i %{_local_initrd_dir}/jolla-init

sledges commented 5 years ago

sed "s/@EMBED_RECOVERY@/%{?embed_recovery}%{!?embed_recovery:0}/g" -i %{_local_initrd_dir}/jolla-init

Below link is the complete rewrite without sed, I have not fully tested on a running device yet, as I have some doubts about this line: https://github.com/sledges/hybris-initrd/commit/58ab8a4b795c29f69d72937a6ee88096618aa0f6#diff-ae5e5322c8e93e423e4ef2ac5e20cd84R101 Will test when I find time ASAP, probably early next week.

Apologies for coming back on this only now, but github does not send emails about updated PR. We're lucky I was checking my timesheed as it's the end of the month, and found your PR again:)

Thaodan commented 5 years ago

@sledges No problem. I fixed that line that you mean in mksfosinitrd and cleaned that feature a bit up. About the actual init script to you want the embed recovery code to be present when embed recovery is not used or not present when its not used (shpp solution)?

Thaodan commented 5 years ago

Yes fixed.

Olf0 commented 3 years ago

This was looking well on its way and close to be ready for merging, after the many fixes and improvements above. @sledges & @Thaodan, is there a specific reason, why this has been stalling for more than 2 years?

Olf0 commented 3 years ago

The reason why iI am asking, is that

  1. The "Changes requested" displayed below are the ones @sledges requested on 19 Nov 2018: AFAICS these have been addressed. Hence @sledges' open ToDos might be to perform his "I haven't checked the changes in .sh for now" to finish his review and ultimately close the open review process.
  2. @Thaodan's last comment is "Yes fixed." on 22 Jun 2019, hence I assume he sees no open issues with this MR for more than two years now.
  3. Because this MR has been stalled for more than two years, meanwhile merges now result in merge conflicts and created the need to re-base. This will only become worse, if the stalling continues.
  4. The Xperia 10 II is the first device officially supported by Jolla, which needs an "embedded recovery". As its support was announced and deployed in early 2021, resolving this issue (MER#1987) is crucial in order to cease offering the clumsy, current official advice to stubbornly flash the recovery image, use it and then re-flash the boot image.
sledges commented 3 years ago

This was looking well on its way and close to be ready for merging, after the many fixes and improvements above. @sledges & @Thaodan, is there a specific reason, why this has been stalling for more than 2 years?

The reason is that such change needs to be tested on all Jolla's supported devices to avoid regressions, and in case such risk is minimal and/or this functionality is not enabled in a given kernel, the work of updating submodule for each device is still required.

Since we had had a workaround for recovery, this PR was not on a critical path and thus turned into technical debt, due to other priorities. It has certainly become more actual with releasing Xperia 10 II, and we will adjust prioritisation accordingly as possible. For now please use the workaround [1], which is, agreed, more involving than other Xperias, nevertheless recovery mode is (and should) not be a frequently used feature.

[1] https://jolla.zendesk.com/hc/en-us/articles/360021620740

Olf0 commented 2 years ago

[…] this PR […] turned into technical debt, due to other priorities. It has certainly become more actual with releasing Xperia 10 II, and we will adjust prioritisation accordingly as possible.

… and even more so by releasing SailfishOS for the Xperia 10 III recently.

Thaodan commented 2 years ago

Summary of what has to be done to use this PR.

  1. Rebase the PR (cc me :) )
  2. Update the droid-hal-img-boot submodule to use this patch/branch, (%define embed_recovery)
  3. Make sure that Ignore skip_initramfs is still passed but doesn't do anything on your devices kernel. For the Xperia XA2 this PR can be used: https://github.com/mer-hybris/android_kernel_sony_msm/pull/26 This commit contains the required change: https://github.com/mer-hybris/android_kernel_sony_msm/pull/26/commits/c73ed25d4ae2d6131094b6140ac19d3fa618677d

Both droid-hal and droid-hal-img-boot have to be build after applying the changes mentioned above, after doing so flashing _hybrisboot.img is enough to test if the PR works.

Thaodan commented 3 months ago

This PR is obsolete for devices using Android 12 and up. It was never required for devices using a dedicated recovery partition (refer to the graph above for devices starting with Android 13): https://source.android.com/docs/core/architecture/partitions/generic-boot#figure-2