UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor venturezhao
Visitor
1,400 Views
Registered: ‎03-14-2018

How to read/write file in emulation environment of SDsoc?

Jump to solution

Hi. guys,

 

When I compile the SDsoc project which need read/write files of SD card, it works well on Zynq hardware. 

fp = fopen("/mnt/inputfile/file0.pgm","r");
if(fp == NULL)
    {//...}

However, when I want to evaluate such code in emulation mode, it is difficult to find the correct directory where the file can be load by the emulator. 

Firstly, I want to find if there exists some setting that can mapping the host directory to the emulator. However I cannot find that.

Then, I analyzed the elements of the emulator, and knows that the vivado emulator regenerates the SD card image every time when it starts. So it is also no use to put the input file in the SD card fold, as shown below:

wenzhe@plusai-xian101:~/Project/02.stereo_matching/src/ELAS_SoC/Debug/_sds/emulation/sd_card$ ll
total 20104
drwxrwxr-x 2 wenzhe wenzhe     4096 Mar 26 19:10 ./
drwxrwxr-x 3 wenzhe wenzhe     4096 Mar 26 19:10 ../
-rw-r--r-- 1 wenzhe wenzhe      264 Dec 16 12:26 generic.readme
-rw-r--r-- 1 wenzhe wenzhe 18876160 Dec 16 12:26 image.ub
-rwxrwxr-x 1 wenzhe wenzhe  1692464 Mar 26 18:27 sdx_demo.elf*

So my question is how to deal with the input file if we use emulation mode? I think this is a very important scenario of the real project.

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Explorer
Explorer
1,858 Views
Registered: ‎09-19-2017

Re: How to read/write file in emulation environment of SDsoc?

Jump to solution

Hi venturezhao,

 

Check out the User Guide 1027: https://www.xilinx.com/support/documentation/sw_manuals/xilinx2017_4/ug1027-sdsoc-user-guide.pdf page 97 at the bottom. It says:

 

-sdcard <data directory>

Specify a optional directory containing additional files to include in the SD card image.

 

Sam

View solution in original post

3 Replies
Highlighted
Explorer
Explorer
1,859 Views
Registered: ‎09-19-2017

Re: How to read/write file in emulation environment of SDsoc?

Jump to solution

Hi venturezhao,

 

Check out the User Guide 1027: https://www.xilinx.com/support/documentation/sw_manuals/xilinx2017_4/ug1027-sdsoc-user-guide.pdf page 97 at the bottom. It says:

 

-sdcard <data directory>

Specify a optional directory containing additional files to include in the SD card image.

 

Sam

View solution in original post

Visitor venturezhao
Visitor
1,390 Views
Registered: ‎03-14-2018

Re: How to read/write file in emulation environment of SDsoc?

Jump to solution
Thank you, Sam!

That is great! So I can add such parameter in the parameters of compiling. will provide an detailed operation later~
0 Kudos
Visitor venturezhao
Visitor
1,328 Views
Registered: ‎03-14-2018

Re: How to read/write file in emulation environment of SDsoc?

Jump to solution

Hi, Sam,

 

I tried to add such parameter ' -sdcard "/mnt/wenzhe/Project/sdcard/" to both compiler and link commands, and it works. Thank you.

However, I still have some question about this parameter:

 

1) it seems that such parameter cannot recognize directory, instead it just involve all files into the SD card image, without keeping the directory construct. i.e.,

In the host file system:

wenzhe@plusai-xian101:~/Project/sdcard$ find ./
./
./img
./img/000000_R.pgm
./img/000000_L.pgm
./img/FinalResults

while when I added such directory into the image of emulator, no directory information left:

root@xilinx-zcu102-2017_4:/mnt# ls -l
total 20601
-rwxrwx---    1 root     disk        262806 Jan  1  2015 000000_L.pgm
-rwxrwx---    1 root     disk        262806 Jan  1  2015 000000_R.pgm
-rwxrwx---    1 root     disk       1691224 Feb  7 06:28 elas_demo.elf
-rwxrwx---    1 root     disk           264 Jan  1  2015 generic.readme
-rwxrwx---    1 root     disk      18876160 Jan  1  2015 image.ub

 So my question is how to keep the directory construct when we add the additional files to SD card image?

 

2) My code write some files during the emulation. But it seems that the output file just exists in the virtual machine, How can I copy them out to the host?

 

Many thanks for your help.

 

Wenzhe

0 Kudos