海思3861环境搭建(代码片段)

耳东 耳东     2022-12-18     223

关键词:

开发环境

ubuntu18.04

DOPI3861开发板  

Q群:735884031

一.安装编译工具

1.按照官方文档下载编译工具并添加到环境变量中

https://device.harmonyos.com/cn/docs/start/introduce/quickstart-lite-env-setup-linux-0000001105407498

2.切换本地python / python3 环境

3861编译环境最低要求python3.7环境,先查看系统已安装的python环境

/usr/bin# ls python*
python  python2  python2.7  python3  python3.6  python3.6-config  python3.6m  python3.6m-config  python3.8  python3-config  python3m  python3m-config

 笔者系统已经安装了python2.7 、python3.6 和 python3.8版本,如果有小伙伴的系统里没有安装3.8以上版本的请自行更新旧版本python或重新安装新版本的python。

先查看系统默认使用的python版本

/usr/bin# python --version
Python 2.7.17
/usr/bin# python3 --version
Python 3.6.9

这里默认使用的版本显然是不符合3861编译的要求的,接下来将系统默认的版本切换到python3.8,先建立python组添加而可选项

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1 # 添加Python可选项,优先级为1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1 # 添加Python2可选项,优先级为1

执行完之后可以看到python和python3均链接到 /etc/alternatives/ 下了

/usr/bin# ls -l python*
lrwxrwxrwx 1 root root      24 8月   3 22:21 python -> /etc/alternatives/python
lrwxrwxrwx 1 root root       9 4月  16  2018 python2 -> python2.7
-rwxr-xr-x 1 root root 3633000 2月  27 23:10 python2.7
lrwxrwxrwx 1 root root      25 8月   3 22:26 python3 -> /etc/alternatives/python3
-rwxr-xr-x 2 root root 4526456 1月  26  2021 python3.6
lrwxrwxrwx 1 root root      33 1月  26  2021 python3.6-config -> x86_64-linux-gnu-python3.6-config
-rwxr-xr-x 2 root root 4526456 1月  26  2021 python3.6m
lrwxrwxrwx 1 root root      34 1月  26  2021 python3.6m-config -> x86_64-linux-gnu-python3.6m-config
-rwxr-xr-x 1 root root 5203488 2月  26 06:10 python3.8
lrwxrwxrwx 1 root root      16 10月 25  2018 python3-config -> python3.6-config
lrwxrwxrwx 1 root root      10 10月 25  2018 python3m -> python3.6m
lrwxrwxrwx 1 root root      17 10月 25  2018 python3m-config -> python3.6m-config

 切换python使用版本,选择对应的python版本就可以了

/usr/bin# update-alternatives --config python
有 3 个候选项可用于替换 python (提供 /usr/bin/python)。

  选择       路径              优先级  状态
------------------------------------------------------------
  0            /usr/bin/python2.7   1         自动模式
* 1            /usr/bin/python2.7   1         手动模式
  2            /usr/bin/python3.6   1         手动模式
  3            /usr/bin/python3.8   1         手动模式

要维持当前值[*]请按<回车键>,或者键入选择的编号:3

查看下当前使用的python版本(将python3也使用同样的方式切换至3.8版本),至此python环境就搭建好了,可以安心的编译了

/usr/bin# python --version
Python 3.8.0

3.安装交叉编译链,下载sdk

交叉编译链下载:

https://repo.huaweicloud.com/harmonyos/compiler/gcc_riscv32/7.3.0/linux/gcc_riscv32-linux-7.3.0.tar.gz

sdk下载

https://device.harmonyos.com/cn/docs/start/get-code/sourcecode-acquire-0000001050769927

解压交叉编译链,笔者喜欢把交叉编译链放在/opt下,有其他爱好的小伙伴也可以在sdk目录下

/home/cjx/fdsk/hi3861/tools# ls
gn-linux-x86-1717.tar.gz  hcc_riscv32.tar.gz  llvm.tar.gz  ninja.1.9.0.tar
/home/cjx/fdsk/hi3861/tools# tar -zxvf hcc_riscv32.tar.gz -C /opt/

在 /etc/profile 文件的最后添加,也可以在sdk目录下新建一个shll脚本,开发前先source下该脚本

export PATH="/opt/hcc_riscv32/bin:$PATH"

4.编译

解压sdk后再根目录下执行make,全编译

