Skip to content

Instantly share code, notes, and snippets.

@xc-racer99
Created August 6, 2016 15:55
Show Gist options
  • Save xc-racer99/82b95d1badcbbf2180c9275163ad615a to your computer and use it in GitHub Desktop.
Save xc-racer99/82b95d1badcbbf2180c9275163ad615a to your computer and use it in GitHub Desktop.
aries mkbootimg patch
From b142685accf2c50c7f412ba7482d10b78cc538d2 Mon Sep 17 00:00:00 2001
From: xc-racer99 <xc-racer2@live.ca>
Date: Mon, 1 Aug 2016 14:25:31 -0700
Subject: [PATCH] [1/3] aries-common: Support custom mkbootimg
Currently, we build both the recovery ramdisk and the main ramdisk into the kernel. This done with the flag BOARD_CUSTOM_BOOTIMG_MK, which is not an AOSP-supported flag (CAF originally?).
Instead, lets store the ramdisks on our previously unused (except in the case of fascinatemtd - not sure if the reason is still valid though) second mtd partition. This has been relabelled to "ramdisk" (from "recovery"). Our stage1 ramdisk now mounts that partitions and loads the correct ramdisk.
The other reason BOARD_CUSTOM_BOOTIMG_MK was used was so that we didn't append the ramdisk afterwards. Now, we use a BOARD_CUSTOM_MKBOOTIMG which simply copies the kernel to the boot.img (or whatever the output flag is).
This has some advantages and disadvantages to the previous method:
Advantages:
-The size of the boot.img is reduced as the ramdisks are stored externally
-We now use the previously unused partition on the onenand
-Is more AOSP-compatible as the remaining function of BOARD_CUSTOM_BOOTIMG_MK is solely to build the busybox and erase_image executables for inline kernel building (which AOSP doesn't support)
-Is easier to manually edit the ramdisks (before it was essentially impossible)
-We can independently update the recovery ramdisk from the ROM
-Could easily be modified for multi-ROM kernels (ie add another ramdisk for CM)...
Disadvantages:
-Is a little bit more cumbersome in the updater.sh and the releasetools
-Doesn't support the fascinatemtd (which could be changed fairly easily, presuming that the recovery_kernel that is currently flashed is indeed unused...)
-Still not totally AOSP-compatible, but this can be easily changed as listed above.
-Slightly longer bootup time
I have also increased the colboot timeout in this patch (we were over the limit before anyways).
You can still flash a "regular" kernel overtop and it will use its built-in ramdisk's without a problem
---
BoardConfigCommon.mk | 4 ++
mksgsbootimg/Android.mk | 13 ++++
mksgsbootimg/mksgsbootimg.c | 147 ++++++++++++++++++++++++++++++++++++++++++++
recovery/twrp.fstab | 20 +++---
releasetools.py | 4 ++
shbootimg.mk | 19 ++----
updater.sh | 25 ++++++++
7 files changed, 209 insertions(+), 23 deletions(-)
create mode 100644 mksgsbootimg/Android.mk
create mode 100644 mksgsbootimg/mksgsbootimg.c
diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk
index 4621adc..dd063e2 100644
--- a/BoardConfigCommon.mk
+++ b/BoardConfigCommon.mk
@@ -110,9 +110,13 @@ TARGET_USERIMAGES_USE_EXT4 := true
TARGET_USERIMAGES_USE_F2FS := true
BOARD_USES_BML_OVER_MTD := true
BOARD_CUSTOM_BOOTIMG_MK := device/samsung/aries-common/shbootimg.mk
+BOARD_CUSTOM_MKBOOTIMG := mksgsbootimg
TARGET_RECOVERY_FSTAB := device/samsung/aries-common/rootdir/fstab.aries
RECOVERY_FSTAB_VERSION := 2
+# Increase coldboot timeout
+TARGET_INCREASES_COLDBOOT_TIMEOUT := true
+
# Open Source Charging Mode
BOARD_CHARGER_ENABLE_SUSPEND := true
diff --git a/mksgsbootimg/Android.mk b/mksgsbootimg/Android.mk
new file mode 100644
index 0000000..38703ce
--- /dev/null
+++ b/mksgsbootimg/Android.mk
@@ -0,0 +1,13 @@
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := mksgsbootimg.c
+LOCAL_STATIC_LIBRARIES := libmincrypt
+LOCAL_CFLAGS := -Werror
+
+LOCAL_MODULE := mksgsbootimg
+
+include $(BUILD_HOST_EXECUTABLE)
+
+$(call dist-for-goals,dist_files,$(LOCAL_BUILT_MODULE))
diff --git a/mksgsbootimg/mksgsbootimg.c b/mksgsbootimg/mksgsbootimg.c
new file mode 100644
index 0000000..3f8ae2c
--- /dev/null
+++ b/mksgsbootimg/mksgsbootimg.c
@@ -0,0 +1,147 @@
+/* tools/mkbootimg/mkbootimg.c
+**
+** Copyright 2007, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <stdbool.h>
+
+static void *load_file(const char *fn, unsigned *_sz)
+{
+ char *data;
+ int sz;
+ int fd;
+
+ data = 0;
+ fd = open(fn, O_RDONLY);
+ if(fd < 0) return 0;
+
+ sz = lseek(fd, 0, SEEK_END);
+ if(sz < 0) goto oops;
+
+ if(lseek(fd, 0, SEEK_SET) != 0) goto oops;
+
+ data = (char*) malloc(sz);
+ if(data == 0) goto oops;
+
+ if(read(fd, data, sz) != sz) goto oops;
+ close(fd);
+
+ if(_sz) *_sz = sz;
+ return data;
+
+oops:
+ close(fd);
+ if(data != 0) free(data);
+ return 0;
+}
+
+int usage(void)
+{
+ fprintf(stderr,"usage: mkbootimg\n"
+ " --kernel <filename>\n"
+ " [ --ramdisk <filename> ]\n"
+ " [ --second <2ndbootloader-filename> ]\n"
+ " [ --cmdline <kernel-commandline> ]\n"
+ " [ --board <boardname> ]\n"
+ " [ --base <address> ]\n"
+ " [ --pagesize <pagesize> ]\n"
+ " [ --dt <filename> ]\n"
+ " [ --id ]\n"
+ " -o|--output <filename>\n"
+ );
+ return 1;
+}
+
+int main(int argc, char **argv)
+{
+ char *kernel_fn = NULL;
+ void *kernel_data = NULL;
+ char *bootimg = NULL;
+ int fd;
+ uint32_t kernel_size;
+
+ argc--;
+ argv++;
+
+ bool get_id = false;
+ while(argc > 0){
+ char *arg = argv[0];
+ if (!strcmp(arg, "--id")) {
+ get_id = true;
+ argc -= 1;
+ argv += 1;
+ } else if(argc >= 2) {
+ char *val = argv[1];
+ argc -= 2;
+ argv += 2;
+ if(!strcmp(arg, "--output") || !strcmp(arg, "-o")) {
+ bootimg = val;
+ } else if(!strcmp(arg, "--kernel")) {
+ kernel_fn = val;
+ } else if(!strcmp(arg, "--ramdisk")) {
+ } else if(!strcmp(arg, "--second")) {
+ } else if(!strcmp(arg, "--cmdline")) {
+ } else if(!strcmp(arg, "--base")) {
+ } else if(!strcmp(arg, "--kernel_offset")) {
+ } else if(!strcmp(arg, "--ramdisk_offset")) {
+ } else if(!strcmp(arg, "--second_offset")) {
+ } else if(!strcmp(arg, "--tags_offset")) {
+ } else if(!strcmp(arg, "--board")) {
+ } else if(!strcmp(arg,"--pagesize")) {
+ } else if(!strcmp(arg, "--dt")) {
+ } else {
+ return usage();
+ }
+ } else {
+ return usage();
+ }
+ }
+
+ if(bootimg == 0) {
+ fprintf(stderr,"error: no output filename specified\n");
+ return usage();
+ }
+
+ if(kernel_fn == 0) {
+ fprintf(stderr,"error: no kernel image specified\n");
+ return usage();
+ }
+
+ kernel_data = load_file(kernel_fn, &kernel_size);
+
+ fd = open(bootimg, O_CREAT | O_TRUNC | O_WRONLY, 0644);
+ if(fd < 0) {
+ fprintf(stderr,"error: could not create '%s'\n", bootimg);
+ return 1;
+ }
+
+ if(write(fd, kernel_data, kernel_size) != (ssize_t) kernel_size) goto fail;
+
+ return 0;
+
+fail:
+ unlink(bootimg);
+ close(fd);
+ fprintf(stderr,"error: failed writing '%s': %s\n", bootimg,
+ strerror(errno));
+ return 1;
+}
diff --git a/recovery/twrp.fstab b/recovery/twrp.fstab
index f59e196..18043e2 100644
--- a/recovery/twrp.fstab
+++ b/recovery/twrp.fstab
@@ -1,10 +1,10 @@
-# mount point fstype device options (length for cryptfs encryption footer)
-/boot mtd boot
-/recovery mtd recovery
-/radio mtd radio
-/cache yaffs2 cache flags=backup=1;canbewiped;wipeingui;wipeduringfactoryreset
-/system ext4 /dev/lvpool/system flags=backup=1;canbewiped;wipeingui
-/datadata yaffs2 datadata flags=backup=1;canbewiped;wipeingui;wipeduringfactoryreset
-/data auto /dev/lvpool/userdata length=-16384 flags=backup=1;canbewiped;wipeingui;wipeduringfactoryreset
-/sdcard vfat /dev/block/mmcblk0p1 flags=display="Internal SD Card";storage;wipeingui;settingsstorage
-/external_sd vfat /dev/block/mmcblk1p1 flags=display="External SD Card";storage;wipeingui;removable
+# mount point fstype device options (length for cryptfs encryption footer)
+/boot mtd boot
+/ramdisk yaffs2 ramdisk flags=subpartitionof=/boot
+/radio mtd radio
+/cache yaffs2 cache flags=backup=1;canbewiped;wipeingui;wipeduringfactoryreset
+/system ext4 /dev/lvpool/system flags=backup=1;canbewiped;wipeingui
+/datadata yaffs2 datadata flags=backup=1;canbewiped;wipeingui;wipeduringfactoryreset
+/data auto /dev/lvpool/userdata length=-16384 flags=backup=1;canbewiped;wipeingui;wipeduringfactoryreset
+/sdcard vfat /dev/block/mmcblk0p1 flags=display="Internal SD Card";storage;wipeingui;settingsstorage
+/external_sd vfat /dev/block/mmcblk1p1 flags=display="External SD Card";storage;wipeingui;removable
diff --git a/releasetools.py b/releasetools.py
index f8bd6f7..c037dda 100644
--- a/releasetools.py
+++ b/releasetools.py
@@ -30,6 +30,8 @@ def FullOTA_Assertions(info):
info.output_zip.write(os.path.join(UTILITIES_DIR, "erase_image"), "erase_image")
info.output_zip.write(os.path.join(UTILITIES_DIR, "bml_over_mtd"), "bml_over_mtd")
info.output_zip.write(os.path.join(TARGET_DIR, "bml_over_mtd.sh"), "bml_over_mtd.sh")
+ info.output_zip.write(os.path.join(TARGET_DIR, "ramdisk.img"), "ramdisk.img")
+ info.output_zip.write(os.path.join(TARGET_DIR, "ramdisk-recovery.img"), "ramdisk-recovery.img")
info.script.AppendExtra(
('package_extract_file("modem.bin", "/tmp/modem.bin");\n'
@@ -57,6 +59,8 @@ def FullOTA_Assertions(info):
'set_metadata("/tmp/bml_over_mtd.sh", "uid", 0, "gid", 0, "mode", 0777);'))
info.script.AppendExtra('package_extract_file("boot.img", "/tmp/boot.img");')
+ info.script.AppendExtra('package_extract_file("ramdisk.img", "/tmp/ramdisk.img");')
+ info.script.AppendExtra('package_extract_file("ramdisk-recovery.img", "/tmp/ramdisk-recovery.img");')
info.script.AppendExtra('assert(run_program("/tmp/updater.sh") == 0);')
diff --git a/shbootimg.mk b/shbootimg.mk
index fff6280..6eb280f 100644
--- a/shbootimg.mk
+++ b/shbootimg.mk
@@ -1,17 +1,10 @@
LOCAL_PATH := $(call my-dir)
-# Uncompress ramdisk.img to avoid double compression
-uncompressed_ramdisk := $(PRODUCT_OUT)/ramdisk.cpio
-$(uncompressed_ramdisk): $(INSTALLED_RAMDISK_TARGET)
- $(MINIGZIP) -d < $(INSTALLED_RAMDISK_TARGET) > $@
-
# Add ramdisk dependencies to kernel
-TARGET_KERNEL_BINARIES: $(recovery_ramdisk) $(uncompressed_ramdisk) $(PRODUCT_OUT)/utilities/flash_image $(PRODUCT_OUT)/utilities/busybox $(PRODUCT_OUT)/utilities/make_ext4fs $(PRODUCT_OUT)/utilities/erase_image
-
-INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
-$(INSTALLED_BOOTIMAGE_TARGET): $(INSTALLED_KERNEL_TARGET)
- $(call pretty,"Boot image: $@")
- $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $@
+TARGET_KERNEL_BINARIES: $(PRODUCT_OUT)/utilities/flash_image $(PRODUCT_OUT)/utilities/busybox $(PRODUCT_OUT)/utilities/make_ext4fs $(PRODUCT_OUT)/utilities/erase_image
-$(INSTALLED_RECOVERYIMAGE_TARGET): $(INSTALLED_BOOTIMAGE_TARGET)
- $(ACP) $(INSTALLED_BOOTIMAGE_TARGET) $@
+# Dummy recovery image generation
+$(INSTALLED_RECOVERYIMAGE_TARGET): $(recovery_ramdisk) $(MKBOOTIMG) $(recovery_kernel)
+ @echo -e ${PRT_IMG}"----- Making recovery image ------"${CL_RST}
+ $(call build-recoveryimage-target, $@)
+ @echo -e ${PRT_IMG}"----- Made recovery image: $@ --------"${CL_RST}
diff --git a/updater.sh b/updater.sh
index b505499..22c174a 100755
--- a/updater.sh
+++ b/updater.sh
@@ -266,6 +266,19 @@ restore_modem() {
fi
}
+copy_ramdisks() {
+ # format the ramdisk partition and copy the ramdisks to it
+ /tmp/busybox umount -l /dev/block/mtdblock1
+ /tmp/erase_image ramdisk
+ check_mount /ramdisk /dev/block/mtdblock1 yaffs2
+ /tmp/busybox cp /tmp/ramdisk.img /ramdisk/ramdisk.img
+ /tmp/busybox cp /tmp/ramdisk-recovery.img /ramdisk/ramdisk-recovery.img
+ /tmp/busybox sync
+
+ # unmount the ramdisk partition
+ /tmp/busybox umount -l /dev/block/mtdblock1
+}
+
if /tmp/busybox test -e /dev/block/bml7 ; then
################################################################################
################################################################################
@@ -288,6 +301,11 @@ if /tmp/busybox test -e /dev/block/bml7 ; then
# write the package path to sdcard omni.cfg
echo "${UPDATE_PACKAGE}" > /mnt/sdcard/omni.cfg;
+ if $IS_GSM ; then
+ # Copy the recovery ramdisk to the SD
+ /tmp/busybox cp /tmp/ramdisk-recovery.img /sdcard/ramdisk-recovery.img
+ fi
+
# write new kernel to boot partition
/tmp/flash_image boot /tmp/boot.img;
if [ "$?" != "0" ] ; then
@@ -347,6 +365,10 @@ elif /tmp/busybox test -e /dev/block/mtdblock0 ; then
# restore modem.bin
restore_modem;
+ if $IS_GSM ; then
+ copy_ramdisks;
+ fi
+
# check lvm resize
if /tmp/busybox test -e /dev/lvpool/system ; then
if [ "$(/tmp/busybox blockdev --getsize64 /dev/mapper/lvpool-system)" != "${SYSTEM_SIZE}" ] || \
@@ -382,6 +404,9 @@ elif /tmp/busybox test -e /dev/block/mtdblock0 ; then
# prevent loops
/tmp/busybox rm -fr /sdcard/omni.cfg;
+ # remove the recovery ramdisk from the SD
+ /tmp/busybox rm -f /sdcard/ramdisk-recovery.img
+
# efs
restore_efs;
--
2.7.4
From 7fc688d2e9c98ecacaf5ce1c5bc0ff25b6765a20 Mon Sep 17 00:00:00 2001
From: xc-racer99 <xc-racer2@live.ca>
Date: Mon, 1 Aug 2016 11:07:04 -0700
Subject: [PATCH] [2/3] aries: Support custom mkbootimg
---
drivers/mtd/onenand/samsung_galaxys4g.h | 2 +-
drivers/mtd/onenand/samsung_gsm.h | 2 +-
usr/galaxys4gmtd_initramfs.list | 3 +--
usr/galaxys4gmtd_initramfs_files/init | 23 +++++++++++++++--------
usr/galaxysmtd_initramfs.list | 3 +--
usr/galaxysmtd_initramfs_files/init | 17 ++++++++++++-----
6 files changed, 31 insertions(+), 19 deletions(-)
diff --git a/drivers/mtd/onenand/samsung_galaxys4g.h b/drivers/mtd/onenand/samsung_galaxys4g.h
index 9f2d40d..ece991d 100644
--- a/drivers/mtd/onenand/samsung_galaxys4g.h
+++ b/drivers/mtd/onenand/samsung_galaxys4g.h
@@ -35,7 +35,7 @@ struct mtd_partition s3c_partition_info[] = {
.size = (30*SZ_256K), //101
},
{
- .name = "recovery",
+ .name = "ramdisk",
.offset = (102*SZ_256K),
.size = (30*SZ_256K), //131
},
diff --git a/drivers/mtd/onenand/samsung_gsm.h b/drivers/mtd/onenand/samsung_gsm.h
index 948dbb5..7ef0445 100644
--- a/drivers/mtd/onenand/samsung_gsm.h
+++ b/drivers/mtd/onenand/samsung_gsm.h
@@ -35,7 +35,7 @@ struct mtd_partition s3c_partition_info[] = {
.size = (30*SZ_256K), //101
},
{
- .name = "recovery",
+ .name = "ramdisk",
.offset = (102*SZ_256K),
.size = (30*SZ_256K), //131
},
diff --git a/usr/galaxys4gmtd_initramfs.list b/usr/galaxys4gmtd_initramfs.list
index 0cf3151..0c763aa 100644
--- a/usr/galaxys4gmtd_initramfs.list
+++ b/usr/galaxys4gmtd_initramfs.list
@@ -37,11 +37,10 @@ dir /proc 755 0 0
dir /stage1 755 0 0
dir /system 755 0 0
dir /cache 755 0 0
+dir /ramdisk 755 0 0
dir /sdcard 755 0 0
file /stage1/busybox ../../utilities/busybox 755 0 0
file /stage1/init source/usr/galaxys4gmtd_initramfs_files/init 755 0 0
file /stage1/erase_image ../../utilities/erase_image 755 0 0
-file /stage1/ramdisk.cpio ../../ramdisk.cpio 700 0 0
-file /stage1/ramdisk-recovery.cpio ../../ramdisk-recovery.cpio 700 0 0
dir /sys 755 0 0
diff --git a/usr/galaxys4gmtd_initramfs_files/init b/usr/galaxys4gmtd_initramfs_files/init
index ff0d7d1..a8e5ac0 100644
--- a/usr/galaxys4gmtd_initramfs_files/init
+++ b/usr/galaxys4gmtd_initramfs_files/init
@@ -10,15 +10,16 @@ busybox mount -t proc proc /proc
busybox mount -t sysfs sysfs /sys
busybox mount -t yaffs2 /dev/block/mtdblock2 /system
busybox mount -t yaffs2 /dev/block/mtdblock5 /cache
+busybox mount -t yaffs2 -o ro /dev/block/mtdblock1 /ramdisk
-image=/stage1/ramdisk.cpio
+image=/ramdisk/ramdisk.img
if busybox test -e /cache/.startrecovery || busybox grep -q bootmode=2 /proc/cmdline ; then
# recovery boot
busybox echo 'RECOVERY BOOT' >>boot.txt
busybox rm -fr /cache/.startrecovery
- image=/stage1/ramdisk-recovery.cpio
- busybox echo "loading ramdisk-recovery.cpio" >>boot.txt
+ image=/ramdisk/ramdisk-recovery.img
+ busybox echo "loading ramdisk-recovery.img" >>boot.txt
# disable lpm
busybox echo 0 > /sys/class/power_supply/battery/charging_mode_booting
@@ -43,12 +44,14 @@ elif ! busybox test -e /system/build.prop ; then
busybox echo "creating recovery command" >>boot.txt
busybox touch /cache/recovery/command
busybox echo "--update_package=`busybox cat /sdcard/galaxys4g.cfg`" > /cache/recovery/command
+
+ busybox cp /sdcard/ramdisk-recovery.img /ramdisk/ramdisk-recovery.img
else
busybox echo "galaxys4g.cfg not found" >>boot.txt
fi
- busybox echo "loading ramdisk-recovery.cpio" >>boot.txt
- image=/stage1/ramdisk-recovery.cpio
+ busybox echo "loading ramdisk-recovery.img" >>boot.txt
+ image=/ramdisk/ramdisk-recovery.img
# disable lpm
busybox echo 0 > /sys/class/power_supply/battery/charging_mode_booting
@@ -59,18 +62,22 @@ elif ! busybox test -e /system/build.prop ; then
else
# android boot
busybox echo "ANDROID BOOT" >>boot.txt
- busybox echo "loading ramdisk.cpio" >>boot.txt
+ busybox echo "loading ramdisk.img" >>boot.txt
fi
busybox umount /cache
busybox umount /system
busybox rmdir /sdcard
-busybox cpio -ui < $image
+busybox gzip -d < $image > /stage1/ramdisk.cpio
+
+busybox umount /ramdisk
+
+busybox cpio -ui < /stage1/ramdisk.cpio
busybox umount /sys
busybox umount /proc
busybox date >>boot.txt
-busybox rm -rf /stage1 /dev/*
+busybox rm -rf /stage1 /ramdisk /dev/*
export PATH="${_PATH}"
exec /init
diff --git a/usr/galaxysmtd_initramfs.list b/usr/galaxysmtd_initramfs.list
index f64e7a5..ea0451e 100644
--- a/usr/galaxysmtd_initramfs.list
+++ b/usr/galaxysmtd_initramfs.list
@@ -39,6 +39,7 @@ dir /proc 755 0 0
dir /stage1 755 0 0
dir /system 755 0 0
dir /cache 755 0 0
+dir /ramdisk 755 0 0
dir /sdcard 755 0 0
dir /lvm 755 0 0
dir /lvm/etc 755 0 0
@@ -48,6 +49,4 @@ file /lvm/sbin/lvm source/usr/galaxysmtd_initramfs_files/lvm 755 0 0
file /stage1/busybox ../../utilities/busybox 755 0 0
file /stage1/init source/usr/galaxysmtd_initramfs_files/init 755 0 0
file /stage1/erase_image ../../utilities/erase_image 755 0 0
-file /stage1/ramdisk.cpio ../../ramdisk.cpio 700 0 0
-file /stage1/ramdisk-recovery.cpio ../../ramdisk-recovery.cpio 700 0 0
dir /sys 755 0 0
diff --git a/usr/galaxysmtd_initramfs_files/init b/usr/galaxysmtd_initramfs_files/init
index 9b0ca30..868b75c 100755
--- a/usr/galaxysmtd_initramfs_files/init
+++ b/usr/galaxysmtd_initramfs_files/init
@@ -19,14 +19,15 @@ done
busybox mount -t ext4 /dev/lvpool/system /system
busybox mount -t yaffs2 /dev/block/mtdblock3 /cache
+busybox mount -t yaffs2 -o ro /dev/block/mtdblock1 /ramdisk
-image=/stage1/ramdisk.cpio
+image=/ramdisk/ramdisk.cpio
if busybox test -e /cache/.startrecovery || busybox grep -q bootmode=2 /proc/cmdline ; then
# recovery boot
busybox echo 'RECOVERY BOOT' >>boot.txt
busybox rm -fr /cache/.startrecovery
- image=/stage1/ramdisk-recovery.cpio
+ image=/ramdisk/ramdisk-recovery.cpio
busybox echo "loading ramdisk-recovery.img" >>boot.txt
# disable lpm
@@ -52,12 +53,14 @@ elif ! busybox test -e /system/build.prop ; then
busybox echo "creating recovery command" >>boot.txt
busybox touch /cache/recovery/command
busybox echo "--update_package=`busybox cat /sdcard/omni.cfg`" > /cache/recovery/command
+
+ busybox cp /sdcard/ramdisk-recovery.img /ramdisk/ramdisk-recovery.img
else
busybox echo "omni.cfg not found" >>boot.txt
fi
busybox echo "loading ramdisk-recovery.img" >>boot.txt
- image=/stage1/ramdisk-recovery.cpio
+ image=/ramdisk/ramdisk-recovery.cpio
# disable lpm
busybox echo 0 > /sys/class/power_supply/battery/charging_mode_booting
@@ -75,11 +78,15 @@ busybox umount /cache
busybox umount /system
busybox rmdir /sdcard
-busybox cpio -ui < $image
+busybox gzip -d < $image > /stage1/ramdisk.cpio
+
+busybox umount /ramdisk
+
+busybox cpio -ui < /stage1/ramdisk.cpio
busybox umount /sys
busybox umount /proc
busybox date >>boot.txt
-busybox rm -fr /stage1 /dev/*
+busybox rm -fr /stage1 /ramdisk /dev/*
export PATH="${_PATH}"
exec /init
--
2.7.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment