*/
COMMAND_HELPER(flash_command_get_bank, unsigned name_index,
struct flash_bank **bank);
+/**
+ * Retrieves @a bank from a command argument, reporting errors parsing
+ * the bank identifier or retrieving the specified bank. The bank
+ * may be identified by its bank number or by @c name.instance, where
+ * @a instance is driver-specific.
+ * @param name_index The index to the string in args containing the
+ * bank identifier.
+ * @param bank On output, contains a pointer to the bank or NULL.
+ * @param do_probe Does auto-probing when set, otherwise without probing.
+ * @returns ERROR_OK on success, or an error indicating the problem.
+ */
+COMMAND_HELPER(flash_command_get_bank_probe_optional, unsigned int name_index,
+ struct flash_bank **bank, bool do_probe);
/**
* Returns the flash bank like get_flash_bank_by_num(), without probing.
* @param num The flash bank number.
bank->sectors = NULL;
bank->driver_priv = info;
- info->tap = NULL;
+ if (!bank->target->tap) {
+ LOG_ERROR("Target has no JTAG tap");
+ return ERROR_FAIL;
+ }
+ info->tap = bank->target->tap;
info->probed = false;
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[6], info->ir);
return ERROR_COMMAND_SYNTAX_ERROR;
}
- retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
+ /* calling flash_command_get_bank without probing because handle_set is used
+ to set device parameters if not autodetected. So probing would fail
+ anyhow.
+ */
+ retval = CALL_COMMAND_HANDLER(flash_command_get_bank_probe_optional, 0,
+ &bank, false);
if (ERROR_OK != retval)
return retval;
info = bank->driver_priv;
return ERROR_COMMAND_SYNTAX_ERROR;
}
- retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
+ /* calling flash_command_get_bank without probing because we like to be
+ able to send commands before auto-probing occurred. For example sending
+ "release from power down" is needed before probing when flash is in
+ power down mode.
+ */
+ retval = CALL_COMMAND_HANDLER(flash_command_get_bank_probe_optional, 0,
+ &bank, false);
if (ERROR_OK != retval)
return retval;
}
info->probed = false;
- if (!bank->target->tap) {
- LOG_ERROR("Target has no JTAG tap");
- return ERROR_FAIL;
- }
- info->tap = bank->target->tap;
-
jtagspi_cmd(bank, SPIFLASH_READ_ID, NULL, 0, in_buf, -3);
/* the table in spi.c has the manufacturer byte (first) as the lsb */
id = le_to_h_u24(in_buf);
* Implements Tcl commands used to access NOR flash facilities.
*/
-static COMMAND_HELPER(flash_command_get_bank_maybe_probe, unsigned name_index,
+COMMAND_HELPER(flash_command_get_bank_probe_optional, unsigned int name_index,
struct flash_bank **bank, bool do_probe)
{
const char *name = CMD_ARGV[name_index];
COMMAND_HELPER(flash_command_get_bank, unsigned name_index,
struct flash_bank **bank)
{
- return CALL_COMMAND_HANDLER(flash_command_get_bank_maybe_probe,
+ return CALL_COMMAND_HANDLER(flash_command_get_bank_probe_optional,
name_index, bank, true);
}
if (CMD_ARGC != 1)
return ERROR_COMMAND_SYNTAX_ERROR;
- retval = CALL_COMMAND_HANDLER(flash_command_get_bank_maybe_probe, 0, &p, false);
+ retval = CALL_COMMAND_HANDLER(flash_command_get_bank_probe_optional, 0, &p, false);
if (retval != ERROR_OK)
return retval;
target create $_TARGETNAME testee -chain-position $_CHIPNAME.tap
flash bank $_FLASHNAME jtagspi 0 0 0 0 $_TARGETNAME $_JTAGSPI_IR
-proc jtagspi_init {chain_id proxy_bit} {
+# initialize jtagspi flash
+# chain_id: identifier of pld (you can get a list with 'pld devices')
+# proxy_bit: file with bitstream connecting JTAG and SPI interface in the PLD.
+# release_from_pwr_down_cmd: optional, command sent to spi flash before probing.
+# ex: 0xAB to release from power-dowm.
+# Just omit it to not send a command.
+
+proc jtagspi_init {chain_id proxy_bit {release_from_pwr_down_cmd -1}} {
# load proxy bitstream $proxy_bit and probe spi flash
global _FLASHNAME
pld load $chain_id $proxy_bit
reset halt
+ if {$release_from_pwr_down_cmd != -1} {
+ jtagspi cmd $_FLASHNAME 0 $release_from_pwr_down_cmd
+ }
flash probe $_FLASHNAME
}