# ls
app  boot  build  build_patch.sh  build.sh  components  config  factory.mk  include  Makefile  non_factory.mk  output  platform  SConstruct  third_party  tools

编译的过程当然不会是一帆风顺了,报错查找不到ecdsa编译工具

在官方文档中开发步骤,安装开发板环境中,按照文档安装python依赖库

 安装完成后重新编译,编译完成

-------------/home/cjx/fdsk/hi3861/Hi3861V100R001C00SPC025/output/bin/Hi3861_demo_ota.bin image info print start-------------
[image_id=0x3c78961e][struct_version=0x0]]
[section_offset=0x280][section_len=0x55780]
[file_type=0xf0][file_version=0x0][encrypt_flag=0x42]
[file_len=0x55a00][key_len=0x120]
[file_attr=0x44]
[hash_alg=0x0][sign_alg=0x3f][sign_param=0x0]
[aes_key[0-1-14-15]=[0x0][0x0][0x0][0x0]]
[aes_iv [0-1-14-15]=[0x0][0x0][0x0][0x0]]
[common key][00]=[0x0]
[common key][01]=[0x0]
[common key][30]=[0x0]
[common key][31]=[0x0]
[common sign][00]=[0x3a]
[common sign][01]=[0xb5]
[common sign][30]=[0xa7]
[common sign][31]=[0xdf]
[section sign][00]=[0x7c]
[section sign][01]=[0x30]
[section sign][30]=[0xbc]
[section sign][31]=[0x6c]
[image_id=0x3c78961e][struct_version=0x0]]
[hash_alg=0x0][sign_alg=0x3f][sign_param=0x0]
[section_count=0x1]
[section0_compress=0x1][section0_offset=0x3c0][section0_len=0x55639]
[section1_compress=0x0][section1_offset=0x0][section1_len=0x0]
-------------/home/cjx/fdsk/hi3861/Hi3861V100R001C00SPC025/output/bin/Hi3861_demo_ota.bin image info print end--------------
< ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >
                              BUILD SUCCESS
< ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >
make[1]: 离开目录“/home/cjx/fdsk/hi3861/Hi3861V100R001C00SPC025”
/home/cjx/fdsk/hi3861/Hi3861V100R001C00SPC025#

 5.烧录

选择 output/bin/Hi3861_xxx_allinone.bin,勾选Auto burn

点击connect后按下开发板的复位按键,等待下载完成,下载完成后点击disconnect

 

 5.添加helloword

 在app下新建一个hello_word的文件夹,hello_word下新建一个src用于存放源代码

拷贝app/demo/app.json和SConscript到hello_word下

拷贝app/demo/src/SConscript到hello_word/src下

hello_word# tree
.
├── app.json
├── SConscript
└── src
    ├── helloword.c
    └── SConscript

修改app.json,该文件用于指定工程的源文件和头文件路径


    "TARGET_LIB": "demo",
    "APP_SRCS": [
        "src"
    ],
    "INCLUDE": [
        "components/iperf2/include",
        "config/app",
        "config/diag",
        "platform/os/Huawei_LiteOS/net/ripple/exports",
        "components/ripple/exports",
        "components/hilink/include",
        "third_party/mbedtls/include/mbedtls/",
        "include/OHOS"
    ],
    "CC_FLAGS": [
    ],
    "DEFINES": [
        "_PRE_WLAN_FEATURE_CSI",
        "_PRE_WLAN_FEATURE_P2P",
        "LWIP_ENABLE_DIAG_CMD=0"
    ],
    "AR_FLAGS": [],
    "LD_FLAGS": [],
    "AS_FLAGS": [],
    "LD_DIRS": [],
    "CLEAN": []

helloword.c文件

hi_void app_main(hi_void)

 	while(1)
	
		printf("hello word\\n");
		sleep(1);
	

SConscript文件不做修改,回到sdk的根目录下使用build.sh单独编译helloword

# ./build.sh hello_word

查看output/bin目录下,生成了hello_word对应的固件

# ll
总用量 29320
drwxrwxrwx 2 root root     4096 8月   6 22:55 ./
drwxrwxrwx 3 1014 1014     4096 8月   5 22:49 ../
-rwxrwxrwx 1 root root    24576 8月   6 22:24 Hi3861_boot_signed_B.bin*
-rw-r--r-- 1 root root    23312 8月   6 22:24 Hi3861_boot_signed.bin
-rwxrwxrwx 1 root root   614820 8月   6 22:24 Hi3861_demo_allinone.bin*
-rwxrwxrwx 1 root root 13982586 8月   6 22:24 Hi3861_demo.asm*
-rwxrwxrwx 1 root root   599984 8月   6 22:24 Hi3861_demo_burn.bin*
-rwxrwxrwx 1 root root    24272 8月   6 22:24 Hi3861_demo_flash_boot_ota.bin*
-rwxrwxrwx 1 root root  2090180 8月   6 22:24 Hi3861_demo.map*
-rwxrwxrwx 1 root root   350720 8月   6 22:24 Hi3861_demo_ota.bin*
-rwxr-xr-x 1 root root  1396384 8月   6 22:24 Hi3861_demo.out*
-rwxrwxrwx 1 root root        8 8月   6 22:24 Hi3861_demo_vercfg.bin*
-rw-r--r-- 1 root root   224324 8月   6 22:55 Hi3861_hello_word_allinone.bin
-rw-r--r-- 1 root root  7575499 8月   6 22:55 Hi3861_hello_word.asm
-rw-r--r-- 1 root root   209488 8月   6 22:55 Hi3861_hello_word_burn.bin
-rw-r--r-- 1 root root    24272 8月   6 22:55 Hi3861_hello_word_flash_boot_ota.bin
-rw-r--r-- 1 root root  1900185 8月   6 22:55 Hi3861_hello_word.map
-rw-r--r-- 1 root root    99024 8月   6 22:44 Hi3861_hello_word_ota.bin
-rwxr-xr-x 1 root root   825080 8月   6 22:55 Hi3861_hello_word.out*
-rw-r--r-- 1 root root        8 8月   6 22:55 Hi3861_hello_word_vercfg.bin
-rw-r--r-- 1 root root    14688 8月   6 22:24 Hi3861_loader_signed.bin

选择Hi3861_hello_word_allinone.bin进行烧录

ready to OS start
hello word
hello word
hello word
hello word

ubuntu搭建小熊派hi3861环境(代码片段)

目录开发平台:工具安装:代码编译:过程注意:开发平台:基于Hi3861芯片的小熊派全貌:工具安装:参考官方Gitee,文件形式下载的将它存放在Linux下自己知道的目录下就行:交叉编译器gcc_risc... 查看详情

海思3519av100开发:linux环境搭建(代码片段)

海思文档+nfsAxe+SecureCRT8.1破解版资源网盘链接提取码:pzxg1.Linux环境搭建参考文档:ReleaseDoc\\zh\\01.software\\board\\SVP\\HiSVP开发指南.pdf概念:NNIE(NeuralNetworkInferenceEngine)其他概念和开发流程等等都省略,只为安装好对应的环... 查看详情

linux-海思nnie环境搭建(cpu版本)(代码片段)

1.引言参考文档:ReleaseDoc\\zh\\01.software\\board\\SVP\\HiSVP开发指南.pdf概念:NNIE(NeuralNetworkInferenceEngine)(神经网络推理机)其他概念和开发流程等等都省略,只为安装好对应的环境,和记录自己踩过的坑。、2.环境1.Ubuntu18.042.gcc4.8.5... 查看详情

最新hi3861开发环境搭建(代码片段)

Hi3861开发环境最好参考官方文档:Hi3861开发环境这里做下记录(1)安装编译依赖基础软件(仅Ubuntu20+需要)执行以下命令进行安装:sudoapt-getinstallbuild-essentialgccg++makezlib*libffi-dev(2)安装Sc... 查看详情

最新hi3861开发环境搭建(代码片段)

Hi3861开发环境最好参考官方文档:Hi3861开发环境这里做下记录(1)安装编译依赖基础软件(仅Ubuntu20+需要)执行以下命令进行安装:sudoapt-getinstallbuild-essentialgccg++makezlib*libffi-dev(2)安装Sc... 查看详情

ubuntu搭建小熊派hi3861环境(代码片段)

.../pan.baidu.com/s/1bp2ypAfH2HaNPTY2KwEhEA 提取码:1234其中python环境的要安装许多其他的轮子,具体看官方的手册。下载的工具解压后,将文件 查看详情

ubuntu搭建小熊派hi3861环境(代码片段)

.../pan.baidu.com/s/1bp2ypAfH2HaNPTY2KwEhEA 提取码:1234其中python环境的要安装许多其他的轮子,具体看官方的手册。下载的工具解压后,将文件 查看详情

openharmony开发环境搭建(代码片段)

开发环境:开发系统:Ubuntu20.04开发板:Pegasus物联网开发板MCU:Hi3861OpenHarmony版本:3.0.1-LTS本文将介绍如何搭建OpenHarmony开发环境,OpenHarmony主要在Linux平台上开发,因此需要使用Linux环境开发,要想... 查看详情

openharmony源码编译与下载(代码片段)

...1a;3.0.1-LTS3.1OpenHarmony源码编译Pegasus物联网开发板基于华为海思Hi3861芯片,对应的产品名字是wifiiot_hispark_pegasus。接下来编译wifi 查看详情

openharmony源码编译与下载(代码片段)

...1a;3.0.1-LTS3.1OpenHarmony源码编译Pegasus物联网开发板基于华为海思Hi3861芯片,对应的产品名字是wifiiot_hispark_pegasus。接下来编译wifi 查看详情

智能交通灯上报功能(代码片段)

硬件环境搭建硬件要求:Hi3861V100核心板、扩展板,OLED板,交通灯板;硬件搭建及组网图如下图所示。Hi3861V100核心板参考:HiSpark_WiFi_IoT智能开发套件_原理图硬件资料\\原理图\\HiSpark_WiFi-IoT_Hi3861_CH340G_VER.B.pdf扩... 查看详情

hisparkipccamera开发环境搭建(基于v1.1.4)(代码片段)

...tu20.04Harmony版本:code-v1.1.4-LTS.tarHiSparkIPCCamera基于华为海思Hi3518芯片,支持LiteOS、OpenHarmony,广泛应用于智能摄像头、安防监控等场景。本文将介绍如何搭建HiSparkIPCCamera开发环境,OpenHar 查看详情

海思3519a开发环境设置相关(代码片段)

设置板卡和虚拟机的网络参数setenvserverip192.168.1.107setenvipaddr192.168.1.10setenvgatewayip192.168.1.1setenvnetmask255.255.255.0saveenv文件系统制作osdrv/pub/bin/pc/mkyaffs2image100osdrv/pub/rootfs_glibcosdrv/pub/rootfs 查看详情

海思3519av100开发:开发板环境搭建

海思文档+nfsAxe+SecureCRT8.1破解版资源网盘链接提取码:pzxg2开发板环境设置本文省去kernel、uboot、文件系统烧写步骤,详见海思文档。工具:开发板、usb转串口(dp9)、usb转网卡、网线、windows10系统+nfsAxe+SecureC... 查看详情

海思3519av100开发:开发板环境搭建

海思文档+nfsAxe+SecureCRT8.1破解版资源网盘链接提取码:pzxg2开发板环境设置本文省去kernel、uboot、文件系统烧写步骤,详见海思文档。工具:开发板、usb转串口(dp9)、usb转网卡、网线、windows10系统+nfsAxe+SecureC... 查看详情

ubuntu10.04搭建海思开发环境

(1)Ubuntu10.04.4LTS(LucidLynx) 下载地址:http://old-releases.ubuntu.com/releases/lucid/(2)passwdroot,然后以root登录,gedit /etc/network/interfaces,添加静态ip:ifaceeth0inetstaticaddress192.168.10.64#changet 查看详情

hi3861使用iic驱动adxl346(代码片段)

开发平台Ubuntu18.04DOPI hi3861lv开发板、adxl346模组Q群:735884031一.配置3861iic1.搭建demo工程,可参考我的上一篇博客2.查看引脚复用,使用GPIO9、GPIO10作为iic0IO3.配置io复用,初始化iic控制器/Hi3861V100R001C00SPC025/app/adxl346$t 查看详情

hi3861使用iic驱动adxl346(代码片段)

开发平台Ubuntu18.04DOPI hi3861lv开发板、adxl346模组Q群:735884031一.配置3861iic1.搭建demo工程,可参考我的上一篇博客2.查看引脚复用,使用GPIO9、GPIO10作为iic0IO3.配置io复用,初始化iic控制器/Hi3861V100R001C00SPC025/app/adxl346$t 查看详情