【嵌入式AI】全志 XR806 OpenHarmony 鴻蒙系統固件編譯


歡迎關注我的公眾號 [極智視界],回復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 鴻蒙系統固件編譯

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM