Skip to content

Commit

Permalink
Make TWRP compile for arm64
Browse files Browse the repository at this point in the history
-Remove dosfstools for arm64 until we can make it compile
-Fix TW_USE_TOOLBOX flag to work again
-Fix symlinking and handling of sh when using mksh
-Fix legacy properties to find futex_wake function
-Fix libcrecovery to not use bsd_signal anymore
-Fix rules for building with regards to libcrecovery
-Update toolbox_recovery rules to compile tools in lollipop
-Fix a few compile errors specific to arm64

Testers report that TWRP does not boot on Nexus 9 and we fail to
get a shell for adb shell. At least it compiles without errors.

Change-Id: I286be8628defb60cc527b8a548c0bdfcb0ebb574
  • Loading branch information
Dees-Troy committed Nov 12, 2014
1 parent 4e36d50 commit bcc502c
Show file tree
Hide file tree
Showing 13 changed files with 175 additions and 156 deletions.
24 changes: 16 additions & 8 deletions Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ LOCAL_C_INCLUDES += bionic external/stlport/stlport
LOCAL_STATIC_LIBRARIES :=
LOCAL_SHARED_LIBRARIES :=

LOCAL_STATIC_LIBRARIES += libcrecovery libguitwrp
LOCAL_STATIC_LIBRARIES += libguitwrp
LOCAL_SHARED_LIBRARIES += libz libc libstlport libcutils libstdc++ libtar libblkid libminuitwrp libminadbd libmtdutils libminzip libaosprecovery
LOCAL_SHARED_LIBRARIES += libgccdemangle
LOCAL_SHARED_LIBRARIES += libgccdemangle libcrecovery

ifneq ($(wildcard system/core/libsparse/Android.mk),)
LOCAL_SHARED_LIBRARIES += libsparse
Expand Down Expand Up @@ -324,15 +324,10 @@ endif
LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker

LOCAL_ADDITIONAL_DEPENDENCIES := \
busybox_symlinks \
dosfsck \
dosfslabel \
dump_image \
erase_image \
flash_image \
fix_permissions.sh \
fsck_msdos_symlink \
mkdosfs \
mke2fs.conf \
mkexfatfs \
pigz \
Expand All @@ -342,6 +337,16 @@ LOCAL_ADDITIONAL_DEPENDENCIES := \
unpigz_symlink \
updater

ifneq ($(TARGET_ARCH), arm64)
LOCAL_ADDITIONAL_DEPENDENCIES += \
dosfsck \
dosfslabel \
fsck_msdos_symlink \
mkdosfs
endif
ifneq ($(TW_USE_TOOLBOX), true)
LOCAL_ADDITIONAL_DEPENDENCIES += busybox_symlinks
endif
ifeq ($(BOARD_HAS_NO_REAL_SDCARD),)
LOCAL_ADDITIONAL_DEPENDENCIES += parted
endif
Expand Down Expand Up @@ -495,7 +500,6 @@ include $(commands_recovery_local_path)/injecttwrp/Android.mk \
$(commands_recovery_local_path)/mtdutils/Android.mk \
$(commands_recovery_local_path)/flashutils/Android.mk \
$(commands_recovery_local_path)/pigz/Android.mk \
$(commands_recovery_local_path)/dosfstools/Android.mk \
$(commands_recovery_local_path)/libtar/Android.mk \
$(commands_recovery_local_path)/crypto/cryptsettings/Android.mk \
$(commands_recovery_local_path)/crypto/cryptfs/Android.mk \
Expand All @@ -508,6 +512,10 @@ include $(commands_recovery_local_path)/injecttwrp/Android.mk \
$(commands_recovery_local_path)/twrpTarMain/Android.mk \
$(commands_recovery_local_path)/mtp/Android.mk

ifneq ($(TARGET_ARCH), arm64)
include $(commands_recovery_local_path)/dosfstools/Android.mk
endif

ifeq ($(TW_INCLUDE_CRYPTO_SAMSUNG), true)
include $(commands_recovery_local_path)/crypto/libcrypt_samsung/Android.mk
endif
Expand Down
5 changes: 2 additions & 3 deletions bmlutils/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

BOARD_RECOVERY_DEFINES := BOARD_BML_BOOT BOARD_BML_RECOVERY
LOCAL_STATIC_LIBRARY := libcrecovery

