OpenHarmony移植之编译工具链
1、下载工具链
选择适合自己芯片的arm编译工具链,因为我的是arm cortex-a9的芯片,所以我选择如下交叉工具链
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 @@ endif
KERNEL_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.4
CLANG_HOST_TOOLCHAIN := $(OHOS_BUILD_HOME)/prebuilts/clang/ohos/linux-x86_64/llvm/bin
KERNEL_HOSTCC := $(CLANG_HOST_TOOLCHAIN)/clang
KERNEL_PREBUILT_MAKE := make
CLANG_CC := $(CLANG_HOST_TOOLCHAIN)/clang
ifeq ($(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/bin
KERNEL_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"
+else
KERNEL_CROSS_COMPILE += CC="$(CLANG_CC)"
+endif
ifneq ($(KERNEL_ARCH), x86_64)
KERNEL_CROSS_COMPILE += CROSS_COMPILE="$(KERNEL_TARGET_TOOLCHAIN_PREFIX)"
@@ -101,7 +105,16 @@ endif
ifeq ($(KERNEL_VERSION), linux-5.10)
$(hide) $(KERNEL_MAKE) -C $(KERNEL_SRC_TMP_PATH) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) modules_prepare
endif
+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)
+endif
endif
ifeq ($(DEVICE_NAME), hispark_phoenix)
$(hide) $(KERNEL_MAKE) -C