
The fdt header files must come from the u-boot versions when building the tools (we must use the same definitions in the tools as in the u-boot image). To ensure this, generate the "fdt_host.h" file in the Makefile to use the full path to the u-boot fdt header files.
Signed-off-by: Gerald Van Baren vanbaren@cideas.com ---
This is *NOT* a final answer. I'm still getting a build error that I cannot figure out so I figured I would appeal to the Wisdom of the List.
In this patch, I'm auto-generating the fdt_host.h header to specifically include the u-boot fdt headers (as opposed to the host's headers). There may be better way(s) of doing this and there are the aforementioned errors to fix. Treat this as a challenge for improvements. ;-)
Thanks, gvb
Makefile | 1 + include/image.h | 4 ++++ tools/Makefile | 36 ++++++++++++++++++++++++++---------- tools/fdt_host.h | 28 ---------------------------- tools/mkimage.h | 2 +- 5 files changed, 32 insertions(+), 39 deletions(-) delete mode 100644 tools/fdt_host.h
diff --git a/Makefile b/Makefile index 8d82ef5..be08685 100644 --- a/Makefile +++ b/Makefile @@ -3152,6 +3152,7 @@ clean: @rm -f $(obj)nand_spl/{u-boot-spl,u-boot-spl.map,System.map} @rm -f $(obj)onenand_ipl/onenand-{ipl,ipl.bin,ipl-2k.bin,ipl-4k.bin,ipl.map} @rm -f $(obj)api_examples/demo $(VERSION_FILE) + @rm -f $(SRCTREE)/tools/fdt_host.h @find $(OBJTREE) -type f \ ( -name 'core' -o -name '*.bak' -o -name '*~' \ -o -name '*.o' -o -name '*.a' ) -print \ diff --git a/include/image.h b/include/image.h index 9be806e..f28e9fc 100644 --- a/include/image.h +++ b/include/image.h @@ -55,9 +55,13 @@ #endif
#if defined(CONFIG_FIT) +#ifndef USE_HOSTCC #include <fdt.h> #include <libfdt.h> #include <fdt_support.h> +#else +#include <fdt_host.h> +#endif #define CONFIG_MD5 /* FIT images need MD5 support */ #endif
diff --git a/tools/Makefile b/tools/Makefile index 21ea1c2..5ab5456 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -124,9 +124,11 @@ BINS := $(addprefix $(obj),$(BIN_FILES)) CPPFLAGS = -idirafter $(SRCTREE)/include \ -idirafter $(OBJTREE)/include2 \ -idirafter $(OBJTREE)/include \ + -idirafter $(OBJTREE)/tools \ -DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC CFLAGS = $(HOST_CFLAGS) $(CPPFLAGS) -O
+ # No -pedantic switch to avoid libfdt compilation warnings FIT_CFLAGS = -Wall $(CPPFLAGS) -O
@@ -190,10 +192,10 @@ $(obj)md5.o: $(obj)md5.c $(obj)sha1.o: $(obj)sha1.c $(CC) -g $(CFLAGS) -c -o $@ $<
-$(obj)image.o: $(obj)image.c +$(obj)image.o: $(obj)image.c $(obj)fdt_host.h $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
-$(obj)mkimage.o: $(src)mkimage.c +$(obj)mkimage.o: $(src)mkimage.c $(obj)fdt_host.h $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
$(obj)ncb.o: $(src)ncb.c @@ -208,19 +210,19 @@ $(obj)inca-swap-bytes.o: $(src)inca-swap-bytes.c $(obj)mpc86x_clk.o: $(src)mpc86x_clk.c $(CC) -g $(CFLAGS) -c -o $@ $<
-$(obj)fdt.o: $(obj)fdt.c +$(obj)fdt.o: $(obj)fdt.c $(obj)fdt_host.h $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
-$(obj)fdt_ro.o: $(obj)fdt_ro.c +$(obj)fdt_ro.o: $(obj)fdt_ro.c $(obj)fdt_host.h $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
-$(obj)fdt_rw.o: $(obj)fdt_rw.c +$(obj)fdt_rw.o: $(obj)fdt_rw.c $(obj)fdt_host.h $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
-$(obj)fdt_strerror.o: $(obj)fdt_strerror.c +$(obj)fdt_strerror.o: $(obj)fdt_strerror.c $(obj)fdt_host.h $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
-$(obj)fdt_wip.o: $(obj)fdt_wip.c +$(obj)fdt_wip.o: $(obj)fdt_wip.c $(obj)fdt_host.h $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
subdirs: @@ -266,9 +268,6 @@ $(obj)image.c: if [ ! -f $(obj)mkimage.h ] ; then \ ln -s $(src)../tools/mkimage.h $(obj)mkimage.h; \ fi - if [ ! -f $(obj)fdt_host.h ] ; then \ - ln -s $(src)../tools/fdt_host.h $(obj)fdt_host.h; \ - fi
$(obj)fdt.c: $(obj)libfdt_internal.h @rm -f $(obj)fdt.c @@ -297,6 +296,23 @@ $(obj)libfdt_internal.h: $(LOGO_H): $(obj)bmp_logo $(LOGO_BMP) $(obj)./bmp_logo $(LOGO_BMP) >$@
+# +# fdt_host.h has to point to the u-boot version of the libfdt headers +# +$(obj)fdt_host.h: + echo "Auto-generating fdt_host.h" + @echo "/* AUTO GENERATED, do not edit manually */" > $@ + @echo "" >> $@ + @echo "#ifndef __FDT_HOST_H__" >> $@ + @echo "#define __FDT_HOST_H__" >> $@ + @echo "" >> $@ + @echo "/* Include u-boot, *not* the host, version of libfdt include files */" >> $@ + @echo "#include "$(SRCTREE)/include/fdt.h"" >> $@ + @echo "#include "$(SRCTREE)/include/libfdt.h"" >> $@ + @echo "#include "$(SRCTREE)/include/fdt_support.h"" >> $@ + @echo "" >> $@ + @echo "#endif /* __FDT_HOST_H__ */" >> $@ + #########################################################################
# defines $(obj).depend target diff --git a/tools/fdt_host.h b/tools/fdt_host.h deleted file mode 100644 index 085013e..0000000 --- a/tools/fdt_host.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * (C) Copyright 2008 Semihalf - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA - */ - -#ifndef __FDT_HOST_H__ -#define __FDT_HOST_H__ - -/* Make sure to include u-boot version of libfdt include files */ -#include "../include/fdt.h" -#include "../include/libfdt.h" -#include "../include/fdt_support.h" - -#endif /* __FDT_HOST_H__ */ diff --git a/tools/mkimage.h b/tools/mkimage.h index a2d5248..be94a02 100644 --- a/tools/mkimage.h +++ b/tools/mkimage.h @@ -33,7 +33,7 @@ #include <time.h> #include <unistd.h> #include <sha1.h> -#include "fdt_host.h" +#include <fdt_host.h>
#define MKIMAGE_DEBUG