全志XR806编译中的几个问题以及hello跑起来

2024-02-02 15:26:32 浏览数 (2)

首先我们先看https://xr806.docs.aw-ol.com/ 该文档部分不适应 当前最新gitee

如果没有repo工具,可通过下面的git命令获取repo。

代码语言:javascript复制
git clone https://gerrit-googlesource.lug.ustc.edu.cn/git-repo

下载代码 没有使用ssh://方式 过于麻烦

代码语言:javascript复制
mkdir xr806_openharmony
cd xr806_openharmony
repo init -u https://gitee.com/openharmony-sig/manifest.git -b OpenHarmony_1.0.1_release --no-repo-verify -m devboard_xr806.xml
repo sync -c
repo forall -c 'git lfs pull'   #下载部分大容量二进制文件

编译流程

代码语言:javascript复制
cd device/xradio/xr806/xr_skylark                               #(1)进入原生SDK目录
cp project/demo/audio_demo/gcc/deconfig .config                 #(2)复制配置文件
make menuconfig                                                 #(3)图形化界面配置
make build_clean                                                #(4)清除旧配置
make lib -j                                                     #(5)根据配置生成静态库和全局头文件
cd -                                                            #(6)返回Harmony根目录
hb set                                                          #(7)选择wifi_skylark
hb build -f                                                     #(8)编译,后续不需要重新配置

编译中遇到的问题 1.缺少SDKconfig.gni 直接导致 hb build -f 报错编译失败 解决方法 修改xr806_openharmony/device/xradio/xr806/xr_skylark/config.py 该文件的换行符 unix格式

代码语言:javascript复制
#!/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!nn')
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
]nn')

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}nn'.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)

2.hello 一直不出现 修改xr806_openharmony/device/xradio/xr806/libcopy.py 该文件的换行符 是windows格式(很奇怪对吧)。

代码语言:javascript复制
#!/usr/bin/python3

import os
import json

pwd = os.path.dirname (__file__)

XTS_TEST = "disable"

def filenames_filter(filename_list,Features_str,extention_name):
    confirm_list = []
    for filename in filename_list:
        if filename.find(Features_str) != -1:
            if extention_name == os.path.splitext(filename)[1]:
                confirm_list.append(filename)
    return confirm_list

# whether config.json define compoent "test"?
vendorf = open('{0}/../../../vendor/xradio/xr806/config.json'.format(pwd),'r')
configData = json.load(vendorf)
subsystemsData = configData['subsystems']
for JSON_TXET in subsystemsData:
    ComponentJson = json.dumps(JSON_TXET)    
    componentPython = json.loads(ComponentJson)
    if componentPython["subsystem"] == "test":
        XTS_TEST = "enable"


GNf = open('{0}/xr_skylark/ohos.mk'.format(pwd),'w')
FnList = os.listdir('{0}/xr_skylark/lib/ohos'.format(pwd))
APPlib = filenames_filter(FnList,'libapp_','.a')

if XTS_TEST == "enable":
    TESTlib = filenames_filter(FnList,'libmodule_','.a')
    # if test XTS_UPgrade,KEYlib should add 'libhota.a'
    KEYlib = ['libwifiservice.a','libhiview_lite.a','libhilog_lite.a',
    'libhievent_lite.a','libbootstrap.a','libhctest.a','libbroadcast.a']
else:
    TESTlib = []
    KEYlib = []
RTOSlib = list(set(FnList) - set(APPlib) - set(TESTlib) - set(KEYlib))

GNf.write('#n# Rules for ohos libraryn#nn')

GNf.write('OHOSSOURCE = -Wl,--whole-archiven')
for lib in KEYlib:
    GNf.write('OHOSSOURCE  = $(ROOT_PATH)/lib/ohos/{0}n'.format(lib)) 
for lib in APPlib:
    GNf.write('OHOSSOURCE  = $(ROOT_PATH)/lib/ohos/{0}n'.format(lib))
for lib in TESTlib:
    GNf.write('OHOSSOURCE  = $(ROOT_PATH)/lib/ohos/{0}n'.format(lib))
GNf.write('OHOSSOURCE  = -Wl,--no-whole-archiven')
GNf.write('n')

GNf.write('OHOSSOURCE  = -Wl,--start-groupn')
for lib in RTOSlib:
    GNf.write('OHOSSOURCE  = $(ROOT_PATH)/lib/ohos/{0}n'.format(lib))
GNf.write('OHOSSOURCE  = -Wl,--end-groupn')

GNf.write('#n# end of filen#nn')
  1. win下make menuconfig问题 建议用linux(能烧录哦)
代码语言:javascript复制
目前我用了
Cygwin
msys2 以及msys2中带的msys
都是同类型错误,建议看看其他坛友是否有方法
MinGW 未试

问题2分析

代码语言:javascript复制
文件xr806_openharmony/device/xradio/xr806/xr_skylark/ohos.mk
默认有
OHOSSOURCE = -Wl,--whole-archive
OHOSSOURCE  = $(ROOT_PATH)/lib/ohos/libapp_console.a
OHOSSOURCE  = -Wl,--no-whole-archive
所以编译后能跑起来
libcopy.py 未能正确运行导致
文件未被更新如:
OHOSSOURCE = -Wl,--whole-archive
OHOSSOURCE  = $(ROOT_PATH)/lib/ohos/libapp_console.a
OHOSSOURCE  = $(ROOT_PATH)/lib/ohos/libapp_led.a
OHOSSOURCE  = $(ROOT_PATH)/lib/ohos/libapp_WlanTest.a
OHOSSOURCE  = -Wl,--no-whole-archive
所以 不管你怎么改都只是 支持libapp_console 设置
可手工添加(不建议。

hello 跑起来怎么改? https://xr806.docs.aw-ol.com/study/soft_helloword/ 给的文档已经过期不适合 现在最新的gitee代码

代码语言:javascript复制
修改
xr806_openharmony/device/xradio/xr806/ohosdemo/BUILD.gn
内容:
group("ohosdemo") {
    deps = [
        "hello_demo:app_hello",
        "LED:app_led",
        #"iot_peripheral:app_peripheral",
        #"wlan_demo:app_WlanTest",
    ]
}

如此这般hello_demo 就能愉快的跑起来了。

原贴链接:https://bbs.aw-ol.com/topic/790/

0 人点赞