简体   繁体   English

在PetaLinux上为Zynq FPGA上的Rocket Chip部署C可执行文件

[英]Deploy C executable on PetaLinux for Rocket Chip on Zynq FPGA

I'm currently trying to deploy an application (simple c program) to the Zynq ZedBoard . 我目前正在尝试 应用程序 (简单的c程序) 部署Zynq ZedBoard I followed the Rocket Chip on Zynq FPGAs github page to generate all the necessary files, put them on a SD card and boot PetaLinux . 我按照Zynq FPGA github页面Rocket Chip生成了所有必要的文件,将它们放在SD卡上并启动PetaLinux

In the tutorial, a pre-packed hello application can be executed after booting 在本教程中,可以在启动后执行预打包的hello应用程序

root@zynq:~# ./fesvr-zynq pk hello
hello!

I successfully managed to get to this point. 我成功地做到了这一点。 However, i'm wondering how i can deploy my own c code to an executable that will appear in the internal filesystem like the hello one above. 但是,我想知道如何将自己的C代码部署到一个可执行文件,该可执行文件将出现在内部文件系统中,就像上面的问好一样。

Thanks @user3528438 for giving me the right hint. 感谢@ user3528438给我正确的提示。 I'm writing this for future reference. 我正在写这篇文章,以备将来参考。

I was able to deploy and execute my own C application by doing the following: 通过执行以下操作,我能够部署和执行自己的C应用程序:


Write my own C code i want to execute on the Rocket Chip. 编写我想在火箭芯片上执行的自己的C代码

#include <stdio.h>
int main(void) {
    printf("Hello Rocket!\n");
    return 0;
}

Compile the code for the riscv architecture and generate executable . 编译 riscv体系结构的代码并生成可执行文件 This requires the riscv toolchain to be installed of course! 当然,这需要安装riscv工具链!

$ riscv64-unknown-elf-gcc -o myhello hello.c

Copy the generated myhello executable on your sd card that you insert in the ZedBoard. 生成的myhello可执行文件复制到插入ZedBoard的SD卡中。

Turn on the ZedBoard and login. 打开ZedBoard并登录。

Mount the sd card to be able to access your myhello executable. 装入sd卡即可访问您的myhello可执行文件。

$ mkdir /sdcard
$ mount /dev/mmcblk0p1 /sdcard

Change to the /sdcard directory and copy your executable to the /home/root directory. 转到/ sdcard目录,然后将可执行文件复制到/ home / root目录。 (This is where you find the standard hello executable) (在这里可以找到标准的hello可执行文件)

$ cd ../../sdcard
$ cp myhello /home/root

Switch back to the /home/root directory and execute your myhello file on the Rocket Chip via the frontend-server! 切换回/ home / root目录,并通过前端服务器在Rocket Chip上执行myhello文件

$ ./fesvr-zynq pk myhello

This prints the expected output to the console. 这会将预期的输出打印到控制台。

Hello Rocket!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM