marklove

Parser 不要单凭语言判断一个人,要看实际行动。 “贵人不可贱用”

导航

【XR806开发板试用】编译中的几个问题以及hello跑起来

http://download.savannah.nongnu.org/releases/lwip/
http://git.savannah.gnu.org/cgit/lwip.git
Clone
git://git.savannah.gnu.org/lwip.git
https://git.savannah.gnu.org/git/lwip.git
ssh://git.savannah.gnu.org/srv/git/lwip.git
这些都没有源码
wpas
hostapd
wpa
wpas
hostapd
wpa
net80211
net80211
airkiss_aes
sc_assistant
reverb
adt
zbar
eq
drc
opus
libaac.a    libblec.a       libcedarx.a      libspeex.a       libwpas_wps.a
libamr.a    lib_ble_host.a  libmp3.a         libwatchpoint.a
libamren.a  libbt_driver.a  libsecureboot.a  libwav.a

./prebuilts/build-tools/linux-x86/bin/ninja -C out/xr806/wifi_skylark/
1
2
3
4
首先我们先看https://xr806.docs.aw-ol.com/
硬件资料 https://www.aw-ol.com/downloads?cat=12
鸿蒙教程指南 https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-env-setup-linux.md#section12202192215415
该文档部分不适应 当前最新gitee

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

git clone https://gerrit-googlesource.lug.ustc.edu.cn/git-repo

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

mkdir xr806_openharmony
cd xr806_openharmony
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'
https://mirrors.tuna.tsinghua.edu.cn/help/git-repo/
https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/
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'   #下载部分大容量二进制文件

编译流程

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格式

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

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

#!/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 library\n#\n\n')

GNf.write('OHOSSOURCE = -Wl,--whole-archive\n')
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-archive\n')
GNf.write('\n')

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

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

问题2分析

文件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代码

修改
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 就能愉快的跑起来了。

windows

缺少文件 generated/autoconf.h
[OHOS ERROR] ../../../device/xradio/xr806/xr_skylark/include/xr_config.h:33:10: fatal error: generated/autoconf.h: No such file or directory
[OHOS ERROR]    33 | #include "generated/autoconf.h"
增加了$(MENUBUILD) 
去掉了chmod 
xr806\device\xradio\xr806\xr_skylark\tools\config
Makefile
MENUBUILD   := ./build

MENUCFLAGS  := -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>" -DLOCALE -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer

ifeq ($(shell uname -s),Linux)
MENULDFLAGS := -lncurses
else
MENULDFLAGS := -lncurses -lintl
endif

HOSTCC      := gcc

common-objs := $(addprefix $(MENUBUILD)/, confdata.o expr.o lexer.lex.o \
		   parser.tab.o preprocess.o symbol.o util.o)

lxdialog    := $(addprefix $(MENUBUILD)/lxdialog/, \
		     checklist.o inputbox.o menubox.o textbox.o util.o yesno.o)

all: mconf

$(MENUBUILD)/%.o: %.c
	@mkdir -p $(MENUBUILD)
	@mkdir -p $(MENUBUILD)/lxdialog
	@echo "HOSTCC $<"; $(HOSTCC) -c $(MENUCFLAGS) $< -o $@

mconf: $(MENUBUILD)/mconf.o $(lxdialog) $(common-objs)
	@echo "HOSTLD $<"; $(HOSTCC) -o  $(MENUBUILD)/$@ $^ $(MENULDFLAGS); \
	#chmod 777 $@

conf: $(MENUBUILD)/conf.o $(common-objs)
	@echo "HOSTLD $<"; $(HOSTCC) -o  $(MENUBUILD)/$@ $^ $(MENULDFLAGS); \
	#chmod 777 $@

clean :
	-@rm mconf conf; rm -rf $(MENUBUILD)/*

gn ninja 问题 具体是怎么被下载到这的还没找到说明 可自行软件仓库安装或源码安装

下载ninja
https://repo.huaweicloud.com/harmonyos/compiler/ninja/1.10.1/linux/ninja-linux-x86-1.10.1.tar.gz

下载gn
https://repo.huaweicloud.com/harmonyos/compiler/gn/latest/linux/gn-linux-x86-1717.tar.gz

/home/make/xr806_openharmony/prebuilts/
├── build-tools
│   └── linux-x86
│       └── bin
│           ├── gn
│           ├── gn_pkg
│           ├── ninja
│           └── ninja_pkg

wsl 问题
https://www.cnblogs.com/Excr/p/12296525.html
gn 问题
https://blog.csdn.net/qiuguolu1108/article/details/103842556
下载加速
https://blog.csdn.net/qq_43744723/article/details/119084698
挂代理
https://blog.csdn.net/rodgerjie1993/article/details/86613137
https://blog.csdn.net/hm11104105/article/details/75617615
关证书
https://www.cnblogs.com/freedom-try/p/12586792.html
llvm
https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-env-setup-linux.md#section12202192215415
https://repo.huaweicloud.com/harmonyos/compiler/clang/9.0.0-36191/linux/llvm-linux-9.0.0-36191.tar

posted on 2021-12-13 22:38  marklove  阅读(244)  评论(0编辑  收藏  举报