Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
11 years ago

system console master_read_to_file

Hi guys

I am very new to altera, fpgas, qsys and system console, but i have managed to get a basic spi interface working with my DUT. Works very well. The code was done with qsys and nios ii and software on a modified hello world in eclipse.

My next task is to transfer the data that the alt_avalon_spi receives from my DUT back to my host pc.

One thing that looked promising was using system console with some tcl scripts. i watched a few tutorials on it, but cant quite get it.

i think that master_read_to_file might be what i need:

% help master_read_to_file

Uploads data from memory accessible from the specified master channel to a binary file on disk

Arguments:

<service-path>

<filename> The file to write to

<address> Start address in memory

<count> Number of bytes to write to file

I am able to connect to the master nios but i cant get my command to work...

im assuming that system console has access to my pc c: drive...

I believe that i should be using my onchip mem address for address and i just wanted to test it with something small (1000 bytes)

so im using this command

master_read_to_file $mypath 'c:\mydir\file11.bin' 0x00040000 1000

no errors come back but no file gets created either.

Can you guys tell me what im doing wrong? and where/what is a valid file path for the file?

Ill worry about linking my c code variables to onchip memory later (any pointers on that would be appreciated too)

thanks!

6 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    master_read_to_file $mypath 'c:\mydir\file11.bin' 0x00040000 1000

    --- Quote End ---

    I haven't used that function, but I think your problem is likely Windows "\" vs. UNIX "/" and you want to be using double quote " around the entire filename string (like what you would do in C). Try using "/". If that doesn't work, just use "foo.bin" and it ought to show up in the directory from which System Console is currently executing.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Tcl has a procedure for creating valid file names ... try this

    
    set filename 
    master_read_to_file $mypath $filename 0x00040000 1000
    

    The 'join' part of file join comes from the fact that you can use it to build up longer filenames. There is also a file normalize command, but it doesn't work in all tools, eg., the latest Qsys Java Tcl interpreter chokes on it.

    Cheers,

    Dave
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks guys! you were both correct! file showed up. now i just have to link the spi data to the onboard mem

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    yes, that was me. when you say "exact same thing," what are you trying to do? download a file? do it with a python interface?

    thanks