携手OpenHarmony,先楫半导体HPMicro ohos v1.0.0 正式发布
各位关注先楫的小伙伴们,基于OpenHarmony 4.0-Release版本和hpm_sdk v1.4.0 版本的 HPMicro ohos v1.0.0 正式发布了。
Repo 链接为:
- https://gitee.com/openharmony/device_board_hpmicro/tree/OpenHarmony-4.0-Release
- https://gitee.com/openharmony/vendor_hpmicro/tree/OpenHarmony-4.0-Release
- https://gitee.com/openharmony/device_soc_hpmicro/tree/OpenHarmony-4.0-Release
支持的开发板:
- HPM6750EVK2
- HPM6800EVK
- HPM6300EVK
- HPM6200EVK
- HPM5300EVK
提供的主要功能
对如下组件和驱动进行了适配:
- 基本通信外设:
UART
, I2C
, SPI
- 高速通信接口: Ethernet
- 定时器类: WATCHDOG
- 文件系统: littlefs
- 网络协议栈: lwip
- C库:musl
- 组件类:
bootstrap_lite
, utils_lite
, liteos_m
, samgr_lite
, hilog_lite
, hievent_lite
, hiview_lite
, xts_acts
, xts_tools
开发环境
推荐采用Windows+Ubuntu环境进行开发:
- Windows环境用于编写代码、下载程序和烧入固件等,系统要求:Windows 10 64位系统。
- Linux环境用于代码下载、编译工程和生成固件等,系统要求:Ubuntu 20.04 64位及以上版本。
注意:若不确定所使用的Linux设备的系统及版本,请在bash中运行如下命令查看:
lsb_release -a
请在确认Linux系统不低于Ubuntu 20.04.XX LTS的情况下执行后续的步骤;否则,请升级或更换合适的Liunx设备。
若需要支持在Linux与Windows之间的文件共享以及编辑,请在Linux设备上适当地安装和配置samba、vim等常用软件。
OpenHarmony开发环境搭建:
[准备开发环境]
https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-pkg-prepare.md
[安装库和工具集]
https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-pkg-install-package.md
编译工具安装
[gcc工具下载]
https://repo.huaweicloud.com/harmonyos/compiler/gcc_riscv32/7.3.0/linux/gcc_riscv32-linux-7.3.0.tar.gz
设置环境变量
说明:如果直接采用编译好的riscv32 gcc包,请先执行以下命令将压缩包解压到用户的home(也可以是其他目录,注意使用实际的PATH即可):
tar -xvf gcc_riscv32-linux-7.3.0.tar.gz -C ~
将以下命令拷贝到.bashrc
文件的最后一行,保存并退出。
export PATH=~/gcc_riscv32/bin:$PATH
执行下面命令使环境变量生效:
source ~/.bashrc
Shell命令行中输入如下命令 riscv32-unknown-elf-gcc -v
,如果能正确显示编译器版本号,表明编译器安装成功。
Using built-in specs.
COLLECT_GCC=riscv32-unknown-elf-gcc
COLLECT_LTO_WRAPPER=/home/hhp/ohos/tools/gcc_riscv32/bin/../libexec/gcc/riscv32-unknown-elf/7.3.0/lto-wrapper
Target: riscv32-unknown-elf
Configured with: ../riscv-gcc/configure --prefix=/home/yuanwenhong/gcc_compiler_riscv/gcc_riscv32/gcc_riscv32 --target=riscv32-unknown-elf --with-arch=rv32imc --with-abi=ilp32 --disable-__cxa_atexit --disable-libgomp --disable-libmudflap --enable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-multilib --enable-poison-system-directories --enable-languages=c,c++ --with-gnu-as --with-gnu-ld --with-newlib --with-system-zlib CFLAGS='-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE' CXXFLAGS='-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -fPIE' LDFLAGS=-Wl,-z,relro,-z,now,-z,noexecstack 'CXXFLAGS_FOR_TARGET=-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar' 'CFLAGS_FOR_TARGET=-Os -mcmodel=medlow -Wall -fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -fno-short-enums -fno-short-wchar' --with-headers=/home/yuanwenhong/gcc_compiler_riscv/gcc_riscv32/gcc-riscv32/riscv32-unknown-elf/include --with-mpc=/usr/local/mpc-1.1.0 --with-gmp=/usr/local/gmp-6.1.2 --with-mpfr=/usr/local/mpfr-4.0.2
Thread model: single
源码获取:
[获取源码]
https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-pkg-sourcecode.md
[安装hb工具]
https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-pkg-install-tool.md
注意: 默认下载的是master分支版本,如果想下载其他分支版本请将-b master
改为需要下载的分支。
比如下载OpenHarmony-4.0-Release:
repo init -u git@gitee.com:openharmony/manifest.git -b OpenHarmony-4.0-Release
hb 安装报错:
WARNING: The scripts alldefconfig, allmodconfig, allnoconfig, allyesconfig, defconfig, genconfig, guiconfig, listnewconfig, menuconfig, oldconfig, olddefconfig, savedefconfig and setconfig are installed in '/home/xxx/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use
WARNING: The script hb is installed in '/home/xxx/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use
解决办法:
- 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。
export PATH=~/.local/bin:$PATH
- 执行如下命令更新环境变量
source ~/.bashrc
python3 -m pip uninstall ohos-build
python3 -m pip install --user build/hb
工程编译
选择目标工程:
执行hb set
选择hpmicro
下的hpm6750evk2
:
也可以直接通过命令指定
hb set -p hpm6750evk2
编译工程
执行hb build -f
进行工程编译,编译成功后显示如下内容:
打开xts功能
执行hb build -f --gn-args="build_xts=true"
命令进行xts编译。
镜像烧录
下载安装烧录工具(windows)
点击[先楫系列资料] 百度网盘下载sdk/HPMicro_Manufacturing_Tool_vx.x.x.zip
网盘链接:https://pan.baidu.com/s/1RaYHOD7xk7fnotmgLpoAlA?pwd=xk2n
下载后解压HPMicro_Manufacturing_Tool_vx.x.x.zip文件到任意目录。
找到 hpm_manufacturing_gui.exe,双击执行程序:
下载程序到开发板:
- 将开发板的 USB2UART0 接口连接至PC,正确连接后,PC可识别到一路usb串口,hpm6750evk2板载了ch340 usb转串口芯片。
- 将BOOT拨码开关设置为:
boot0: 0
boot1: 1
拨码开关设置好后,点击开发板的RESTN
按钮,进行复位,复位后进入到isp模式。
- 配置hpm_manufacturing_gui的 类型为:UART 并选择选择步骤1中对用的串口,点击 连接:
连接成功:
4. 拷贝编译好的固件程序out/hpm6750evk2/hpm6750evk2/OHOS_Image.bin到windows。
5. 选择固件程序,点击 烧写 进行下载:
- 设置拨码开关为正常模式
boot0: 0
boot1: 0
-
打开一个串口终端 MobaXterm,重启开发板,串口打印启动信息
-
hpm_manufacturing_gui更多用法,请参考:HPMicro_Manufacturing_Tool_vx.x.x\doc\user_manual.html
openocd 进行调试镜像
- 下载openocd
git clone git@gitee.com:hpmicro/riscv-openocd.git -b riscv-hpmicro
- 安装依赖工具
sudo apt install libtool libusb-1.0-0-dev libhidapi-dev libftdi-dev
- 安装
进入源码目录,并执行下面的命令
./bootstrap
./configure
make -j16
sudo make install
sudo cp contrib/60-openocd.rules /etc/udev/rules.d/
- 连接烧写和目标板
- 启动openocd
进入到ohos源码device/soc/hpmicro/sdk/hpm_sdk/boards/openocd,执行如下命令:
$ openocd -s . -f probes/cmsis_dap.cfg -f soc/hpm6750-single-core.cfg -f boards/hpm6750evk2.cfg
Open On-Chip Debugger 0.11.0+dev (2024-01-08-14:39)
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
srst_only separate srst_gates_jtag srst_open_drain connect_deassert_srst
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : CMSIS-DAP: SWD supported
Info : CMSIS-DAP: JTAG supported
Info : CMSIS-DAP: Atomic commands supported
Info : CMSIS-DAP: Test domain timer supported
Info : CMSIS-DAP: FW Version = 2.0.0
Info : CMSIS-DAP: Interface Initialised (JTAG)
Info : SWCLK/TCK = 0 SWDIO/TMS = 1 TDI = 0 TDO = 1 nTRST = 0 nRESET = 0
Info : CMSIS-DAP: Interface ready
Info : clock speed 8000 kHz
Info : cmsis-dap JTAG TLR_RESET
Info : cmsis-dap JTAG TLR_RESET
Info : JTAG tap: hpm6750.cpu tap/device found: 0x1000563d (mfg: 0x31e (Andes Technology Corporation), part: 0x0005, ver: 0x1)
Info : [hpm6750.cpu0] datacount=4 progbufsize=8
Info : Examined RISC-V core; found 2 harts
Info : hart 0: XLEN=32, misa=0x4094112d
[hpm6750.cpu0] Target successfully examined.
Info : starting gdb server for hpm6750.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
- 打开另一个终端,并进入ohos源码目录,启动gdb
$ riscv32-unknown-elf-gdb
GNU gdb (GDB) 8.1.50.20180718-git
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-pc-linux-gnu --target=riscv32-unknown-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http:
Find the GDB manual and other documentation resources online at:
<http:
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb)
- 选择需要调试的镜像,并进行加载调试
(gdb) file out/hpm6750evk2/hpm6750evk2/OHOS_Image
Reading symbols from out/hpm6750evk2/hpm6750evk2/OHOS_Image...done.
(gdb) target extended-remote :3333
Remote debugging using :3333
warning: Target-supplied registers are not supported by the current architecture
_start () at ../../../device/soc/hpmicro/hpm6700/liteos_m/los_start.S:26
26 la gp, __global_pointer$
(gdb) load
Loading section .nor_cfg_option, size 0x10 lma 0x80000400
Loading section .boot_header, size 0x90 lma 0x80001000
Loading section .start, size 0x2e lma 0x80003000
Loading section .vectors, size 0x3c0 lma 0x8000302e
Loading section .text, size 0x5876e lma 0x800033ee
Loading section .data, size 0x1158 lma 0x8005bb5c
Start address 0x80003000, load size 367956
Transfer rate: 6 KB/sec, 13141 bytes/write.
(gdb) c
相关仓库
[vendor_hpmicro]
https://gitee.com/openharmony/vendor_hpmicro
[device_soc_hpmicro]
https://gitee.com/openharmony/device_soc_hpmicro
[device_board_hpmicro]
https://gitee.com/openharmony/device_board_hpmicro
联系先楫
如果您在开发过程中有问题,请在仓库[issues]提问。
https://gitee.com/openharmony/device_soc_hpmicro/issues
感谢您的关注与支持!
完
“先楫半导体”(HPMicro)是一家致力于高性能嵌入式解决方案的半导体公司,总部位于上海,产品覆盖微控制器、微处理器和周边芯片,以及配套的开发工具和生态系统。公司成立于2020年6月,总部坐落于上海市浦东软件园区,并在天津、苏州、深圳和杭州均设立分公司。核心团队来自世界知名半导体公司管理团队,具有15年以上,超过20个SoC的丰富的研发及管理经验。先楫半导体以产品质量为本,所有产品均通过严格的可靠性测试。目前已经量产的高性能通用MCU产品包含HPM6700/6400、HPM6300、HPM6200、HPM5300及HPM6800系列,性能领先国际同类产品并通过AEC-Q100认证。公司已完成ISO9001质量管理认证和ISO 26262/IEC61508功能安全管理体系双认证,全力服务中国乃至全球的工业、汽车和能源市场。更多信息,请访问 https://hpmicro.com/