繁体   English   中英

是否可以从u-boot为arm建立dumpimage?

[英]Is it possible to build dumpimage from u-boot for arm .?

我正在尝试提取mkimage在ARM板上创建的FIT图像。

通常,当我们构建u-bootmkimage主机构建mkimagedumpimage

相反,我想交叉编译并安装在ramfs 有什么方法可以做到这一点?

重写Makefile:

我修改了make文件,使其将手臂交叉工具作为HOSTCC,我可以看到为手臂弓创建了.o文件( 文件* .o )。 **示例Makefile如下所示(只是我想将dumpimage编译为arm,所以我已注释掉所有其他部分)=>

# 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 \

输出是=>

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

注意我已经下载并编译了arm和openssl的openssl,并且路径已分配给LDFLAGS,如我们在Makefile补丁中所见

如何链接为arm单独构建的库?

如果我做错了,请纠正我。

除了如上所述的Makefile文件更改外,在加密和ssl链接问题上,我还为arm编译了openssl并使用HOSTLDFLAGS在u-boot顶层Makefile中链接了* .a。

您可以构建交叉编译的U-boot工具。 示例:使ARCH = arm CROSS_COMPILE = aarch64-linux-gnu- CROSS_BUILD_TOOLS = 1工具

这将为您提供在您的tools目录中生成的交叉编译工具。

我在Linux x86 / 64上只需要dumpimage工具时遇到了这个问题。 以下对我有用。

1)wget ftp://ftp.denx.de/pub/u-boot/u-boot-latest.tar.bz2
2)光盘u-boot-2017.09
3)制作qemu-x86_defconfig
4)制作工具

主机工具现已准备就绪。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM