笔者最近将htop移植到OpenHar[mony,老规矩开源!!!

先上图,笔者的机器的是此芯星睿o6开发板+AMD显卡rx6600xt,OpenHarmony 5.0.0

image.png


可以看见cix p1芯片有四核大核 Cortex®-A720、四核中核 Cortex®-A720、四核小核 Cortex®-A520,一共12个核

b25ad52b7c1222ef719ff2f74018148a.png

如何集成htop到OpenHarmony

git clone https://gitee.com/OpenHarmony_rk_equipment_transplantation/ttyd_openharmony.git

cd ttyd_openharmony/lycium/
# 设置oh交叉编译环境
export OHOS_SDK=/root/OpenHarmony/cix_myself_5.0.0/prebuilts/ohos-sdk/linux/12

# 编译依赖库
./build.sh ncurses
# 编译htop
./build.sh htop

1.编译好的文件在ttyd_openharmony/lycium/usr/htop,将准备好的htop文件推送到开发板

image.png

2.将htop运行需要的terminfo 数据库文件编译出来,然后推送到开发板中

  • 编译x86 linux的ncurses可以得到terminfo 数据库文件。
    # 编译x86 linux的ncurses,得到terminfo 数据库
    wget https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.5.tar.gz
    tar -xvzf ncurses-6.5.tar.gz
    cd ncurses-6.5
    ./configure --prefix=/root/OpenHarmony/temp3/ncurses_install --with-termlib --with-cxx-binding --with-widec --without-ada --disable-mixed-case
    make -j $(shell nproc)
    make install
    

image.png

hdc file send "\\wsl.localhost\Ubuntu-20.04\root\OpenHarmony\temp3\ncurses_install\share\terminfo" /data

# 开发板上安装验证
export TERMINFO=/data/terminfo
./htop

移植思路

先完成ncurses 6.5 交叉编译移植到OpenHarmomy,然后交叉编译htop,编译时需要链接到ncurses的编译产物,然后开启编译htop时的静态链接。

https://codeload.github.com/htop-dev/htop/tar.gz/refs/tags/3.4.1
tar -zxvf 3.4.1 
cd htop-3.4.1/
./autogen.sh
./configure --host=aarch64-linux-gnu --prefix=/root/OpenHarmony/temp3/htop_install LDFLAGS="-L/root/OpenHarmony/temp3/ncurses_install/lib" CPPFLAGS="-I/root/OpenHarmony/temp3/ncurses_install/include  -D_FORTIFY_SOURCE=2" --enable-static --enable-affinity

最后如果有读者需要将htop二进制集成到固件里面,不知道默认设置环境变量export TERMINFO=/data/terminfo的话,可以参考笔者文章OpenHarmony中默认export 添加环境变量

Logo

社区规范:仅讨论OpenHarmony相关问题。

更多推荐