我正在尝试在ARM板上提取由mkimage
创建的FIT图像。
通常在我们构建u-boot
时,会为主机构建mkimage
和dumpimage
。
我希望在ramfs
中交叉编译和安装。有没有办法做到这一点?
重写Makefile:
我修改了make文件,以便将arm cross tool作为HOSTCC,我可以看到.o文件是为arm arch创建的( file * .o )。 **示例Makefile如下所示**(我只想为dump编译armi,所以我已经注释掉了所有其他部分)=>
# git diff 0b94ce5ed4a6c2cd0fec7b8337e776b03e387347
diff --git a/Makefile b/Makefile
index 88128ec..8ed7a33 100755
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,7 @@ PATCHLEVEL = 07
SUBLEVEL =
EXTRAVERSION =
NAME =
+CC=arm-linux-gnueabihf-gcc
# *DOCUMENTATION*
# To see a list of typical targets execute "make help"
@@ -224,7 +225,7 @@ unexport CDPATH
#########################################################################
-HOSTARCH := $(shell uname -m | \
+#HOSTARCH := $(shell uname -m | \
sed -e s/i.86/x86/ \
-e s/sun4u/sparc64/ \
-e s/arm.*/arm/ \
@@ -233,6 +234,7 @@ HOSTARCH := $(shell uname -m | \
-e s/ppc/powerpc/ \
-e s/macppc/powerpc/\
-e s/sh.*/sh/)
+HOSTARCH := arm
HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
sed -e 's/\(cygwin\).*/cygwin/')
@@ -254,8 +256,8 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
else if [ -x /bin/bash ]; then echo /bin/bash; \
else echo sh; fi ; fi)
-HOSTCC = cc
-HOSTCXX = c++
+HOSTCC = arm-linux-gnueabihf-gcc
+HOSTCXX = arm-linux-gnueabihf-g++
HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
HOSTCXXFLAGS = -O2
@@ -283,7 +285,7 @@ os_x_before = $(shell if [ $(DARWIN_MAJOR_VERSION) -le $(1) -a \
$(DARWIN_MINOR_VERSION) -le $(2) ] ; then echo "$(3)"; else echo "$(4)"; fi ;)
# Snow Leopards build environment has no longer restrictions as described above
-HOSTCC = $(call os_x_before, 10, 5, "cc", "gcc")
+HOSTCC = $(call os_x_before, 10, 5, "arm-linux-gnueabihf-gcc", "arm-linux-gnueabihf-gcc")
HOSTCFLAGS += $(call os_x_before, 10, 4, "-traditional-cpp")
HOSTLDFLAGS += $(call os_x_before, 10, 5, "-multiply_defined suppress")
@@ -392,13 +394,13 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
# Rules shared between *config targets and build targets
# Basic helpers built in scripts/
-PHONY += scripts_basic
-scripts_basic:
- $(Q)$(MAKE) $(build)=scripts/basic
- $(Q)rm -f .tmp_quiet_recordmcount
+#PHONY += scripts_basic
+#scripts_basic:
+# $(Q)$(MAKE) $(build)=scripts/basic
+# $(Q)rm -f .tmp_quiet_recordmcount
# To avoid any implicit rule to kick in, define an empty command.
-scripts/basic/%: scripts_basic ;
+#scripts/basic/%: scripts_basic ;
PHONY += outputmakefile
# outputmakefile generates a Makefile in the output directory, if using a
@@ -470,11 +472,11 @@ ifeq ($(config-targets),1)
KBUILD_DEFCONFIG := sandbox_defconfig
export KBUILD_DEFCONFIG KBUILD_KCONFIG
-config: scripts_basic outputmakefile FORCE
- $(Q)$(MAKE) $(build)=scripts/kconfig $@
+#config: scripts_basic outputmakefile FORCE
+# $(Q)$(MAKE) $(build)=scripts/kconfig $@
-%config: scripts_basic outputmakefile FORCE
- $(Q)$(MAKE) $(build)=scripts/kconfig $@
+#%config: scripts_basic outputmakefile FORCE
+# $(Q)$(MAKE) $(build)=scripts/kconfig $@
else
# ===========================================================================
@@ -670,7 +672,7 @@ libs-y += $(if $(BOARDDIR),board/$(BOARDDIR)/)
libs-y := $(sort $(libs-y))
-u-boot-dirs := $(patsubst %/,%,$(filter %/, $(libs-y))) tools examples
+u-boot-dirs := tools
u-boot-alldirs := $(sort $(u-boot-dirs) $(patsubst %/,%,$(filter %/, $(libs-))))
@@ -1197,7 +1199,7 @@ u-boot.sym: u-boot FORCE
# The actual objects are generated when descending,
# make sure no implicit rule kicks in
-$(sort $(u-boot-init) $(u-boot-main)): $(u-boot-dirs) ;
+#$(sort $(u-boot-init) $(u-boot-main)): $(u-boot-dirs) ;
# Handle descending into subdirectories listed in $(vmlinux-dirs)
# Preset locale variables to speed up the build process. Limit locale
@@ -1205,24 +1207,30 @@ $(sort $(u-boot-init) $(u-boot-main)): $(u-boot-dirs) ;
# make menuconfig etc.
# Error messages still appears in the original language
-PHONY += $(u-boot-dirs)
-$(u-boot-dirs): prepare scripts
- $(Q)$(MAKE) $(build)=$@
+PHONY += tools
+#-Xlinker -rpath-link=/home/phate/rpi/chroot-raspbian-armhf/usr/lib/arm-linux-gnueabihf
+LDFLAGS += -L./lib_sample/ -lcrypto
+LDFLAGS += -L/home/pritam/documents/workspace/codebase/linux/u-boot/codebase/openssl/openssl/ -lcrypto
-tools: prepare
+LD_LIBRARY_PATH=./lib_sample/
+export LD_LIBRARY_PATH
+tools: #prepare scripts
+ make $(build)=$@
+
+#tools: #prepare
# The "tools" are needed early
-$(filter-out tools, $(u-boot-dirs)): tools
+#$(u-boot-dirs)):
# The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC
# is "yes"), so compile examples after U-Boot is compiled.
-examples: $(filter-out examples, $(u-boot-dirs))
+#examples: $(filter-out examples, $(u-boot-dirs))
define filechk_uboot.release
- echo "$(UBOOTVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
+# echo "$(UBOOTVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
endef
# Store (new) UBOOTRELEASE string in include/config/uboot.release
-include/config/uboot.release: include/config/auto.conf FORCE
- $(call filechk,uboot.release)
+#include/config/uboot.release: include/config/auto.conf FORCE
+# $(call filechk,uboot.release)
# Things we need to do before we recursively start building the kernel
@@ -1232,7 +1240,7 @@ include/config/uboot.release: include/config/auto.conf FORCE
# version.h and scripts_basic is processed / created.
# Listed in dependency order
-PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
+#PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
# prepare3 is used to check if we are building in a separate output directory,
# and if so do:
@@ -1257,7 +1265,7 @@ ifeq ($(wildcard $(LDSCRIPT)),)
@/bin/false
endif
-archprepare: prepare1 scripts_basic
+#archprepare: prepare1 scripts_basic
prepare0: archprepare FORCE
$(Q)$(MAKE) $(build)=.
@@ -1377,11 +1385,11 @@ checkarmreloc: u-boot
false; \
fi
-env: scripts_basic
- $(Q)$(MAKE) $(build)=tools/$@
+#env: scripts_basic
+# $(Q)$(MAKE) $(build)=tools/$@
-tools-only: scripts_basic $(version_h) $(timestamp_h)
- $(Q)$(MAKE) $(build)=tools
+#tools-only: scripts_basic $(version_h) $(timestamp_h)
+# $(Q)$(MAKE) $(build)=tools
tools-all: export HOST_TOOLS_ALL=y
tools-all: env tools ;
diff --git a/common/image-sig.c b/common/image-sig.c
index eda5e13..c6df99f 100644
--- a/common/image-sig.c
+++ b/common/image-sig.c
@@ -3,6 +3,7 @@
*
* SPDX-License-Identifier: GPL-2.0+
*/
+//#undef USE_HOSTCC
#ifdef USE_HOSTCC
#include "mkimage.h"
diff --git a/scripts/Makefile b/scripts/Makefile
index 2f081f7..345a272 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -16,4 +16,4 @@ build_docproc: $(obj)/docproc
@:
# Let clean descend into subdirs
-subdir- += basic kconfig
+#subdir- += basic kconfig
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 06e5c20..9056412 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -269,8 +269,8 @@ define rule_cc_o_c
$(cmd_modversions) \
$(call echo-cmd,record_mcount) \
$(cmd_record_mcount) \
- scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \
- $(dot-target).tmp; \
+#scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \
+# $(dot-target).tmp; \
rm -f $(depfile); \
mv -f $(dot-target).tmp $(dot-target).cmd
endef
diff --git a/scripts/basic/Makefile b/scripts/basic/Makefile
index f883857..b281340 100644
--- a/scripts/basic/Makefile
+++ b/scripts/basic/Makefile
@@ -11,8 +11,8 @@
# SPDX-License-Identifier: GPL-2.0
#
-hostprogs-y := fixdep
-always := $(hostprogs-y)
+#hostprogs-y := fixdep
+#always := $(hostprogs-y)
-# fixdep is needed to compile other host programs
-$(addprefix $(obj)/,$(filter-out fixdep,$(always))): $(obj)/fixdep
+## fixdep is needed to compile other host programs
+#$(addprefix $(obj)/,$(filter-out fixdep,$(always))): $(obj)/fixdep
diff --git a/tools/Makefile b/tools/Makefile
index f72294a..be9b221 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -225,6 +225,7 @@ HOST_EXTRACFLAGS += -include $(srctree)/include/libfdt_env.h \
$(patsubst -I%,-idirafter%, $(filter -I%, $(UBOOTINCLUDE))) \
-I$(srctree)/lib/libfdt \
-I$(srctree)/tools \
+ -I/home/pritam/documents/workspace/codebase/linux/u-boot/codebase/openssl/openssl/include \
-DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE) \
-DUSE_HOSTCC \
-D__KERNEL_STRICT_NAMES \
OUTPUT =>>
make -f ./scripts/Makefile.build obj=tools
HOSTLD tools/dumpimage
/home/pritam/documents/workspace/tools/sdks/bolide/petalinux/tools/linux-i386/gcc-arm-linux-gnueabi/bin/../lib/gcc/arm-linux-gnueabihf/5.2.1/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lssl
/home/pritam/documents/workspace/tools/sdks/bolide/petalinux/tools/linux-i386/gcc-arm-linux-gnueabi/bin/../lib/gcc/arm-linux-gnueabihf/5.2.1/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status
scripts/Makefile.host:103: recipe for target 'tools/dumpimage' failed
make[1]: *** [tools/dumpimage] Error 1
Makefile:1217: recipe for target 'tools' failed
make: *** [tools] Error 2
注意我已经下载并编译openssl for arm,路径分配给 LDFLAGS ,正如我们在 Makefile补丁
中看到的那样如何链接为arm单独构建的库?
如果我出错,请纠正我。
答案 0 :(得分:0)
除了上面提到的Makefile的变化之外,在crypto和ssl链接问题上,我已经使用HOSTLDFLAGS编译了openssl for arm和链接* .a在u-boot顶级Makefile中。
答案 1 :(得分:0)
您可以构建Cross编译的U-boot工具。 例如:make ARCH = arm CROSS_COMPILE = aarch64-linux-gnu- CROSS_BUILD_TOOLS = 1工具
这将为您提供在工具目录中生成的交叉编译工具。
答案 2 :(得分:0)
我在Linux x86 / 64上只需要dumpimage工具时遇到了这个问题。 以下对我有用。
1)wget ftp://ftp.denx.de/pub/u-boot/u-boot-latest.tar.bz2
2)cd u-boot-2017.09
3)制作qemu-x86_defconfig
4)制作工具
主机工具现已准备就绪。