RISC-V技术论坛
直播中

mjgame

2年用户 4经验值
私信 关注
[经验]

【Milk-V Duo 开发板首发免费试用】环境搭建、编译、运行

  1. 克隆SDK,克隆地址:https://github.com/milkv-duo/duo-buildroot-sdk.git
git clone [https://github.com/milkv-duo/duo-buildroot-sdk.git](https://github.com/milkv-duo/duo-buildroot-sdk.git)

image.png

image.png

下载SDK后,需要安装SDK环境依赖,我是22.04版本ubuntu,执行以下

sudo apt install pkg-config build-essential ninja-build automake autoconf
libtool wget curl git gcc libssl-dev bc slib squashfs-tools
android-sdk-libsparse-utils jq python3-distutils scons parallel tree
python3-dev python3-pip device-tree-compiler ssh cpio fakeroot libncurses5 flex
bison libncurses5-dev genext2fs rsync unzip dosfstools mtools tcl
openssh-client cmake

另外SDK中的mkimage命令依赖的libssl1.1,在Ubuntu22.04中已不存在,需要单独安装。还有其他安装方法,可以参考git库。

echo "deb
http://security.ubuntu.com/ubuntu focal-security main" | sudo tee
/etc/apt/sources.list.d/focal-security.list

sudo apt update

sudo apt install libssl1.1

3.进行编译,执行一键编译

cd duo-buildroot-sdk/
./build_milkv.sh

出现以下结果,就是编译成功了

image.png

4.烧录
下载烧录工具: balenaEtcher - 将操作系统映像闪存到 SD 卡和 USB 驱动器

image.png

下载成功后,将SD卡,插入板子,板子等待几秒后,闪烁蓝灯,代表运行成功
image.png

5.编译应用代码,编译,执行

编写以下代码,保存为milkv_hello.c

#include <stdio.h>
int main()
{  
    printf("hello world\r\n");
    return 0;
}

为当前窗口加载编译环境

source build/cvisetup.sh
defconfig cv1800b_milkv_duo_sd

affd5e1052a6a7e88ec7918ce5a8855.jpg

使用milkv的工具链进行编译

riscv64-unknown-linux-musl-gcc milkv_hello.c -o hello

10876614788ef410bce11b21aea518e.jpg

6.运行
将编译好的hello执行文件拷贝到板子上,板子默认有usb的网络共享功能,电脑需要安装NDIS驱动后,就可以通过usb 网络拷贝到板子上。

sudo scp ./hello  root@192.168.42.1:/root/

效果如下:

6fc98543940eaaca21933b37b7289c2.jpg

更多回帖

发帖
×
20
完善资料,
赚取积分