01
环境搭建
①搭建 ubuntu 环境,下载必须要的软件和 Docker:
sudo apt-get installopenssh- servervim net-tools openssh- servervim git curl samba samba-common python3 python3-pip git-lfs
curl -sSL https://get.daocloud.io/docker | sh
②配置 git:
git config--global user.name "yourname"
git config--global user.email "your-email-address"
git config--global credential.helper store
③装 repo:
curl https:/ /gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo
chmod a+x /usr/local/bin/repo
pip3 install -i https:/ /repo.huaweicloud.com/repository/pypi/simplerequests
④下载代码:
repoinit -u https://gitee.com/openharmony/manifest.git -b master -- no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'
02
编译
①下载 docker 镜像并运行编译代码:
sudo docker pull swr.cn-south- 1.myhuaweicloud.com/openharmony-docker/openharmony-docker- standard:0. 0. 1
sudo docker run -it -v $(pwd) :/home/openharmonyswr.cn-south- 1.myhuaweicloud.com/openharmony-docker/openharmony-docker- standard:0. 0. 1
在源码的根目录执行预处理脚本:
../s/prepare.sh
编译代码:
./build.sh --product-name Hi3516DV300
编译所生成的文件都归档在 out/ohos-arm-release/ 目录下,结果镜像输出在 out/ohos-arm-release/packages/phone/images/ 目录下。
②使用 samba 方便写代码:
mm@mm-virtual-machine:~$ sudo vim /etc/samba/smb.conf
## 在最后面添加
[work]
comment= samba home directory
path= /home/mm/
public= yes
browseable = yes
public= yes
writeable = yes
readonly= no
valid users= mm
createmask= 0777
directorymask= 0777
#force user = nobody
#force group = nogroup
available = yes
mm@mm- virtual-machine:~$ sudo smbpasswd -a mm ## 设置密码 mm是名字
mm@mm- virtual-machine:~$ sudo service smbd restart ## 重启
03
烧录
①烧录前的准备
烧录之前需要设置 root,如果设置过了就不需要设置了:
setenvbootcmd "mmc read 0x0 0x80000000 0x800 0x4800; go 0x80000000";
setenvbootargs "console=ttyAMA0,115200n8 root=emmc fstype=vfat rootaddr=10M rootsize=20M rw";
saveenv
reset
②开始烧录
打开 HITOOL,选择 EMMC,然后选择之前编译出来的 XML 文件,点击烧录开始烧录: