AN 425: Using the Command-Line Jam STAPL Solution for Device Programming

ID 683089
Date 12/09/2016
Public
Document Table of Contents

1.8.2. Running the Jam STAPL Byte-Code Player

Calling the Jam STAPL Byte-Code Player is like calling any other subroutine. In this case, the subroutine is given actions and a file name, and then it performs its function.

In some cases, you can perform in-field upgrades depending on whether the current device design is up-to-date. The JTAG USERCODE value is often used as an electronic "stamp" that indicates the device design revision. If the USERCODE is set to an older value, the embedded firmware updates the device.

The following pseudocode shows how you can call the Jam Byte-Code Player multiple times to update the target Altera device:

result = jbi_execute(jbc_file_pointer, jbc_file_size, 0, 0,\
"READ_USERCODE", 0, error_line, exit_code);

The Jam STAPL Byte-Code Player reads the JTAG USERCODE and exports it using the jbi_export() routine. The code then branches based on the result.

With Jam STAPL Byte-Code software support, updates to the supported Altera devices are as easy as adding a few lines of code.

Switch Statement

You can use a switch statement, as shown in this example, to determine which device needs to be updated and which design revision you must use.

switch (USERCODE)
{
    case "0001":        /*Rev 1 is old - update to new Rev*/
        result = jbi_execute (rev3_file, file_size_3, 0, 0,\
        "PROGRAM", 0, error_line, exit_code);
    case "0002":        /*Rev 2 is old - update to new Rev*/
        result = jbi_excecute(rev3_file, file_size_3, 0, 0,\
        "PROGRAM", 0, error_line, exit_code);
    case "0003":
        ;               /*Do nothing - this is the current Rev*/
    default:            /*Issue warning and update to current Rev*/
        Warning - unexpected design revision;
                        /*Program device with newest Rev anyway*/
        result = jbi_execute(rev3_file, file_size_3, 0, 0,\
        "PROGRAM", 0, error_line, exit_code);
}