1. 环境搭建

推荐编译主机配置如下:

  1. Ubuntu22.04 LTS搭建开发环境
  2. 64 位 CPU
  3. DDR至少16GB
  4. 至少120GB的硬盘空间

安装工具包,在编译主机执行以下命令:

$ sudo apt-get install aptitude
$ sudo aptitude install -y binutils binutils-dev git git-lfs gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib gcc-arm-none-eabi gcc-arm-linux-gnueabi x11proto-core-dev libx11-dev lib32z1-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4 bc gnutls-bin python3-pip ruby genext2fs device-tree-compiler make libffi-dev e2fsprogs pkg-config perl openssl libssl-dev libelf-dev libdwarf-dev u-boot-tools mtd-utils cpio doxygen liblz4-tool openjdk-8-jre gcc g++ texinfo dosfstools mtools default-jre default-jdk libncurses5 apt-utils wget scons tar rsync git-core libxml2-dev lib32z-dev grsync xxd libglib2.0-dev libpixman-1-dev kmod jfsutils reiserfsprogs xfsprogs squashfs-tools git-lfs
$ sudo apt-get install -y pcmciautils quota ppp libtinfo-dev libtinfo5 libncurses5-dev libncursesw5 libstdc++6  vim ssh locales gcc-arm-linux-gnueabi

2. OpenHarmony5.0 SDK编译

2.1. OHOS5.0 源码获取

OpenHarmony5.0Release版本特性说明:

https://gitee.com/openharmony/docs/blob/master/zh-cn/release-notes/OpenHarmony-v5.0.0-release.md

2.1.1. 全量SDK获取

链接: https://pan.baidu.com/s/1ngEcAr7NgtTwfStgv8WyHg?pwd=1234

提取码: 1234

下载后解压前先核对md5sum是否正确,成功后才能正常解压完成。

$ md5sum -c md5sum.txt
Purple-Pi-OH-5.0.tar.gz:成功
$ tar xzvf Purple-Pi-OH-5.0.tar.gz -C .

注意:全量代码无需再次打补丁,只需按2.3章节编译即可

2.1.2. OHOS5.0 官方源码获取

在Linux主机执行以下命令,获取的是与版本发布时完全一致的源码

$ repo init -u https://gitee.com/openharmony/manifest -b refs/tags/OpenHarmony-v5.0.0-Release --no-repo-verify
$ repo sync -c
$ repo forall -c 'git lfs pull'

SDK代码文件目录如下图所示:

 

2.2. 打补丁

本地下载:📎IDO_PurplePiOH_V1A_OHOS5.0r_Patch_241017.zip

下载后将补丁放到当前代码根目录下,如下图所示:

 

然后进入该补丁内执行命令:

$ unzip IDO_PurplePiOH_V1A_OHOS5.0r_Patch_241017.zip
$ cd IDO_PurplePiOH_V1A_OHOS5.0r_Patch_241017/
$ ./ido_patch.sh

补丁合并成功,如下图所示:

 

2.3. OHOS5.0 SDK编译

2.3.1. SDK完整编译

先下载工具链,然后再执行编译命令(默认编译为32位系统)

$ bash build/prebuilts_download.sh
$ ./build.sh --product-name purple_pi_oh --ccache

编译结果如下图所示:

 

失败时log索引位置:./out/purple_pi_oh/error.log

固件索引位置:./out/purple_pi_oh/packages/phone/images/

2.3.2. 编译MIPI固件

默认编译出来的是HDMI固件,如果需要编译MIPI固件则修改:

device/board/industio/purple_pi_oh/kernel/build_kernel.sh
注释:#eval $MAKE_OHOS_ENV ./make-ohos.sh IDO-PurPle-Pi-OH-HDMI $RAMDISK_ARG ${ENABLE_LTO_O0}
使用:eval $MAKE_OHOS_ENV ./make-ohos.sh IDO-PurPle-Pi-OH-MIPI $RAMDISK_ARG ${ENABLE_LTO_O0}

如下图所示:

 

2.4. full-sdk下载链接

链接: https://pan.baidu.com/s/1L_aJDaMfENR5PQnIqJe8gg?pwd=1234

提取码: 1234

 

3.

3. OpenHarmony4.1 SDK编译

3.1. OHOS4.1 源码获取

OpenHarmony4.1Release版本特性说明:

https://gitee.com/openharmony/docs/blob/master/zh-cn/release-notes/OpenHarmony-v4.1-release.md

