0

I'm currently trying to deploy an application (simple c program) to the 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.

In the tutorial, a pre-packed hello application can be executed after booting

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.

mtosch
  • 351
  • 4
  • 18
  • download armhf tool chain, setup environment variables for cross-compiling for armhf, make all – user3528438 Dec 19 '16 at 19:41
  • Since you don't seem to know much about cross-compiling, or compiling in general, I assume your project is small and involves less 5 source files. If that is the case, just run `arm-linux-gnueabi-gcc` instead of `gcc`. Also something worth trying is to see if there's gcc on the board, if there is, you can just copy the whole project to the board and compile it there. If you are not missing dependencies, then that should do it. – user3528438 Dec 19 '16 at 19:44

1 Answers1

0

Thanks @user3528438 for giving me the right hint. I'm writing this for future reference.

I was able to deploy and execute my own C application by doing the following:


Write my own C code i want to execute on the Rocket Chip.

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

Compile the code for the riscv architecture and generate executable. This requires the riscv toolchain to be installed of course!

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

Copy the generated myhello executable on your sd card that you insert in the ZedBoard.

Turn on the ZedBoard and login.

Mount the sd card to be able to access your myhello executable.

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

Change to the /sdcard directory and copy your executable to the /home/root directory. (This is where you find the standard hello executable)

$ 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!

$ ./fesvr-zynq pk myhello

This prints the expected output to the console.

Hello Rocket!
mtosch
  • 351
  • 4
  • 18