AMC13Tool2 is a command-line utility designed to exercise all functions of the AMC13. The tool can be run in either interactive or scripted mode.


AMC13Tool2.exe  [-p ] [-X ] [-i ] ...  [-c ] ...  [--] [--version] [-h]

Argument Type NotesSorted ascending
-i, --id string connection file ID prefix (requires connection file too)
-c, --connect file name, ip address, or serial number connection file name, ip address, or AMC13 serial number (may be repeated for multiple AMC13)
-X, --script string name of script file to execute
-p, --path path path to address table files (if not using connection file)


The tool make be started with no command-line options, in which case it will immediately enter interactive mode without establishing communication with any AMC13. Typically the first interactive command would then be "connect" to attach an AMC13.

Specifying AMC13 Modules

Use the -c argument to specify AMC13 modules to communicate with.

IP Address or Serial Number

The argument after -c may be a numeric I/P address, in the standard form e.g., or simply the serial number e.g. 67. To specify the control hub protocol, append /c e.g. AMC13Tool2.exe -c (AMC13Tool2.exe -c 67/c). Always specify the T2 board (lower) IP address or serial number. The tool will automatically connect to the address specified + 1 for T1.

If you specify an IP address, you must also tell the tool where to find the IPBus address tables. You can either set the environment variable AMC13_ADDRESS_TABLE_PATH or use the -p option on the command line to do this. The path must be the name of a directory containing the two files AMC13_T1.xml and AMC13_T2.xml. (In the standard source distribution these are symlinks in the directory ...amc13/etc/amc35 below the top level. In the RPM distribution they are in /opt/cactus/etc/amc13).

Connection File

Alternatively you may specify the name of a connection file. See Cactus Tutorial for details.

If you specify a connection file, by default it must contain the entries with ID T1 and T2 for one AMC13. If you have multiple ID in the same file, name them with different prefixes and pairs ending in .T1 and .T2. Then specify the ID prefix with the -i command-line argument.

Running Scripts

A script file may be created with a list of AMC13Tool2 commands. A script may be executed in two ways:

  1. By specifying the file name after -X (note capitol X) on the command line
  2. By executing the command include <file_name> in interactive mode or from within another script

After executing a script the tool will normally return to interactive mode. If you wish the tool to exit (e.g. so you can run scripts from within a shell script) just terminate the script with the command quit.

Interactive Mode

The tool will enter interactive mode after executing any scripts specified. A &Launcher::AMC13VerifyFlashHeader, "*>* prompt is displayed. Type h for a list of commands. Type h <command> for detailed help, or h * for detailed help on all commands.

Generally, interactive commands consist of a command word followed by optional arguments. The command words are case-sensitive. Each command may have aliases (alternative names) given in parenthesis in the help.

Numeric arguments are interpreted as decimal unless prefixed with 0x in which case they are interpreted as hexadecimal.

Tab completion and history editing are provided by the GNU readline library. Tab completion is particularly useful for command words and address table entries.

Wildcards are permitted in address table entries in certain cases. For example, the command readT1 stat*ttc*err* will read and display all address table entries matching the expression with wildcards.

Wildcards are simple shell-style by default, where * matches any string. An argument may be preceded with the string perl: to force full perl-style regular expression matching.

Detailed Command List

help (h)

Display list of commands. A command name may be given for a longer description of a particular command.

quit (q, exit)

Exit the program.


Echo the arguments after the command to the terminal (useful in scripts)


Delay execution for the specified time in seconds. Decimal values may be used.

connect <module_id>

Connect to an AMC13 using the specified IP address, serial number, or connection file. See section above for details on the syntax.

list (fv)

List all connected AMC13 modules with firmware version, serial number and IP addresses. The module currently accepting commands is marked with a - character.

For example:

Connected AMC13s
*0: SN:  86 T1v: 0211 T2v: 0021 cf:
 1: SN:  82 T1v: 4007 T2v: 0021 cf:

sel <number>

Select an AMC13 to accept commands. Specify a number as shown in the output of the list command.

readT1 (rv) <address> [<count>]
readT2 (rs) <address> [<count>]

Read from a register on the T1 or T2 board. <address> may be any of the following:

  • a numeric address (remember to use 0x prefix for hex
  • the name of one address table item
  • an expression containing wildcard characters

An optional count may be given if the address specifies a single register. The specified number of 32-bit words will be read and displayed.

All displayed values are in hex.

writeT1 (wv) <address> [<data>]
writeT2 (ws) <address> [<data>]

Write to an address on T1 or T2 board. Address may be numeric or an address table item. Data must be numeric.

Data may be omitted in which case a special masked write is performed. This is typically used for address table items with names starting with ACTION.. For example:


Will correctly reset the T1 board.

i (en) <inputs> <options> (initialize AMC13 for data taking)
 i (en)              :   Initialize AMC13
                             inputs:   list of inputs e.g. '1-12'
                                       '*' enables all inputs which show AMC link ready
                             options:  T to enable loop-back TTC on TTS output fiber
                                       F to generate fake events in AMC13
                                       N to leave AMC13 out of run mode after initialization

Using "F" will cause fake data of size determined by the T1 register CONF.AMC.FAKE_DATA_SIZE ( addr 0x18 ) to appear to come from the AMC slots given in the list of inputs. The list of inputs is comma delimited with no spaces, and you can use single numbers( 2,7,10 ), inclusive ranges indicated with a hyphen ( 1-7 ), or a combination of the two ( 1-3,5,7,9-12).

When using multiple event builders ( >daq 2 for example ), you must enable at least one AMC slot for each SFP channel. See the daq command for more info.

daq <config> (configure DAQ fiber output)

This command sets the configuration for the DAQ fiber (aka S-Link express, DAQLSC) outputs. Options:

  • 1 - enable SFP0 (top) DAQ fiber for AMC1-AMC12 readout
  • 2 - enable SFP0 for AMC1-AMC6, SFP1 for AMC7-AMC12
  • 3 - enable SFP0 for AMC1-AMC4, SFP1 for AMC5-AMC8, SFP2 for AMC9-AMC12
  • d - disable all fibers
  • 0 - disable all fibers

Enter 'L' after number of DAQs to enable local mode (using local triggers). Example: >daq 2 L.

When initializing AMCs, at least one AMC from each SFP channel must be initialized.

Note: recommend doing 'rd' (daq reset) after changing configuration

fed <link_no> <id>

Set Source_ID or FED number for link 0-3.

localL1A <mode> <burst> <rate> (Configure local L1A generator)

Option Function Note
mode "o" specifies one trigger per <rate> orbits
mode "b" specifies one trigger per <rate> BX
mode "r" specifies random triggers in <rate> Hz
mode "d" disable local L1A
burst number of triggers per burst in single-burst mode
rate number of orbits or BX between triggers or random rate in Hz units

The burst parameter is ignored in random mode.

The maximum rate which can be specified is about 1MHz but the trigger rules limit it to less than that unless they are disabled (see below). The low 4 bits of the specified rate are ignored (use value is divided by 16, written to a register, and then multiplied by 16 in the firmware).

Note that CMS "standard" trigger rules are applied. Individual rules may be disabled, see Local_L1A_Generator.

setOcrCommand (set orbit count reset TTC command)

Specify the TTC command to use for orbit count reset. Note that the low two bits must be zero as they have predefined meanings (bit 0=BcR; bit 1=EcR)

setOrbitGap <start> <end> (set orbit gap for local triggers)

Triggers generated by the local L1A generator will not occur in this range of BCN.

<start> must be in the range 0-3562

<end> must be in the range 1-3563

prescale <mode> <factor> (set local event capture mode/prescale)

This command sets the parameters for capture of selected events in the SDRAM buffer for readout over IPBus using the commands re and df or other means.

    mode:  0 for simple prescale (record every n events, n from 1...0x10000)
           1 to match EvN with n low bits =0 where n from 5..20
  factor:  if mode=0, 1...0x10000
           if mode=1, 5..20

lt <mode/count> (Enable/disable local L1A generator)

If <mode/count> is an integer, send that many bursts of triggers (typically you would want to set the burst size to 1 using the localL1A command if using this feature).

If <mode/count> is a letter, perform one of these functions:

Mode Function
e Enable local trigger generator
d Disable local trigger generator
c Start continuous triggers
If you set up the trigger generator using localL1A it is automatically enabled (e.g. lt 5 would generate 5 bursts) but it does not start to run continuously unless you enter lt e. To stop continuous triggers, enter lt d.

rg (general reset)

Reset most AMC13 logic. For firmwares before 0x20f/0x4006 this resets DAQ links too. After this version, use 'rd' to reset DAQ separately

rc (counter reset)

Reset AMC13 counters.

rd (DAQ reset)

DAQ Link reset (firmware 0x20f/0x4006 and above)

start (Enable run mode)
stop (Disable run mode)

nodes {T1|T2} <regex> <options> (list address table nodes)

This traverses the IPBus address table for either T1 or T2 board and displays all items matching the specified regular expression. The regular expression format is rather simple; '*' matches any string.

Option "V" will display a description of each item.

Option "D" provides debugging output.

For example:

>nodes t1 *ttc*error*
9 nodes matched
    0: STATUS.TTC.BCNT_ERROR chip_type:    specifies firmware file suffix denoting T2 chip type                                       (addr=00000000 mask=00000040)  r
    1: STATUS.TTC.BCNT_ERRORS_HI                                    (addr=00000045 mask=0000ffff)  r
    2: STATUS.TTC.BCNT_ERRORS_LO                                    (addr=00000044 mask=ffffffff)  r
    3: STATUS.TTC.MULT_BIT_ERROR                                    (addr=00000000 mask=00000100)  r
    4: STATUS.TTC.MULT_BIT_ERRORS_HI                                (addr=00000043 mask=0000ffff)  r
    5: STATUS.TTC.MULT_BIT_ERRORS_LO                                (addr=00000042 mask=ffffffff)  r
    6: STATUS.TTC.SGL_BIT_ERROR                                     (addr=00000000 mask=00000080)  r
    7: STATUS.TTC.SGL_BIT_ERRORS_HI                                 (addr=00000041 mask=0000ffff)  r
    8: STATUS.TTC.SGL_BIT_ERRORS_LO                                 (addr=00000040 mask=ffffffff)  r

Verbose option to display descriptions:

>nodes t1 status*tts_state v
2 nodes matched
    0: STATUS.AMC_TTS_STATE                                         (addr=00000019 mask=001f0000)  r
       encoded TTS from enabled AMCs
    1: STATUS.T1_TTS_STATE                                          (addr=00000019 mask=0000f000)  r
       Current T1 overall TTS state

re <all> (read/display event from SDRAM)

This command will read the next event from the SDRAM and display the first 10 words and last 5 words of the event. If the argument all is given, the entire event is displayed. The read pointer is advanced to the next event.

rev (read/display event using new vector interface)

This command is equivalent to re except that it uses (tests) the new vector-based function to read events.

df <file> <count> (read events to file)

This command reads events from the SDRAM buffer and writes them to a binary file. The file argument specifies the file to write. The count argument specifies the number of events (default is 1).

The file format is defined as a list of 64-bit words in little-endian byte order as follows. See AMC13CommonFirmwareProposal for detailed description of AMC13 payload format.

  badc0ffeebadcafe   magic number present at start of each event
  cccccccccccccccc   size of event in 64-bit words
  510000781f412308   CMS common data format header
  104101401a540110   AMC13 header, specifying 4 AMCs
  c62b8d9c000781f4   AMC13 trailer with CRC
  a0001014c3590000   CMS command data format trailer

ttc <options> (control TTC history capture)
   ttc h on                 - ttc history enable
   ttc h off                - ttc history disable
   ttc h clr                - ttc history clear
   ttc h d             - ttc history display  items or all
   ttc f on                 - ttc filter enable
   ttc f off                - ttc filter disable
   ttc f clr                - ttc filter clear
   ttc f s ! !  - set TTC filter list item
            is item 0-15 to set
             is value to match for filtering commands
            is bits to ignore when filtering commands
   ttc f list               - list currently-defined filters
   ttc f ena             - enable specific filter by number
   ttc f dis             - disable specific filter by number

The TTC history capture must be enabled with ttc h on. Using the default settings (no filters) the history will fill with BC0 commands. To set up a filter to ignore BC0, use the following command:

  > ttc f s 1 0xfe

For example:

[hazen@cms4 amc13]$ AMC13Tool2.exe -c
>en 1-4 f t
parsed list "1-4" as mask 0xf
Enabling fake data
Enabling TTS as TTC for loop-back
AMC13 out of run mode
AMC13 is back in run mode and ready
>ttc h on                         (turn on TTC history)
>ttc h d 5                        (display 5 commands)
History buffer has 512 entries
NOTE:  TTC history capture disabled before readout
    Cmd --Orbit- BcN --EvN-
  0: 01 0003cf4e dea 000001       (these are all Bc0 and uninteresting)
  1: 01 0003cf4f dea 000001
  2: 01 0003cf50 dea 000001
  3: 01 0003cf51 dea 000001
  4: 01 0003cf52 dea 000001
>ttc f s 0 0x01 0xfe              (set filter item 0 to 0x01 with mask 0xfe)
>ttc f on                         (turn on filtering)
>ttc h clr                        (clear the history)
>ttc h on                         (turn history back on)
>ttc h d 5                        (display 5 entries)
History buffer has 0 entries
>ttc h on                         (turn history back on)
>wv ACTION.LOCAL_TRIG.SEND_OCR    (send OcR command)
>wv ACTION.LOCAL_TRIG.SEND_OCR    (twice for fun)
>ttc h d 5                        (display 5 entries)
History buffer has 2 entries
NOTE:  TTC history capture disabled before readout
    Cmd --Orbit- BcN --EvN-
  0: 28 00021c6b a17 000001
  1: 28 000203d5 b65 000001
>ttc f list                       (list the items being filtered)
Item Ena CMD Mask
   0 On   01 fe
   1 Off  00 00
  15 Off  00 00

The detailed documentation for the following commands hasn't been written yet, but in general they should be used only by expert users.

 vfh                 :   verify flash header -- vfh OR vfh <chip_type>
 vbs                 :   verify flash golden -- vbs OR vbs <chip_type>
 vs                  :   verify flash spartan -- vs OR vs <chip_type>
 vv (vk)             :   verify flash virtex/kintex -- vv OR vv <chip_type>
 pfh                 :   program flash header -- pfh OR pfh <chip_type>
 pbs                 :   program flash golden -- pbs OR pbs <chip_type>
 ps                  :   program flash spartan -- ps OR ps <chip_type>
 pv (pk)             :   program flash virtex/kintex -- pv OR pv <chip_type>
 status (st)         :   Display AMC13 Status
                         status  table_name
                           level from 1..9 with 1 being least verbose (99 displays everything)
                           table_name limits the display to the table named
 statusHTML          :   Display AMC13 status in basic HTML format
                         statusHTML  table_name
                           level from 1..9 with 1 being least verbose (99 displays everything)
                           table_name limits the display to the table named
 openStatusFile      :   Open a text file to stream status info to
 closeStatusFile     :   Close the text file
 printFlash          :   print flash data for testing only
 verifyFlash         :   verify flash data from file -- verifyFlash file address
 programFlash        :   program flash data from file -- programFlash file address
 reconfigureFPGAs    :   reconfigure FPGAs from flash
 verifyFlashFile     :   verify flash data from file -- verifyFlash file
 programFlashFile    :   program flash data from file -- programFlash file
 selectFileTest      :   test function for MCS file parsing -- selectFileTest file

Flash Programming Commands (for firmware updates, etc.)

Flash programming commands uses the board's serial number to identify the relevant firmware chip-type for the user indicated flash region. It then looks for matching mcs files in the current directory and lists them for the user to pick from. Once the user selects the mcs file to use, the flash action (verify or program) will be carried out.

When reprogramming, once the flash has been programmed, load the new firmware using 'reconfigureFPGAs'

For detailed recipe for updating firmware follow this link: Firmware Update Recipe

vfh (Verify Flash Header)
vfh:    verify flash header
             vfh OR vfh <chip_type>
             chip_type: specifies firmware file suffix denoting T2 chip type
vbs (Verify Backup Spartan, e.g. Golden)
vbs:    verify flash backup spartan (golden) \n" \
             vbs OR vbs <chip_type>
             chip_type: specifies firmware file suffix denoting T2 chip type
vs (Verify Spartan, e.g. T2)
vs:     verify flash spartan
             vs OR vs <chip_type>
             chip_type: specifies firmware file suffix denoting T2 chip type
vk (or vv) (Verify Kintex/Virtex, e.g. T1)
vv:     verify flash virtex/kintex
             vv OR vv <chip_type>
             chip_type: specifies firmware file suffix denoting T2 chip type
pfh (Program Flash Header)
pfh:    program flash header\n" \
             Usage:\n" \
             pfh OR pfh <chip_type>\n" \
             chip_type: specifies firmware file suffix denoting T2 chip type
pbs (Program Backup Spartan, e.g. Golden)
pbs:   program flash backup spartan (golden)
             pbs OR pbs <chip_type>
             chip_type: specifies firmware file suffix denoting T2 chip type
ps (Program Spartan, e.g. T2)
ps:     program flash spartan
             ps OR ps <chip_type>
             chip_type: specifies firmware file suffix denoting T2 chip type
pk (or pv) (Program Kintex/Virtex, e.g. T1)
pv:     program flash virtex/kintex
             pv OR pv <chip_type>
             chip_type: specifies firmware file suffix denoting T2 chip type
reconfigureFPGAs (reconfigure FPGAs from flash)


dump (wu) (dump register values in Mr. Wu's format)
dump (wu): dump registers in Mr. Wu's format to .txt file with a status (st) command at the end
             wu OR wu <filename> OR wu <status_verbosity_level> OR wu <filename> <status_verbosity_level>

-- EricHazen - 18 Oct 2014

Edit | Attach | Watch | Print version | History: r25 < r24 < r23 < r22 < r21 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r22 - 18 Jun 2021 - EricHazen
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2023 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback