[linux][d1.docs.aw-ol.com] Lichee D1-H 编译程序

前提

板子:Lichee RV Dock
系统:Tina系统

编译工具链:
riscv64-glibc-gcc-thead_20200702下载 (有问题,改用 全志sdk D1-H 内的编译工具链)

adb 使用

安装软件包

adb install /path/to/apk.apk

查看已安装的软件包

adb shell pm list packages

卸载已安装软件包
卸载不能通过安装apk时的apk文件名进行卸卸,需要指定软件完整包名进行卸载,包名可通过3.4介绍的办法进行查找

adb uninstall package_name

查看apk数据存放位置

adb shell pm path package_name

查看当前所在目录

adb shell pwd

查看根目录下有哪些文件(夹)

adb shell ls /

查看磁盘挂载情况

adb shell df -h

上传文件到手机

adb push /local/path/to/file/filename /phone/file/path/to/save

从手机下载文件到本地

adb pull /phone/path/to/file/filename /local/file/path/to/save

ADB
确认设备连接正常后:

adb push hello_word ./.

编译

解压交叉编译工具

mkdir 
tar -zxvf riscv64-glibc-gcc-thead_20200702.tar.gz

配置编译环境变量

export PATH=$PATH:/home/dysonnnn/lichee/riscv64-linux-x86_64-20210329/bin

检查环境变量

riscv64-unknown-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=riscv64-unknown-linux-gnu-gcc
Target: riscv64-unknown-linux-gnu
Configured with: /ldhome/software/toolsbuild/slave2/workspace/Toolchain/release-riscv-0/build/../source/riscv/riscv-gcc/configure --target=riscv64-unknown-linux-gnu --with-gmp=/ldhome/software/toolsbuild/slave2/workspace/Toolchain/release-riscv-0/lib-for-gcc-x86_64-linux/ --with-mpfr=/ldhome/software/toolsbuild/slave2/workspace/Toolchain/release-riscv-0/lib-for-gcc-x86_64-linux/ --with-mpc=/ldhome/software/toolsbuild/slave2/workspace/Toolchain/release-riscv-0/lib-for-gcc-x86_64-linux/ --with-libexpat-prefix=/ldhome/software/toolsbuild/slave2/workspace/Toolchain/release-riscv-0/lib-for-gcc-x86_64-linux/ --with-pkgversion='T-HEAD RISCV Tools V2.0.0.10 B20210329' --prefix=/ldhome/software/toolsbuild/slave2/workspace/Toolchain/release-riscv-0/install --with-sysroot=/ldhome/software/toolsbuild/slave2/workspace/Toolchain/release-riscv-0/install/sysroot --with-system-zlib --enable-shared --enable-tls --enable-languages=c,c++,fortran --disable-libmudflap --disable-libssp --disable-libquadmath --disable-libsanitizer --disable-nls --disable-bootstrap --src=../../source/riscv/riscv-gcc --enable-multilib --with-abi=lp64d --with-arch=rv64gcxthead 'CFLAGS_FOR_TARGET=-O2   -mcmodel=medany' 'CXXFLAGS_FOR_TARGET=-O2   -mcmodel=medany'
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.2.0 (T-HEAD RISCV Tools V2.0.0.10 B20210329) 

编译hello world 代码

编写打印 Hello Word 代码的小demo,在 hello_word.c 中写入:

#include <stdio.h>
int main(int argc, char const *argv[])
{
    printf("Hello world\n");
    return 0;
}

问题:

  1. 'cc1': execvp: No such file or directory
$ riscv64-unknown-linux-gnu-gcc hello_word.c -o hello_world
riscv64-unknown-linux-gnu-gcc: error trying to exec 'cc1': execvp: No such file or directory

解决方法:
libexc 目录缺失,找到对应的目录放到编译工具目录下即可。

  1. 缺少运行库 libc.so.6
root@MaixLinux:/demo# ./hello_riscv 
./hello_riscv: relocation error: ./hello_riscv: symbol __libc_start_main version GLIBC_2.29 not defined in file libc.so.6 with link time reference

更换 全志sdk D1-H 内的编译工具链, 版本 gcc version 8.1.0 (C-SKY RISCV Tools V1.8.4 B20200702) 即可正常运行。

image

参考内容:

d1.docs.aw-ol.com 编译第一个程序:Hello Word

d1.docs.aw-ol.com 您可以到全志客户服务平台获取相关源码:全志客户服务平台-资源下载具体步骤

www.cnblogs.com adb(Android Debug Bridge)安装使用教程

posted @ 2023-03-18 10:19  dysonnnn  阅读(40)  评论(0编辑  收藏  举报