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 andy.watts
Visitor
15,204 Views
Registered: ‎08-02-2009

Programming from command line

Hi,

 

I am using window OS. I want to be able to program my SPI Flash (via the FPGA) in command line mode as I am tired of the button pressing in impact. I have already successfully scripted the .mcs file build.

 

I am using Artix 7 with attached  N25Q64 flash. This FPGA is the only device on the command line.

 

I have got the followng cmd file:

 

   setMode -bscan
   setCable -p auto
   addDevice -p 1 -spi N25Q64 -file outputs\progfile.mcs
   program -e -p 1 -v
   quit

 

Which is called from a batch file/command:

 

   %impact% -batch prog.cmd

 

However I get an error. Below is from the impact log file:

 

Preference Table
Name                 Setting            
StartupClock         Auto_Correction    
AutoSignature        False              
KeepSVF              False              
ConcurrentMode       False              
UseHighz             False              
ConfigOnFailure      Stop               
UserLevel            Novice             
MessageLevel         Detailed           
svfUseTime           false              
SpiByteSwap          Auto_Correction    
AutoInfer            false              
SvfPlayDisplayComments false              
ERROR:iMPACT:335 - Invalid command, .

 

Could anyone point out where I am going wrong?

 

0 Kudos
8 Replies
Xilinx Employee
Xilinx Employee
15,199 Views
Registered: ‎04-16-2012

Re: Programming from command line

Hi

 

Try running individual command instead of prog.cmd to narrow down the issue to specific command. 

 

Thanks,

Vinay

--------------------------------------------------------------------------------------------
Have you tried typing your question in Google? If not you should before posting. Also, MARK this is as an answer in case it helped resolve your query/issue.Give kudos to the post that helped you to find the solution.
0 Kudos
Moderator
Moderator
15,187 Views
Registered: ‎01-15-2008

Re: Programming from command line

Hi andy in the batch file can you remove the %.

i.e. can you write/type

impact -batch prog.cmd 

Let us know if this succeeds

 

--Krishna

0 Kudos
Visitor andy.watts
Visitor
15,183 Views
Registered: ‎08-02-2009

Re: Programming from command line

Sorry if I am not seeing the obvious but what is the best way to run individual commands?

I tried cutting by cmd file down to just setMode -bscan but I still get an error.
0 Kudos
Visitor andy.watts
Visitor
15,182 Views
Registered: ‎08-02-2009

Re: Programming from command line

That doesnt work. I believe I need the % % to pick up the impact environment variable.

0 Kudos
Moderator
Moderator
15,176 Views
Registered: ‎01-15-2008

Re: Programming from command line

Hi Andy,

 

what is the batch file extension, i believe it will .bat.

If you have set the enviroment variables(in advanced tab of your system properties) for the xilinx install path than you dont need to provide again in the batch file you have created.

 

--Krishna

0 Kudos
Visitor andy.watts
Visitor
15,169 Views
Registered: ‎08-02-2009

Re: Programming from command line

Yes its .bat.

 

I thought I was doing it correctly. I have got the environment variable set. As above I am not using the pull path in the .bat file, I am using %impact%. A web search shoows this is generally how to access an environment viariable from a batch file.

0 Kudos
Participant sean.durkin
Participant
15,167 Views
Registered: ‎05-15-2013

Re: Programming from command line

Hi Andy,

 

I've been doing this for a while and I wrote a Tcl procedure to do this for me, pasted below.

 

Now, what this does:

  • it accepts a bitfile filename as an argument you can pass when calling the procdure
  • it then generates a name for the PROM file, which is just changing the suffix from *.bit to *.mcs
  • it runs promgen to generate the MCS. you might have to adjust the -s parameter. I think you need to set this to 8192  in your case, but you'd have to check (it's your flash's size in kBytes)
  • it then creates a batch file for iMPACT, similar to yours; in my case I make sure it uses my Xilinx USB cable with the specified speed.
  • it the runs iMPACT with that batch file and erases the batch afterwards

I have a bunch of procedures that I source in Vivado and have those as additional commands.

 

HTH,

Sean

 

# ----------------------------------------------------------------------------------------------------
# flash_fpga: creates PROM file and flashes it to the SPI flash attached to the FPGA
# This either flashes the file passed as an argument or uses the currently active bitfile.
# ----------------------------------------------------------------------------------------------------
proc flash_fpga args {
		
	if {[llength $args] > 0} {
		set bitfile $args
	} else {
return -code error "Error! No bitfile was passed when calling this procedure!" } # create a name for the prom file to be generated by substituting .bit by .mcs set promfile [string replace $bitfile [string length $bitfile]-3 [string length $bitfile] mcs] puts stdout "Generating PROM file $promfile..." # first, generate a PROM file from the bitfile passed as an argument # use catch to capture the program's output catch {exec promgen -spi -w -p mcs -o $promfile -s 8192 -u 0 $bitfile} result puts stdout $result puts stdout "Generating batch file for iMPACT..." # now, create a batch file for iMPACT if {[catch { set fh [open impact_batch.cmd w] puts $fh "setMode -bs" puts $fh "setCable -port usb21 -baud 6000000" puts $fh "addDevice -p 1 -file $bitfile" puts $fh "attachflash -position 1 -spi \"N25Q64\"" puts $fh "assignfiletoattachedflash -position 1 -file $promfile" puts $fh "program -p 1 -dataWidth 1 -spionly -e -loadfpga" puts $fh "quit" close $fh } res ] } { return -code error $res } puts "Running iMPACT to flash the PROM file..." # finally, flash the bitfile to the SPI flash on the board # iMPACT is stupid, because it always exits with a return code > 0, even # if everything is OK. So catch is needed here to capture the output and prevent the shell from exiting catch {exec impact -batch impact_batch.cmd} result puts stdout $result # delete the batch file after use file delete -force impact_batch.cmd }

 

0 Kudos
Highlighted
Visitor andy.watts
Visitor
15,156 Views
Registered: ‎08-02-2009

Re: Programming from command line

Hi,

 

My main problem in the end was that I had spaces infront of the comands in the .cmd file not realising that this would cause a problem.

 

A also had ommitted the attach flash commands. Thanks sean for the help with that one.

 

Now working

0 Kudos