Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)

Issue FACTORY command

Altera_Forum
Honored Contributor II
2,533 Views

I'm using a Cyclone III LS 150 (780 pin), and programmed it using Active Serial. Now, I am altering the program stored in the Serial Device by programming through the JTAG port nad using the FPGA as the serial loader. However, I cannot reprogram the FPGA and Serial Device. Altera says I need to issue a FACTORY command via JTAG to solve this. 

 

Can anyone give me instructions on how to do this via Quartus and the USB Blaster? Or is it even possible? 

 

Thanks in advance
0 Kudos
18 Replies
Altera_Forum
Honored Contributor II
1,073 Views

Is it possible to issue JTAG commands via .tcl scripts? 

 

Or perhaps using the JTAG Chain Debugger?
0 Kudos
Altera_Forum
Honored Contributor II
1,073 Views

 

--- Quote Start ---  

Is it possible to issue JTAG commands via .tcl scripts? 

 

Or perhaps using the JTAG Chain Debugger? 

--- Quote End ---  

 

 

Use 'quartus_stp -s' from the command line, source the attached Tcl script, and then use jtag_open, and then read_idcode or read_usercode. If you have the IR value for FACTORY, you can create a new Tcl procedure to issue that command. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
1,073 Views

Thank you Dave! This could be just what I need. 

 

I followed your instructions, however, once I use jtag_open it says "The specified device is not found".
0 Kudos
Altera_Forum
Honored Contributor II
1,073 Views

The problem is, that all Quartus JTAG stack operations are starting with identifying the connected JTAG chain by an IDCODE read, which is apparently disabled with configured C III LS.  

 

In this situation, you can only access the device, if you know which devices are connected to the chain. That seems to be the reason why Altera suggests to use third party tools for the FACTORY command related operations.  

 

In my opinion, they designed this feature without much thinking. You can easily access the device, but not using Altera standard tools. The C III LS development board has a switch to disable the default configuration and unlock JTAG access, if I understand right.  

 

You still can use the USB Blaster with third party tools that support it or access JTAG through your own software.
0 Kudos
Altera_Forum
Honored Contributor II
1,073 Views

Ah, okay.  

 

Yes, this feature has been the source of much frustration. 

 

I wonder, if I can supply the IDCODE to the jtag_open command, perhaps that may let it work.
0 Kudos
Altera_Forum
Honored Contributor II
1,073 Views

Alright, it turns out I still had the JTAG Chain Debugger open, preventing it from accessing the JTAG Chain. That's why I got that error. 

 

So, jtag_open works now, and the read_idcode works (returns 0x000000, which is what I expect). 

 

I added this to the sourced .tcl file:  

 

proc send_factory {} { 

device_lock -timeout 10000 

 

# Shift-IR: = USERCODE = 281 

device_ir_shift -ir_value 281  

 

device_unlock 

return  

 

 

281 is the hex value of FACTORY (10 1000 0001) 

 

However, this does not reset the FPGA it appears, the IDCODE is still all zero's and I am unable to reprogram. 

 

Perhaps I need to hold nCONFIG low...
0 Kudos
Altera_Forum
Honored Contributor II
1,073 Views

Okay, if anyone else has the issue in the future, you must hold nCONFIG low, issue the FACTORY command, and then release nCONFIG. once you close the jtag port, you can use Quartus to program as normal.

0 Kudos
Altera_Forum
Honored Contributor II
1,073 Views

Just F.Y.I 

If you are suing Cyclone III LS 150 devkit, the system controler(max2) will issue the factory_command right after power cycle.
0 Kudos
Altera_Forum
Honored Contributor II
1,073 Views

 

--- Quote Start ---  

Just F.Y.I 

If you are suing Cyclone III LS 150 devkit, the system controler(max2) will issue the factory_command right after power cycle. 

--- Quote End ---  

 

 

I wish it had been that easy! :) 

 

It was on a custom PCB, but at least I figured it out. With help!
0 Kudos
Altera_Forum
Honored Contributor II
1,073 Views

You must issue the FACTORY command before the device is configured as otherwise it will be ignored.  

 

This applies whether you are using Altera tools or third party tools.
0 Kudos
Altera_Forum
Honored Contributor II
1,073 Views

 

--- Quote Start ---  

Use 'quartus_stp -s' from the command line, source the attached Tcl script, and then use jtag_open, and then read_idcode or read_usercode. If you have the IR value for FACTORY, you can create a new Tcl procedure to issue that command. 

 

Cheers, 

Dave 

--- Quote End ---  

 

 

I'm sorry for asking the stupid questions, but exactly how do I "source the attahched Tcl script?"  

 

