# vendor_xiaomi **Repository Path**: jackwl/vendor_xiaomi ## Basic Information - **Project Name**: vendor_xiaomi - **Description**: 小米6适配OpenHarmony - **Primary Language**: C - **License**: MulanPSL-2.0 - **Default Branch**: OpenHarmony-3.2-Release - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 4 - **Created**: 2023-05-19 - **Last Updated**: 2023-05-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # OpenHarmony-xiaomi6 #### 介绍 该项目介绍,如何在小米6/小米POCO F1上运行 [OpenHarmony 3.2 Release](https://gitee.com/openharmony/docs/blob/master/zh-cn/release-notes/OpenHarmony-v3.2-release.md)标准系统。 支持图形显示硬件加速。 支持HDC连接。 POCO F1支持WiFi,小米6可以连接无密码WiFi # 搭建开发环境 ## 1.1 硬件环境 准备一台装有ubuntu20.04系统X86主机,内存最低配置要求16G。 ## 1.2 下载repo脚本文件 1. 注册码云gitee账号。 2. 注册码云SSH公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191)。 3. 安装[git](https://gitee.com/openharmony/docs/blob/master/zh-cn/release-notes/OpenHarmony-v3.2-beta1.md#https://gitee.com/link?target=https%3A%2F%2Fgit-scm.com%2Fbook%2Fzh%2Fv2%2F%25E8%25B5%25B7%25E6%25AD%25A5-%25E5%25AE%2589%25E8%25A3%2585-Git)客户端和[git-lfs](https://gitee.com/vcs-all-in-one/git-lfs?_from=gitee_search#downloading)并配置用户信息。 ``` git config --global user.name "yourname" git config --global user.email "your-email-address" git config --global credential.helper store ``` 4. 安装码云repo工具,可以执行如下命令。 ``` curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests ``` 如果没有权限,可下载至其他目录,并将其配置到环境变量中chmod a+x /usr/local/bin/repo ``` mkdir ~/bin curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o ~/bin/repo chmod a+x ~/bin/repo pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests ``` ``` vim ~/.bashrc # 编辑环境变量 export PATH=~/bin:$PATH # 在环境变量的最后添加一行repo路径信息 source ~/.bashrc # 应用环境变量 ``` ## 1.3 获取OpenHarmony标准系统源码 通过repo + ssh 下载(需注册公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191))。 ``` export WORK_SPACE=/home/xxx/OpenHarmony #替换成自己定义的workspace路径 export PROJ_ROOT=$WORK_SPACE/3.2-Release mkdir $WORK_SPACE mkdir $PROJ_ROOT cd $PROJ_ROOT repo init -u https://gitee.com/openharmony/manifest -b OpenHarmony-3.2-Release --no-repo-verify repo sync -c repo forall -c 'git lfs pull' ``` ## 1.4 获取编译工具链 参考[OpenHamony快速入门文档](https://gitee.com/openharmony/docs/tree/master/zh-cn/device-dev/quick-start),基于命令行入门。 ``` sudo apt-get update && sudo apt-get install binutils git git-lfs gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4 bc gnutls-bin python3.8 python3-pip ruby default-jdk libssl-dev libtinfo5 genext2fs u-boot-tools mtools mtd-utils scons gcc-arm-none-eabi abootimg ``` ## 1.5 执行prebuilts 在源码根目录下执行脚本,安装编译器及二进制工具。 ``` cd $PROJ_ROOT bash build/prebuilts_download.sh ``` # 小米设备代码下载与整合 ## 2.1 下载适配源码 进到项目根目录,下载xiaomi dvice源码: ``` git clone -b OpenHarmony-3.2-Release https://gitee.com/ohos-porting-communities/vendor_xiaomi.git vendor/xiaomi git clone -b OpenHarmony-3.2-Release https://gitee.com/ohos-porting-communities/device_board_xiaomi.git device/board/xiaomi git clone -b OpenHarmony-3.2-Release https://gitee.com/ohos-porting-communities/device_soc_qualcomm.git device/soc/qualcomm #下载米6内核(835内核) git clone https://gitee.com/ohos-porting-communities/linux_sagit.git kernel/linux/linux-sagit #下载845内核 git clone -b OpenHarmony-3.2-Release https://gitee.com/openharmony-dg/kernel_linux_6.2.git kernel/linux/linux-6.2 #替换默认toybox,以便使能modprobe命令 cd third_party/toybox/ git remote add op https://gitee.com/ohos-porting-communities/third_party_toybox.git git branch -m master old git fetch op git checkout -b master op/master ``` # 代码编译 ## 3.1 OpenHarmony编译 ``` cd $PROJ_ROOT #小米6 ./build.sh --product-name sagit --ccache #小米POCO F1 ./build.sh --product-name beryllium --ccache ``` 编译成功提示: ``` post_process =====build sagit successful. ``` 编译生成的文件 ``` $PROJ_ROOT/out/sagit/packages/phone/images/system.img $PROJ_ROOT/out/sagit/packages/phone/images/vendor.img $PROJ_ROOT/out/sagit/packages/phone/images/userdata.img $PROJ_ROOT/out/sagit/packages/phone/images/ramdisk.img ``` ## 3.2 boot.img编译 编译好OpenHarmony的文件之后使用以下命令打包boot.img ``` #小米6 ./build.sh --product-name sagit --build-target=sagit_build_bootimg --fast-rebuild #小米POCO F1 ./build.sh --product-name beryllium --build-target=beryllium_build_bootimg --fast-rebuild ``` # 镜像烧写 参考我的文章使用twrp刷入或者bootloader线刷 https://ost.51cto.com/posts/20924 # 开源许可协议 Apache 2.0 # 维护者邮箱 开源鸿蒙系统移植社区 598757652@qq.com