diff options
author | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2021-09-25 18:13:35 +0200 |
---|---|---|
committer | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2021-09-25 18:57:28 +0200 |
commit | 6b520e17e5ee4f4663e7fa452af7a6808e3858df (patch) | |
tree | c2620dc44cd457dd76c1d30c111d99b60f40a783 | |
parent | 6681e4bb3dbbc6fbad5663055aff79483cb21b87 (diff) | |
download | build_make-6b520e17e5ee4f4663e7fa452af7a6808e3858df.tar.gz build_make-6b520e17e5ee4f4663e7fa452af7a6808e3858df.tar.bz2 build_make-6b520e17e5ee4f4663e7fa452af7a6808e3858df.zip |
Add support for XZ recoveries
We do need the highest compression ratio support for the
recovery as on the Galaxy SIII (GT-I9300) and
Galaxy SIII 4G (GT-I9305) the recovery partition is 8MiB
and we need to fit a bootimage with inside a kernel image
and a recovery initramfs.
We cannot simply fit a recovery initramfs in the RECOVERY
partition without any kernel because even if Android 11
supports that, if have a bootimage without any kernel or
bootloader code instead, rebooting to recovery or booting
to recovery does result in the device booting directly to
the dowload mode and we have a screen with the following:
[Android logo]
Downloading....
Do not rurn off target !!
and then there is no other way to make the device boot to
the BOOT partition other than flashing code (like a
recovery) to the RECOVERY partition in order to make it
reboot to the normal BOOT partition.
And here, even 'heimdall close-pc-screen' doesn't change
the boot mode.
While writing some code code reboot the device to the BOOT
partition is trivial to do[1], the result is not totally
transparent as pressing the power up, menu and power button
don't result in the device booting to the RECOVERY.
In addition it would probably complexify a lot the
installation instructions because, when the recovery
initramfs is on a separate partition, the kenrel still
depends on the init daemon that is inside the SYSTEM
partition to be able to boot the recovery.
And Installing big images (like system.img) with heimdall
is not very reliable on the Exynos devices that are
supported by Replicant.
So we are left with two possibilities: we can either:
- Write a tiny bootloader that would be installed in
the RECOVERY bootimage instead of the kernel, and that
would retrieve the kernel from the BOOT bootimage, and
boot the kernel with the recovery initramfs.
- Shrink as much as possible the kernel image used for the
recovery and the recovery initramfs.
Doing the former would require to write code to retrieve
data from eMMC partitions (and probably support all eMMC
standards as we don't have a list of possible eMMCs and
that some could come from reparations having been made),
parse the bootimages, and write code to retrieve the boot
arguments, because we can't tell the kernel to load a
recovery image from a partition as the kernel doesn't
have support for that yet. As we also need a bootimage
in the RECOVERY partition, we would also probably need
tricks to add a compressed squashfs that would be treated
as block device.
If we manage to do that we would still need to modify a
bit the installation instructions, and this would break
the many unofficial tutorials (often in local languages)
that are not made by Replicant.
So for now we did the later as for now we managed to shrink
the kernel and recovery enough to work.
To do that we used the kenrel's xz_wrap.sh script to ensure
that the XZ options we use are compatible with Linux's xz
decompressor.
As XZ_WRAP variables are not used anywhere else (I've checked with
repo grep XZ_WRAP) they are safe to use here.
We do not set XZ as it's already set somewhere else and we probably
don't want to use kernel specific XZ options for everything.
[1]https://git.replicant.us/contrib/GNUtoo/tools/s-boot_usb_exploit/tree/shellcode/reboot.c
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
-rw-r--r-- | core/Makefile | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/core/Makefile b/core/Makefile index 45ad60f416..fedee10e3c 100644 --- a/core/Makefile +++ b/core/Makefile @@ -1154,6 +1154,34 @@ ifeq ($(BOARD_RAMDISK_USE_LZ4),true) COMPRESSION_COMMAND_DEPS := $(LZ4) COMPRESSION_COMMAND := $(LZ4) -l -12 --favor-decSpeed RAMDISK_EXT := .lz4 +else ifeq ($(BOARD_RAMDISK_USE_XZ),true) +# The prebuilt xz lacks some options: +# $ prebuilts/build-tools/linux-x86/bin/xz \ +# --check=crc32 --arm --lzma2=dict=32MiB +# prebuilts/build-tools/linux-x86/bin/xz: Unsupported filter chain or filter +# options +# so we use the host xz through out/.path/xz instead. +XZ_WRAP_XZ := out/.path/xz + +# According to core/build-system.html from this repository, Android supports the +# following architectures: arm, arm64, mips, mips64, x86, x86_64 +# And kernel/replicant/scripts/xz_wrap.sh supports architecture specific BCJ +# filters for the following architectures: arm, ia64 (itanium), powerpc, sparc, +# x86 +ifeq ($(TARGET_ARCH),arm) +XZ_WRAP_SRCARCH := arm +else ifeq ($(TARGET_ARCH),arm64) +XZ_WRAP_SRCARCH := arm +else ifeq ($(TARGET_ARCH),x86) +XZ_WRAP_SRCARCH := x86 +else ifeq ($(TARGET_ARCH),x86_64) +XZ_WRAP_SRCARCH := x86 +endif + +COMPRESSION_COMMAND := \ + SRCARCH=$(XZ_WRAP_SRCARCH) XZ=$(XZ_WRAP_XZ) \ + kernel/replicant/linux/scripts/xz_wrap.sh +RAMDISK_EXT := .xz else COMPRESSION_COMMAND_DEPS := $(MINIGZIP) COMPRESSION_COMMAND := $(MINIGZIP) |