头图

Welcome to pay attention to my public account [Extreme Wisdom Vision], reply 001 to get Google programming specification

O_o>_<   o_OO_o~_~o_O

Hello everyone, I am Jizhi Vision. This tutorial records the method of compiling the firmware of the Allwinner XR806 OpenHarmony Hongmeng system in detail.

XR806 is a highly integrated wireless MCU chip that supports WiFi and BLE, developed and designed by Guangzhou Xinzhilian, a subsidiary of Allwinner Technology, and supports Hongmeng L0 system. It has the advantages of high integration, simple hardware design, low BOM cost, safety and reliability. It can be widely meet smart home, intelligent buildings, industrial connectivity, children's toys, electronic competition, geeks DIY wireless connectivity needs and other areas. Above:

Now start the firmware compilation.

# 下载 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

It should be noted here that directly executing the above command should report an error of fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle . The solution is to modify the Tsinghua source. There are two modifications, as follows:

(1) Modify bin/repo in 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) Command --repo-url=http://mirrors.tuna.tsinghua.edu.cn/git/git-repo/ after executing the command, that is:

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/

continue:

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

Start compiling the firmware:

cd <xr806_openharmony_path>
cd device/xradio/xr806/xr_skylark
cp project/demo/audio_demo/gcc/deconfig .config

make menuconfig

Generate a graphical configuration interface and exit EXIT

make build_clean    # 清除旧配置
 
make lib -j         # 根据配置生成静态库和全局头文件

cd -

hb set           # 选择 wifi_skylark

At this point, press Enter again, select wifi_shylark , and then press Enter directly:

hb build -f     # 开始编译

Error Unable to load SDKconfig.gni

Solution:

cd <xr806_openharmony_path>
cd device/xradio/xr806/xr_skylark

python config.py

The officially provided config.py has path-related bugs, which can be changed to the following:

#!/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)

When finished, <xr806_openharmony_path>/device/xradio/xr806/liteos_m will be generated in the 061f11c6aeab14 directory, and then continue:

cd -

hb build -f

<xr806_openharmony_path>/device/xradio/xr806/xr_skylark/out , the compiled firmware image related files will be generated under 061f11c6aeab43:

Among them, xr_system.img is the image file that we need to use for firmware burning later.

At this point, the firmware compilation of XR806 OpenHarmony has been completed. I hope my sharing can help you in your study.


【Public number transmission】
" [Embedded AI] Allwinner XR806 OpenHarmony Hongmeng System Firmware Compilation "


极智视界
13 声望4 粉丝