您的位置:首页 > 房产 > 家装 > OpenHarmony移植之编译工具链

OpenHarmony移植之编译工具链

2024/10/14 10:29:42 来源:https://blog.csdn.net/longyuzi/article/details/140463072  浏览:    关键词:OpenHarmony移植之编译工具链

OpenHarmony移植之编译工具链

1、下载工具链

选择适合自己芯片的arm编译工具链,因为我的是arm cortex-a9的芯片,所以我选择如下交叉工具链

Downloads | GNU-A Downloads – Arm DeveloperDownload the The GNU Toolchain for the Cortex-A Family are integrated and validated packages featuring the GCC compiler, libraries and other GNU tools necessary for software development on devices based on the Arm Cortex-A processors or the Arm A-profile architecture.icon-default.png?t=N7T8https://developer.arm.com/downloads/-/gnu-a

2、将工具链放入OpenHarmony目录

2.1、放入prebuilts目录下面

3、配置编译工具链

3.1、在device目录下配置编译工具链

device/board/exynos/fs4412/linux/config.gni
# Board CPU type, e.g. "cortex-a7", "riscv32".
board_cpu = "cortex-a9"# Board arch, e.g.  "armv7-a", "rv32imac".
board_arch = "armv7"# Toolchain name used for system compiling.
# E.g. gcc-arm-none-eabi, arm-linux-harmonyeabi-gcc, ohos-clang,  riscv32-unknown-elf.
# Note: The default toolchain is "ohos-clang". It's not mandatory if you use the default toolchain.
board_toolchain = "arm-none-linux-gnueabi-gcc"# The toolchain path installed, it's not mandatory if you have added toolchain path to your ~/.bashrc.
board_toolchain_path = "~/openharmony/openharmony_3.2/prebuilts/gcc-4.6.4/bin"# Compiler prefix.
board_toolchain_prefix = "arm-none-linux-gnueabi-"# Compiler type, "gcc" or "clang".
board_toolchain_type = "gcc"

3.2、在kernel/linux/build目录下配置编译工具链

kernel/linux/build/kernel.mk
diff --git a/kernel.mk b/kernel.mk
index dc3343b..415e4d0 100644
--- a/kernel.mk
+++ b/kernel.mk
@@ -27,15 +27,15 @@ endifKERNEL_SRC_PATH := $(OHOS_BUILD_HOME)/kernel/linux/${KERNEL_VERSION}KERNEL_PATCH_PATH := $(OHOS_BUILD_HOME)/kernel/linux/patches/${KERNEL_VERSION}KERNEL_CONFIG_PATH := $(OHOS_BUILD_HOME)/kernel/linux/config/${KERNEL_VERSION}
-PREBUILTS_GCC_DIR := $(OHOS_BUILD_HOME)/prebuilts/gcc
+PREBUILTS_GCC_DIR := $(OHOS_BUILD_HOME)/prebuilts/gcc-4.6.4CLANG_HOST_TOOLCHAIN := $(OHOS_BUILD_HOME)/prebuilts/clang/ohos/linux-x86_64/llvm/binKERNEL_HOSTCC := $(CLANG_HOST_TOOLCHAIN)/clangKERNEL_PREBUILT_MAKE := makeCLANG_CC := $(CLANG_HOST_TOOLCHAIN)/clangifeq ($(KERNEL_ARCH), arm)
-    KERNEL_TARGET_TOOLCHAIN := $(PREBUILTS_GCC_DIR)/linux-x86/arm/gcc-linaro-7.5.0-arm-linux-gnueabi/bin
-    KERNEL_TARGET_TOOLCHAIN_PREFIX := $(KERNEL_TARGET_TOOLCHAIN)/arm-linux-gnueabi-
+    KERNEL_TARGET_TOOLCHAIN := $(PREBUILTS_GCC_DIR)/bin
+    KERNEL_TARGET_TOOLCHAIN_PREFIX := $(KERNEL_TARGET_TOOLCHAIN)/arm-none-linux-gnueabi-else ifeq ($(KERNEL_ARCH), arm64)KERNEL_TARGET_TOOLCHAIN := $(PREBUILTS_GCC_DIR)/linux-x86/aarch64/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/binKERNEL_TARGET_TOOLCHAIN_PREFIX := $(KERNEL_TARGET_TOOLCHAIN)/aarch64-linux-gnu-
@@ -49,7 +49,11 @@ ifeq ($(DEVICE_NAME), hispark_phoenix)KERNEL_CROSS_COMPILE += CONFIG_MSP="y"endif+ifeq ($(DEVICE_NAME), fs4412)
+KERNEL_CROSS_COMPILE += CC="$(KERNEL_TARGET_TOOLCHAIN_PREFIX)gcc"
+elseKERNEL_CROSS_COMPILE += CC="$(CLANG_CC)"
+endififneq ($(KERNEL_ARCH), x86_64)KERNEL_CROSS_COMPILE += CROSS_COMPILE="$(KERNEL_TARGET_TOOLCHAIN_PREFIX)"
@@ -101,7 +105,16 @@ endififeq ($(KERNEL_VERSION), linux-5.10)$(hide) $(KERNEL_MAKE) -C $(KERNEL_SRC_TMP_PATH) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) modules_prepareendif
+ifeq ($(DEVICE_NAME), fs4412)
+ifeq ($(KERNEL_VERSION), linux-5.10)
+       $(hide) $(KERNEL_MAKE) -C $(KERNEL_SRC_TMP_PATH) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) -j64 $(KERNEL_IMAGE) LOADADDR=0x40008000
+else$(hide) $(KERNEL_MAKE) -C $(KERNEL_SRC_TMP_PATH) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) -j64 $(KERNEL_IMAGE)
+endif
+       $(hide) $(KERNEL_MAKE) -C $(KERNEL_SRC_TMP_PATH) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) dtbs
+else
+       $(hide) $(KERNEL_MAKE) -C $(KERNEL_SRC_TMP_PATH) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) -j64 $(KERNEL_IMAGE)
+endifendififeq ($(DEVICE_NAME), hispark_phoenix)$(hide) $(KERNEL_MAKE) -C

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com