本帖最后由 qinyunti 于 2025-4-3 11:03 编辑
准备
供电,Type-C USB供电
Boot模式选择EMMC B3 B2 B1 B0 0010
连接串口
使用串口终端连接
115200--8-n-1
输入root登录
一.应用编译环境
我这里使用WSL+Ubuntu
下载的03-Tools.zip下解压Compile Toolchain/myir-image-full-openstlinux-weston-myd-ld25x-x86_64-toolchain-4.2.4-snapshot.sh
./myir-image-full-openstlinux-weston-myd-ld25x-x86_64-toolchain-4.2.4-snapshot.sh
指定路径回车默认
输入y
每次使用初始化环境
source /opt/st/myd-ld25x/4.2.4-snapshot/environment-setup-cortexa35-ostl-linux
查看 $CC和$XCC
qinyunti@qinyunti:~$ echo $CC
aarch64-ostl-linux-gcc -mcpu=cortex-a35 -march=armv8-a+crc -mbranch-protection=standard --sysroot=/opt/st/myd-ld25x/4.2.4-snapshot/sysroots/cortexa35-ostl-linux
qinyunti@qinyunti:~$ echo $CXX
aarch64-ostl-linux-g++ -mcpu=cortex-a35 -march=armv8-a+crc -mbranch-protection=standard --sysroot=/opt/st/myd-ld25x/4.2.4-snapshot/sysroots/cortexa35-ostl-linux
qinyunti@qinyunti:~$
二.HelloWorld
mkdir ld25x
cd ld25x/
nano helloworld.c
输入
#include <stdio.h>
int main(void){
printf("Hello World\r\n");
return 0;
}
ctrl+o回车保存
ctrl+x退出
编译
$CC helloworld.c -o helloworld
导出到win下
cp helloworld /mnt/d
Win下使用crt登录终端
rz导入helloworld文件
chmod +x helloworld
运行
三.总结
以上简单分享下交叉编译环境搭建,与c程序编译执行测试。为后面开发做准备。