共计 4097 个字符,预计需要花费 11 分钟才能阅读完成。
欢送关注我的公众号 [极智视界],回复 001 获取 Google 编程标准
O_o
>_<
o_O
O_o
~_~
o_O
大家好,我是极智视界,本教程具体记录了全志 XR806 OpenHarmony 鸿蒙零碎固件编译的办法。
XR806 是全志科技旗下子公司广州芯之联研发设计的一款反对 WiFi 和 BLE 的高集成度无线 MCU 芯片,反对鸿蒙 L0 零碎。具备集成度高、硬件设计简略、BOM 成本低、安全可靠等长处。可宽泛满足 智能家居、智慧楼宇、工业互联、儿童玩具、电子比赛、极客 DIY 等畛域的无线连接需要。上图:
上面开始固件编译。
# 下载 repo
mkdir -p bin
curl https://storage.googleapis.com/git-repo-downloads/repo > bin/repo
chmod a+rx bin/repo
PATH="`pwd`/bin:$PATH"
# 下载 hb
pip install -i https://pypi.douban.com/simple --user ohos-build
PATH="$HOME/.local/bin:$PATH"
# 下载 openharmony 源码
repo init -u ssh://git@gitee.com/openharmony-sig/manifest.git -b OpenHarmony_1.0.1_release --no-repo-verify -m devboard_xr806.xml
这里须要留神一下,间接执行上述命令应该会报错 fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle
,解决办法为批改清华源。有两种批改形式,如下:
(1) 批改 bin/repo
中的 REPO_URL
REPO_URL = os.environ.get('REPO_URL', None)
if not REPO_URL:
# REPO_URL = 'http://gerrit.googlesource.com/git-repo'
REPO_URL = 'http://mirrors.tuna.tsinghua.edu.cn/git/git-repo/' # 批改为这个
(2) 在执行命令后指令 --repo-url=http://mirrors.tuna.tsinghua.edu.cn/git/git-repo/
,也即:
repo init -u ssh://git@gitee.com/openharmony-sig/manifest.git -b OpenHarmony_1.0.1_release --no-repo-verify -m devboard_xr806.xml --repo-url=http://mirrors.tuna.tsinghua.edu.cn/git/git-repo/
持续:
repo sync -c
repo forall -c 'git lfs pull'
# 下载 arm toolchain
wget -c https://developer.arm.com/-/media/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2
tar -xf gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2
# 创立 ~/tools 目录
mkdir ~/tools
cp -r ./gcc-arm-none-eabi-10-2020-q4-major ~/tools
# 更新 toolchain
cd <xr806_openharmony_path>
sed -i "s@~/tools/gcc-arm-none-eabi-10-2020-q4-major/bin/arm-none-eabi-@`pwd`/gcc-arm-none-eabi-10-2020-q4-major/bin/arm-none-eabi-@g" ./device/xradio/xr806/liteos_m/config.gni
sed -i "s@~/tools/gcc-arm-none-eabi-10-2020-q4-major/bin@`pwd`/gcc-arm-none-eabi-10-2020-q4-major/bin@g" ./device/xradio/xr806/xr_skylark/gcc.mk
# 修改 SDKconfig.gni
sed -i "s@open('\.{0}/@open('{0}/@g" ./device/xradio/xr806/xr_skylark/config.py
sed -i "s@open('\.{0}/@open('{0}/@g" ./device/xradio/xr806/libcopy.py
开始编译固件:
cd <xr806_openharmony_path>
cd device/xradio/xr806/xr_skylark
cp project/demo/audio_demo/gcc/deconfig .config
make menuconfig
生成图形化配置界面,间接 EXIT
退出即可。
make build_clean # 革除旧配置
make lib -j # 依据配置生成动态库和全局头文件
cd -
hb set # 抉择 wifi_skylark
此时再按一下回车,抉择 wifi_shylark
,而后再间接回车就行:
hb build -f # 开始编译
报错 Unable to load SDKconfig.gni
解决办法:
cd <xr806_openharmony_path>
cd device/xradio/xr806/xr_skylark
python config.py
官网提供的 config.py 有门路相干的 Bug,改成如下:
#!/usr/bin/python3
import os
pwd = os.path.dirname (__file__)
f = open('{0}.config'.format(pwd),'r') # 门路改成这样
DATA = ['#XR806 config']
for line in f.readlines():
if line[0] != '#' and line[0] != '\n':
line = line.strip('\n')
DATA.append(line)
GNf = open('{0}../liteos_m/SDKconfig.gni'.format(pwd),'w') # 门路改成这样
GNf.write('#Build by config.py DO NOT EDIT!\n\n')
GNf.write('SDK_cflags = [\n\"-mcpu=cortex-m33",\n\"-mtune=cortex-m33",\n\"-march=armv8-m.main+dsp",\n\"-mfpu=fpv5-sp-d16",\n\"-mfloat-abi=softfp",\n\"-mcmse",\n\"-mthumb",\n\"-c",\n\"-g",\n\"-fno-common",\n\"-fmessage-length=0",\n\"-fno-exceptions",\n\"-ffunction-sections",\n\"-fdata-sections",\n\"-fomit-frame-pointer",\n\"-Wall",\n\
#"-Werror",\n\
"-Wno-cpp",\n\
"-Wpointer-arith",\n\
"-Wno-error=unused-function",\n\
"-MMD",\n\
"-MP",\n\
"-Os",\n\
"-DNDEBUG",\n\
"-Wno-error=stringop-truncation",\n\
"-Wno-error=restrict",\n\
"-includexr_config.h",\n\
"-includecommon/prj_conf_opt.h",\n\
"-DCONFIG_CHIP_ARCH_VER=3",\n\
"-DCONFIG_ARCH_APP_CORE",\n\
"-DCONFIG_CPU_CM33F",\n\
]\n\n')
PROJECT = [x for i,x in enumerate(DATA) if x.find('CONFIG_PROJECT=') != -1]
if len(PROJECT) == 1:
ProjectPath = PROJECT[0]
ProjectPath = ProjectPath.strip('CONFIG_PROJECT=')
GNf.write('ProjectPath = {0}\n\n'.format(ProjectPath))
if ProjectPath == '"bootloader"' or ProjectPath == '"test/etf"':
GNf.write('declare_args() {IsBootloader ="true"}\n')
else:
GNf.write('declare_args() {IsBootloader ="false"}\n')
#print (DATA)
完了会在 <xr806_openharmony_path>/device/xradio/xr806/liteos_m
目录下生成 SDKconfig.gni,而后持续:
cd -
hb build -f
完了会在 <xr806_openharmony_path>/device/xradio/xr806/xr_skylark/out
下生成编译好的固件镜像相干文件:
其中 xr_system.img 就是前面咱们固件烧录须要用到的镜像文件。
至此就实现了 XR806 OpenHarmony 的固件编译,心愿我的分享能对你的学习有一点帮忙。
【公众号传送】
《【嵌入式 AI】全志 XR806 OpenHarmony 鸿蒙零碎固件编译》