当前位置:   article > 正文

移植minicom到OpenHarmony4.0

移植minicom到OpenHarmony4.0

一. 下载minicom包和ncurses包

  1. wget https://fossies.org/linux/misc/minicom-2.9.tar.bz2
  2. 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:

  1. #!/bin/bash
  2. set -e
  3. if [ "$1" == "clean" ] || [ "$1" == "distclean" ];then
  4. make $1
  5. exit 0
  6. fi
  7. export OHOS_SDK_HONE=/opt/sdk/ohos
  8. export OHOS_NATIVE_HOME=/opt/sdk/ohos/native
  9. export PATH=$OHOS_NATIVE_HOME/llvm/bin:$PATH
  10. export AR="$OHOS_NATIVE_HOME/llvm/bin/llvm-ar"
  11. export AS="$OHOS_NATIVE_HOME/llvm/bin/llvm-as"
  12. export LD="$OHOS_NATIVE_HOME/llvm/bin/ld.lld"
  13. export RANLIB="$OHOS_NATIVE_HOME/llvm/bin/llvm-ranlib"
  14. export STRIP="$OHOS_NATIVE_HOME/llvm/bin/llvm-strip"
  15. export CC="$OHOS_NATIVE_HOME/llvm/bin/clang"
  16. export NM="$OHOS_NATIVE_HOME/llvm/bin/llvm-nm"
  17. export OBJDUMP="$OHOS_NATIVE_HOME/llvm/bin/llvm-objdump"
  18. export CFLAGS="--target=aarch64-linux-ohos --sysroot=$OHOS_NATIVE_HOME/sysroot"
  19. export CPPFLAGS="--target=aarch64-linux-ohos --sysroot=$OHOS_NATIVE_HOME/sysroot"
  20. export LDFLAGS="--target=aarch64-linux-ohos --rtlib=compiler-rt -fuse-ld=lld -lunwind"
  21. ./configure --prefix=${PWD}/_install \
  22. --target=aarch64-linux-ohos \
  23. --host=aarch64-linux-ohos \
  24. ${EXTOPTS}
  25. make -j$(($(nproc)*2)) && make install

5. 开始编译

编译成功后,把静态库拷贝到交叉编译工具链路径:

  1. ./build_ncurses.sh
  2. cp _install/lib/*.a /opt/sdk/ohos/native/sysroot/usr/lib/aarch64-linux-ohos/

备注:中途如果有如下运行错误,可以忽略
 

  1. mkdir -p /home/wxx/work/porting/ohos/ncurses-6.4/_install/bin
  2. /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/$//'`
  3. strip: Unable to recognise the format of the input file `/home/wxx/work/porting/ohos/ncurses-6.4/_install/bin/aarch64-linux-ohos-tic'
  4. /usr/bin/install: strip process terminated abnormally
  5. make[1]: *** [Makefile:219: install.progs] Error 1
  6. make[1]: Leaving directory '/home/wxx/work/porting/ohos/ncurses-6.4/progs'
  7. make: *** [Makefile:136: install] Error 2

三. 交叉编译minicom

1. 修改config.sub文件,添加ohos系统支持:

2. 创建编译脚本build_minicom.sh:

  1. #!/bin/bash
  2. set -e
  3. if [ "$1" == "clean" ] || [ "$1" == "distclean" ];then
  4. make $1
  5. exit 0
  6. fi
  7. export OHOS_SDK_HONE=/opt/sdk/ohos
  8. export OHOS_NATIVE_HOME=/opt/sdk/ohos/native
  9. export PATH=$OHOS_NATIVE_HOME/llvm/bin:$PATH
  10. export AR="$OHOS_NATIVE_HOME/llvm/bin/llvm-ar"
  11. export AS="$OHOS_NATIVE_HOME/llvm/bin/llvm-as"
  12. export LD="$OHOS_NATIVE_HOME/llvm/bin/ld.lld"
  13. export RANLIB="$OHOS_NATIVE_HOME/llvm/bin/llvm-ranlib"
  14. export STRIP="$OHOS_NATIVE_HOME/llvm/bin/llvm-strip"
  15. export CC="$OHOS_NATIVE_HOME/llvm/bin/clang"
  16. export NM="$OHOS_NATIVE_HOME/llvm/bin/llvm-nm"
  17. export OBJDUMP="$OHOS_NATIVE_HOME/llvm/bin/llvm-objdump"
  18. 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"
  19. export CPPFLAGS="--target=aarch64-linux-ohos --sysroot=$OHOS_NATIVE_HOME/sysroot -I/home/wxx/work/porting/ohos/ncurses-6.4/install/include/ncurses"
  20. export LDFLAGS="--target=aarch64-linux-ohos -lncurses"
  21. ./configure --prefix=${PWD}/_install \
  22. --target=aarch64-linux-ohos \
  23. --host=aarch64-linux-ohos \
  24. ${EXTOPTS}
  25. make -j$(($(nproc)*2)) && make install

3. 开始编译

./build_minicom.sh

编译成功后,minicom会在_install/bin/下生成。

四. minocom在OpenHarmony上的使用

1. 在windows下,通过hdc工具,把minicom和vt100拷贝到OpenHarmony系统

这两个文件,可以通过这里直接下载:minicom+vt100

  1. hdc file send minicom /data
  2. hdc shell chmod +x /data/minicom
  3. hdc shell mkdir -p /data/terminfo/v/
  4. hdc file send vt100 /data/terminfo/v/

2.运行minicom

minicom在hdc shell下操作不友好,可以通过串口调试进去操作 

  1. setenforce 0
  2. export TERMINFO=/data/terminfo
  3. export TERM=vt100
  4. /data/minicom -D /dev/ttyS9

下面就是运行界面

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/602815
推荐阅读
相关标签
  

闽ICP备14008679号