2022-02-06 21:26:14
0
1、前言
因为之前快速移植的时候,除了boot.img用自己编译的,其他img多用树莓派3B的img就能正常点亮,所以为了能快速成功移植选用树莓派3B作为参考。目前已经可以编译通过,可以显示画面,并支持触摸驱动,其他功能还很不完善。
2、 manifest base 的选择
树莓派3B的代码下载可以参考以下官方链接:
树莓派3B快速上手 OpenHarmony:https://gitee.com/openharmony-si ... 1%E5%9B%BA%E4%BB%B6
或者原作者xfan1024的Gitee 仓库 https://gitee.com/xfan1024/oh-rpi3b
树莓派移植的主要仓库在:https://gitee.com/xfan1024/
我的编译环境之前用的 repo init 指令如下:
- repo init -u https://gitee.com/xfan1024/oh-rpi3b.git -m oh-rpi3b.xml -b openharmony-3.0 --no-repo-verify
复制代码
repo 参数说明如下:
-u URL,指定manifest位置
-m 选择仓库中的manifest文件,缺省为default.xml
-b 指定revision, 如一个特定的manifest分支.
从以上可以看出我用的树莓派3B对应的mainfest仓库为 https://gitee.com/xfan1024/oh-rpi3b.git 这个仓库的openharmony-3.0分支的oh-rpi3b.xml
如果参考openharmony官方网站的则是- repo init -u https://gitee.com/openharmony-sig/manifest.git -m devboard_rpi3b.xml -b master --no-repo-verify
复制代码
对应的mainfest仓库为 https://gitee.com/openharmony-sig/manifest.git 这个仓库的master 分支的devboard_rpi3b.xml文件
这两个仓库版目前版本上差异不大只是vendor/rpi3这个仓库一个用sig下的一个是用xfan1024下的
3、参考树莓派3B新增NanoPi M1 Plus 的仓库
3.1、克隆树莓派3B仓库到自己的Gitee下
从oh-rpi3b.xml 中可以知道针对树莓派3B的主要差异如下:
- <!--StartFragment--><blockquote> <remote name="xfan1024" fetch="." review="https://gitee.com/xfan1024/"/>
复制代码 可以先将这几个仓库从 https://gitee.com/xfan1024/ 克隆到自己的gitee下,我这边新建了一个OHOS_nanopi_m1_plus组织,然后将以上6个仓库克隆过来。
OHOS_nanopi_m1_plus组织地址:https://gitee.com/ohos_nanopi_m1_plus
修改oh-rpi3b.xml中以下内容:
将remote name="xfan1024"替换为remote name="ohos_nanopi_m1_plus"
将fetch="." 替换fetch="https://gitee.com/ohos_nanopi_m1_plus"
将review="https://gitee.com/xfan1024/"/替换为review="https://gitee.com/ohos_nanopi_m1_plus/"
将全部的remote="xfan1024"替换为remote="ohos_nanopi_m1_plus"
相关修改如下
- <blockquote><span style="font-size: 14px;"> <remote name="ohos_nanopi_m1_plus" fetch="https://gitee.com/ohos_nanopi_m1_plus" review="https://gitee.com/ohos_nanopi_m1_plus/"/></span>
复制代码 将修改后的完整oh-rpi3b.xml重命名为任意你想要的名字如devboard_nanopim1plus_tag.xml,并在自己的gitee/或组织下建立一个manifest的仓库,把这个文件上传,将repo ini 指令中的url和manifest换成你自己的地址和文件,这样子你就可以通过以下指令下载到可以编译树莓派3B的仓库。
- <blockquote><span style="font-size: 14px;">repo init -u https://gitee.com/ohos_nanopi_m1_plus/manifest.git -m devboard_nanopim1plus_tagr.xml -b master --no-repo-verify</span>
复制代码
3.2、客制化NanoPi M1 Plus
首先我们列一个表格,填入信息如下
| product | device | vendor | socvendor |
含义 | 嵌入式产品名 | SOC名 | 产品制造商 | SOC制造商 |
名字 | nanopim1plus | allwinnerh3 | friendlyarm | allwinner |
3.2.1、 建立NanoPi M1 Plus的 kernel 仓库
NanoPi M1 Plus的kernel 移植可以参考之前发的帖子 https://bbs.elecfans.com/forum.php?mod=viewthread&tid=2232704&page=1#pid8663169
目前我移植使用的config是ohos_sunxi_defconfig可以比对sunxi_defconfig来查看差异部分,多开的config如下
- CONFIG_DRM_FBDEV_OVERALLOC=100#修改显示问题,具体原因还不清楚
- CONFIG_HID_MULTITOUCH=y#修改支持触摸
- CONFIG_HILOG=y#以下ohos 特性移植
- CONFIG_HI_LOG_BUFFER_SIZE=2048
- CONFIG_HIEVENT=y
- CONFIG_DRIVERS_HDF=y
- CONFIG_HDF_SUPPORT_LEVEL=2
- CONFIG_DRIVERS_HDF_PLATFORM=y
- CONFIG_DRIVERS_HDF_PLATFORM_MIPI_DSI=y
- CONFIG_DRIVERS_HDF_PLATFORM_GPIO=y
- CONFIG_DRIVERS_HDF_PLATFORM_I2C=y
- CONFIG_DRIVERS_HDF_PLATFORM_UART=y
- CONFIG_DRIVERS_HDF_TEST=y
- CONFIG_AUDIT=y#以下SECURITY相关
- CONFIG_HAVE_ARCH_AUDITSYSCALL=y
- CONFIG_AUDITSYSCALL=y
- CONFIG_AUDIT_WATCH=y
- CONFIG_AUDIT_TREE=y
- CONFIG_NETWORK_SECMARK=y
- CONFIG_ANDROID=y
- CONFIG_ANDROID_BINDER_IPC=y
- CONFIG_ANDROID_BINDER_DEVICES="binder,hwbinder,vndbinder"
- CONFIG_ANDROID_BINDER_IPC_32BIT=y
- CONFIG_NFS_V4_SECURITY_LABEL=y
- CONFIG_SECURITY=y
- CONFIG_LSM_MMAP_MIN_ADDR=32768
- CONFIG_SECURITY_NETWORK=y
- CONFIG_SECURITY_SELINUX=y
- CONFIG_SECURITY_SELINUX_BOOTPARAM=y
- CONFIG_SECURITY_SELINUX_BOOTPARAM_VALUE=1
- CONFIG_SECURITY_SELINUX_DEVELOP=y
- CONFIG_SECURITY_SELINUX_AVC_STATS=y
- CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE=1
- CONFIG_INTEGRITY=y
- CONFIG_INTEGRITY_AUDIT=y
复制代码
移植后的仓库已上传 https://gitee.com/ohos_nanopi_m1_plus/oh-nanopi-m1-plus-kernel
上传好后将devboard_nanopim1plus_tagr.xml中
- <project name="oh-rpi3b-vendor" path="vendor/rpi3" remote="xfan1024" revision="f6da250bb8cdd166f6ff2ddb061c60aa3aa70b09" upstream="master" dest-branch="master"/>
复制代码
修改为
- <project name="oh-nanopi-m1-plus-kernel" path="kernel/linux-nanopim1plus" remote="ohos_nanopi_m1_plus" revision="master" upstream="master" dest-branch="master"/>
复制代码
这样子就将kernel 的仓库替换好了。
3.2.2、 建立NanoPi M1 Plus的 vendor 仓库
Vendor 的仓库内容暂时没有做修改,但是为了后续修改方便,我拷贝了一份上传到
https://gitee.com/ohos_nanopi_m1_plus/oh-nanopi-m1-plus-vendor
另外因为我们定义的"产品制造商"是“friendlyarm”所以要放到"vendor/friendlyarm"路径下,修改devboard_nanopim1plus_tagr.xml中
- <project name="oh-rpi3b-vendor" path="vendor/rpi3" remote="xfan1024" revision="f6da250bb8cdd166f6ff2ddb061c60aa3aa70b09" upstream="master" dest-branch="master"/>
复制代码
为
- <project name="oh-nanopi-m1-plus-vendor" path="vendor/friendlyarm" remote="ohos_nanopi_m1_plus" revision="master" upstream="master" dest-branch="master"/>
复制代码
3.2.3、 建立NanoPi M1 Plus的 device 仓库
device 目录结构是device{SOC制造商}{SOC名} 先拷贝一份devicerpi3为deviceallwinner
修改如下 deviceallwinnerbuildohos.build
- {
- "subsystem": "allwinner_products",
- "parts": {
- "allwinner_products": {
- "module_list": [
- "//device/allwinner/build:products_group"
- ]
- }
- }
- }
复制代码 deviceallwinnerbuildBUILD.gn
- import("//build/ohos.gni")
- device_type = "allwinnerh3"
- group("products_group") {
- if (device_type == "allwinnerh3") {
- deps = [
- "//device/allwinner/allwinnerh3:allwinnerh3_group",
- ]
- }
- }
复制代码
将deviceallwinnerrpi3改为deviceallwinnerallwinnerh3,并 将目下make_rpi_sdcard_image.py修改为make_nanopim1plus_sdcard_image.py 将build-rpi3.py修改为deviceallwinnerallwinnerh3build-nanopim1plus.py并修改如下:
- cmd = 'bash build.sh --product-name nanopim1plus --ccache --build-target firmware'
- print('please run: python3 ./build-nanopim1plus.py build')
- print(' python3 ./build-nanopim1plus.py build')
- print(' python3 ./build-nanopim1plus.py flash /dev/sdx')
复制代码
将deviceallwinnerallwinnerh3BUILD.gn修改为如下
- import("//build/ohos.gni")
- print("allwinnerh3_group in")
- group("allwinnerh3_group") {
- deps = [
- "kernel:allwinnerh3_modules",
- "hisi_lib:hisi_lib",
- "build:allwinnerh3_prebuilts_files",
- "prebuilts:prebuilts",
- ]
- }
- action("firmware") {
- deps = [
- "kernel:allwinnerh3_bootimg",
- "//build/core/gn:images",
- "//third_party/firmware-utils:ptgen(${host_toolchain})"
- ]
- script = "make_nanopim1plus_sdcard_image.py"
- outputs = [ "$root_build_dir/packages/phone/images/firmware.img" ]
- args = [
- "--output",
- rebase_path("$root_build_dir/packages/phone/images/firmware.img"),
- #"--userdata",
- #"300M",
- rebase_path("$root_build_dir/packages/phone/images/boot.img"),
- rebase_path("$root_build_dir/packages/phone/images/system.img"),
- rebase_path("$root_build_dir/packages/phone/images/vendor.img"),
- rebase_path("$root_build_dir/packages/phone/images/userdata.img"),
- ]
- }
复制代码
deviceallwinnerallwinnerh3kernelbuild_kernel.py 修改如下
- os.environ['CROSS_COMPILE'] = 'arm-linux-'
- defconfig = 'ohos_sunxi_defconfig'
- kernel_dir = os.path.abspath('../../kernel/linux-nanopim1plus')
- subprocess.run(F'touch .scmversion', shell=True, check=True)
- subprocess.run(F'make {defconfig} ARCH=arm CROSS_COMPILE=arm-linux-', shell=True, check=True)
- subprocess.run(F'make -j{nproc+1} zImage dtbs ARCH=arm CROSS_COMPILE=arm-linux-', shell=True, check=True)
- #for ko in kolist:
- # shutil.copy(os.path.join(kernel_dir, ko), modules_dir)
- #overlays_dir = 'boot/overlays'
- #os.mkdir(overlays_dir)
- os.path.join(kernel_dir, 'arch/arm/boot/dts/sun8i-h3-nanopi-m1-plus.dtb'),
- #shutil.copy(
- # os.path.join(kernel_dir, 'arch/arm/boot/dts/overlays/vc4-kms-v3d.dtbo'),
- # overlays_dir
- #)
复制代码
接着将所有子目录下的BUILD.gn中rpi3_products改为allwinner_products在将其他的“rpi3_”开头的内容修改为“allwinnerh3_” BUILD.gn还有修改的内容参考如下 deviceallwinnerallwinnerh3kernelBUILD.gn
- group("allwinnerh3_modules") {
- print("allwinnerh3_modules in")
- # deps = allwinnerh3_modules_deps
- }
复制代码 deviceallwinnerallwinnerh3hisi_libBUILD.gn
- GPL_SDK_LIB_DIR = "//device/allwinner/allwinnerh3/hisi_lib/lib"
- GPL_SDK_ETC_DIR = "//device/allwinner/allwinnerh3/hisi_lib/etc"
复制代码
另外将 deviceallwinnerallwinnerh3buildvendoretcfstab.rpi3 修改为fstab.allwinnerh3
并且deviceallwinnerallwinnerh3kernelboot这个目录替换为NanoPi M1 Plus的boot 分区
修改后的仓库上传 https://gitee.com/ohos_nanopi_m1_plus/oh-nanopi-m1-plus-device
最后修改 上传好后将devboard_nanopim1plus_tagr.xml中
- <project name="oh-rpi3b-device" path="device/rpi3" remote="xfan1024" revision="14fd2079bc9286d13ad6793149a71db8f35507c1" upstream="master" dest-branch="master">
- <linkfile src="rpi3/build-rpi3.py" dest="build-rpi3.py"/>
- </project>
复制代码
修改为
- <project name="oh-nanopi-m1-plus-device" path="device/allwinner" remote="ohos_nanopi_m1_plus" revision="master" upstream="master" dest-branch="master">
- <linkfile src="allwinnerh3/build-nanopim1plus.py" dest="build-nanopim1plus.py"/>
- </project>
复制代码
3.2.4、 建立NanoPi M1 Plus的 projectpatch 仓库
这一部分主要修改如下 将projectpatchpatchesbuild001-build-support-rpi3.patch移除并在这个目录下新增如下 0001-PATCH-Support-nanopim1plus.patch,这个patch可以修改后commit再用git format-patch生成 0001-PATCH-Support-nanopim1plus.patch
- From a131f7d235ca7cf8acd0506a654bf02fa3294e03 Mon Sep 17 00:00:00 2001
- From: soon_l <[email]lxs_vip@126.com[/email]>
- Date: Tue, 11 Jan 2022 23:37:38 +0800
- Subject: [PATCH] [PATCH] Support nanopim1plus
- :Release Notes:
- [PATCH] Support nanopim1plus
- :Detailed Notes:
- - Problem : [PATCH] Support nanopim1plus
- - RootCause : [PATCH] Support nanopim1plus
- - Solution : [PATCH] Support nanopim1plus
- - Author : Soon_L
- - Build : ok
- :Testing Preformed:
- How to Test :
- build
- Change-Id: I2f09e00e8c5ee27da4b7422fc5bfd0878d10af5d
- ---
- subsystem_config.json | 6 ++++++
- 1 file changed, 6 insertions(+)
- diff --git a/subsystem_config.json b/subsystem_config.json
- index 4288f49..21447e3 100644
- --- a/subsystem_config.json
- +++ b/subsystem_config.json
- @@ -11,6 +11,12 @@
- "name": "account",
- "dir": "base"
- },
- + "allwinner_products":{
- + "project": "hmf/allwinner_products",
- + "path": "device/allwinner/build",
- + "name": "allwinner_products",
- + "dir": "device/allwinner"
- + },
- "distributeddatamgr": {
- "project": "hmf/distributeddatamgr",
- "path": "foundation/distributeddatamgr",
- --
- 2.25.1
复制代码
修改projectpatchpatchesdrivers_peripheral001-support-rpi3.patch
- + if ((device_type == "Hi3516DV300") || (device_type == "DAYU") || (device_type == "ohos-arm64") || (device_type == "rpi3")) {
复制代码
改为
- + if ((device_type == "Hi3516DV300") || (device_type == "DAYU") || (device_type == "ohos-arm64") || (device_type == "nanopim1plus")) {
复制代码
projectpatchpatchesproductdefine_common下删除0001-support-rpi3.patch,新增 0001-PATCH-Support-nanopim1plus.patch
- From a944c7ee0608aa0255b535668e59338ca5f07f06 Mon Sep 17 00:00:00 2001
- From: soon_l <[email]lxs_vip@126.com[/email]>
- Date: Sun, 16 Jan 2022 21:58:57 +0800
- Subject: [PATCH] [PATCH] [PATCH] Support nanopim1plus
- :Release Notes:
- :Detailed Notes:
- - Problem : Support nanopim1plus
- - RootCause : Support nanopim1plus
- - Solution : Support nanopim1plus
- - Author : Soon_L
- - Build : ok
- :Testing Preformed:
- How to Test :
- build
- Change-Id: Ic2aabbb2b0bff96ad7447225b8f9d82398040319
- ---
- device/allwinnerh3.json | 7 ++++
- products/nanopim1plus.json | 81 ++++++++++++++++++++++++++++++++++++++
- 2 files changed, 88 insertions(+)
- create mode 100755 device/allwinnerh3.json
- create mode 100755 products/nanopim1plus.json
- diff --git a/device/allwinnerh3.json b/device/allwinnerh3.json
- new file mode 100755
- index 0000000..68dcf27
- --- /dev/null
- +++ b/device/allwinnerh3.json
- @@ -0,0 +1,7 @@
- +{
- + "device_name": "allwinnerh3",
- + "device_company": "allwinner",
- + "target_os": "ohos",
- + "target_cpu": "arm",
- + "kernel_version": ""
- +}
- diff --git a/products/nanopim1plus.json b/products/nanopim1plus.json
- new file mode 100755
- index 0000000..0f142c1
- --- /dev/null
- +++ b/products/nanopim1plus.json
- @@ -0,0 +1,81 @@
- +{
- + "product_name": "nanopim1plus",
- + "product_company": "friendlyarm",
- + "product_device": "allwinnerh3",
- + "version": "2.0",
- + "type": "standard",
- + "parts":{
- + "ace:ace_engine_standard":{},
- + "ace:napi":{},
- + "account:os_account_standard":{},
- + "distributeddatamgr:native_appdatamgr":{},
- + "distributeddatamgr:distributeddatamgr":{},
- + "distributeddatamgr:appdatamgr_jskits":{},
- + "distributeddatamgr:distributedfilejs":{},
- + "distributeddatamgr:e2fsprogs":{},
- + "common:common":{},
- + "security:permission_standard":{},
- + "startup:startup_l2":{},
- + "startup:init":{},
- + "hiviewdfx:hiviewdfx_hilog_native":{},
- + "hiviewdfx:hilog_native":{},
- + "hiviewdfx:hilog_service":{},
- + "hiviewdfx:hisysevent_native":{},
- + "hiviewdfx:hiappevent_js":{},
- + "hiviewdfx:hiview":{},
- + "hiviewdfx:faultloggerd":{},
- + "utils:utils_base":{},
- + "subsystem_examples:subsystem_examples":{},
- + "allwinner_products:allwinner_products":{},
- + "appexecfwk:appexecfwk_standard":{},
- + "aafwk:aafwk_standard":{},
- + "notification:ces_standard":{},
- + "notification:ans_standard":{},
- + "communication:ipc":{},
- + "communication:net_manager":{},
- + "communication:dsoftbus_standard":{},
- + "communication:wifi_standard":{},
- + "communication:wifi_native_js":{},
- + "communication:bluetooth_native_js":{},
- + "distributedschedule:samgr_L2":{},
- + "distributedschedule:safwk":{},
- + "distributedschedule:dmsfwk_standard":{},
- + "hdf:hdf":{},
- + "updater:updater":{},
- + "developtools:bytrace_standard":{},
- + "developtools:dropbear":{},
- + "developtools:profiler":{},
- + "sensors:sensors_miscdevice":{},
- + "graphic:graphic_standard":{},
- + "security:appverify":{},
- + "security:huks_standard":{},
- + "security:deviceauth_standard":{},
- + "security:dataclassification":{},
- + "sensors:sensors_sensor":{},
- + "miscservices:time_native":{},
- + "multimedia:multimedia_histreamer":{},
- + "multimedia:multimedia_media_standard":{},
- + "multimedia:multimedia_audio_standard":{},
- + "multimedia:multimedia_camera_standard":{},
- + "multimedia:multimedia_image_standard":{},
- + "multimedia:multimedia_media_library_standard":{},
- + "multimodalinput:multimodalinput_base":{},
- + "telephony:core_service":{},
- + "telephony:ril_adapter":{},
- + "telephony:data_storage":{},
- + "telephony:state_registry":{},
- + "telephony:cellular_call":{},
- + "telephony:cellular_data":{},
- + "telephony:sms_mms":{},
- + "telephony:call_manager":{},
- + "global:i18n_standard":{},
- + "global:resmgr_standard":{},
- + "powermgr:power_manager_native":{},
- + "powermgr:battery_manager_native":{},
- + "powermgr:display_manager_native":{},
- + "applications:prebuilt_hap":{},
- + "wpa_supplicant-2.9:wpa_supplicant-2.9":{},
- + "xts:phone_tests":{},
- + "distributedhardware:device_manager_base":{}
- + }
- +}
- --
- 2.25.1
复制代码
修改后projectpatch上传 https://gitee.com/ohos_nanopi_m1_plus/oh-nanopi-m1-plus-projectpatch
上传好后将devboard_nanopim1plus_tagr.xml中
- <project name="oh-rpi3b-projectpatch" path="projectpatch" remote="xfan1024" revision="fd9ab7480be43d80e2306a9fae8b38974223ee1a" upstream="master" dest-branch="master"/>
复制代码
修改为
- <project name="oh-nanopi-m1-plus-projectpatch" path="projectpatch" remote="ohos_nanopi_m1_plus" revision="master" upstream="master" dest-branch="master"/>
复制代码
3.2.4、 建立NanoPi M1 Plus的 toolchain 和 oh-sd-fuse_h3仓库
toolchain 主要放编译kernel的toolchain仓库路径:https://gitee.com/ohos_nanopi_m1_plus/oh-nanopi-m1-plus-toolchain oh-sd-fuse_h3 仓库路径 https://gitee.com/ohos_nanopi_m1_plus/oh-sd-fuse_h3
4 NanoPi M1 Plus 项目编译说明
4.1 NanoPi M1 Plus 移植Openharmony项目源码下载
通过repo获取 方式一(推荐) 通过repo + ssh 下载(需注册公钥,请参考码云帮助中心)。
- <font color="#333333" face="微软雅黑"><span style="font-size: 18px;">repo init -u </span></font><a href="mailto:git@gitee.com" target="_blank" style="color: rgb(51, 51, 51); font-family: 微软雅黑; font-size: 18px;">[email]git@gitee.com[/email]</a><font color="#333333" face="微软雅黑"><span style="font-size: 18px;">:ohos_nanopi_m1_plus/manifest.git -m devboard_nanopim1plus_tag.xml -b master --no-repo-verify</span></font>
复制代码
方式二
通过repo + https 下载。
- <font color="#333333" face="微软雅黑"><span style="font-size: 18px;">repo init -u </span></font><a href="https://gitee.com/ohos_nanopi_m1_plus/manifest.git" target="_blank" style="color: rgb(51, 51, 51); font-family: 微软雅黑; font-size: 18px;">[url]https://gitee.com/ohos_nanopi_m1_plus/manifest.git</a><font[/url] color="#333333" face="微软雅黑"><span style="font-size: 18px;"> -m devboard_nanopim1plus_tag.xml -b master --no-repo-verify</span></font>
复制代码
4.2 执行prebuilts在源码根目录下执行脚本,安装编译器及二进制工具。
- bash build/prebuilts_download.sh
复制代码
4.3 打入补丁解压toolchain在源码根目录下执行
- python3 projectpatch/patch.py
复制代码
4.4 编译指令
在源码根目录下执行
- export PATH="$PATH:$(pwd)/toolchain/4.9.3/bin"
复制代码
4.5 合成SD卡烧录档案
在源码根目录下执行拷贝system.img、vendor.img 、userdata.img、boot.img的动作,然后进入device/allwinner/allwinnerh3/oh-sd-fuse_h3/执行生成烧录档案。
- cp -f out/ohos-arm-release/packages/phone/images/system.img device/allwinner/allwinnerh3/oh-sd-fuse_h3/friendlycore-focal_4.14_armhf/
复制代码
会在device/allwinner/allwinnerh3/oh-sd-fuse_h3/out生成可以烧录到SD 卡的h3-sd-friendlycore.img
以上NanoPi M1 Plus 移植 Openharmony 之建立自己的开发仓库的分享,祝大家新春愉快!
再次吐槽下论坛发帖功能,求改进支持MD,格式比较乱,感兴趣的可以下载附件阅读。
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容图片侵权或者其他问题,请联系本站作侵删。
侵权投诉