From b248acae9578400173524088965349753ceb5ce3 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 19 Feb 2009 17:17:16 +0000 Subject: [PATCH] add mkyaffs2image (based on android sources) SVN-Revision: 14567 --- tools/Makefile | 2 +- tools/yaffs2/Makefile | 37 ++++++++ tools/yaffs2/patches/100-compile.patch | 114 +++++++++++++++++++++++++ 3 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 tools/yaffs2/Makefile create mode 100644 tools/yaffs2/patches/100-compile.patch diff --git a/tools/Makefile b/tools/Makefile index f2e4bafbfe..c5a9933448 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -9,7 +9,7 @@ curdir:=tools # subdirectories to descend into -$(curdir)/builddirs := sed sstrip ipkg-utils genext2fs squashfs mtd-utils lzma mkimage firmware-utils patch-cmdline pkg-config automake $(if $(CONFIG_CCACHE),ccache) bison $(if $(CONFIG_powerpc),dtc) lua quilt autoconf $(if $(CONFIG_GCC_VERSION_4_3),gmp mpfr) +$(curdir)/builddirs := sed sstrip ipkg-utils genext2fs squashfs mtd-utils lzma mkimage firmware-utils patch-cmdline pkg-config automake $(if $(CONFIG_CCACHE),ccache) bison $(if $(CONFIG_powerpc),dtc) lua quilt autoconf $(if $(CONFIG_GCC_VERSION_4_3),gmp mpfr) yaffs2 # builddir dependencies $(curdir)/squashfs/compile := $(curdir)/lzma/install diff --git a/tools/yaffs2/Makefile b/tools/yaffs2/Makefile new file mode 100644 index 0000000000..37da033d76 --- /dev/null +++ b/tools/yaffs2/Makefile @@ -0,0 +1,37 @@ +# +# Copyright (C) 2008 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=yaffs2_android +PKG_VERSION:=2008-12-18 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 +PKG_SOURCE_URL:=git://android.git.kernel.org/platform/external/yaffs2.git +PKG_SOURCE_PROTO:=git +PKG_SOURCE_SUBDIR:=$(PKG_NAME) +PKG_SOURCE_VERSION:=d333fc232d7e5ae3370080d5d6f7d88ea9c6b3a1 +PKG_BUILD_DIR=$(BUILD_DIR_HOST)/$(PKG_NAME) + +include $(INCLUDE_DIR)/host-build.mk + +define Build/Compile + $(MAKE) -C $(PKG_BUILD_DIR)/yaffs2/utils \ + CFLAGS="$(HOST_CFLAGS) -include endian.h" \ + mkyaffs2image +endef + +define Build/Install + $(INSTALL_DIR) $(STAGING_DIR_HOST)/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/yaffs2/utils/mkyaffs2image $(STAGING_DIR_HOST)/bin/ +endef + +define Build/Clean + rm -f $(STAGING_DIR_HOST)/bin/mkyaffs2image +endef + +$(eval $(call HostBuild)) diff --git a/tools/yaffs2/patches/100-compile.patch b/tools/yaffs2/patches/100-compile.patch new file mode 100644 index 0000000000..154f3895b7 --- /dev/null +++ b/tools/yaffs2/patches/100-compile.patch @@ -0,0 +1,114 @@ +--- a/yaffs2/utils/Makefile ++++ b/yaffs2/utils/Makefile +@@ -16,12 +16,11 @@ + + #KERNELDIR = /usr/src/kernel-headers-2.4.18 + +-CFLAGS = -I/usr/include -I.. -O2 -Wall -DCONFIG_YAFFS_UTIL +-CFLAGS+= -Wshadow -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Wmissing-declarations +-CFLAGS+= -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Winline ++CPPFLAGS = -I.. -DCONFIG_YAFFS_UTIL ++CFLAGS = -O2 + + ## Change if you are using a cross-compiler +-MAKETOOLS = ++MAKETOOLS = + + CC=$(MAKETOOLS)gcc + +@@ -41,7 +40,7 @@ $(COMMONLINKS) $(MKYAFFSLINKS) $(MKYAFFS + ln -s ../$@ $@ + + $(COMMONOBJS) $(MKYAFFSIMAGEOBJS) $(MKYAFFS2IMAGEOBJS) : %.o: %.c +- $(CC) -c $(CFLAGS) $< -o $@ ++ $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ + + mkyaffsimage: $(COMMONOBJS) $(MKYAFFSIMAGEOBJS) + $(CC) -o $@ $(COMMONOBJS) $(MKYAFFSIMAGEOBJS) +--- a/yaffs2/utils/mkyaffs2image.c ++++ b/yaffs2/utils/mkyaffs2image.c +@@ -32,8 +32,6 @@ + #include + #include + +-#include +- + #include "yaffs_ecc.h" + #include "yaffs_guts.h" + +@@ -69,10 +67,12 @@ static int outFile; + + static int error; + +-#ifdef HAVE_BIG_ENDIAN ++#if BYTE_ORDER == BIG_ENDIAN + static int convert_endian = 1; +-#elif defined(HAVE_LITTLE_ENDIAN) ++#elif BYTE_ORDER == LITTLE_ENDIAN + static int convert_endian = 0; ++#else ++#error Unknown endian type + #endif + + static int obj_compare(const void *a, const void * b) +@@ -298,8 +298,8 @@ static int write_object_header(int objId + + static void fix_stat(const char *path, struct stat *s) + { +- path += source_path_len; +- fs_config(path, S_ISDIR(s->st_mode), &s->st_uid, &s->st_gid, &s->st_mode); ++ s->st_uid = 0; ++ s->st_gid = 0; + } + + static int process_directory(int parent, const char *path, int fixstats) +@@ -342,9 +342,8 @@ static int process_directory(int parent, + newObj = obj_id++; + nObjects++; + +- if (fixstats) { ++ if (fixstats) + fix_stat(full_name, &stats); +- } + + //printf("Object %d, %s is a ",newObj,full_name); + +@@ -473,13 +472,13 @@ int main(int argc, char *argv[]) + fprintf(stderr," -f fix file stat (mods, user, group) for device\n"); + fprintf(stderr," dir the directory tree to be converted\n"); + fprintf(stderr," image_file the output file to hold the image\n"); +- fprintf(stderr," 'convert' produce a big-endian image from a little-endian machine\n"); ++ fprintf(stderr," 'convert' produce a big-endian image\n"); + exit(1); + } + + if ((argc == 4) && (!strncmp(argv[3], "convert", strlen("convert")))) + { +- convert_endian = 1; ++ convert_endian = !convert_endian; + } + + if(stat(argv[1],&stats) < 0) +@@ -503,20 +502,9 @@ int main(int argc, char *argv[]) + exit(1); + } + +- if (fixstats) { +- int len = strlen(argv[1]); +- +- if((len >= 4) && (!strcmp(argv[1] + len - 4, "data"))) { +- source_path_len = len - 4; +- } else if((len >= 7) && (!strcmp(argv[1] + len - 6, "system"))) { +- source_path_len = len - 6; +- } else { +- fprintf(stderr,"Fixstats (-f) option requested but filesystem is not data or android!\n"); +- exit(1); +- } ++ if (fixstats) + fix_stat(argv[1], &stats); +- } +- ++ + //printf("Processing directory %s into image file %s\n",argv[1],argv[2]); + error = write_object_header(1, YAFFS_OBJECT_TYPE_DIRECTORY, &stats, 1,"", -1, NULL); + if(error)