I have saved it locally and have added the jtag_open() command from this thread as well. But I don't know how to actually call the function from within quartus_stp. 

 

I'm an FPGA guy, but have not yet learned Tcl scripting. My apologies! 

 

thanks, 

..dane
0 Kudos
Altera_Forum
Honored Contributor II
1,073 Views

 

--- Quote Start ---  

I'm sorry for asking the stupid questions, but exactly how do I "source the attahched Tcl script?"  

 

--- Quote End ---  

 

 

The word 'source' didn't provide the clue? :) 

 

1) Start a NIOS II IDE shell 

 

2) Start quartus_stp via 

 

bash-3.1$ quartus_stp -s 

 

3) Source the script myscript.tcl 

 

tcl> source myscript.tcl 

 

where myscript.tcl is a file in the same directory as where you started quartus_stp. 

 

If the script is somewhere else, you can source it with a path 

 

tcl> source c:/path_to_my_scripts/myscript.tcl 

 

or if you've got a Windows format, 'cause you copied-and-pasted from Windows Explorer, use 

 

tcl> source {c:\path_to_my_scripts\myscript.tcl} 

 

and the {} braces pass the path as a list to Tcl, and it fixes up the path separators. 

 

 

--- Quote Start ---  

 

I'm an FPGA guy, but have not yet learned Tcl scripting. My apologies! 

 

--- Quote End ---  

 

 

The book by Brent Welch is a pretty good reference for Tcl programming. 

 

Ask questions when you get stuck. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
1,073 Views

Dave- 

 

I'm red-faced with embarrassment! :oops: Thank you for that instruction. I have passed a link to this thread on to my coworker who is working this issue directly and will have him try it. 

 

We are in Windows, but the procedure I'm sure is remarkably similar. :) 

 

I had just tried "quartus -s <filename.tcl>" and seemed to get errors. I will ask him to try it the way you suggested and report back. 

 

cheers, 

..dane
0 Kudos
Altera_Forum
Honored Contributor II
1,073 Views

 

--- Quote Start ---  

 

We are in Windows, but the procedure I'm sure is remarkably similar. :) 

 

--- Quote End ---  

 

 

That was the procedure for Windows. 

 

Under Linux, you start a bash shell, and then source nios2_command_shell.sh from within the nios2eds folder in your Altera installation. Under windows, starting the NIOS II IDE from the start menu runs a batch file that does the same setup.  

 

Once you're in a bash shell, the procedure is identical. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
1,073 Views

Hi Dave. Question: is it necessary to start a NIOS IDE shell first? Can we just run quartus_stp -s from the Windows/DOS command prompt and go from there? 

 

We're trying it currently without anything to do with NIOS, and it's not working yet. We're currently verifying the nCONFIG is in fact asserted low and held low during the instruction and then released to float high once the instruction is sent. 

 

thanks, 

..dane
0 Kudos
Altera_Forum
Honored Contributor II
1,073 Views

 

--- Quote Start ---  

Question: is it necessary to start a NIOS IDE shell first? Can we just run quartus_stp -s from the Windows/DOS command prompt and go from there? 

 

--- Quote End ---  

 

 

The NIOS IDE shell is pretty much identical to a Windows/DOS command prompt. Did you try and bring one up? 

 

quartus_stp should work for both, however, the paths to the Altera tools might not be setup correctly. The advantage of using the Altera bash shell is that the paths are all correct. 

 

I have several versions of Quartus installed, and Cygwin, and I find it much less trouble if I just use the shell from the specific Altera installation. 

 

 

--- Quote Start ---  

 

We're trying it currently without anything to do with NIOS 

 

--- Quote End ---  

 

 

The NIOS II IDE Shell is just what its called on the Windows Start Menu. It doesn't have to involve a NIOS processor in your design. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
1,073 Views

Well, we got it working (somehow) using the scripts from this page. I think we had a glitch trying to maintain nConfig low at first or something like that. But net result, we just ran "quartus_stp -s" from the command prompt in the same folder path as the tcl script file sourced, and went from there.. 

 

thank you! 

..dane
0 Kudos
Altera_Forum
Honored Contributor II
1,073 Views

 

--- Quote Start ---  

Well, we got it working (somehow) using the scripts from this page. I think we had a glitch trying to maintain nConfig low at first or something like that. But net result, we just ran "quartus_stp -s" from the command prompt in the same folder path as the tcl script file sourced, and went from there. 

 

--- Quote End ---  

 

 

Great, glad to hear its working. 

 

Cheers, 

Dave
0 Kudos
Reply