在PC端的Linux主机执行以下命令,获取的是与版本发布时完全一致的源码。

# git在线下载最新SDK源码
$ repo init -u https://gitee.com/openharmony/manifest -b refs/tags/OpenHarmony-v4.1-Release --no-repo-verify
$ repo sync -c
$ repo forall -c 'git lfs pull'

SDK代码文件目录如下图所示:

 

3.2. 打补丁

直接下载:

📎IDO_PurplePiOH_V1A_OHOS4.1r_Patch_20240624.tar

网盘下载:

链接:https://pan.baidu.com/s/1I_UvsKL44TPOODv-n6mzkg?pwd=1234

提取码:1234

下载后将补丁放到当前代码根目录下,如下图所示:

 

然后执行如下命令:

$ tar -xvf  IDO_PurplePiOH_V1A_OHOS4.1r_Patch_20240624.tar
$ cd IDO_PurplePiOH_V1A_OHOS4.1r_Patch_20240624/
$ ./ido_patch.sh

打入补丁成功后如下图所示:

 

注意:一定要用命令解压,不能直接window本地解压,否则解压出来的文件会有问题

3.3. OHOS4.1 SDK编译

3.3.1. SDK完整编译

$ bash build/prebuilts_download.sh
$ ./build.sh --product-name purple_pi_oh --ccache --no-prebuilt-sdk

编译结果如下图所示:

 

失败时log索引位置:./out/purple_pi_oh/error.log

固件索引位置:./out/purple_pi_oh/packages/phone/images/

3.3.2. 编译不同dts

修改device/board/industio/purple_pi_oh/kernel/build_kernel.sh中的"IDO-PurPle-Pi-OH-HDMI"

编译为MIPI固件则改为:"IDO-PurPle-Pi-OH-MIPI"

#eval $MAKE_OHOS_ENV ./make-ohos.sh IDO-PurPle-Pi-OH-HDMI $RAMDISK_ARG ${ENABLE_LTO_O0}
eval $MAKE_OHOS_ENV ./make-ohos.sh IDO-PurPle-Pi-OH-MIPI $RAMDISK_ARG ${ENABLE_LTO_O0}

4. OpenHarmony4.0 SDK编译

4.1. OHOS4.0 源码获取

OpenHarmony4.0Release版本特性说明:

https://gitee.com/openharmony/docs/blob/master/zh-cn/release-notes/OpenHarmony-v4.0-release.md

在PC端的Linux主机执行以下命令,git在线下载最新SDK源码:

注意:获取的是与版本发布时完全一致的源码。

$ repo init -u https://gitee.com/openharmony/manifest -b refs/tags/OpenHarmony-v4.0-Release --no-repo-verify
$ repo sync -c 
$ repo forall -c 'git lfs pull'

获取到的SDK文件如下图所示:

 

4.2. 打补丁

直接下载:

📎purple-pi-oh-patch.zip

网盘下载:

链接:https://pan.baidu.com/s/14HMKFxyfwmTJWJS_Xv08mQ?pwd=1234

提取码:1234

下载后将补丁放到当前代码根目录下,如下图所示:

 

然后执行如下命令:

$ unzip purple-pi-oh-patch.zip 
$ cd purple-pi-oh-patch/
$  ./ido_patch.sh 

打入补丁成功后如下图所示:

 

4.3. OHOS4.0 SDK编译

4.3.1. SDK完整编译

$ bash build/prebuilts_download.sh
$ ./build.sh --product-name purple_pi_oh --ccache --no-prebuilt-sdk

SDK编译成功如下图所示:

 

失败时log索引位置:./out/purple_pi_oh/error.log

固件索引位置:./out/purple_pi_oh/packages/phone/images/

4.3.2. 编译不同dts

修改device/board/industio/purple_pi_oh/kernel/build_kernel.sh中的"IDO-PurPle-Pi-OH-HDMI"

编译为MIPI固件则改为:"IDO-PurPle-Pi-OH-MIPI"

#eval $MAKE_OHOS_ENV ./make-ohos.sh IDO-PurPle-Pi-OH-HDMI $RAMDISK_ARG ${ENABLE_LTO_O0}
eval $MAKE_OHOS_ENV ./make-ohos.sh IDO-PurPle-Pi-OH-MIPI $RAMDISK_ARG ${ENABLE_LTO_O0}
Logo

社区规范:仅讨论OpenHarmony相关问题。

更多推荐