$(foreach board_define,$(BOARD_RECOVERY_DEFINES), \
$(if $($(board_define)), \
$(eval LOCAL_CFLAGS += -D$(board_define)=\"$($(board_define))\") \
) \
)

LOCAL_STATIC_LIBRARIES := libcrecovery
LOCAL_C_INCLUDES := $(commands_recovery_local_path)/libcrecovery

LOCAL_SRC_FILES := bmlutils.c
LOCAL_MODULE := libbmlutils
LOCAL_MODULE_TAGS := eng
Expand All @@ -22,6 +20,7 @@ include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)

BOARD_RECOVERY_DEFINES := BOARD_BML_BOOT BOARD_BML_RECOVERY
LOCAL_SHARED_LIBRARIES := libcrecovery

$(foreach board_define,$(BOARD_RECOVERY_DEFINES), \
$(if $($(board_define)), \
Expand Down
45 changes: 1 addition & 44 deletions bmlutils/bmlutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,50 +22,7 @@

#include <bmlutils.h>

#undef _PATH_BSHELL
#define _PATH_BSHELL "/sbin/sh"

int __system(const char *command)
{
pid_t pid;
sig_t intsave, quitsave;
sigset_t mask, omask;
int pstat;
char *argp[] = {"sh", "-c", NULL, NULL};

if (!command) /* just checking... */
return(1);

argp[2] = (char *)command;

sigemptyset(&mask);
sigaddset(&mask, SIGCHLD);
sigprocmask(SIG_BLOCK, &mask, &omask);
switch (pid = vfork()) {
case -1: /* error */
sigprocmask(SIG_SETMASK, &omask, NULL);
return(-1);
case 0: /* child */
sigprocmask(SIG_SETMASK, &omask, NULL);
execve(_PATH_BSHELL, argp, environ);
_exit(127);
}

intsave = (sig_t) bsd_signal(SIGINT, SIG_IGN);
quitsave = (sig_t) bsd_signal(SIGQUIT, SIG_IGN);
pid = waitpid(pid, (int *)&pstat, 0);
sigprocmask(SIG_SETMASK, &omask, NULL);
(void)bsd_signal(SIGINT, intsave);
(void)bsd_signal(SIGQUIT, quitsave);
return (pid == -1 ? -1 : pstat);
}

static struct pid {
struct pid *next;
FILE *fp;
pid_t pid;
} *pidlist;

#include "../libcrecovery/common.h"

static int restore_internal(const char* bml, const char* filename)
{
Expand Down
2 changes: 1 addition & 1 deletion flashutils/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ LOCAL_SRC_FILES := flashutils.c
LOCAL_MODULE := libflashutils
LOCAL_MODULE_TAGS := eng
LOCAL_C_INCLUDES += $(commands_recovery_local_path)
LOCAL_SHARED_LIBRARIES := libc libmmcutils libbmlutils
LOCAL_SHARED_LIBRARIES := libc libmmcutils libbmlutils libcrecovery
LOCAL_STATIC_LIBRARIES := libmtdutils

BOARD_RECOVERY_DEFINES := BOARD_BML_BOOT BOARD_BML_RECOVERY
Expand Down
2 changes: 2 additions & 0 deletions gui/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ $(TWRP_RES_GEN):
$(TWRP_COMMON_XML)
$(TWRP_REMOVE_FONT)
mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sbin/
ifneq ($(TW_USE_TOOLBOX), true)
ln -sf $(TWRP_SH_TARGET) $(TARGET_RECOVERY_ROOT_OUT)/sbin/sh
endif
ln -sf /sbin/pigz $(TARGET_RECOVERY_ROOT_OUT)/sbin/gzip
ln -sf /sbin/unpigz $(TARGET_RECOVERY_ROOT_OUT)/sbin/gunzip

Expand Down
4 changes: 3 additions & 1 deletion legacy_property_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include <limits.h>
#include <errno.h>

#include "../../bionic/libc/private/bionic_futex.h"

#include <cutils/properties.h>

#include "legacy_properties.h"
Expand Down Expand Up @@ -181,7 +183,7 @@ static int legacy_property_set(const char *name, const char *value)
memcpy(pi->value, value, valuelen + 1);

pa->toc[pa->count] =
(namelen << 24) | (((unsigned) pi) - ((unsigned) pa));
(namelen << 24) | (((unsigned long) pi) - ((unsigned long) pa));

pa->count++;
pa->serial++;
Expand Down
6 changes: 6 additions & 0 deletions libcrecovery/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ LOCAL_MODULE := libcrecovery
LOCAL_MODULE_TAGS := eng
include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_SRC_FILES := system.c popen.c
LOCAL_MODULE := libcrecovery
LOCAL_MODULE_TAGS := eng
include $(BUILD_SHARED_LIBRARY)

endif
8 changes: 4 additions & 4 deletions libcrecovery/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ __system(const char *command)
_exit(127);
}

intsave = (sig_t) bsd_signal(SIGINT, SIG_IGN);
quitsave = (sig_t) bsd_signal(SIGQUIT, SIG_IGN);
intsave = (sig_t) signal(SIGINT, SIG_IGN);
quitsave = (sig_t) signal(SIGQUIT, SIG_IGN);
pid = waitpid(pid, (int *)&pstat, 0);
sigprocmask(SIG_SETMASK, &omask, NULL);
(void)bsd_signal(SIGINT, intsave);
(void)bsd_signal(SIGQUIT, quitsave);
(void)signal(SIGINT, intsave);
(void)signal(SIGQUIT, quitsave);
return (pid == -1 ? -1 : pstat);
}
2 changes: 1 addition & 1 deletion minui/graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ static int get_framebuffer(GGLSurface *fb)
fb->stride = fi.line_length/PIXEL_SIZE;
fb->format = PIXEL_FORMAT;
if (!has_overlay) {
fb->data = (void*) (((unsigned) bits) + vi.yres * fi.line_length);
fb->data = (void*) (((unsigned long) bits) + vi.yres * fi.line_length);
memset(fb->data, 0, vi.yres * fi.line_length);
}

Expand Down
4 changes: 2 additions & 2 deletions minuitwrp/graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,10 @@ static int get_framebuffer(GGLSurface *fb)
fb->height = vi.yres;
#ifdef BOARD_HAS_JANKY_BACKBUFFER
fb->stride = fi.line_length/2;
fb->data = (void*) (((unsigned) bits) + vi.yres * fi.line_length);
fb->data = (GGLubyte*) (((unsigned long) bits) + vi.yres * fi.line_length);
#else
fb->stride = vi.xres_virtual;
fb->data = (void*) (((unsigned) bits) + vi.yres * fb->stride * PIXEL_SIZE);
fb->data = (GGLubyte*) (((unsigned long) bits) + vi.yres * fb->stride * PIXEL_SIZE);
#endif
fb->format = PIXEL_FORMAT;
if (!has_overlay) {
Expand Down
17 changes: 11 additions & 6 deletions prebuilt/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@ RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/erase_image
ifneq ($(TW_USE_TOOLBOX), true)
RELINK_SOURCE_FILES += $(TARGET_OUT_OPTIONAL_EXECUTABLES)/busybox
else
RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/mksh
RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/sh
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libcrypto.so
endif
RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/pigz
RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/dosfsck
RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/dosfslabel
RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/mkdosfs
# dosfstools does not build for arm64 right now
ifneq ($(TARGET_ARCH), arm64)
RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/dosfsck
RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/dosfslabel
RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/mkdosfs
endif
RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/e2fsck
RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/mke2fs
RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/tune2fs
Expand All @@ -31,6 +35,7 @@ RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libc.so
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libcutils.so
# Not available in 5.0
#RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libcorkscrew.so
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libcrecovery.so
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libusbhost.so
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libgccdemangle.so
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libutils.so
Expand Down Expand Up @@ -123,9 +128,9 @@ ifneq ($(TW_EXCLUDE_ENCRYPTED_BACKUPS), true)
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libopenaes.so
endif
ifeq ($(TARGET_USERIMAGES_USE_F2FS), true)
RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/mkfs.f2fs
RELINK_SOURCE_FILES += $(TARGET_ROOT_OUT_SBIN)/mkfs.f2fs
RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/fsck.f2fs
RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/fibmap.f2fs
#RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/fibmap.f2fs
endif
ifneq ($(wildcard system/core/reboot/Android.mk),)
RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/reboot
Expand Down
Loading

0 comments on commit bcc502c

Please sign in to comment.