Skip to content

Commit 2910de9

Browse files
committed
motorola/omap4: use kexec for recovery-kernel
Use kexec to boot a custom kernel for TWRP instead of running it on the stock kernel. This adds SELinux-support to the recovery. Change-Id: I4bc3987b6d703adecb4305159b80425ae3c6df46
1 parent 6fd54f4 commit 2910de9

File tree

12 files changed

+107
-10
lines changed

12 files changed

+107
-10
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
#sh $ANDROID_BUILD_TOP/bootable/recovery/safestrap/devices/common/build-install.sh
3+
cd $OUT
4+
rm $OUT/APP/install-files.zip
5+
rm $OUT/install-files/etc/safestrap/2nd-init.zip
6+
rm $OUT/install-files/etc/safestrap/ramdisk-recovery.img
7+
zip -9rj install-files/etc/safestrap/2nd-init 2nd-init-files/*
8+
9+
cd $OUT/recovery/root
10+
# copy correct bbx and fixboot.sh
11+
cp $ANDROID_BUILD_TOP/bootable/recovery/safestrap/bbx ./sbin/bbx
12+
cp $ANDROID_BUILD_TOP/bootable/recovery/safestrap/devices/common/2nd-init-files/fixboot.sh ./sbin/fixboot.sh
13+
cp $ANDROID_BUILD_TOP/bootable/recovery/safestrap/devices/motorola/common-omap4/init.rc ./init.rc
14+
15+
#kexec-files
16+
cp $ANDROID_BUILD_TOP/device/motorola/omap4-common/kexec/* $OUT/install-files/etc/safestrap/kexec/
17+
18+
#kernel
19+
cp $OUT/kernel $OUT/install-files/etc/safestrap/kexec/kernel

safestrap/devices/motorola/common-omap4/build-safestrap.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#!/usr/bin/env bash
22
mkdir -p $OUT/APP
33
mkdir -p $OUT/install-files/bin/
4+
mkdir -p $OUT/install-files/etc/safestrap/kexec/
45
mkdir -p $OUT/install-files/etc/safestrap/res/
56
mkdir -p $OUT/install-files/etc/safestrap/rootfs/
67
mkdir -p $OUT/recovery/root/etc
8+
mkdir -p $OUT/recovery/root/etc/firmware
79
mkdir -p $OUT/recovery/root/sbin
810
cd $ANDROID_BUILD_TOP/bootable/recovery/safestrap/devices/motorola
911
cp -fr common-omap4/res/* $OUT/install-files/etc/safestrap/res/

safestrap/devices/motorola/common-omap4/hijack

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,33 @@ if [ "$RUN_SS" = "1" ]; then
137137
fi
138138

139139
if [ "$ENTER_RECOVERY" = "1" ]; then
140+
# check for kexec files
141+
if [ -e "$RECOVERY_DIR/kexec/kernel" ]; then
142+
$BBX cp $RECOVERY_DIR/ramdisk-recovery.img /
143+
$BBX cp $RECOVERY_DIR/kexec/* /
144+
145+
# unmount SS
146+
$BBX umount $SS_MNT
147+
if [ "$SS_USE_DATAMEDIA" = "1" ]; then
148+
$BBX umount $DATAMEDIA_MNT
149+
fi
150+
$BBX umount -l /system
151+
152+
/sbin/hijack.killall
153+
154+
cd /
155+
$BBX chmod 755 /kexec
156+
$BBX chown 0.2000 /kexec
157+
$BBX insmod /uart.ko
158+
$BBX insmod /arm_kexec.ko
159+
$BBX insmod /kexec.ko
160+
/kexec -l /kernel --devtree=/devtree --ramdisk=/ramdisk-recovery.img
161+
$BBX sleep 1
162+
/kexec -e
163+
exit
164+
fi
165+
166+
# fall back to non-kexec recovery
140167
# filesystem cleanup
141168
$BBX rm /d
142169
$BBX rm /etc

safestrap/devices/motorola/common-omap4/safestrap-common-omap4.mk

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
#SAFESTRAP COMMON
2+
SS_INCLUDE_2NDINIT := true
3+
SS_INCLUDE_SPLASHMENU := true
4+
BOARD_USE_NO_DEVFS_SETUP := false
5+
BOARD_SUPPRESS_EMMC_WIPE := true
6+
7+
# Logging
8+
#TWRP_EVENT_LOGGING := true
9+
110
#TWRP
211
TW_INTERNAL_STORAGE_PATH := "/sdcard"
312
TW_INTERNAL_STORAGE_MOUNT_POINT := "sdcard"
@@ -15,8 +24,8 @@ BOARD_DEFAULT_VIRT_SYSTEM_MAX_SIZE := 1000
1524
BOARD_DEFAULT_VIRT_DATA_SIZE := 2000
1625
BOARD_DEFAULT_VIRT_DATA_MIN_SIZE := 1000
1726
BOARD_DEFAULT_VIRT_DATA_MAX_SIZE := 16000
18-
BOARD_DEFAULT_VIRT_CACHE_SIZE := 300
19-
BOARD_DEFAULT_VIRT_CACHE_MIN_SIZE := 300
27+
BOARD_DEFAULT_VIRT_CACHE_SIZE := 10
28+
BOARD_DEFAULT_VIRT_CACHE_MIN_SIZE := 10
2029
BOARD_DEFAULT_VIRT_CACHE_MAX_SIZE := 1000
2130

2231
TW_CUSTOM_BATTERY_CAPACITY_FIELD := charge_counter
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
#!/usr/bin/env bash
2-
sh $ANDROID_BUILD_TOP/bootable/recovery/safestrap/devices/motorola/common-omap4/build-install.sh
2+
3+
# target specific init.rc (blockdev-symlinks)
4+
cp $ANDROID_BUILD_TOP/device/motorola/maserati/init.target.rc $OUT/recovery/root/
5+
6+
#ducati-firmware is needed for kexecd kernel
7+
cp $ANDROID_BUILD_TOP/vendor/motorola/maserati/proprietary/etc/firmware/ducati-m3.bin $OUT/recovery/root/etc/firmware/
8+
9+
#kexec-files
10+
cp $ANDROID_BUILD_TOP/device/motorola/maserati/kexec/* $OUT/install-files/etc/safestrap/kexec/
11+
12+
sh $ANDROID_BUILD_TOP/bootable/recovery/safestrap/devices/motorola/common-omap4/build-install-kexec.sh
313
sh $ANDROID_BUILD_TOP/bootable/recovery/safestrap/devices/common/build-install-finish.sh
414

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include $(ANDROID_BUILD_TOP)/bootable/recovery/safestrap/devices/common/safestrap-common.mk
1+
#include $(ANDROID_BUILD_TOP)/bootable/recovery/safestrap/devices/common/safestrap-common.mk
22
include $(ANDROID_BUILD_TOP)/bootable/recovery/safestrap/devices/motorola/common-omap4/safestrap-common-omap4.mk
33

44
TW_BRIGHTNESS_PATH := /sys/class/backlight/lm3532_bl/brightness
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
#!/usr/bin/env bash
2-
sh $ANDROID_BUILD_TOP/bootable/recovery/safestrap/devices/motorola/common-omap4/build-install.sh
2+
3+
# target specific init.rc (blockdev-symlinks)
4+
cp $ANDROID_BUILD_TOP/device/motorola/spyder/init.target.rc $OUT/recovery/root/
5+
6+
#ducati-firmware is needed for kexecd kernel
7+
cp $ANDROID_BUILD_TOP/vendor/motorola/spyder/proprietary/etc/firmware/ducati-m3.bin $OUT/recovery/root/etc/firmware/
8+
9+
#kexec-files
10+
cp $ANDROID_BUILD_TOP/device/motorola/spyder/kexec/* $OUT/install-files/etc/safestrap/kexec/
11+
12+
sh $ANDROID_BUILD_TOP/bootable/recovery/safestrap/devices/motorola/common-omap4/build-install-kexec.sh
313
sh $ANDROID_BUILD_TOP/bootable/recovery/safestrap/devices/common/build-install-finish.sh
414

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
include $(ANDROID_BUILD_TOP)/bootable/recovery/safestrap/devices/common/safestrap-common.mk
1+
#include $(ANDROID_BUILD_TOP)/bootable/recovery/safestrap/devices/common/safestrap-common.mk
22
include $(ANDROID_BUILD_TOP)/bootable/recovery/safestrap/devices/motorola/common-omap4/safestrap-common-omap4.mk
33

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
#!/usr/bin/env bash
2-
sh $ANDROID_BUILD_TOP/bootable/recovery/safestrap/devices/motorola/common-omap4/build-install.sh
2+
3+
# target specific init.rc (blockdev-symlinks)
4+
cp $ANDROID_BUILD_TOP/device/motorola/targa/init.target.rc $OUT/recovery/root/
5+
6+
#ducati-firmware is needed for kexecd kernel
7+
cp $ANDROID_BUILD_TOP/vendor/motorola/targa/proprietary/etc/firmware/ducati-m3.bin $OUT/recovery/root/etc/firmware/
8+
9+
#kexec-files
10+
cp $ANDROID_BUILD_TOP/device/motorola/targa/kexec/* $OUT/install-files/etc/safestrap/kexec/
11+
12+
sh $ANDROID_BUILD_TOP/bootable/recovery/safestrap/devices/motorola/common-omap4/build-install-kexec.sh
313
sh $ANDROID_BUILD_TOP/bootable/recovery/safestrap/devices/common/build-install-finish.sh
414

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include $(ANDROID_BUILD_TOP)/bootable/recovery/safestrap/devices/common/safestrap-common.mk
1+
#include $(ANDROID_BUILD_TOP)/bootable/recovery/safestrap/devices/common/safestrap-common.mk
22
include $(ANDROID_BUILD_TOP)/bootable/recovery/safestrap/devices/motorola/common-omap4/safestrap-common-omap4.mk
33

44
TW_BRIGHTNESS_PATH := /sys/class/backlight/lm3532_bl/brightness

0 commit comments

Comments
 (0)