Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make it easy to cross compile without Android source code #14

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.o
*.d
*.a
*.ro
5 changes: 5 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ include $(srcdir)/util_lib/Makefile
#
include $(srcdir)/util/Makefile


#
# purgatory (code between kernels)
#
Expand All @@ -161,11 +162,15 @@ include $(srcdir)/purgatory/Makefile
#
include $(srcdir)/kexec/Makefile

# libfdt
# include $(srcdir)/kexec/libfdt/Makefile

# kdump (read a crashdump from memory)
#
include $(srcdir)/kdump/Makefile



#
# kexec_test (test program)
#
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cross compile for arm or arm64 device

1. Install arm-linux-gnueabi-gcc (i have test with gcc5) toolchain from the software center by apt-get or dnf what you like

2. Install libz for arm-linux-gnueabi-gcc toolchain (need to use cross compile)

3. Configure the kexectools

```bash
root@sndnvaps-PC:/home/sndnvaps/kexec-tools# mkdir build_install
root@sndnvaps-PC:/home/sndnvaps/kexec-tools# CC=arm-linux-gnueabi-gcc-5 LDFLAGS="-static" CFLAGS="-I${PWD}/include -I${PWD}/util_lib/include -I${PWD}/kexec/arch/arm/include -I${PWD}/kexec/libfdt -I${PWD}/purgatory/include" LIBS="-lc" ./configure --host=arm-unknown-linux-gnueabi --prefix=/home/sndnvaps/kexec-tools/build_install

root@sndnvaps-PC:/home/sndnvaps/kexec-tools# make
root@sndnvaps-PC:/home/sndnvaps/kexec-tools# make install
```
4. you will got what you want in build_install/sbin
2 changes: 1 addition & 1 deletion include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#define PACKAGE_BUGREPORT ""

/* Define to the release date of this package */
#define PACKAGE_DATE "29 July 2010"
#define PACKAGE_DATE "15 July 2024"

/* Define to the full name of this package. */
#define PACKAGE_NAME "kexec-tools"
Expand Down
2 changes: 2 additions & 0 deletions kdump/kdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
#include <fcntl.h>
#include <endian.h>
#include <elf.h>
#include <errno.h>

extern char *strerror(int errnum);
#if !defined(__BYTE_ORDER) || !defined(__LITTLE_ENDIAN) || !defined(__BIG_ENDIAN)
#error Endian defines missing
#endif
Expand Down
6 changes: 4 additions & 2 deletions kexec/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ include $(srcdir)/kexec/arch/s390/Makefile
include $(srcdir)/kexec/arch/sh/Makefile
include $(srcdir)/kexec/arch/x86_64/Makefile

include $(srcdir)/kexec/libfdt/Makefile

KEXEC_SRCS += $($(ARCH)_KEXEC_SRCS)

KEXEC_OBJS = $(call objify, $(KEXEC_SRCS) $(KEXEC_GENERATED_SRCS))
Expand All @@ -75,11 +77,11 @@ KEXEC_MANPAGE = $(MANDIR)/man8/kexec.8

-include $(KEXEC_DEPS)

$(KEXEC): $(KEXEC_OBJS) $(UTIL_LIB)
$(KEXEC): $(KEXEC_OBJS) $(UTIL_LIB) $(FDT_LIB)
@$(MKDIR) -p $(@D)
$(LINK.o) -o $@ $^ $(LIBS)

$(KEXEC): CPPFLAGS+=-I$(srcdir)/kexec/arch/$(ARCH)/include
$(KEXEC): CPPFLAGS+=-I$(srcdir)/kexec/arch/$(ARCH)/include -I$(srcdir)/kexec/libfdt

$(KEXEC_MANPAGE): kexec/kexec.8
@$(MKDIR) -p $(MANDIR)/man8
Expand Down
6 changes: 5 additions & 1 deletion kexec/arch/arm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ arm_KEXEC_SRCS+= kexec/arch/arm/kexec-zImage-arm.c
arm_KEXEC_SRCS+= kexec/arch/arm/kexec-uImage-arm.c
arm_KEXEC_SRCS+= kexec/arch/arm/kexec-arm.c
arm_KEXEC_SRCS+= kexec/arch/arm/crashdump-arm.c
arm_KEXEC_SRCS+= kexec/arch/arm/mach-hammerhead.c
arm_KEXEC_SRCS+= kexec/arch/arm/mach-m8.c
arm_KEXEC_SRCS+= kexec/arch/arm/mach-shamu.c
arm_KEXEC_SRCS+= kexec/arch/arm/mach.c
arm_KEXEC_SRCS+= kexec/kexec-uImage.c

arm_PHYS_TO_VIRT = kexec/arch/arm/phys_to_virt.c

dist += kexec/arch/arm/Makefile $(arm_KEXEC_SRCS) $(arm_PHYS_TO_VIRT) \
kexec/arch/arm/crashdump-arm.h kexec/arch/arm/kexec-arm.h \
kexec/arch/arm/include/arch/options.h
kexec/arch/arm/mach.h kexec/arch/arm/include/arch/options.h
23 changes: 23 additions & 0 deletions kexec/libfdt/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Makefile.libfdt
#
# This is not a complete Makefile of itself. Instead, it is designed to
# be easily embeddable into other systems of Makefiles.
#

LIBFDT_SRCS = kexec/libfdt/fdt.c kexec/libfdt/fdt_ro.c \
kexec/libfdt/fdt_wip.c kexec/libfdt/fdt_sw.c \
kexec/libfdt/fdt_rw.c kexec/libfdt/fdt_strerror.c

LIBFDT_OBJS = $(call objify, $(LIBFDT_SRCS))

FDT_LIB = libfdt.a

dist += kexec/libfdt/Makefile $(LIBFDT_SRCS) \
kexec/libfdt/fdt.h kexec/libfdt/libfdt.h \
kexec/libfdt/libfdt_env.h \
kexec/libfdt/libfdt_internal.h
clean += $(LIBFDT_OBJS) $(FDT_LIB)

$(FDT_LIB):$(LIBFDT_OBJS)
@$(MKDIR) -p $(@D)
$(AR) rs $(FDT_LIB) $(LIBFDT_OBJS)
13 changes: 0 additions & 13 deletions kexec/libfdt/Makefile.libfdt

This file was deleted.

7 changes: 7 additions & 0 deletions kexec/libfdt/fdt_ro.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@

#include "libfdt_internal.h"


#include <string.h>

extern size_t strlen(const char *string);
extern void *memchr(const void *str, int c, size_t n);


static int _fdt_nodename_eq(const void *fdt, int offset,
const char *s, int len)
{
Expand Down
5 changes: 5 additions & 0 deletions kexec/libfdt/fdt_rw.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@

#include "libfdt_internal.h"

#include <string.h>

extern void *memmove(void *str1, const void *str2, size_t n);
extern size_t strlen(const char *string);

static int _fdt_blocks_misordered(const void *fdt,
int mem_rsv_size, int struct_size)
{
Expand Down
5 changes: 5 additions & 0 deletions kexec/libfdt/fdt_sw.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@

#include "libfdt_internal.h"

#include <string.h>

extern void *memmove(void *str1, const void *str2, size_t n);
extern size_t strlen(const char *string);

static int _fdt_sw_check_header(void *fdt)
{
if (fdt_magic(fdt) != FDT_SW_MAGIC)
Expand Down
Loading