赞
踩
一. 下载minicom包和ncurses包
- wget https://fossies.org/linux/misc/minicom-2.9.tar.bz2
- wget https://ftp.gnu.org/gnu/ncurses/ncurses-6.4.tar.gz
二. 交叉编译ncurses
1.创建新的链接
cd /opt/sdk/ohos/native/llvm/bin
ln -s clang aarch64-linux-ohos-gcc
2. 修改config.sub文件,添加ohos系统支持:
4. 创建编译脚本build_ncurses.sh:
- #!/bin/bash
-
- set -e
-
- if [ "$1" == "clean" ] || [ "$1" == "distclean" ];then
- make $1
- exit 0
- fi
-
- export OHOS_SDK_HONE=/opt/sdk/ohos
- export OHOS_NATIVE_HOME=/opt/sdk/ohos/native
-
- export PATH=$OHOS_NATIVE_HOME/llvm/bin:$PATH
-
- export AR="$OHOS_NATIVE_HOME/llvm/bin/llvm-ar"
- export AS="$OHOS_NATIVE_HOME/llvm/bin/llvm-as"
- export LD="$OHOS_NATIVE_HOME/llvm/bin/ld.lld"
- export RANLIB="$OHOS_NATIVE_HOME/llvm/bin/llvm-ranlib"
- export STRIP="$OHOS_NATIVE_HOME/llvm/bin/llvm-strip"
- export CC="$OHOS_NATIVE_HOME/llvm/bin/clang"
- export NM="$OHOS_NATIVE_HOME/llvm/bin/llvm-nm"
- export OBJDUMP="$OHOS_NATIVE_HOME/llvm/bin/llvm-objdump"
-
-
- export CFLAGS="--target=aarch64-linux-ohos --sysroot=$OHOS_NATIVE_HOME/sysroot"
- export CPPFLAGS="--target=aarch64-linux-ohos --sysroot=$OHOS_NATIVE_HOME/sysroot"
- export LDFLAGS="--target=aarch64-linux-ohos --rtlib=compiler-rt -fuse-ld=lld -lunwind"
-
- ./configure --prefix=${PWD}/_install \
- --target=aarch64-linux-ohos \
- --host=aarch64-linux-ohos \
- ${EXTOPTS}
-
- make -j$(($(nproc)*2)) && make install
5. 开始编译
编译成功后,把静态库拷贝到交叉编译工具链路径:
- ./build_ncurses.sh
- cp _install/lib/*.a /opt/sdk/ohos/native/sysroot/usr/lib/aarch64-linux-ohos/
备注:中途如果有如下运行错误,可以忽略
- mkdir -p /home/wxx/work/porting/ohos/ncurses-6.4/_install/bin
- /usr/bin/install -c -s tic /home/wxx/work/porting/ohos/ncurses-6.4/_install/bin/`echo tic| sed 's/$//'|sed 's,^,aarch64-linux-ohos-,'|sed 's/$//'`
- strip: Unable to recognise the format of the input file `/home/wxx/work/porting/ohos/ncurses-6.4/_install/bin/aarch64-linux-ohos-tic'
- /usr/bin/install: strip process terminated abnormally
- make[1]: *** [Makefile:219: install.progs] Error 1
- make[1]: Leaving directory '/home/wxx/work/porting/ohos/ncurses-6.4/progs'
- make: *** [Makefile:136: install] Error 2
三. 交叉编译minicom
1. 修改config.sub文件,添加ohos系统支持:
2. 创建编译脚本build_minicom.sh:
- #!/bin/bash
-
- set -e
-
- if [ "$1" == "clean" ] || [ "$1" == "distclean" ];then
- make $1
- exit 0
- fi
-
- export OHOS_SDK_HONE=/opt/sdk/ohos
- export OHOS_NATIVE_HOME=/opt/sdk/ohos/native
-
- export PATH=$OHOS_NATIVE_HOME/llvm/bin:$PATH
-
- export AR="$OHOS_NATIVE_HOME/llvm/bin/llvm-ar"
- export AS="$OHOS_NATIVE_HOME/llvm/bin/llvm-as"
- export LD="$OHOS_NATIVE_HOME/llvm/bin/ld.lld"
- export RANLIB="$OHOS_NATIVE_HOME/llvm/bin/llvm-ranlib"
- export STRIP="$OHOS_NATIVE_HOME/llvm/bin/llvm-strip"
- export CC="$OHOS_NATIVE_HOME/llvm/bin/clang"
- export NM="$OHOS_NATIVE_HOME/llvm/bin/llvm-nm"
- export OBJDUMP="$OHOS_NATIVE_HOME/llvm/bin/llvm-objdump"
-
- export CFLAGS="--target=aarch64-linux-ohos --sysroot=$OHOS_NATIVE_HOME/sysroot -I/home/wxx/work/porting/ohos/ncurses-6.4/include -I/home/wxx/work/porting/ohos/ncurses-6.4/install/include"
- export CPPFLAGS="--target=aarch64-linux-ohos --sysroot=$OHOS_NATIVE_HOME/sysroot -I/home/wxx/work/porting/ohos/ncurses-6.4/install/include/ncurses"
- export LDFLAGS="--target=aarch64-linux-ohos -lncurses"
-
- ./configure --prefix=${PWD}/_install \
- --target=aarch64-linux-ohos \
- --host=aarch64-linux-ohos \
- ${EXTOPTS}
-
- make -j$(($(nproc)*2)) && make install
3. 开始编译
./build_minicom.sh
编译成功后,minicom会在_install/bin/下生成。
四. minocom在OpenHarmony上的使用
1. 在windows下,通过hdc工具,把minicom和vt100拷贝到OpenHarmony系统
这两个文件,可以通过这里直接下载:minicom+vt100
- hdc file send minicom /data
- hdc shell chmod +x /data/minicom
- hdc shell mkdir -p /data/terminfo/v/
- hdc file send vt100 /data/terminfo/v/
2.运行minicom
minicom在hdc shell下操作不友好,可以通过串口调试进去操作
- setenforce 0
- export TERMINFO=/data/terminfo
- export TERM=vt100
- /data/minicom -D /dev/ttyS9
下面就是运行界面
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。