--- Quote Start ---
Say I take your example design with the ram, leds and buttons, and instead of buttons I use switches.
I run this design on two boards.
On one board I put the switch to high / one, meaning Master.
On the other board I put the switch to low/zero, meaning Slave.
--- Quote End ---
I have a similar setup with two Stratix IV GX Development kits.
The first thing I did was download FTDI's FT_PROG tool
http://www.ftdichip.com/support/utilities.htm and I reprogrammed the Serial Number in the on-board USB-Blaster to have a unique value for each board, eg., S4GXDK01 and S4GXDK02. This ensures that Windows does not have issues when seeing two devices attached with the same USB serial numbers (in my experience all boards ship with a common serial number).
--- Quote Start ---
I connect two usb-byteblaster to my pc and start System Console
Situation 1:
How do I:
- Scan for all available jtag2avalon master?
--- Quote End ---
The Tcl code in jtag_open ...
# Get the list of masters
set masters
if { == 0} {
error "Error: No JTAG-to-Avalon-MM device found!"
}
# Access the first master in the masters list
set jtag(master)
open_service master $jtag(master)
Always accesses the first master in the list. In your code, you would modify this code to be something like
1. Add an argument which is the switch ID, eg., 0 or 1
2. Has the switch ID to master index mapping been created? If no, go to step 3, else go to step 4
3. Identify the two boards
- Open the first master, read its ID switch setting, store that info in the jtag global
- Open the second master, read its ID switch setting, store that info in the jtag global
4. Based on the switch ID argument, open_service on the master
Its been a while since I've played with my hardware setup, but I recall that System Console did not allow multiple JTAG masters to be accessed at the same time, i.e., you had to close one before opening the other. To deal with that, your JTAG read/write procedures need an extra argument, i.e., the master index, and then inside the read/write procedures you need to open the master perform the read/write, and then close the master.
In Tcl you can use a default value, eg.,
proc jtag_read {addr {master 0}} {
# Read from addr on JTAG master 0 by default
}
--- Quote Start ---
Situation 2:
This should be dynamic.
When I have this running, I want to be able to switch both boards in the other mode.
Meaning, the master becomes slave, and the slave becomes master.
--- Quote End ---
If you want it to be dynamic, then the mapping between ID and master would not be cached as described above, but determined for every access, i.e., read/write would be
1. Open the first master, is it the correct ID? Yes, go to step 3
2. Open the second master, is it the correct ID? (It should be)
3. Perform the read/write
4. Close the master
--- Quote Start ---
I would like to run the same script without modifying it, and detect the new master and new slave board. Is that possible?
--- Quote End ---
Once you have modified the read/write procedures to open, detect the board, perform the read/write, and then close the board, then yes, this is all automated.
--- Quote Start ---
Situation 3:
Now I start debugging, and add sometimes a NIOS with a jtag_uart, sometimes signaltap, sometimes both and sometimes none.
Can this script then still identify the jtag2avalon master and detect the master board and the slave board?
I assume that the nios has certain "jtag_identifier_code", and the signaltap as well.
--- Quote End ---
You'll have to try it and see.
I've had problems initializing SignalTap II triggers if I do not first "open" the JTAG master that is the source of the trigger, eg., it writes to a particular location.
Cheers,
Dave