pld: harmonize refresh commands 39/7839/12
authorDaniel Anselmi <danselmi@gmx.ch>
Sat, 17 Dec 2022 12:11:30 +0000 (13:11 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 23 Sep 2023 14:36:14 +0000 (14:36 +0000)
add refresh command for lattice devices
rename gowin reprogram to refresh
rename virtex2 program to refresh

Change-Id: I9da83a614b96da3e947ac4608b0a291b1d126914
Signed-off-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-on: https://review.openocd.org/c/openocd/+/7839
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
doc/openocd.texi
src/pld/certus.c
src/pld/certus.h
src/pld/ecp2_3.c
src/pld/ecp2_3.h
src/pld/ecp5.c
src/pld/ecp5.h
src/pld/gowin.c
src/pld/lattice.c
src/pld/lattice_cmd.h
src/pld/virtex2.c

index 7ad48c8629e646e59ee65febd8411a55c742cd16..2d59238b804726aaab87492d34c001dd49bad5e0 100644 (file)
@@ -8764,8 +8764,8 @@ Change values for boundary scan instructions selecting the registers USER1 to US
 Description of the arguments can be found at command @command{virtex2 set_instr_codes}.
 @end deffn
 
-@deffn {Command} {virtex2 program} pld_name
-Load the bitstream from external memory for FPGA @var{pld_name}. A.k.a. refresh.
+@deffn {Command} {virtex2 refresh} pld_name
+Load the bitstream from external memory for FPGA @var{pld_name}. A.k.a. program.
 @end deffn
 @end deffn
 
@@ -8796,6 +8796,10 @@ for FPGA @var{pld_name} with value @var{val}.
 Set the length of the register for the preload. This is needed when the JTAG ID of the device is not known by openocd (newer NX devices).
 The load command for the FPGA @var{pld_name} will use a length for the preload of @var{length}.
 @end deffn
+
+@deffn {Command} {lattice refresh} pld_name
+Load the bitstream from external memory for FPGA @var{pld_name}. A.k.a program.
+@end deffn
 @end deffn
 
 
@@ -8850,9 +8854,9 @@ Reads and displays the user register
 for FPGA @var{pld_name}.
 @end deffn
 
-@deffn {Command} {gowin reload} pld_name
+@deffn {Command} {gowin refresh} pld_name
 Load the bitstream from external memory for
-FPGA @var{pld_name}. A.k.a. refresh.
+FPGA @var{pld_name}. A.k.a. reload.
 @end deffn
 @end deffn
 
index 8bfdff4952c4ce55e2169e70700d99184364ebbe..a49501f5414eb72f75ed88896452d0cc7acf05be 100644 (file)
@@ -304,3 +304,27 @@ int lattice_certus_get_facing_read_bits(struct lattice_pld_device *pld_device_in
 
        return ERROR_OK;
 }
+
+int lattice_certus_refresh(struct lattice_pld_device *lattice_device)
+{
+       struct jtag_tap *tap = lattice_device->tap;
+       if (!tap)
+               return ERROR_FAIL;
+
+       int retval = lattice_preload(lattice_device);
+       if (retval != ERROR_OK)
+               return retval;
+
+       retval = lattice_set_instr(tap, LSC_REFRESH, TAP_IDLE);
+       if (retval != ERROR_OK)
+               return retval;
+       jtag_add_runtest(2, TAP_IDLE);
+       jtag_add_sleep(200000);
+       retval = lattice_set_instr(tap, BYPASS, TAP_IDLE);
+       if (retval != ERROR_OK)
+               return retval;
+       jtag_add_runtest(100, TAP_IDLE);
+       jtag_add_sleep(1000);
+
+       return jtag_execute_queue();
+}
index d21ad61d201a92ac44234bc858c86d17212601ba..0fbfdef45c0edb308bba60bb4b3a1f3e25ea2740 100644 (file)
@@ -17,5 +17,6 @@ int lattice_certus_load(struct lattice_pld_device *lattice_device, struct lattic
 int lattice_certus_connect_spi_to_jtag(struct lattice_pld_device *pld_device_info);
 int lattice_certus_disconnect_spi_from_jtag(struct lattice_pld_device *pld_device_info);
 int lattice_certus_get_facing_read_bits(struct lattice_pld_device *pld_device_info, unsigned int *facing_read_bits);
+int lattice_certus_refresh(struct lattice_pld_device *lattice_device);
 
 #endif /* OPENOCD_PLD_CERTUS_H */
index a7b7580c72ca945dd386648e5e737c2e36971a34..5dfea9a2770a7fc8bae5c3bf38b8140881e6b61e 100644 (file)
@@ -304,3 +304,14 @@ int lattice_ecp2_3_get_facing_read_bits(struct lattice_pld_device *pld_device_in
 
        return ERROR_OK;
 }
+
+int lattice_ecp2_3_refresh(struct lattice_pld_device *lattice_device)
+{
+       if (!lattice_device || !lattice_device->tap)
+               return ERROR_FAIL;
+
+       int retval = lattice_set_instr(lattice_device->tap, LSCC_REFRESH, TAP_IDLE);
+       if (retval != ERROR_OK)
+               return retval;
+       return jtag_execute_queue();
+}
index c5dec5693a1ed1960e27bdd0fb6b2d02b01183a3..d3f7464e121f39eab567fa6eb1204f2c9f6bfcd5 100644 (file)
@@ -18,5 +18,6 @@ int lattice_ecp3_load(struct lattice_pld_device *lattice_device, struct lattice_
 int lattice_ecp2_3_connect_spi_to_jtag(struct lattice_pld_device *pld_device_info);
 int lattice_ecp2_3_disconnect_spi_from_jtag(struct lattice_pld_device *pld_device_info);
 int lattice_ecp2_3_get_facing_read_bits(struct lattice_pld_device *pld_device_info, unsigned int *facing_read_bits);
+int lattice_ecp2_3_refresh(struct lattice_pld_device *lattice_device);
 
 #endif /* OPENOCD_PLD_ECP2_3_H */
index 024fe2b4a728ba95c66647ea42af46f8768dafb8..f8ba33eaff045f524237eb10dd3256cbdf451afd 100644 (file)
@@ -276,3 +276,27 @@ int lattice_ecp5_get_facing_read_bits(struct lattice_pld_device *pld_device_info
 
        return ERROR_OK;
 }
+
+int lattice_ecp5_refresh(struct lattice_pld_device *lattice_device)
+{
+       struct jtag_tap *tap = lattice_device->tap;
+       if (!tap)
+               return ERROR_FAIL;
+
+       int retval = lattice_preload(lattice_device);
+       if (retval != ERROR_OK)
+               return retval;
+
+       retval = lattice_set_instr(tap, LSC_REFRESH, TAP_IDLE);
+       if (retval != ERROR_OK)
+               return retval;
+       jtag_add_runtest(2, TAP_IDLE);
+       jtag_add_sleep(200000);
+       retval = lattice_set_instr(tap, BYPASS, TAP_IDLE);
+       if (retval != ERROR_OK)
+               return retval;
+       jtag_add_runtest(100, TAP_IDLE);
+       jtag_add_sleep(1000);
+
+       return jtag_execute_queue();
+}
index daf481fa6a31a5db1d8d449ca88d1209dc14bb1e..975678ece3511e80014a5c2d6615a7525b48c7a8 100644 (file)
@@ -17,5 +17,6 @@ int lattice_ecp5_load(struct lattice_pld_device *lattice_device, struct lattice_
 int lattice_ecp5_connect_spi_to_jtag(struct lattice_pld_device *pld_device_info);
 int lattice_ecp5_disconnect_spi_from_jtag(struct lattice_pld_device *pld_device_info);
 int lattice_ecp5_get_facing_read_bits(struct lattice_pld_device *pld_device_info, unsigned int *facing_read_bits);
+int lattice_ecp5_refresh(struct lattice_pld_device *lattice_device);
 
 #endif /* OPENOCD_PLD_ECP5_H */
index c42b2f22c9f5ebbcefe908b18fc3a33aadedf9e2..bbc2fe15f6f59d86ddcd0da4d308d78a0da02a99 100644 (file)
@@ -543,10 +543,10 @@ static const struct command_registration gowin_exec_command_handlers[] = {
                .help = "reading user register from FPGA",
                .usage = "pld_name",
        }, {
-               .name = "reload",
+               .name = "refresh",
                .mode = COMMAND_EXEC,
                .handler = gowin_reload_command_handler,
-               .help = "reloading bitstream from flash to SRAM",
+               .help = "reload bitstream from flash to SRAM",
                .usage = "pld_name",
        },
        COMMAND_REGISTRATION_DONE
index 4858603a86b73cb658c9f93bafcd10a70e24c700..cd72d3cb596978d758bb7e91827202ad6df296cd 100644 (file)
@@ -575,6 +575,35 @@ COMMAND_HANDLER(lattice_read_status_command_handler)
        return retval;
 }
 
+COMMAND_HANDLER(lattice_refresh_command_handler)
+{
+       if (CMD_ARGC != 1)
+               return ERROR_COMMAND_SYNTAX_ERROR;
+
+       struct pld_device *device = get_pld_device_by_name_or_numstr(CMD_ARGV[0]);
+       if (!device) {
+               command_print(CMD, "pld device '#%s' is out of bounds or unknown", CMD_ARGV[0]);
+               return ERROR_FAIL;
+       }
+
+       struct lattice_pld_device *lattice_device = device->driver_priv;
+       if (!lattice_device)
+               return ERROR_FAIL;
+
+       int retval = lattice_check_device_family(lattice_device);
+       if (retval != ERROR_OK)
+               return retval;
+
+       if (lattice_device->family == LATTICE_ECP2 || lattice_device->family == LATTICE_ECP3)
+               return lattice_ecp2_3_refresh(lattice_device);
+       else if (lattice_device->family == LATTICE_ECP5)
+               return lattice_ecp5_refresh(lattice_device);
+       else if (lattice_device->family == LATTICE_CERTUS)
+               return lattice_certus_refresh(lattice_device);
+
+       return ERROR_FAIL;
+}
+
 static const struct command_registration lattice_exec_command_handlers[] = {
        {
                .name = "read_status",
@@ -600,6 +629,12 @@ static const struct command_registration lattice_exec_command_handlers[] = {
                .handler = lattice_set_preload_command_handler,
                .help = "set length for preload (device specific)",
                .usage = "pld_name value",
+       }, {
+               .name = "refresh",
+               .mode = COMMAND_EXEC,
+               .handler = lattice_refresh_command_handler,
+               .help = "refresh from configuration memory",
+               .usage = "pld_name",
        },
        COMMAND_REGISTRATION_DONE
 };
index 389b7afe4240de1331c2be84f9a4cc5ff51d25da..0c1062583262560a99f9d7a5c4affbbd2e0ad9c5 100644 (file)
@@ -13,6 +13,7 @@
 #define PROGRAM_SPI          0x3A
 #define LSC_READ_STATUS      0x3C
 #define LSC_INIT_ADDRESS     0x46
+#define LSC_REFRESH          0x79
 #define LSC_BITSTREAM_BURST  0x7A
 #define READ_USERCODE        0xC0
 #define ISC_ENABLE           0xC6
index fce764c1af8c1dc02e119c0b278e5a24583c52a0..3dff90621a3f093e9af2553b0d0374107224e35f 100644 (file)
@@ -265,7 +265,7 @@ static int virtex2_load(struct pld_device *pld_device, const char *filename)
        return retval;
 }
 
-COMMAND_HANDLER(virtex2_handle_program_command)
+COMMAND_HANDLER(virtex2_handle_refresh_command)
 {
        struct pld_device *device;
 
@@ -449,10 +449,10 @@ static const struct command_registration virtex2_exec_command_handlers[] = {
                .help = "set instructions codes used for jtag-hub",
                .usage = "pld_name user1 [user2 [user3 [user4]]]",
        }, {
-               .name = "program",
+               .name = "refresh",
                .mode = COMMAND_EXEC,
-               .handler = virtex2_handle_program_command,
-               .help = "start loading of configuration (refresh)",
+               .handler = virtex2_handle_refresh_command,
+               .help = "start loading of configuration (program)",
                .usage = "pld_name",
        },
        COMMAND_REGISTRATION_DONE

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)