# pc **Repository Path**: rkl_212/pc ## Basic Information - **Project Name**: pc - **Description**: PC演示仓与PC生态共建仓情况说明 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-07-15 - **Last Updated**: 2025-09-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # PC演示仓与PC生态共建仓编译 ```bash data_time=`date '+%Y_%m_%d'` image_name="openharmony_img_no_uboot.img" image_name="${IMAGE_NAME%.*}" tar zcvf ${image_name}_${data_time}.tar.gz ./${IMAGE_NAME} echo -e "${green}generate ${image_name}_${data_time}.tar.gz successfully!!!!!! ${normal}" ``` ## 1. Ubuntu 20.04系统安装 配置OpenHarmony开发环境之前,需要先具备Ubuntu 20.04的基本环境。可以通过以下四种方式安装Ubuntu 20.04系统。 - 本地电脑安装Ubuntu 20.04的系统或者Windows+Ubuntu 20.04双系统 - 本地电脑Windows环境,基于虚拟机安装Ubuntu 20.04系统 - 本地电脑Windows环境,基于WSL安装Ubuntu 20.04系统 - 云服务器,配置为Ubuntu 20.04Ubuntu 20.04系统 其中,第一种方式会给不是完全习惯Ubuntu系统的开发者带来很大的适应或学习成本;第二种方式会导致计算机性能的极大浪费;本文推荐第三和第四种方式,其中,基于WSL安装Ubuntu 20.04系统可以参考[Windows 10安装Linux子系统](Windows10安装Linux子系统.md)。 ## 2. Ubuntu 20.04基本环境配置 ### 2.1 配置软件源 - 备份软件源 ```bash sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak ``` - 清空软件源 ```bash sudo echo "" > /etc/apt/sources.list ``` - 更改软件源 ```bash sudo vim /etc/apt/sources.list # 使用vim打开文件,写入如下内容 ``` 写入的内容如下: - ubuntu 20.04 清华镜像源 ```normal deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse # 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换 deb http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse deb-src http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse # 预发布软件源,不建议启用 # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse ``` 阿里镜像源 ```normal deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse ``` ### 2.2 更新系统软件 依次执行如下命令,将系统软件升级至最新版本 ```bash sudo apt update sudo apt upgrade ``` ### 2.3 配置root用户密码 执行如下命令,按照提示先输入当前用户的密码,之后会提示输入要设置的root用户密码,执行完毕即可。之前设置过的不用再次设置。 ```bash sudo passwd root ``` ## 3. 配置OpenHarmony编译环境 ### 3.1 安装编译所需软件 执行如下命令即可安装编译OpenHarmony需要的所有工具。 ```bash sudo apt-get update -y sudo apt-get install -y # 如果是ubuntu20.04系统请直接安装python3.9,如果是ubuntu18.04请改为安装python3.8 sudo apt-get install -y apt-utils binutils bison flex bc build-essential make mtd-utils gcc-arm-linux-gnueabi u-boot-tools python3.9 python3-pip git zip unzip curl wget gcc g++ ruby dosfstools mtools default-jre default-jdk scons python3-distutils perl openssl libssl-dev cpio git-lfs m4 ccache zlib1g-dev tar rsync liblz4-tool genext2fs binutils-dev device-tree-compiler e2fsprogs git-core gnupg gnutls-bin gperf lib32ncurses5-dev libffi-dev zlib* libelf-dev libx11-dev libgl1-mesa-dev lib32z1-dev xsltproc x11proto-core-dev libc6-dev-i386 libxml2-dev lib32z-dev libdwarf-dev sudo apt-get install -y grsync xxd libglib2.0-dev libpixman-1-dev kmod jfsutils reiserfsprogs xfsprogs squashfs-tools pcmciautils quota ppp libtinfo-dev libtinfo5 libncurses5 libncurses5-dev libncursesw5 libstdc++6 gcc-arm-none-eabi vim ssh locales doxygen sudo apt-get install -y libxinerama-dev libxcursor-dev libxrandr-dev libxi-dev ``` ```bash 结合自己实际需要,卸载python3.8,设置python3.9 sudo apt-get remove python3.8 sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1 sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1 ``` ### 3.2 配置git环境 - 配置本地git环境 - 设置git用户名: ```bash git config --global user.name "username" ``` - 设置git签名邮箱: ```bash git config --global user.email "youremail@example.com" ``` - 设置git凭证存储方式:[相关参考](https://blog.csdn.net/DavidFFFFFF/article/details/88849419) ```bash git config --global credential.helper store ``` - 注册gitee账号 参考如下链接,按照提示逐步进行,即可完成gitee账号注册。[注册 Gitee 账号](https://gitee.com/help/articles/4113#article-header0) - 配置ssh公钥 - 在本地家目录下查看是否有`.ssh`文件夹,若没有,执行如下命令,执行过程中,不必输入,全程enter即可。 ```bash ssh-keygen -t rsa -C "youremail@example.com" ``` - 查看并复制ssh公钥,并将其添加至gitee的个人账户中 ```bash cat ~/.ssh/id_rsa.pub ``` - 验证公钥是否添加成功 ```bash ssh -T git@gitee.com # 命令执行后,提示“Hi XXX! You've successfully authenticated, but GITEE.COM does not provide shell access.”,表示添加成功 ``` ### 3.3 配置repo工具 - 切换到root用户 ```bash su # 切换到root用户,需要root用户密码,若未配置过,请执行上一步 ``` - 下载安装repo工具:需要超级用户状态执行,结束后可退出 ```bash curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo chmod a+x /usr/local/bin/repo ``` - python安装requests库 ```bash sudo dpkg-reconfigure dash ``` ```bash pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests ``` ## 4. 代码拉取与编译 ### 4.1 PC演示仓 此仓合入兼容性处理方案,作为应用穿刺代码记录点 预期:演示仓中可以编译出rk3568, D3000m,D2000m 实际:可以编译出rk3568,D3000m, D2000m(需要使用飞腾的脚本) #### 4.1.1 代码仓初始化 从服务器上下载最新的 repo 源代码和 manifest 仓库,此命令只需要执行一次。 - PC演示仓 ```bash repo init -u https://gitee.com/cooperation-teams-PC-YS/manifest -b OpenHarmony-5.1.0-Release ``` #### 4.1.2 同步代码 该命令首次执行会下载所有代码,其后执行该命令会是本地代码与远程仓库代码同步。 ```bash repo sync -c ``` #### 4.1.3 下载所有代码仓所需的大文件 ```bash repo forall -c 'git lfs pull' ``` #### 4.1.4 预编译 ```bash bash build/prebuilts_download.sh ``` #### 4.1.5 编译rk3568 - 编译rk3568镜像,首次编译需要打patch ```bash ./build.sh --product-name rk3568 --target-cpu arm64 --disable-package-image --gn-args enable_notice_collection=false --keep-ninja-going --patch ``` - 已经打过patch的,在编译选项中去掉--patch ```bash ./build.sh --product-name rk3568 --target-cpu arm64 --disable-package-image --gn-args enable_notice_collection=false --keep-ninja-going ``` - patch回退 ```bash cd vendor/hihope/rk3568 python patch_revert.py ``` #### 4.1.6 编译D3000m - 编译D3000m镜像,首次编译需要打patch ```bash ./build.sh --product-name pd2508_laptop --ccache --target-cpu arm64 --gn-args enable_notice_collection=false --gn-args linux_kernel_version=linux-6.6 --gn-args gpu_model=ftg340 --patch ``` - 已经打过patch的,在编译选项中去掉--patch ```bash ./build.sh --product-name pd2508_laptop --ccache --target-cpu arm64 --gn-args enable_notice_collection=false --gn-args linux_kernel_version=linux-6.6 --gn-args gpu_model=ftg340 ``` - 打包成整体镜像 ```bash cd out/pd2508_laptop/packages/phone/images ./generate_image.sh ``` - patch回退 ```bash cd /vendor/phytium/pd2508_laptop python patch_revert.py ``` ### 4.2 PC生态共建仓 此仓作为主干孵化仓,应用穿刺暴露出来的问题,合入方案目标为上主干 预期:PC生态共建中可以编译出rk3568, D3000m 实际:可以编译出D3000m,rk3568(需要配置一下) 备注:device_board_phytium,device_soc_phytium,vendor_phytium三仓受到特殊管控,如果想要有拉取三个仓的权限,需要申请。 #### 4.2.1 代码仓初始化 - PC生态共建仓 ```bash repo init -u https://gitee.com/cooperation-teams-pc/manifest -b OpenHarmony-5.1.0-Release ``` #### 4.2.2 同步代码 该命令首次执行会下载所有代码,其后执行该命令会是本地代码与远程仓库代码同步。 ```bash repo sync -c ``` #### 4.2.3 下载所有代码仓所需的大文件 ```bash repo forall -c 'git lfs pull' ``` #### 4.2.4 预编译 ```bash bash build/prebuilts_download.sh ``` #### 4.2.5 编译rk3568 - 编译rk3568镜像,首次编译需要打patch ```bash ./build.sh --product-name rk3568 --target-cpu arm64 --disable-package-image --gn-args enable_notice_collection=false --keep-ninja-going --patch ``` - 已经打过patch的,在编译选项中去掉--patch ```bash ./build.sh --product-name rk3568 --target-cpu arm64 --disable-package-image --gn-args enable_notice_collection=false --keep-ninja-going ``` - patch回退 ```bash cd vendor/hihope/rk3568 python patch_revert.py ``` #### 4.2.6 编译D3000m - 编译D3000m镜像,首次编译需要打patch ```bash ./build.sh --product-name pd2508_laptop --ccache --target-cpu arm64 --gn-args enable_notice_collection=false --gn-args linux_kernel_version=linux-6.6 --gn-args gpu_model=ftg340 --patch ``` - 已经打过patch的,在编译选项中去掉--patch ```bash ./build.sh --product-name pd2508_laptop --ccache --target-cpu arm64 --gn-args enable_notice_collection=false --gn-args linux_kernel_version=linux-6.6 --gn-args gpu_model=ftg340 ``` - patch回退 ```bash cd /vendor/phytium/pd2508_laptop python patch_revert.py ``` #### 5. 常用编译指令 ```bash /home/wl/pc-ys/source/prebuilts/build-tools/linux-x86/bin/ninja -w dupbuild=warn -C /home/wl/pc-ys/source/out/pd2508_laptop images ``` ```bash dd=`date '+%Y_%m_%d'` tar zcvf openharmony_img_no_uboot_${dd}.tar.gz ./openharmony_img_no_uboot.img ``` ```bash 沙箱视角 ps -ef | grep 应用名称 nsenter -t 进程号 -m sh ``` ```bash cd foundation/communication/netmanager_base a. git add * b. git commit -m "xxxx" c. 编辑文件,或者新建文件编辑 d. git add * e. git diff --cached > 0001_fix_net_restart.patch #patch名称前四位为编号,后面的可以大致描述解决的问题 ``` ```bash 解除log限流 hdc shell hilog -Q pidoff hdc shell hilog -Q domainoff ``` ```bash Debug trace hdc shell param set persist.sys.graphic.openDebugTrace 1 hdc shell reboot =============================== hdc shell param set persist.sys.hilog.binary.on false hdc shell reboot ``` ### linux uboot 设置bootargs和bootcmd启动linux ` setenv bootargs 'console=ttymxc0,115200 root=/dev/mmcblk1p2 rootwait rw' setenv bootcmd 'mmc dev 1; fatload mmc 1:1 80800000 zImage; fatload mmc 1:1 83000000 imx6ull-alientek-emmc.dtb; bootz 80800000 - 83000000;' `