forked from auracaster/openocd
Merge branch 'master' into from_upstream
Change-Id: I036350ee06aa396344fb8a80c7dba148ec24c9c8
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
noinst_LTLIBRARIES += %D%/libflash.la
|
||||
%C%_libflash_la_SOURCES = \
|
||||
%D%/common.c %D%/common.h \
|
||||
%D%/mflash.c %D%/mflash.h
|
||||
%D%/common.c %D%/common.h
|
||||
|
||||
%C%_libflash_la_LIBADD = \
|
||||
%D%/nor/libocdflashnor.la \
|
||||
|
||||
-1449
File diff suppressed because it is too large
Load Diff
@@ -1,289 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2007-2008 by unsik Kim <donari75@gmail.com> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef OPENOCD_FLASH_MFLASH_H
|
||||
#define OPENOCD_FLASH_MFLASH_H
|
||||
|
||||
struct command_context;
|
||||
|
||||
typedef unsigned long mg_io_uint32;
|
||||
typedef unsigned short mg_io_uint16;
|
||||
typedef unsigned char mg_io_uint8;
|
||||
|
||||
struct mflash_gpio_num {
|
||||
char port[2];
|
||||
signed short num;
|
||||
};
|
||||
|
||||
struct mflash_gpio_drv {
|
||||
const char *name;
|
||||
int (*set_gpio_to_output)(struct mflash_gpio_num gpio);
|
||||
int (*set_gpio_output_val)(struct mflash_gpio_num gpio, uint8_t val);
|
||||
};
|
||||
|
||||
typedef struct _mg_io_type_drv_info {
|
||||
|
||||
mg_io_uint16 general_configuration; /* 00 */
|
||||
mg_io_uint16 number_of_cylinders; /* 01 */
|
||||
mg_io_uint16 reserved1; /* 02 */
|
||||
mg_io_uint16 number_of_heads; /* 03 */
|
||||
mg_io_uint16 unformatted_bytes_per_track; /* 04 */
|
||||
mg_io_uint16 unformatted_bytes_per_sector; /* 05 */
|
||||
mg_io_uint16 sectors_per_track; /* 06 */
|
||||
mg_io_uint16 vendor_unique1[3]; /* 07/08/09 */
|
||||
|
||||
mg_io_uint8 serial_number[20]; /* 10~19 */
|
||||
|
||||
mg_io_uint16 buffer_type; /* 20 */
|
||||
mg_io_uint16 buffer_sector_size; /* 21 */
|
||||
mg_io_uint16 number_of_ecc_bytes; /* 22 */
|
||||
|
||||
mg_io_uint8 firmware_revision[8]; /* 23~26 */
|
||||
mg_io_uint8 model_number[40]; /* 27 */
|
||||
|
||||
mg_io_uint8 maximum_block_transfer; /* 47 low byte */
|
||||
mg_io_uint8 vendor_unique2; /* 47 high byte */
|
||||
mg_io_uint16 dword_io; /* 48 */
|
||||
|
||||
mg_io_uint16 capabilities; /* 49 */
|
||||
mg_io_uint16 reserved2; /* 50 */
|
||||
|
||||
mg_io_uint8 vendor_unique3; /* 51 low byte */
|
||||
mg_io_uint8 pio_cycle_timing_mode; /* 51 high byte */
|
||||
mg_io_uint8 vendor_unique4; /* 52 low byte */
|
||||
mg_io_uint8 dma_cycle_timing_mode; /* 52 high byte */
|
||||
mg_io_uint16 translation_fields_valid; /* 53 (low bit) */
|
||||
mg_io_uint16 number_of_current_cylinders; /* 54 */
|
||||
mg_io_uint16 number_of_current_heads; /* 55 */
|
||||
mg_io_uint16 current_sectors_per_track; /* 56 */
|
||||
mg_io_uint16 current_sector_capacity_lo; /* 57 & 58 */
|
||||
mg_io_uint16 current_sector_capacity_hi; /* 57 & 58 */
|
||||
mg_io_uint8 multi_sector_count; /* 59 low */
|
||||
mg_io_uint8 multi_sector_setting_valid; /* 59 high (low bit) */
|
||||
|
||||
mg_io_uint16 total_user_addressable_sectors_lo; /* 60 & 61 */
|
||||
mg_io_uint16 total_user_addressable_sectors_hi; /* 60 & 61 */
|
||||
|
||||
mg_io_uint8 single_dma_modes_supported; /* 62 low byte */
|
||||
mg_io_uint8 single_dma_transfer_active; /* 62 high byte */
|
||||
mg_io_uint8 multi_dma_modes_supported; /* 63 low byte */
|
||||
mg_io_uint8 multi_dma_transfer_active; /* 63 high byte */
|
||||
mg_io_uint16 adv_pio_mode;
|
||||
mg_io_uint16 min_dma_cyc;
|
||||
mg_io_uint16 recommend_dma_cyc;
|
||||
mg_io_uint16 min_pio_cyc_no_iordy;
|
||||
mg_io_uint16 min_pio_cyc_with_iordy;
|
||||
mg_io_uint8 reserved3[22];
|
||||
mg_io_uint16 major_ver_num;
|
||||
mg_io_uint16 minor_ver_num;
|
||||
mg_io_uint16 feature_cmd_set_suprt0;
|
||||
mg_io_uint16 feature_cmd_set_suprt1;
|
||||
mg_io_uint16 feature_cmd_set_suprt2;
|
||||
mg_io_uint16 feature_cmd_set_en0;
|
||||
mg_io_uint16 feature_cmd_set_en1;
|
||||
mg_io_uint16 feature_cmd_set_en2;
|
||||
mg_io_uint16 reserved4;
|
||||
mg_io_uint16 req_time_for_security_er_done;
|
||||
mg_io_uint16 req_time_for_enhan_security_er_done;
|
||||
mg_io_uint16 adv_pwr_mgm_lvl_val;
|
||||
mg_io_uint16 reserved5;
|
||||
mg_io_uint16 re_of_hw_rst;
|
||||
mg_io_uint8 reserved6[68];
|
||||
mg_io_uint16 security_stas;
|
||||
mg_io_uint8 vendor_uniq_bytes[62];
|
||||
mg_io_uint16 cfa_pwr_mode;
|
||||
mg_io_uint8 reserved7[186];
|
||||
|
||||
mg_io_uint16 scts_per_secure_data_unit;
|
||||
mg_io_uint16 integrity_word;
|
||||
|
||||
} mg_io_type_drv_info;
|
||||
|
||||
typedef struct _mg_pll_t {
|
||||
unsigned int lock_cyc;
|
||||
unsigned short feedback_div; /* 9bit divider */
|
||||
unsigned char input_div; /* 5bit divider */
|
||||
unsigned char output_div; /* 2bit divider */
|
||||
} mg_pll_t;
|
||||
|
||||
struct mg_drv_info {
|
||||
mg_io_type_drv_info drv_id;
|
||||
uint32_t tot_sects;
|
||||
};
|
||||
|
||||
struct mflash_bank {
|
||||
uint32_t base;
|
||||
|
||||
struct mflash_gpio_num rst_pin;
|
||||
|
||||
struct mflash_gpio_drv *gpio_drv;
|
||||
struct target *target;
|
||||
struct mg_drv_info *drv_info;
|
||||
};
|
||||
|
||||
int mflash_register_commands(struct command_context *cmd_ctx);
|
||||
|
||||
#define MG_MFLASH_SECTOR_SIZE (0x200) /* 512Bytes = 2^9 */
|
||||
#define MG_MFLASH_SECTOR_SIZE_MASK (0x200-1)
|
||||
#define MG_MFLASH_SECTOR_SIZE_SHIFT (9)
|
||||
|
||||
#define MG_BUFFER_OFFSET 0x8000
|
||||
#define MG_REG_OFFSET 0xC000
|
||||
#define MG_REG_FEATURE 0x2 /* write case */
|
||||
#define MG_REG_ERROR 0x2 /* read case */
|
||||
#define MG_REG_SECT_CNT 0x4
|
||||
#define MG_REG_SECT_NUM 0x6
|
||||
#define MG_REG_CYL_LOW 0x8
|
||||
#define MG_REG_CYL_HIGH 0xA
|
||||
#define MG_REG_DRV_HEAD 0xC
|
||||
#define MG_REG_COMMAND 0xE /* write case */
|
||||
#define MG_REG_STATUS 0xE /* read case */
|
||||
#define MG_REG_DRV_CTRL 0x10
|
||||
#define MG_REG_BURST_CTRL 0x12
|
||||
|
||||
#define MG_OEM_DISK_WAIT_TIME_LONG 15000 /* msec */
|
||||
#define MG_OEM_DISK_WAIT_TIME_NORMAL 3000 /* msec */
|
||||
#define MG_OEM_DISK_WAIT_TIME_SHORT 1000 /* msec */
|
||||
|
||||
#define MG_PLL_CLK_OUT 66000000.0 /* 66Mhz */
|
||||
#define MG_PLL_MAX_FEEDBACKDIV_VAL 512
|
||||
#define MG_PLL_MAX_INPUTDIV_VAL 32
|
||||
#define MG_PLL_MAX_OUTPUTDIV_VAL 4
|
||||
|
||||
#define MG_PLL_STD_INPUTCLK 12000000.0 /* 12Mhz */
|
||||
#define MG_PLL_STD_LOCKCYCLE 10000
|
||||
|
||||
#define MG_UNLOCK_OTP_AREA 0xFF
|
||||
|
||||
#define MG_FILEIO_CHUNK 1048576
|
||||
|
||||
#define ERROR_MG_IO (-1600)
|
||||
#define ERROR_MG_TIMEOUT (-1601)
|
||||
#define ERROR_MG_INVALID_PLL (-1603)
|
||||
#define ERROR_MG_INTERFACE (-1604)
|
||||
#define ERROR_MG_INVALID_OSC (-1605)
|
||||
#define ERROR_MG_UNSUPPORTED_SOC (-1606)
|
||||
|
||||
typedef enum _mg_io_type_wait {
|
||||
|
||||
mg_io_wait_bsy = 1,
|
||||
mg_io_wait_not_bsy = 2,
|
||||
mg_io_wait_rdy = 3,
|
||||
mg_io_wait_drq = 4, /* wait for data request */
|
||||
mg_io_wait_drq_noerr = 5, /* wait for DRQ but ignore the error status bit */
|
||||
mg_io_wait_rdy_noerr = 6 /* wait for ready, but ignore error status bit */
|
||||
|
||||
} mg_io_type_wait;
|
||||
|
||||
/*= "Status Register" bit masks. */
|
||||
typedef enum _mg_io_type_rbit_status {
|
||||
|
||||
mg_io_rbit_status_error = 0x01, /* error bit in status register */
|
||||
mg_io_rbit_status_corrected_error = 0x04, /* corrected error in status register */
|
||||
mg_io_rbit_status_data_req = 0x08, /* data request bit in status register */
|
||||
mg_io_rbit_status_seek_done = 0x10, /* DSC - Drive Seek Complete */
|
||||
mg_io_rbit_status_write_fault = 0x20, /* DWF - Drive Write Fault */
|
||||
mg_io_rbit_status_ready = 0x40,
|
||||
mg_io_rbit_status_busy = 0x80
|
||||
|
||||
} mg_io_type_rbit_status;
|
||||
|
||||
/*= "Error Register" bit masks. */
|
||||
typedef enum _mg_io_type_rbit_error {
|
||||
|
||||
mg_io_rbit_err_general = 0x01,
|
||||
mg_io_rbit_err_aborted = 0x04,
|
||||
mg_io_rbit_err_bad_sect_num = 0x10,
|
||||
mg_io_rbit_err_uncorrectable = 0x40,
|
||||
mg_io_rbit_err_bad_block = 0x80
|
||||
|
||||
} mg_io_type_rbit_error;
|
||||
|
||||
/* = "Device Control Register" bit. */
|
||||
typedef enum _mg_io_type_rbit_devc {
|
||||
|
||||
mg_io_rbit_devc_intr = 0x02, /* interrupt enable bit (1:disable, 0:enable) */
|
||||
mg_io_rbit_devc_srst = 0x04 /* softwrae reset bit (1:assert, 0:de-assert) */
|
||||
|
||||
} mg_io_type_rbit_devc;
|
||||
|
||||
/* "Drive Select/Head Register" values. */
|
||||
typedef enum _mg_io_type_rval_dev {
|
||||
|
||||
mg_io_rval_dev_must_be_on = 0x80, /* These 1 bits are always on */
|
||||
mg_io_rval_dev_drv_master = (0x00 | mg_io_rval_dev_must_be_on), /* Master */
|
||||
mg_io_rval_dev_drv_slave0 = (0x10 | mg_io_rval_dev_must_be_on), /* Slave0 */
|
||||
mg_io_rval_dev_drv_slave1 = (0x20 | mg_io_rval_dev_must_be_on), /* Slave1 */
|
||||
mg_io_rval_dev_drv_slave2 = (0x30 | mg_io_rval_dev_must_be_on), /* Slave2 */
|
||||
mg_io_rval_dev_lba_mode = (0x40 | mg_io_rval_dev_must_be_on)
|
||||
|
||||
} mg_io_type_rval_dev;
|
||||
|
||||
typedef enum _mg_io_type_cmd {
|
||||
mg_io_cmd_read = 0x20,
|
||||
mg_io_cmd_write = 0x30,
|
||||
|
||||
mg_io_cmd_setmul = 0xC6,
|
||||
mg_io_cmd_readmul = 0xC4,
|
||||
mg_io_cmd_writemul = 0xC5,
|
||||
|
||||
mg_io_cmd_idle = 0x97, /* 0xE3 */
|
||||
mg_io_cmd_idle_immediate = 0x95, /* 0xE1 */
|
||||
|
||||
mg_io_cmd_setsleep = 0x99, /* 0xE6 */
|
||||
mg_io_cmd_stdby = 0x96, /* 0xE2 */
|
||||
mg_io_cmd_stdby_immediate = 0x94, /* 0xE0 */
|
||||
|
||||
mg_io_cmd_identify = 0xEC,
|
||||
mg_io_cmd_set_feature = 0xEF,
|
||||
|
||||
mg_io_cmd_confirm_write = 0x3C,
|
||||
mg_io_cmd_confirm_read = 0x40,
|
||||
mg_io_cmd_wakeup = 0xC3
|
||||
|
||||
} mg_io_type_cmd;
|
||||
|
||||
typedef enum _mg_feature_id {
|
||||
mg_feature_id_transmode = 0x3
|
||||
} mg_feature_id;
|
||||
|
||||
typedef enum _mg_feature_val {
|
||||
mg_feature_val_trans_default = 0x0,
|
||||
mg_feature_val_trans_vcmd = 0x3,
|
||||
mg_feature_val_trand_vcmds = 0x2
|
||||
} mg_feature_val;
|
||||
|
||||
typedef enum _mg_vcmd {
|
||||
mg_vcmd_update_xipinfo = 0xFA, /* FWPATCH commmand through IOM I/O */
|
||||
mg_vcmd_verify_fwpatch = 0xFB, /* FWPATCH commmand through IOM I/O */
|
||||
mg_vcmd_update_stgdrvinfo = 0xFC, /* IOM identificatin info program command */
|
||||
mg_vcmd_prep_fwpatch = 0xFD, /* FWPATCH commmand through IOM I/O */
|
||||
mg_vcmd_exe_fwpatch = 0xFE, /* FWPATCH commmand through IOM I/O */
|
||||
mg_vcmd_wr_pll = 0x8B,
|
||||
mg_vcmd_purge_nand = 0x8C, /* Only for Seagle */
|
||||
mg_vcmd_lock_otp = 0x8D,
|
||||
mg_vcmd_rd_otp = 0x8E,
|
||||
mg_vcmd_wr_otp = 0x8F
|
||||
} mg_vcmd;
|
||||
|
||||
typedef enum _mg_opmode {
|
||||
mg_op_mode_xip = 1, /* TRUE XIP */
|
||||
mg_op_mode_snd = 2, /* BOOT + Storage */
|
||||
mg_op_mode_stg = 0 /* Only Storage */
|
||||
} mg_opmode;
|
||||
|
||||
#endif /* OPENOCD_FLASH_MFLASH_H */
|
||||
@@ -547,14 +547,14 @@ COMMAND_HANDLER(handle_at91sam9_cle_command)
|
||||
unsigned num, address_line;
|
||||
|
||||
if (CMD_ARGC != 2) {
|
||||
command_print(CMD_CTX, "incorrect number of arguments for 'at91sam9 cle' command");
|
||||
command_print(CMD, "incorrect number of arguments for 'at91sam9 cle' command");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], num);
|
||||
nand = get_nand_device_by_num(num);
|
||||
if (!nand) {
|
||||
command_print(CMD_CTX, "invalid nand device number: %s", CMD_ARGV[0]);
|
||||
command_print(CMD, "invalid nand device number: %s", CMD_ARGV[0]);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -582,7 +582,7 @@ COMMAND_HANDLER(handle_at91sam9_ale_command)
|
||||
COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], num);
|
||||
nand = get_nand_device_by_num(num);
|
||||
if (!nand) {
|
||||
command_print(CMD_CTX, "invalid nand device number: %s", CMD_ARGV[0]);
|
||||
command_print(CMD, "invalid nand device number: %s", CMD_ARGV[0]);
|
||||
return ERROR_COMMAND_ARGUMENT_INVALID;
|
||||
}
|
||||
|
||||
@@ -610,7 +610,7 @@ COMMAND_HANDLER(handle_at91sam9_rdy_busy_command)
|
||||
COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], num);
|
||||
nand = get_nand_device_by_num(num);
|
||||
if (!nand) {
|
||||
command_print(CMD_CTX, "invalid nand device number: %s", CMD_ARGV[0]);
|
||||
command_print(CMD, "invalid nand device number: %s", CMD_ARGV[0]);
|
||||
return ERROR_COMMAND_ARGUMENT_INVALID;
|
||||
}
|
||||
|
||||
@@ -641,7 +641,7 @@ COMMAND_HANDLER(handle_at91sam9_ce_command)
|
||||
COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], num);
|
||||
nand = get_nand_device_by_num(num);
|
||||
if (!nand) {
|
||||
command_print(CMD_CTX, "invalid nand device number: %s", CMD_ARGV[0]);
|
||||
command_print(CMD, "invalid nand device number: %s", CMD_ARGV[0]);
|
||||
return ERROR_COMMAND_ARGUMENT_INVALID;
|
||||
}
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ COMMAND_HELPER(nand_command_get_device, unsigned name_index,
|
||||
COMMAND_PARSE_NUMBER(uint, str, num);
|
||||
*nand = get_nand_device_by_num(num);
|
||||
if (!*nand) {
|
||||
command_print(CMD_CTX, "NAND flash device '%s' not found", str);
|
||||
command_print(CMD, "NAND flash device '%s' not found", str);
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
return ERROR_OK;
|
||||
|
||||
@@ -54,12 +54,12 @@ void nand_fileio_init(struct nand_fileio_state *state)
|
||||
state->oob_format = NAND_OOB_NONE;
|
||||
}
|
||||
|
||||
int nand_fileio_start(struct command_context *cmd_ctx,
|
||||
int nand_fileio_start(struct command_invocation *cmd,
|
||||
struct nand_device *nand, const char *filename, int filemode,
|
||||
struct nand_fileio_state *state)
|
||||
{
|
||||
if (state->address % nand->page_size) {
|
||||
command_print(cmd_ctx, "only page-aligned addresses are supported");
|
||||
command_print(cmd, "only page-aligned addresses are supported");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ int nand_fileio_start(struct command_context *cmd_ctx,
|
||||
int retval = fileio_open(&state->fileio, filename, filemode, FILEIO_BINARY);
|
||||
if (ERROR_OK != retval) {
|
||||
const char *msg = (FILEIO_READ == filemode) ? "read" : "write";
|
||||
command_print(cmd_ctx, "failed to open '%s' for %s access",
|
||||
command_print(cmd, "failed to open '%s' for %s access",
|
||||
filename, msg);
|
||||
return retval;
|
||||
}
|
||||
@@ -131,7 +131,7 @@ COMMAND_HELPER(nand_fileio_parse_args, struct nand_fileio_state *state,
|
||||
return retval;
|
||||
|
||||
if (NULL == nand->device) {
|
||||
command_print(CMD_CTX, "#%s: not probed", CMD_ARGV[0]);
|
||||
command_print(CMD, "#%s: not probed", CMD_ARGV[0]);
|
||||
return ERROR_NAND_DEVICE_NOT_PROBED;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ COMMAND_HELPER(nand_fileio_parse_args, struct nand_fileio_state *state,
|
||||
if (need_size) {
|
||||
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[3], state->size);
|
||||
if (state->size % nand->page_size) {
|
||||
command_print(CMD_CTX, "only page-aligned sizes are supported");
|
||||
command_print(CMD, "only page-aligned sizes are supported");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
}
|
||||
@@ -155,13 +155,13 @@ COMMAND_HELPER(nand_fileio_parse_args, struct nand_fileio_state *state,
|
||||
else if (sw_ecc && !strcmp(CMD_ARGV[i], "oob_softecc_kw"))
|
||||
state->oob_format |= NAND_OOB_SW_ECC_KW;
|
||||
else {
|
||||
command_print(CMD_CTX, "unknown option: %s", CMD_ARGV[i]);
|
||||
command_print(CMD, "unknown option: %s", CMD_ARGV[i]);
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
retval = nand_fileio_start(CMD_CTX, nand, CMD_ARGV[1], filemode, state);
|
||||
retval = nand_fileio_start(CMD, nand, CMD_ARGV[1], filemode, state);
|
||||
if (ERROR_OK != retval)
|
||||
return retval;
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ struct nand_fileio_state {
|
||||
};
|
||||
|
||||
void nand_fileio_init(struct nand_fileio_state *state);
|
||||
int nand_fileio_start(struct command_context *cmd_ctx,
|
||||
int nand_fileio_start(struct command_invocation *cmd,
|
||||
struct nand_device *nand, const char *filename, int filemode,
|
||||
struct nand_fileio_state *state);
|
||||
int nand_fileio_cleanup(struct nand_fileio_state *state);
|
||||
|
||||
@@ -237,7 +237,7 @@ static int lpc3180_init(struct nand_device *nand)
|
||||
|
||||
/* SLC_CFG = 0x (Force nCE assert, DMA ECC enabled, ECC enabled, DMA burst enabled,
|
||||
*DMA read from SLC, WIDTH = bus_width) */
|
||||
target_write_u32(target, 0x20020014, 0x3e | (bus_width == 16) ? 1 : 0);
|
||||
target_write_u32(target, 0x20020014, 0x3e | ((bus_width == 16) ? 1 : 0));
|
||||
|
||||
/* SLC_IEN = 3 (INT_RDY_EN = 1) ,(INT_TC_STAT = 1) */
|
||||
target_write_u32(target, 0x20020020, 0x03);
|
||||
@@ -1290,7 +1290,7 @@ COMMAND_HANDLER(handle_lpc3180_select_command)
|
||||
COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], num);
|
||||
struct nand_device *nand = get_nand_device_by_num(num);
|
||||
if (!nand) {
|
||||
command_print(CMD_CTX, "nand device '#%s' is out of bounds", CMD_ARGV[0]);
|
||||
command_print(CMD, "nand device '#%s' is out of bounds", CMD_ARGV[0]);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -1310,10 +1310,10 @@ COMMAND_HANDLER(handle_lpc3180_select_command)
|
||||
}
|
||||
|
||||
if (lpc3180_info->selected_controller == LPC3180_MLC_CONTROLLER)
|
||||
command_print(CMD_CTX, "%s controller selected",
|
||||
command_print(CMD, "%s controller selected",
|
||||
selected[lpc3180_info->selected_controller]);
|
||||
else
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
lpc3180_info->is_bulk ? "%s controller selected bulk mode is available" :
|
||||
"%s controller selected bulk mode is not available",
|
||||
selected[lpc3180_info->selected_controller]);
|
||||
|
||||
@@ -332,7 +332,7 @@ static int lpc32xx_init(struct nand_device *nand)
|
||||
WIDTH = bus_width)
|
||||
*/
|
||||
retval = target_write_u32(target, 0x20020014,
|
||||
0x3e | (bus_width == 16) ? 1 : 0);
|
||||
0x3e | ((bus_width == 16) ? 1 : 0));
|
||||
if (ERROR_OK != retval) {
|
||||
LOG_ERROR("could not set SLC_CFG");
|
||||
return ERROR_NAND_OPERATION_FAILED;
|
||||
@@ -1760,7 +1760,7 @@ COMMAND_HANDLER(handle_lpc32xx_select_command)
|
||||
COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], num);
|
||||
struct nand_device *nand = get_nand_device_by_num(num);
|
||||
if (!nand) {
|
||||
command_print(CMD_CTX, "nand device '#%s' is out of bounds",
|
||||
command_print(CMD, "nand device '#%s' is out of bounds",
|
||||
CMD_ARGV[0]);
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -1778,7 +1778,7 @@ COMMAND_HANDLER(handle_lpc32xx_select_command)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
command_print(CMD_CTX, "%s controller selected",
|
||||
command_print(CMD, "%s controller selected",
|
||||
selected[lpc32xx_info->selected_controller]);
|
||||
|
||||
return ERROR_OK;
|
||||
|
||||
@@ -157,7 +157,7 @@ COMMAND_HANDLER(handle_mxc_biswap_command)
|
||||
|
||||
int retval = CALL_COMMAND_HANDLER(nand_command_get_device, 0, &nand);
|
||||
if (retval != ERROR_OK) {
|
||||
command_print(CMD_CTX, "invalid nand device number or name: %s", CMD_ARGV[0]);
|
||||
command_print(CMD, "invalid nand device number or name: %s", CMD_ARGV[0]);
|
||||
return ERROR_COMMAND_ARGUMENT_INVALID;
|
||||
}
|
||||
|
||||
@@ -169,9 +169,9 @@ COMMAND_HANDLER(handle_mxc_biswap_command)
|
||||
mxc_nf_info->flags.biswap_enabled = false;
|
||||
}
|
||||
if (mxc_nf_info->flags.biswap_enabled)
|
||||
command_print(CMD_CTX, "BI-swapping enabled on %s", nand->name);
|
||||
command_print(CMD, "BI-swapping enabled on %s", nand->name);
|
||||
else
|
||||
command_print(CMD_CTX, "BI-swapping disabled on %s", nand->name);
|
||||
command_print(CMD, "BI-swapping disabled on %s", nand->name);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -193,7 +193,8 @@ static const struct command_registration mxc_nand_command_handler[] = {
|
||||
.name = "mxc",
|
||||
.mode = COMMAND_ANY,
|
||||
.help = "MXC NAND flash controller commands",
|
||||
.chain = mxc_sub_command_handlers
|
||||
.chain = mxc_sub_command_handlers,
|
||||
.usage = "",
|
||||
},
|
||||
COMMAND_REGISTRATION_DONE
|
||||
};
|
||||
|
||||
+26
-25
@@ -37,20 +37,20 @@ COMMAND_HANDLER(handle_nand_list_command)
|
||||
int i;
|
||||
|
||||
if (!nand_devices) {
|
||||
command_print(CMD_CTX, "no NAND flash devices configured");
|
||||
command_print(CMD, "no NAND flash devices configured");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
for (p = nand_devices, i = 0; p; p = p->next, i++) {
|
||||
if (p->device)
|
||||
command_print(CMD_CTX, "#%i: %s (%s) "
|
||||
command_print(CMD, "#%i: %s (%s) "
|
||||
"pagesize: %i, buswidth: %i,\n\t"
|
||||
"blocksize: %i, blocks: %i",
|
||||
i, p->device->name, p->manufacturer->name,
|
||||
p->page_size, p->bus_width,
|
||||
p->erase_size, p->num_blocks);
|
||||
else
|
||||
command_print(CMD_CTX, "#%i: not probed", i);
|
||||
command_print(CMD, "#%i: not probed", i);
|
||||
}
|
||||
|
||||
return ERROR_OK;
|
||||
@@ -87,7 +87,7 @@ COMMAND_HANDLER(handle_nand_info_command)
|
||||
return retval;
|
||||
|
||||
if (NULL == p->device) {
|
||||
command_print(CMD_CTX, "#%s: not probed", CMD_ARGV[0]);
|
||||
command_print(CMD, "#%s: not probed", CMD_ARGV[0]);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ COMMAND_HANDLER(handle_nand_info_command)
|
||||
if (last >= p->num_blocks)
|
||||
last = p->num_blocks - 1;
|
||||
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"#%i: %s (%s) pagesize: %i, buswidth: %i, erasesize: %i",
|
||||
i++,
|
||||
p->device->name,
|
||||
@@ -123,7 +123,7 @@ COMMAND_HANDLER(handle_nand_info_command)
|
||||
else
|
||||
bad_state = " (block condition unknown)";
|
||||
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"\t#%i: 0x%8.8" PRIx32 " (%" PRId32 "kB) %s%s",
|
||||
j,
|
||||
p->blocks[j].offset,
|
||||
@@ -147,7 +147,7 @@ COMMAND_HANDLER(handle_nand_probe_command)
|
||||
|
||||
retval = nand_probe(p);
|
||||
if (retval == ERROR_OK) {
|
||||
command_print(CMD_CTX, "NAND flash device '%s (%s)' found",
|
||||
command_print(CMD, "NAND flash device '%s (%s)' found",
|
||||
p->device->name, p->manufacturer->name);
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ COMMAND_HANDLER(handle_nand_erase_command)
|
||||
|
||||
retval = nand_erase(p, offset, offset + length - 1);
|
||||
if (retval == ERROR_OK) {
|
||||
command_print(CMD_CTX, "erased blocks %lu to %lu "
|
||||
command_print(CMD, "erased blocks %lu to %lu "
|
||||
"on NAND flash device #%s '%s'",
|
||||
offset, offset + length - 1,
|
||||
CMD_ARGV[0], p->device->name);
|
||||
@@ -233,7 +233,7 @@ COMMAND_HANDLER(handle_nand_check_bad_blocks_command)
|
||||
|
||||
retval = nand_build_bbt(p, first, last);
|
||||
if (retval == ERROR_OK) {
|
||||
command_print(CMD_CTX, "checked NAND flash device for bad blocks, "
|
||||
command_print(CMD, "checked NAND flash device for bad blocks, "
|
||||
"use \"nand info\" command to list blocks");
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ COMMAND_HANDLER(handle_nand_write_command)
|
||||
while (s.size > 0) {
|
||||
int bytes_read = nand_fileio_read(nand, &s);
|
||||
if (bytes_read <= 0) {
|
||||
command_print(CMD_CTX, "error while reading file");
|
||||
command_print(CMD, "error while reading file");
|
||||
nand_fileio_cleanup(&s);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
@@ -262,7 +262,7 @@ COMMAND_HANDLER(handle_nand_write_command)
|
||||
retval = nand_write_page(nand, s.address / nand->page_size,
|
||||
s.page, s.page_size, s.oob, s.oob_size);
|
||||
if (ERROR_OK != retval) {
|
||||
command_print(CMD_CTX, "failed writing file %s "
|
||||
command_print(CMD, "failed writing file %s "
|
||||
"to NAND flash %s at offset 0x%8.8" PRIx32,
|
||||
CMD_ARGV[1], CMD_ARGV[0], s.address);
|
||||
nand_fileio_cleanup(&s);
|
||||
@@ -272,7 +272,7 @@ COMMAND_HANDLER(handle_nand_write_command)
|
||||
}
|
||||
|
||||
if (nand_fileio_finish(&s) == ERROR_OK) {
|
||||
command_print(CMD_CTX, "wrote file %s to NAND flash %s up to "
|
||||
command_print(CMD, "wrote file %s to NAND flash %s up to "
|
||||
"offset 0x%8.8" PRIx32 " in %fs (%0.3f KiB/s)",
|
||||
CMD_ARGV[1], CMD_ARGV[0], s.address, duration_elapsed(&s.bench),
|
||||
duration_kbps(&s.bench, total_bytes));
|
||||
@@ -294,7 +294,7 @@ COMMAND_HANDLER(handle_nand_verify_command)
|
||||
dev.address = file.address;
|
||||
dev.size = file.size;
|
||||
dev.oob_format = file.oob_format;
|
||||
retval = nand_fileio_start(CMD_CTX, nand, NULL, FILEIO_NONE, &dev);
|
||||
retval = nand_fileio_start(CMD, nand, NULL, FILEIO_NONE, &dev);
|
||||
if (ERROR_OK != retval)
|
||||
return retval;
|
||||
|
||||
@@ -302,7 +302,7 @@ COMMAND_HANDLER(handle_nand_verify_command)
|
||||
retval = nand_read_page(nand, dev.address / dev.page_size,
|
||||
dev.page, dev.page_size, dev.oob, dev.oob_size);
|
||||
if (ERROR_OK != retval) {
|
||||
command_print(CMD_CTX, "reading NAND flash page failed");
|
||||
command_print(CMD, "reading NAND flash page failed");
|
||||
nand_fileio_cleanup(&dev);
|
||||
nand_fileio_cleanup(&file);
|
||||
return retval;
|
||||
@@ -310,7 +310,7 @@ COMMAND_HANDLER(handle_nand_verify_command)
|
||||
|
||||
int bytes_read = nand_fileio_read(nand, &file);
|
||||
if (bytes_read <= 0) {
|
||||
command_print(CMD_CTX, "error while reading file");
|
||||
command_print(CMD, "error while reading file");
|
||||
nand_fileio_cleanup(&dev);
|
||||
nand_fileio_cleanup(&file);
|
||||
return ERROR_FAIL;
|
||||
@@ -318,7 +318,7 @@ COMMAND_HANDLER(handle_nand_verify_command)
|
||||
|
||||
if ((dev.page && memcmp(dev.page, file.page, dev.page_size)) ||
|
||||
(dev.oob && memcmp(dev.oob, file.oob, dev.oob_size))) {
|
||||
command_print(CMD_CTX, "NAND flash contents differ "
|
||||
command_print(CMD, "NAND flash contents differ "
|
||||
"at 0x%8.8" PRIx32, dev.address);
|
||||
nand_fileio_cleanup(&dev);
|
||||
nand_fileio_cleanup(&file);
|
||||
@@ -330,7 +330,7 @@ COMMAND_HANDLER(handle_nand_verify_command)
|
||||
}
|
||||
|
||||
if (nand_fileio_finish(&file) == ERROR_OK) {
|
||||
command_print(CMD_CTX, "verified file %s in NAND flash %s "
|
||||
command_print(CMD, "verified file %s in NAND flash %s "
|
||||
"up to offset 0x%8.8" PRIx32 " in %fs (%0.3f KiB/s)",
|
||||
CMD_ARGV[1], CMD_ARGV[0], dev.address, duration_elapsed(&file.bench),
|
||||
duration_kbps(&file.bench, dev.size));
|
||||
@@ -354,7 +354,7 @@ COMMAND_HANDLER(handle_nand_dump_command)
|
||||
retval = nand_read_page(nand, s.address / nand->page_size,
|
||||
s.page, s.page_size, s.oob, s.oob_size);
|
||||
if (ERROR_OK != retval) {
|
||||
command_print(CMD_CTX, "reading NAND flash page failed");
|
||||
command_print(CMD, "reading NAND flash page failed");
|
||||
nand_fileio_cleanup(&s);
|
||||
return retval;
|
||||
}
|
||||
@@ -374,7 +374,7 @@ COMMAND_HANDLER(handle_nand_dump_command)
|
||||
return retval;
|
||||
|
||||
if (nand_fileio_finish(&s) == ERROR_OK) {
|
||||
command_print(CMD_CTX, "dumped %zu bytes in %fs (%0.3f KiB/s)",
|
||||
command_print(CMD, "dumped %zu bytes in %fs (%0.3f KiB/s)",
|
||||
filesize, duration_elapsed(&s.bench),
|
||||
duration_kbps(&s.bench, filesize));
|
||||
}
|
||||
@@ -392,7 +392,7 @@ COMMAND_HANDLER(handle_nand_raw_access_command)
|
||||
return retval;
|
||||
|
||||
if (NULL == p->device) {
|
||||
command_print(CMD_CTX, "#%s: not probed", CMD_ARGV[0]);
|
||||
command_print(CMD, "#%s: not probed", CMD_ARGV[0]);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -400,7 +400,7 @@ COMMAND_HANDLER(handle_nand_raw_access_command)
|
||||
COMMAND_PARSE_ENABLE(CMD_ARGV[1], p->use_raw);
|
||||
|
||||
const char *msg = p->use_raw ? "enabled" : "disabled";
|
||||
command_print(CMD_CTX, "raw access is %s", msg);
|
||||
command_print(CMD, "raw access is %s", msg);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -411,6 +411,7 @@ static const struct command_registration nand_exec_command_handlers[] = {
|
||||
.handler = handle_nand_list_command,
|
||||
.mode = COMMAND_EXEC,
|
||||
.help = "list configured NAND flash devices",
|
||||
.usage = "",
|
||||
},
|
||||
{
|
||||
.name = "info",
|
||||
@@ -500,15 +501,15 @@ COMMAND_HANDLER(handle_nand_init_command)
|
||||
|
||||
static int nand_list_walker(struct nand_flash_controller *c, void *x)
|
||||
{
|
||||
struct command_context *cmd_ctx = x;
|
||||
command_print(cmd_ctx, " %s", c->name);
|
||||
struct command_invocation *cmd = x;
|
||||
command_print(cmd, " %s", c->name);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
COMMAND_HANDLER(handle_nand_list_drivers)
|
||||
{
|
||||
command_print(CMD_CTX, "Available NAND flash controller drivers:");
|
||||
return nand_driver_walk(&nand_list_walker, CMD_CTX);
|
||||
command_print(CMD, "Available NAND flash controller drivers:");
|
||||
return nand_driver_walk(&nand_list_walker, CMD);
|
||||
}
|
||||
|
||||
static COMMAND_HELPER(create_nand_device, const char *bank_name,
|
||||
|
||||
@@ -63,6 +63,7 @@ NOR_DRIVERS = \
|
||||
%D%/str7x.c \
|
||||
%D%/str9x.c \
|
||||
%D%/str9xpec.c \
|
||||
%D%/swm050.c \
|
||||
%D%/tms470.c \
|
||||
%D%/virtual.c \
|
||||
%D%/w600.c \
|
||||
|
||||
@@ -791,9 +791,9 @@ COMMAND_HANDLER(ambiqmicro_handle_mass_erase_command)
|
||||
for (i = 0; i < bank->num_sectors; i++)
|
||||
bank->sectors[i].is_erased = 1;
|
||||
|
||||
command_print(CMD_CTX, "ambiqmicro mass erase complete");
|
||||
command_print(CMD, "ambiqmicro mass erase complete");
|
||||
} else
|
||||
command_print(CMD_CTX, "ambiqmicro mass erase failed");
|
||||
command_print(CMD, "ambiqmicro mass erase failed");
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -815,9 +815,9 @@ COMMAND_HANDLER(ambiqmicro_handle_page_erase_command)
|
||||
return retval;
|
||||
|
||||
if (ambiqmicro_erase(bank, first, last) == ERROR_OK)
|
||||
command_print(CMD_CTX, "ambiqmicro page erase complete");
|
||||
command_print(CMD, "ambiqmicro page erase complete");
|
||||
else
|
||||
command_print(CMD_CTX, "ambiqmicro page erase failed");
|
||||
command_print(CMD, "ambiqmicro page erase failed");
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -838,7 +838,7 @@ COMMAND_HANDLER(ambiqmicro_handle_program_otp_command)
|
||||
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], offset);
|
||||
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], count);
|
||||
|
||||
command_print(CMD_CTX, "offset=0x%08x count=%d", offset, count);
|
||||
command_print(CMD, "offset=0x%08x count=%d", offset, count);
|
||||
|
||||
CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
|
||||
|
||||
|
||||
+19
-18
@@ -249,14 +249,14 @@ struct sam3_reg_list {
|
||||
|
||||
static struct sam3_chip *all_sam3_chips;
|
||||
|
||||
static struct sam3_chip *get_current_sam3(struct command_context *cmd_ctx)
|
||||
static struct sam3_chip *get_current_sam3(struct command_invocation *cmd)
|
||||
{
|
||||
struct target *t;
|
||||
static struct sam3_chip *p;
|
||||
|
||||
t = get_current_target(cmd_ctx);
|
||||
t = get_current_target(cmd->ctx);
|
||||
if (!t) {
|
||||
command_print(cmd_ctx, "No current target?");
|
||||
command_print(cmd, "No current target?");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ static struct sam3_chip *get_current_sam3(struct command_context *cmd_ctx)
|
||||
if (!p) {
|
||||
/* this should not happen */
|
||||
/* the command is not registered until the chip is created? */
|
||||
command_print(cmd_ctx, "No SAM3 chips exist?");
|
||||
command_print(cmd, "No SAM3 chips exist?");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ static struct sam3_chip *get_current_sam3(struct command_context *cmd_ctx)
|
||||
return p;
|
||||
p = p->next;
|
||||
}
|
||||
command_print(cmd_ctx, "Cannot find SAM3 chip?");
|
||||
command_print(cmd, "Cannot find SAM3 chip?");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -3538,7 +3538,7 @@ done:
|
||||
COMMAND_HANDLER(sam3_handle_info_command)
|
||||
{
|
||||
struct sam3_chip *pChip;
|
||||
pChip = get_current_sam3(CMD_CTX);
|
||||
pChip = get_current_sam3(CMD);
|
||||
if (!pChip)
|
||||
return ERROR_OK;
|
||||
|
||||
@@ -3549,7 +3549,7 @@ COMMAND_HANDLER(sam3_handle_info_command)
|
||||
if (pChip->details.bank[0].pBank == NULL) {
|
||||
x = 0;
|
||||
need_define:
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"Please define bank %d via command: flash bank %s ... ",
|
||||
x,
|
||||
at91sam3_flash.name);
|
||||
@@ -3598,7 +3598,7 @@ COMMAND_HANDLER(sam3_handle_gpnvm_command)
|
||||
int r, who;
|
||||
struct sam3_chip *pChip;
|
||||
|
||||
pChip = get_current_sam3(CMD_CTX);
|
||||
pChip = get_current_sam3(CMD);
|
||||
if (!pChip)
|
||||
return ERROR_OK;
|
||||
|
||||
@@ -3608,7 +3608,7 @@ COMMAND_HANDLER(sam3_handle_gpnvm_command)
|
||||
}
|
||||
|
||||
if (pChip->details.bank[0].pBank == NULL) {
|
||||
command_print(CMD_CTX, "Bank0 must be defined first via: flash bank %s ...",
|
||||
command_print(CMD, "Bank0 must be defined first via: flash bank %s ...",
|
||||
at91sam3_flash.name);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
@@ -3647,22 +3647,22 @@ showall:
|
||||
r = FLASHD_GetGPNVM(&(pChip->details.bank[0]), x, &v);
|
||||
if (r != ERROR_OK)
|
||||
break;
|
||||
command_print(CMD_CTX, "sam3-gpnvm%u: %u", x, v);
|
||||
command_print(CMD, "sam3-gpnvm%u: %u", x, v);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
if ((who >= 0) && (((unsigned)(who)) < pChip->details.n_gpnvms)) {
|
||||
r = FLASHD_GetGPNVM(&(pChip->details.bank[0]), who, &v);
|
||||
command_print(CMD_CTX, "sam3-gpnvm%u: %u", who, v);
|
||||
command_print(CMD, "sam3-gpnvm%u: %u", who, v);
|
||||
return r;
|
||||
} else {
|
||||
command_print(CMD_CTX, "sam3-gpnvm invalid GPNVM: %u", who);
|
||||
command_print(CMD, "sam3-gpnvm invalid GPNVM: %u", who);
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (who == -1) {
|
||||
command_print(CMD_CTX, "Missing GPNVM number");
|
||||
command_print(CMD, "Missing GPNVM number");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
@@ -3672,7 +3672,7 @@ showall:
|
||||
(0 == strcmp("clear", CMD_ARGV[0]))) /* quietly accept both */
|
||||
r = FLASHD_ClrGPNVM(&(pChip->details.bank[0]), who);
|
||||
else {
|
||||
command_print(CMD_CTX, "Unknown command: %s", CMD_ARGV[0]);
|
||||
command_print(CMD, "Unknown command: %s", CMD_ARGV[0]);
|
||||
r = ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
return r;
|
||||
@@ -3682,7 +3682,7 @@ COMMAND_HANDLER(sam3_handle_slowclk_command)
|
||||
{
|
||||
struct sam3_chip *pChip;
|
||||
|
||||
pChip = get_current_sam3(CMD_CTX);
|
||||
pChip = get_current_sam3(CMD);
|
||||
if (!pChip)
|
||||
return ERROR_OK;
|
||||
|
||||
@@ -3697,7 +3697,7 @@ COMMAND_HANDLER(sam3_handle_slowclk_command)
|
||||
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], v);
|
||||
if (v > 200000) {
|
||||
/* absurd slow clock of 200Khz? */
|
||||
command_print(CMD_CTX, "Absurd/illegal slow clock freq: %d\n", (int)(v));
|
||||
command_print(CMD, "Absurd/illegal slow clock freq: %d\n", (int)(v));
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
pChip->cfg.slow_freq = v;
|
||||
@@ -3705,11 +3705,11 @@ COMMAND_HANDLER(sam3_handle_slowclk_command)
|
||||
}
|
||||
default:
|
||||
/* error */
|
||||
command_print(CMD_CTX, "Too many parameters");
|
||||
command_print(CMD, "Too many parameters");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
break;
|
||||
}
|
||||
command_print(CMD_CTX, "Slowclk freq: %d.%03dkhz",
|
||||
command_print(CMD, "Slowclk freq: %d.%03dkhz",
|
||||
(int)(pChip->cfg.slow_freq / 1000),
|
||||
(int)(pChip->cfg.slow_freq % 1000));
|
||||
return ERROR_OK;
|
||||
@@ -3731,6 +3731,7 @@ static const struct command_registration at91sam3_exec_command_handlers[] = {
|
||||
.mode = COMMAND_EXEC,
|
||||
.help = "Print information about the current at91sam3 chip"
|
||||
"and its flash configuration.",
|
||||
.usage = "",
|
||||
},
|
||||
{
|
||||
.name = "slowclk",
|
||||
|
||||
+19
-18
@@ -228,14 +228,14 @@ struct sam4_reg_list {
|
||||
|
||||
static struct sam4_chip *all_sam4_chips;
|
||||
|
||||
static struct sam4_chip *get_current_sam4(struct command_context *cmd_ctx)
|
||||
static struct sam4_chip *get_current_sam4(struct command_invocation *cmd)
|
||||
{
|
||||
struct target *t;
|
||||
static struct sam4_chip *p;
|
||||
|
||||
t = get_current_target(cmd_ctx);
|
||||
t = get_current_target(cmd->ctx);
|
||||
if (!t) {
|
||||
command_print(cmd_ctx, "No current target?");
|
||||
command_print(cmd, "No current target?");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ static struct sam4_chip *get_current_sam4(struct command_context *cmd_ctx)
|
||||
if (!p) {
|
||||
/* this should not happen */
|
||||
/* the command is not registered until the chip is created? */
|
||||
command_print(cmd_ctx, "No SAM4 chips exist?");
|
||||
command_print(cmd, "No SAM4 chips exist?");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ static struct sam4_chip *get_current_sam4(struct command_context *cmd_ctx)
|
||||
return p;
|
||||
p = p->next;
|
||||
}
|
||||
command_print(cmd_ctx, "Cannot find SAM4 chip?");
|
||||
command_print(cmd, "Cannot find SAM4 chip?");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -3018,7 +3018,7 @@ done:
|
||||
COMMAND_HANDLER(sam4_handle_info_command)
|
||||
{
|
||||
struct sam4_chip *pChip;
|
||||
pChip = get_current_sam4(CMD_CTX);
|
||||
pChip = get_current_sam4(CMD);
|
||||
if (!pChip)
|
||||
return ERROR_OK;
|
||||
|
||||
@@ -3029,7 +3029,7 @@ COMMAND_HANDLER(sam4_handle_info_command)
|
||||
if (pChip->details.bank[0].pBank == NULL) {
|
||||
x = 0;
|
||||
need_define:
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"Please define bank %d via command: flash bank %s ... ",
|
||||
x,
|
||||
at91sam4_flash.name);
|
||||
@@ -3078,7 +3078,7 @@ COMMAND_HANDLER(sam4_handle_gpnvm_command)
|
||||
int r, who;
|
||||
struct sam4_chip *pChip;
|
||||
|
||||
pChip = get_current_sam4(CMD_CTX);
|
||||
pChip = get_current_sam4(CMD);
|
||||
if (!pChip)
|
||||
return ERROR_OK;
|
||||
|
||||
@@ -3088,7 +3088,7 @@ COMMAND_HANDLER(sam4_handle_gpnvm_command)
|
||||
}
|
||||
|
||||
if (pChip->details.bank[0].pBank == NULL) {
|
||||
command_print(CMD_CTX, "Bank0 must be defined first via: flash bank %s ...",
|
||||
command_print(CMD, "Bank0 must be defined first via: flash bank %s ...",
|
||||
at91sam4_flash.name);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
@@ -3127,23 +3127,23 @@ showall:
|
||||
r = FLASHD_GetGPNVM(&(pChip->details.bank[0]), x, &v);
|
||||
if (r != ERROR_OK)
|
||||
break;
|
||||
command_print(CMD_CTX, "sam4-gpnvm%u: %u", x, v);
|
||||
command_print(CMD, "sam4-gpnvm%u: %u", x, v);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
if ((who >= 0) && (((unsigned)(who)) < pChip->details.n_gpnvms)) {
|
||||
r = FLASHD_GetGPNVM(&(pChip->details.bank[0]), who, &v);
|
||||
if (r == ERROR_OK)
|
||||
command_print(CMD_CTX, "sam4-gpnvm%u: %u", who, v);
|
||||
command_print(CMD, "sam4-gpnvm%u: %u", who, v);
|
||||
return r;
|
||||
} else {
|
||||
command_print(CMD_CTX, "sam4-gpnvm invalid GPNVM: %u", who);
|
||||
command_print(CMD, "sam4-gpnvm invalid GPNVM: %u", who);
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (who == -1) {
|
||||
command_print(CMD_CTX, "Missing GPNVM number");
|
||||
command_print(CMD, "Missing GPNVM number");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
@@ -3153,7 +3153,7 @@ showall:
|
||||
(0 == strcmp("clear", CMD_ARGV[0]))) /* quietly accept both */
|
||||
r = FLASHD_ClrGPNVM(&(pChip->details.bank[0]), who);
|
||||
else {
|
||||
command_print(CMD_CTX, "Unknown command: %s", CMD_ARGV[0]);
|
||||
command_print(CMD, "Unknown command: %s", CMD_ARGV[0]);
|
||||
r = ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
return r;
|
||||
@@ -3163,7 +3163,7 @@ COMMAND_HANDLER(sam4_handle_slowclk_command)
|
||||
{
|
||||
struct sam4_chip *pChip;
|
||||
|
||||
pChip = get_current_sam4(CMD_CTX);
|
||||
pChip = get_current_sam4(CMD);
|
||||
if (!pChip)
|
||||
return ERROR_OK;
|
||||
|
||||
@@ -3178,7 +3178,7 @@ COMMAND_HANDLER(sam4_handle_slowclk_command)
|
||||
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], v);
|
||||
if (v > 200000) {
|
||||
/* absurd slow clock of 200Khz? */
|
||||
command_print(CMD_CTX, "Absurd/illegal slow clock freq: %d\n", (int)(v));
|
||||
command_print(CMD, "Absurd/illegal slow clock freq: %d\n", (int)(v));
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
pChip->cfg.slow_freq = v;
|
||||
@@ -3186,11 +3186,11 @@ COMMAND_HANDLER(sam4_handle_slowclk_command)
|
||||
}
|
||||
default:
|
||||
/* error */
|
||||
command_print(CMD_CTX, "Too many parameters");
|
||||
command_print(CMD, "Too many parameters");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
break;
|
||||
}
|
||||
command_print(CMD_CTX, "Slowclk freq: %d.%03dkhz",
|
||||
command_print(CMD, "Slowclk freq: %d.%03dkhz",
|
||||
(int)(pChip->cfg.slow_freq / 1000),
|
||||
(int)(pChip->cfg.slow_freq % 1000));
|
||||
return ERROR_OK;
|
||||
@@ -3212,6 +3212,7 @@ static const struct command_registration at91sam4_exec_command_handlers[] = {
|
||||
.mode = COMMAND_EXEC,
|
||||
.help = "Print information about the current at91sam4 chip"
|
||||
"and its flash configuration.",
|
||||
.usage = "",
|
||||
},
|
||||
{
|
||||
.name = "slowclk",
|
||||
|
||||
@@ -668,7 +668,8 @@ static const struct command_registration at91sam4l_exec_command_handlers[] = {
|
||||
.name = "smap_reset_deassert",
|
||||
.handler = sam4l_handle_reset_deassert,
|
||||
.mode = COMMAND_EXEC,
|
||||
.help = "deasert internal reset held by SMAP"
|
||||
.help = "deassert internal reset held by SMAP",
|
||||
.usage = "",
|
||||
},
|
||||
COMMAND_REGISTRATION_DONE
|
||||
};
|
||||
|
||||
@@ -1067,7 +1067,7 @@ COMMAND_HANDLER(at91sam7_handle_gpnvm_command)
|
||||
if (bank == NULL)
|
||||
return ERROR_FLASH_BANK_INVALID;
|
||||
if (strcmp(bank->driver->name, "at91sam7")) {
|
||||
command_print(CMD_CTX, "not an at91sam7 flash bank '%s'", CMD_ARGV[0]);
|
||||
command_print(CMD, "not an at91sam7 flash bank '%s'", CMD_ARGV[0]);
|
||||
return ERROR_FLASH_BANK_INVALID;
|
||||
}
|
||||
if (bank->target->state != TARGET_HALTED) {
|
||||
@@ -1091,7 +1091,7 @@ COMMAND_HANDLER(at91sam7_handle_gpnvm_command)
|
||||
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], bit);
|
||||
if ((bit < 0) || (bit >= at91sam7_info->num_nvmbits)) {
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"gpnvm bit '#%s' is out of bounds for target %s",
|
||||
CMD_ARGV[0],
|
||||
at91sam7_info->target_name);
|
||||
|
||||
+20
-16
@@ -947,9 +947,9 @@ COMMAND_HANDLER(samd_handle_chip_erase_command)
|
||||
* perform the erase. */
|
||||
res = target_write_u8(target, SAMD_DSU + SAMD_DSU_CTRL_EXT, (1<<4));
|
||||
if (res == ERROR_OK)
|
||||
command_print(CMD_CTX, "chip erase started");
|
||||
command_print(CMD, "chip erase started");
|
||||
else
|
||||
command_print(CMD_CTX, "write to DSU CTRL failed");
|
||||
command_print(CMD, "write to DSU CTRL failed");
|
||||
}
|
||||
|
||||
return res;
|
||||
@@ -961,7 +961,7 @@ COMMAND_HANDLER(samd_handle_set_security_command)
|
||||
struct target *target = get_current_target(CMD_CTX);
|
||||
|
||||
if (CMD_ARGC < 1 || (CMD_ARGC >= 1 && (strcmp(CMD_ARGV[0], "enable")))) {
|
||||
command_print(CMD_CTX, "supply the \"enable\" argument to proceed.");
|
||||
command_print(CMD, "supply the \"enable\" argument to proceed.");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
@@ -975,9 +975,9 @@ COMMAND_HANDLER(samd_handle_set_security_command)
|
||||
|
||||
/* Check (and clear) error conditions */
|
||||
if (res == ERROR_OK)
|
||||
command_print(CMD_CTX, "chip secured on next power-cycle");
|
||||
command_print(CMD, "chip secured on next power-cycle");
|
||||
else
|
||||
command_print(CMD_CTX, "failed to secure chip");
|
||||
command_print(CMD, "failed to secure chip");
|
||||
}
|
||||
|
||||
return res;
|
||||
@@ -1008,7 +1008,7 @@ COMMAND_HANDLER(samd_handle_eeprom_command)
|
||||
}
|
||||
|
||||
if (code > 6) {
|
||||
command_print(CMD_CTX, "Invalid EEPROM size. Please see "
|
||||
command_print(CMD, "Invalid EEPROM size. Please see "
|
||||
"datasheet for a list valid sizes.");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
@@ -1022,10 +1022,10 @@ COMMAND_HANDLER(samd_handle_eeprom_command)
|
||||
uint32_t size = ((val >> 4) & 0x7); /* grab size code */
|
||||
|
||||
if (size == 0x7)
|
||||
command_print(CMD_CTX, "EEPROM is disabled");
|
||||
command_print(CMD, "EEPROM is disabled");
|
||||
else {
|
||||
/* Otherwise, 6 is 256B, 0 is 16KB */
|
||||
command_print(CMD_CTX, "EEPROM size is %u bytes",
|
||||
command_print(CMD, "EEPROM size is %u bytes",
|
||||
(2 << (13 - size)));
|
||||
}
|
||||
}
|
||||
@@ -1038,7 +1038,7 @@ COMMAND_HANDLER(samd_handle_eeprom_command)
|
||||
static COMMAND_HELPER(get_u64_from_hexarg, unsigned int num, uint64_t *value)
|
||||
{
|
||||
if (num >= CMD_ARGC) {
|
||||
command_print(CMD_CTX, "Too few Arguments.");
|
||||
command_print(CMD, "Too few Arguments.");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
@@ -1049,12 +1049,12 @@ static COMMAND_HELPER(get_u64_from_hexarg, unsigned int num, uint64_t *value)
|
||||
*value = strtoull(&(CMD_ARGV[num][2]), &check, 16);
|
||||
if ((value == 0 && errno == ERANGE) ||
|
||||
check == NULL || *check != 0) {
|
||||
command_print(CMD_CTX, "Invalid 64-bit hex value in argument %d.",
|
||||
command_print(CMD, "Invalid 64-bit hex value in argument %d.",
|
||||
num + 1);
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
} else {
|
||||
command_print(CMD_CTX, "Argument %d needs to be a hex value.", num + 1);
|
||||
command_print(CMD, "Argument %d needs to be a hex value.", num + 1);
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
return ERROR_OK;
|
||||
@@ -1067,7 +1067,7 @@ COMMAND_HANDLER(samd_handle_nvmuserrow_command)
|
||||
|
||||
if (target) {
|
||||
if (CMD_ARGC > 2) {
|
||||
command_print(CMD_CTX, "Too much Arguments given.");
|
||||
command_print(CMD, "Too much Arguments given.");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
@@ -1105,7 +1105,7 @@ COMMAND_HANDLER(samd_handle_nvmuserrow_command)
|
||||
uint64_t value;
|
||||
res = read_userrow(target, &value);
|
||||
if (res == ERROR_OK)
|
||||
command_print(CMD_CTX, "NVMUSERROW: 0x%016"PRIX64, value);
|
||||
command_print(CMD, "NVMUSERROW: 0x%016"PRIX64, value);
|
||||
else
|
||||
LOG_ERROR("NVMUSERROW could not be read.");
|
||||
}
|
||||
@@ -1145,7 +1145,7 @@ COMMAND_HANDLER(samd_handle_bootloader_command)
|
||||
}
|
||||
|
||||
if (code > 6) {
|
||||
command_print(CMD_CTX, "Invalid bootloader size. Please "
|
||||
command_print(CMD, "Invalid bootloader size. Please "
|
||||
"see datasheet for a list valid sizes.");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
@@ -1166,7 +1166,7 @@ COMMAND_HANDLER(samd_handle_bootloader_command)
|
||||
nb = (2 << (8 - size)) * page_size;
|
||||
|
||||
/* There are 4 pages per row */
|
||||
command_print(CMD_CTX, "Bootloader size is %" PRIu32 " bytes (%" PRIu32 " rows)",
|
||||
command_print(CMD, "Bootloader size is %" PRIu32 " bytes (%" PRIu32 " rows)",
|
||||
nb, (uint32_t)(nb / (page_size * 4)));
|
||||
}
|
||||
}
|
||||
@@ -1217,7 +1217,8 @@ static const struct command_registration at91samd_exec_command_handlers[] = {
|
||||
.name = "dsu_reset_deassert",
|
||||
.handler = samd_handle_reset_deassert,
|
||||
.mode = COMMAND_EXEC,
|
||||
.help = "Deasert internal reset held by DSU."
|
||||
.help = "Deassert internal reset held by DSU.",
|
||||
.usage = "",
|
||||
},
|
||||
{
|
||||
.name = "info",
|
||||
@@ -1225,6 +1226,7 @@ static const struct command_registration at91samd_exec_command_handlers[] = {
|
||||
.mode = COMMAND_EXEC,
|
||||
.help = "Print information about the current at91samd chip "
|
||||
"and its flash configuration.",
|
||||
.usage = "",
|
||||
},
|
||||
{
|
||||
.name = "chip-erase",
|
||||
@@ -1232,6 +1234,7 @@ static const struct command_registration at91samd_exec_command_handlers[] = {
|
||||
.mode = COMMAND_EXEC,
|
||||
.help = "Erase the entire Flash by using the Chip-"
|
||||
"Erase feature in the Device Service Unit (DSU).",
|
||||
.usage = "",
|
||||
},
|
||||
{
|
||||
.name = "set-security",
|
||||
@@ -1241,6 +1244,7 @@ static const struct command_registration at91samd_exec_command_handlers[] = {
|
||||
"This makes it impossible to read the Flash contents. "
|
||||
"The only way to undo this is to issue the chip-erase "
|
||||
"command.",
|
||||
.usage = "'enable'",
|
||||
},
|
||||
{
|
||||
.name = "eeprom",
|
||||
|
||||
@@ -765,9 +765,9 @@ COMMAND_HANDLER(same5_handle_chip_erase_command)
|
||||
* perform the erase. */
|
||||
int res = target_write_u8(target, SAMD_DSU + SAMD_DSU_CTRL_EXT, (1<<4));
|
||||
if (res == ERROR_OK)
|
||||
command_print(CMD_CTX, "chip erase started");
|
||||
command_print(CMD, "chip erase started");
|
||||
else
|
||||
command_print(CMD_CTX, "write to DSU CTRL failed");
|
||||
command_print(CMD, "write to DSU CTRL failed");
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -781,7 +781,7 @@ COMMAND_HANDLER(same5_handle_userpage_command)
|
||||
return ERROR_FAIL;
|
||||
|
||||
if (CMD_ARGC > 2) {
|
||||
command_print(CMD_CTX, "Too much Arguments given.");
|
||||
command_print(CMD, "Too much Arguments given.");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
@@ -806,7 +806,7 @@ COMMAND_HANDLER(same5_handle_userpage_command)
|
||||
int res2 = target_read_memory(target, SAMD_USER_ROW, 4, 2, buffer);
|
||||
if (res2 == ERROR_OK) {
|
||||
uint64_t value = target_buffer_get_u64(target, buffer);
|
||||
command_print(CMD_CTX, "USER PAGE: 0x%016"PRIX64, value);
|
||||
command_print(CMD, "USER PAGE: 0x%016"PRIX64, value);
|
||||
} else {
|
||||
LOG_ERROR("USER PAGE could not be read.");
|
||||
}
|
||||
@@ -829,7 +829,7 @@ COMMAND_HANDLER(same5_handle_bootloader_command)
|
||||
unsigned long size = strtoul(CMD_ARGV[0], NULL, 0);
|
||||
uint32_t code = (size + 8191) / 8192;
|
||||
if (code > 15) {
|
||||
command_print(CMD_CTX, "Invalid bootloader size. Please "
|
||||
command_print(CMD, "Invalid bootloader size. Please "
|
||||
"see datasheet for a list valid sizes.");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
@@ -842,7 +842,7 @@ COMMAND_HANDLER(same5_handle_bootloader_command)
|
||||
if (res2 == ERROR_OK) {
|
||||
uint32_t code = (val >> 26) & 0xf; /* grab size code */
|
||||
uint32_t size = (15 - code) * 8192;
|
||||
command_print(CMD_CTX, "Bootloader protected in the first %"
|
||||
command_print(CMD, "Bootloader protected in the first %"
|
||||
PRIu32 " bytes", size);
|
||||
}
|
||||
|
||||
@@ -893,12 +893,14 @@ COMMAND_HANDLER(samd_handle_reset_deassert)
|
||||
static const struct command_registration same5_exec_command_handlers[] = {
|
||||
{
|
||||
.name = "dsu_reset_deassert",
|
||||
.usage = "",
|
||||
.handler = samd_handle_reset_deassert,
|
||||
.mode = COMMAND_EXEC,
|
||||
.help = "Deasert internal reset held by DSU."
|
||||
.help = "Deassert internal reset held by DSU."
|
||||
},
|
||||
{
|
||||
.name = "chip-erase",
|
||||
.usage = "",
|
||||
.handler = same5_handle_chip_erase_command,
|
||||
.mode = COMMAND_EXEC,
|
||||
.help = "Erase the entire Flash by using the Chip-"
|
||||
|
||||
@@ -672,22 +672,22 @@ showall:
|
||||
r = samv_get_gpnvm(target, x, &v);
|
||||
if (r != ERROR_OK)
|
||||
break;
|
||||
command_print(CMD_CTX, "samv-gpnvm%u: %u", x, v);
|
||||
command_print(CMD, "samv-gpnvm%u: %u", x, v);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
if ((who >= 0) && (((unsigned)who) < SAMV_NUM_GPNVM_BITS)) {
|
||||
r = samv_get_gpnvm(target, who, &v);
|
||||
command_print(CMD_CTX, "samv-gpnvm%u: %u", who, v);
|
||||
command_print(CMD, "samv-gpnvm%u: %u", who, v);
|
||||
return r;
|
||||
} else {
|
||||
command_print(CMD_CTX, "invalid gpnvm: %u", who);
|
||||
command_print(CMD, "invalid gpnvm: %u", who);
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (who == -1) {
|
||||
command_print(CMD_CTX, "missing gpnvm number");
|
||||
command_print(CMD, "missing gpnvm number");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
@@ -696,7 +696,7 @@ showall:
|
||||
else if (!strcmp("clr", CMD_ARGV[0]) || !strcmp("clear", CMD_ARGV[0]))
|
||||
r = samv_clear_gpnvm(target, who);
|
||||
else {
|
||||
command_print(CMD_CTX, "unknown command: %s", CMD_ARGV[0]);
|
||||
command_print(CMD, "unknown command: %s", CMD_ARGV[0]);
|
||||
r = ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
return r;
|
||||
|
||||
@@ -433,9 +433,9 @@ COMMAND_HANDLER(avrf_handle_mass_erase_command)
|
||||
for (i = 0; i < bank->num_sectors; i++)
|
||||
bank->sectors[i].is_erased = 1;
|
||||
|
||||
command_print(CMD_CTX, "avr mass erase complete");
|
||||
command_print(CMD, "avr mass erase complete");
|
||||
} else
|
||||
command_print(CMD_CTX, "avr mass erase failed");
|
||||
command_print(CMD, "avr mass erase failed");
|
||||
|
||||
LOG_DEBUG("%s", __func__);
|
||||
return ERROR_OK;
|
||||
|
||||
+10
-7
@@ -45,9 +45,12 @@ struct flash_sector {
|
||||
uint32_t size;
|
||||
/**
|
||||
* Indication of erasure status: 0 = not erased, 1 = erased,
|
||||
* other = unknown. Set by @c flash_driver_s::erase_check.
|
||||
* other = unknown. Set by @c flash_driver_s::erase_check only.
|
||||
*
|
||||
* Flag is not used in protection block
|
||||
* This information must be considered stale immediately.
|
||||
* Don't set it in flash_driver_s::erase or a device mass_erase
|
||||
* Don't clear it in flash_driver_s::write
|
||||
* The flag is not used in a protection block
|
||||
*/
|
||||
int is_erased;
|
||||
/**
|
||||
@@ -118,7 +121,7 @@ struct flash_bank {
|
||||
|
||||
/**
|
||||
* The number of sectors on this chip. This value will
|
||||
* be set intially to 0, and the flash driver must set this to
|
||||
* be set initially to 0, and the flash driver must set this to
|
||||
* some non-zero value during "probe()" or "auto_probe()".
|
||||
*/
|
||||
int num_sectors;
|
||||
@@ -127,12 +130,12 @@ struct flash_bank {
|
||||
|
||||
/**
|
||||
* The number of protection blocks in this bank. This value
|
||||
* is set intially to 0 and sectors are used as protection blocks.
|
||||
* is set initially to 0 and sectors are used as protection blocks.
|
||||
* Driver probe can set protection blocks array to work with
|
||||
* protection granularity different than sector size.
|
||||
*/
|
||||
int num_prot_blocks;
|
||||
/** Array of protection blocks, allocated and initilized by the flash driver */
|
||||
/** Array of protection blocks, allocated and initialized by the flash driver */
|
||||
struct flash_sector *prot_blocks;
|
||||
|
||||
struct flash_bank *next; /**< The next flash bank on this chip */
|
||||
@@ -239,8 +242,8 @@ struct flash_bank *get_flash_bank_by_name_noprobe(const char *name);
|
||||
*/
|
||||
int get_flash_bank_by_num(int num, struct flash_bank **bank);
|
||||
/**
|
||||
* Retreives @a bank from a command argument, reporting errors parsing
|
||||
* the bank identifier or retreiving the specified bank. The 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
|
||||
|
||||
@@ -77,6 +77,7 @@ extern const struct flash_driver stmsmi_flash;
|
||||
extern const struct flash_driver str7x_flash;
|
||||
extern const struct flash_driver str9x_flash;
|
||||
extern const struct flash_driver str9xpec_flash;
|
||||
extern const struct flash_driver swm050_flash;
|
||||
extern const struct flash_driver tms470_flash;
|
||||
extern const struct flash_driver virtual_flash;
|
||||
extern const struct flash_driver w600_flash;
|
||||
@@ -146,6 +147,7 @@ static const struct flash_driver * const flash_drivers[] = {
|
||||
&str7x_flash,
|
||||
&str9x_flash,
|
||||
&str9xpec_flash,
|
||||
&swm050_flash,
|
||||
&tms470_flash,
|
||||
&virtual_flash,
|
||||
&xcf_flash,
|
||||
|
||||
@@ -1093,7 +1093,7 @@ COMMAND_HANDLER(efm32x_handle_debuglock_command)
|
||||
return retval;
|
||||
}
|
||||
|
||||
command_print(CMD_CTX, "efm32x debug interface locked, reset the device to apply");
|
||||
command_print(CMD, "efm32x debug interface locked, reset the device to apply");
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -776,7 +776,7 @@ COMMAND_HANDLER(em357_handle_lock_command)
|
||||
}
|
||||
|
||||
if (em357_erase_options(bank) != ERROR_OK) {
|
||||
command_print(CMD_CTX, "em357 failed to erase options");
|
||||
command_print(CMD, "em357 failed to erase options");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -784,11 +784,11 @@ COMMAND_HANDLER(em357_handle_lock_command)
|
||||
em357_info->option_bytes.RDP = 0;
|
||||
|
||||
if (em357_write_options(bank) != ERROR_OK) {
|
||||
command_print(CMD_CTX, "em357 failed to lock device");
|
||||
command_print(CMD, "em357 failed to lock device");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
command_print(CMD_CTX, "em357 locked");
|
||||
command_print(CMD, "em357 locked");
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -813,16 +813,16 @@ COMMAND_HANDLER(em357_handle_unlock_command)
|
||||
}
|
||||
|
||||
if (em357_erase_options(bank) != ERROR_OK) {
|
||||
command_print(CMD_CTX, "em357 failed to unlock device");
|
||||
command_print(CMD, "em357 failed to unlock device");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
if (em357_write_options(bank) != ERROR_OK) {
|
||||
command_print(CMD_CTX, "em357 failed to lock device");
|
||||
command_print(CMD, "em357 failed to lock device");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
command_print(CMD_CTX, "em357 unlocked.\n"
|
||||
command_print(CMD, "em357 unlocked.\n"
|
||||
"INFO: a reset or power cycle is required "
|
||||
"for the new settings to take effect.");
|
||||
|
||||
@@ -886,9 +886,9 @@ COMMAND_HANDLER(em357_handle_mass_erase_command)
|
||||
for (i = 0; i < bank->num_sectors; i++)
|
||||
bank->sectors[i].is_erased = 1;
|
||||
|
||||
command_print(CMD_CTX, "em357 mass erase complete");
|
||||
command_print(CMD, "em357 mass erase complete");
|
||||
} else
|
||||
command_print(CMD_CTX, "em357 mass erase failed");
|
||||
command_print(CMD, "em357 mass erase failed");
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
#endif
|
||||
|
||||
#define CONTROL_TIMEOUT 5000 /* 5s */
|
||||
#define PAGE_SIZE 4096
|
||||
#define FLASH_PAGE_SIZE 4096
|
||||
#define PB_MAX 32
|
||||
|
||||
#define NUM_NS_PER_S 1000000000ULL
|
||||
@@ -264,7 +264,7 @@ static int esirisc_flash_erase(struct flash_bank *bank, int first, int last)
|
||||
(void)esirisc_flash_disable_protect(bank);
|
||||
|
||||
for (int page = first; page < last; ++page) {
|
||||
uint32_t address = page * PAGE_SIZE;
|
||||
uint32_t address = page * FLASH_PAGE_SIZE;
|
||||
|
||||
target_write_u32(target, esirisc_info->cfg + ADDRESS, address);
|
||||
|
||||
@@ -464,8 +464,8 @@ static int esirisc_flash_probe(struct flash_bank *bank)
|
||||
if (target->state != TARGET_HALTED)
|
||||
return ERROR_TARGET_NOT_HALTED;
|
||||
|
||||
bank->num_sectors = bank->size / PAGE_SIZE;
|
||||
bank->sectors = alloc_block_array(0, PAGE_SIZE, bank->num_sectors);
|
||||
bank->num_sectors = bank->size / FLASH_PAGE_SIZE;
|
||||
bank->sectors = alloc_block_array(0, FLASH_PAGE_SIZE, bank->num_sectors);
|
||||
|
||||
retval = esirisc_flash_init(bank);
|
||||
if (retval != ERROR_OK) {
|
||||
@@ -516,7 +516,7 @@ COMMAND_HANDLER(handle_esirisc_flash_mass_erase_command)
|
||||
|
||||
retval = esirisc_flash_mass_erase(bank);
|
||||
|
||||
command_print(CMD_CTX, "mass erase %s",
|
||||
command_print(CMD, "mass erase %s",
|
||||
(retval == ERROR_OK) ? "successful" : "failed");
|
||||
|
||||
return retval;
|
||||
@@ -536,7 +536,7 @@ COMMAND_HANDLER(handle_esirisc_flash_ref_erase_command)
|
||||
|
||||
retval = esirisc_flash_ref_erase(bank);
|
||||
|
||||
command_print(CMD_CTX, "erase reference cell %s",
|
||||
command_print(CMD, "erase reference cell %s",
|
||||
(retval == ERROR_OK) ? "successful" : "failed");
|
||||
|
||||
return retval;
|
||||
|
||||
@@ -109,6 +109,7 @@ static const struct command_registration faux_command_handlers[] = {
|
||||
.mode = COMMAND_ANY,
|
||||
.help = "faux flash command group",
|
||||
.chain = hello_command_handlers,
|
||||
.usage = "",
|
||||
},
|
||||
COMMAND_REGISTRATION_DONE
|
||||
};
|
||||
|
||||
+2
-2
@@ -958,9 +958,9 @@ COMMAND_HANDLER(fm3_handle_chip_erase_command)
|
||||
for (i = 0; i < bank->num_sectors; i++)
|
||||
bank->sectors[i].is_erased = 1;
|
||||
|
||||
command_print(CMD_CTX, "fm3 chip erase complete");
|
||||
command_print(CMD, "fm3 chip erase complete");
|
||||
} else {
|
||||
command_print(CMD_CTX, "fm3 chip erase failed");
|
||||
command_print(CMD, "fm3 chip erase failed");
|
||||
}
|
||||
|
||||
return ERROR_OK;
|
||||
|
||||
+16
-14
@@ -2895,7 +2895,7 @@ COMMAND_HANDLER(kinetis_nvm_partition)
|
||||
flex_nvm_partition_code = (uint8_t)((sim_fcfg1 >> 8) & 0x0f);
|
||||
switch (flex_nvm_partition_code) {
|
||||
case 0:
|
||||
command_print(CMD_CTX, "No EEPROM backup, data flash only");
|
||||
command_print(CMD, "No EEPROM backup, data flash only");
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
@@ -2903,10 +2903,10 @@ COMMAND_HANDLER(kinetis_nvm_partition)
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
command_print(CMD_CTX, "EEPROM backup %d KB", 4 << flex_nvm_partition_code);
|
||||
command_print(CMD, "EEPROM backup %d KB", 4 << flex_nvm_partition_code);
|
||||
break;
|
||||
case 8:
|
||||
command_print(CMD_CTX, "No data flash, EEPROM backup only");
|
||||
command_print(CMD, "No data flash, EEPROM backup only");
|
||||
break;
|
||||
case 0x9:
|
||||
case 0xA:
|
||||
@@ -2914,13 +2914,13 @@ COMMAND_HANDLER(kinetis_nvm_partition)
|
||||
case 0xC:
|
||||
case 0xD:
|
||||
case 0xE:
|
||||
command_print(CMD_CTX, "data flash %d KB", 4 << (flex_nvm_partition_code & 7));
|
||||
command_print(CMD, "data flash %d KB", 4 << (flex_nvm_partition_code & 7));
|
||||
break;
|
||||
case 0xf:
|
||||
command_print(CMD_CTX, "No EEPROM backup, data flash only (DEPART not set)");
|
||||
command_print(CMD, "No EEPROM backup, data flash only (DEPART not set)");
|
||||
break;
|
||||
default:
|
||||
command_print(CMD_CTX, "Unsupported EEPROM backup size code 0x%02" PRIx8, flex_nvm_partition_code);
|
||||
command_print(CMD, "Unsupported EEPROM backup size code 0x%02" PRIx8, flex_nvm_partition_code);
|
||||
}
|
||||
return ERROR_OK;
|
||||
|
||||
@@ -2986,7 +2986,7 @@ COMMAND_HANDLER(kinetis_nvm_partition)
|
||||
if (result != ERROR_OK)
|
||||
return result;
|
||||
|
||||
command_print(CMD_CTX, "FlexNVM partition set. Please reset MCU.");
|
||||
command_print(CMD, "FlexNVM partition set. Please reset MCU.");
|
||||
|
||||
if (k_chip) {
|
||||
first_nvm_bank = k_chip->num_pflash_blocks;
|
||||
@@ -2996,7 +2996,7 @@ COMMAND_HANDLER(kinetis_nvm_partition)
|
||||
k_chip->probed = false;
|
||||
}
|
||||
|
||||
command_print(CMD_CTX, "FlexNVM banks will be re-probed to set new data flash size.");
|
||||
command_print(CMD, "FlexNVM banks will be re-probed to set new data flash size.");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -3015,12 +3015,12 @@ COMMAND_HANDLER(kinetis_fcf_source_handler)
|
||||
}
|
||||
|
||||
if (allow_fcf_writes) {
|
||||
command_print(CMD_CTX, "Arbitrary Flash Configuration Field writes enabled.");
|
||||
command_print(CMD_CTX, "Protection info writes to FCF disabled.");
|
||||
command_print(CMD, "Arbitrary Flash Configuration Field writes enabled.");
|
||||
command_print(CMD, "Protection info writes to FCF disabled.");
|
||||
LOG_WARNING("BEWARE: incorrect flash configuration may permanently lock the device.");
|
||||
} else {
|
||||
command_print(CMD_CTX, "Protection info writes to Flash Configuration Field enabled.");
|
||||
command_print(CMD_CTX, "Arbitrary FCF writes disabled. Mode safe from unwanted locking of the device.");
|
||||
command_print(CMD, "Protection info writes to Flash Configuration Field enabled.");
|
||||
command_print(CMD, "Arbitrary FCF writes disabled. Mode safe from unwanted locking of the device.");
|
||||
}
|
||||
|
||||
return ERROR_OK;
|
||||
@@ -3035,7 +3035,7 @@ COMMAND_HANDLER(kinetis_fopt_handler)
|
||||
fcf_fopt = (uint8_t)strtoul(CMD_ARGV[0], NULL, 0);
|
||||
fcf_fopt_configured = true;
|
||||
} else {
|
||||
command_print(CMD_CTX, "FCF_FOPT 0x%02" PRIx8, fcf_fopt);
|
||||
command_print(CMD, "FCF_FOPT 0x%02" PRIx8, fcf_fopt);
|
||||
}
|
||||
|
||||
return ERROR_OK;
|
||||
@@ -3074,7 +3074,8 @@ static const struct command_registration kinetis_security_command_handlers[] = {
|
||||
.usage = "",
|
||||
.handler = kinetis_mdm_mass_erase,
|
||||
},
|
||||
{ .name = "reset",
|
||||
{
|
||||
.name = "reset",
|
||||
.mode = COMMAND_EXEC,
|
||||
.help = "Issue a reset via the MDM-AP",
|
||||
.usage = "",
|
||||
@@ -3126,6 +3127,7 @@ static const struct command_registration kinetis_exec_command_handlers[] = {
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "Driver creates additional banks if device with two/four flash blocks is probed",
|
||||
.handler = kinetis_create_banks_handler,
|
||||
.usage = "",
|
||||
},
|
||||
COMMAND_REGISTRATION_DONE
|
||||
};
|
||||
|
||||
@@ -1579,11 +1579,11 @@ COMMAND_HANDLER(lpc2000_handle_part_id_command)
|
||||
int status_code = get_lpc2000_part_id(bank, &part_id);
|
||||
if (status_code != 0x0) {
|
||||
if (status_code == ERROR_FLASH_OPERATION_FAILED) {
|
||||
command_print(CMD_CTX, "no sufficient working area specified, can't access LPC2000 IAP interface");
|
||||
command_print(CMD, "no sufficient working area specified, can't access LPC2000 IAP interface");
|
||||
} else
|
||||
command_print(CMD_CTX, "lpc2000 IAP returned status code %i", status_code);
|
||||
command_print(CMD, "lpc2000 IAP returned status code %i", status_code);
|
||||
} else
|
||||
command_print(CMD_CTX, "lpc2000 part id: 0x%8.8" PRIx32, part_id);
|
||||
command_print(CMD, "lpc2000 part id: 0x%8.8" PRIx32, part_id);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -501,7 +501,7 @@ COMMAND_HANDLER(lpc2900_handle_signature_command)
|
||||
if (status != ERROR_OK)
|
||||
return status;
|
||||
|
||||
command_print(CMD_CTX, "signature: 0x%8.8" PRIx32
|
||||
command_print(CMD, "signature: 0x%8.8" PRIx32
|
||||
":0x%8.8" PRIx32
|
||||
":0x%8.8" PRIx32
|
||||
":0x%8.8" PRIx32,
|
||||
@@ -595,11 +595,11 @@ COMMAND_HANDLER(lpc2900_handle_password_command)
|
||||
lpc2900_info->risky = !strcmp(CMD_ARGV[1], ISS_PASSWORD);
|
||||
|
||||
if (!lpc2900_info->risky) {
|
||||
command_print(CMD_CTX, "Wrong password (use '%s')", ISS_PASSWORD);
|
||||
command_print(CMD, "Wrong password (use '%s')", ISS_PASSWORD);
|
||||
return ERROR_COMMAND_ARGUMENT_INVALID;
|
||||
}
|
||||
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"Potentially dangerous operation allowed in next command!");
|
||||
|
||||
return ERROR_OK;
|
||||
@@ -622,7 +622,7 @@ COMMAND_HANDLER(lpc2900_handle_write_custom_command)
|
||||
|
||||
/* Check if command execution is allowed. */
|
||||
if (!lpc2900_info->risky) {
|
||||
command_print(CMD_CTX, "Command execution not allowed!");
|
||||
command_print(CMD, "Command execution not allowed!");
|
||||
return ERROR_COMMAND_ARGUMENT_INVALID;
|
||||
}
|
||||
lpc2900_info->risky = 0;
|
||||
@@ -721,7 +721,7 @@ COMMAND_HANDLER(lpc2900_handle_secure_sector_command)
|
||||
|
||||
/* Check if command execution is allowed. */
|
||||
if (!lpc2900_info->risky) {
|
||||
command_print(CMD_CTX, "Command execution not allowed! "
|
||||
command_print(CMD, "Command execution not allowed! "
|
||||
"(use 'password' command first)");
|
||||
return ERROR_COMMAND_ARGUMENT_INVALID;
|
||||
}
|
||||
@@ -734,7 +734,7 @@ COMMAND_HANDLER(lpc2900_handle_secure_sector_command)
|
||||
if ((first >= bank->num_sectors) ||
|
||||
(last >= bank->num_sectors) ||
|
||||
(first > last)) {
|
||||
command_print(CMD_CTX, "Illegal sector range");
|
||||
command_print(CMD, "Illegal sector range");
|
||||
return ERROR_COMMAND_ARGUMENT_INVALID;
|
||||
}
|
||||
|
||||
@@ -773,7 +773,7 @@ COMMAND_HANDLER(lpc2900_handle_secure_sector_command)
|
||||
}
|
||||
}
|
||||
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"Sectors security will become effective after next power cycle");
|
||||
|
||||
/* Update the sector security status */
|
||||
@@ -803,7 +803,7 @@ COMMAND_HANDLER(lpc2900_handle_secure_jtag_command)
|
||||
|
||||
/* Check if command execution is allowed. */
|
||||
if (!lpc2900_info->risky) {
|
||||
command_print(CMD_CTX, "Command execution not allowed! "
|
||||
command_print(CMD, "Command execution not allowed! "
|
||||
"(use 'password' command first)");
|
||||
return ERROR_COMMAND_ARGUMENT_INVALID;
|
||||
}
|
||||
|
||||
+15
-14
@@ -772,7 +772,7 @@ COMMAND_HANDLER(max32xxx_handle_mass_erase_command)
|
||||
int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
|
||||
|
||||
if (CMD_ARGC < 1) {
|
||||
command_print(CMD_CTX, "max32xxx mass_erase <bank>");
|
||||
command_print(CMD, "max32xxx mass_erase <bank>");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -784,9 +784,9 @@ COMMAND_HANDLER(max32xxx_handle_mass_erase_command)
|
||||
for (i = 0; i < bank->num_sectors; i++)
|
||||
bank->sectors[i].is_erased = 1;
|
||||
|
||||
command_print(CMD_CTX, "max32xxx mass erase complete");
|
||||
command_print(CMD, "max32xxx mass erase complete");
|
||||
} else
|
||||
command_print(CMD_CTX, "max32xxx mass erase failed");
|
||||
command_print(CMD, "max32xxx mass erase failed");
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -799,7 +799,7 @@ COMMAND_HANDLER(max32xxx_handle_protection_set_command)
|
||||
uint32_t addr, len;
|
||||
|
||||
if (CMD_ARGC != 3) {
|
||||
command_print(CMD_CTX, "max32xxx protection_set <bank> <addr> <size>");
|
||||
command_print(CMD, "max32xxx protection_set <bank> <addr> <size>");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -811,7 +811,7 @@ COMMAND_HANDLER(max32xxx_handle_protection_set_command)
|
||||
/* Convert the range to the page numbers */
|
||||
if (1 != sscanf(CMD_ARGV[1], "0x%"SCNx32, &addr)) {
|
||||
LOG_WARNING("Error parsing address");
|
||||
command_print(CMD_CTX, "max32xxx protection_set <bank> <addr> <size>");
|
||||
command_print(CMD, "max32xxx protection_set <bank> <addr> <size>");
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
/* Mask off the top portion on the address */
|
||||
@@ -819,7 +819,7 @@ COMMAND_HANDLER(max32xxx_handle_protection_set_command)
|
||||
|
||||
if (1 != sscanf(CMD_ARGV[2], "0x%"SCNx32, &len)) {
|
||||
LOG_WARNING("Error parsing length");
|
||||
command_print(CMD_CTX, "max32xxx protection_set <bank> <addr> <size>");
|
||||
command_print(CMD, "max32xxx protection_set <bank> <addr> <size>");
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
@@ -840,9 +840,9 @@ COMMAND_HANDLER(max32xxx_handle_protection_set_command)
|
||||
len = addr + (len / info->sector_size) - 1;
|
||||
|
||||
if (max32xxx_protect(bank, 1, addr, len) == ERROR_OK)
|
||||
command_print(CMD_CTX, "max32xxx protection set complete");
|
||||
command_print(CMD, "max32xxx protection set complete");
|
||||
else
|
||||
command_print(CMD_CTX, "max32xxx protection set failed");
|
||||
command_print(CMD, "max32xxx protection set failed");
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -855,7 +855,7 @@ COMMAND_HANDLER(max32xxx_handle_protection_clr_command)
|
||||
uint32_t addr, len;
|
||||
|
||||
if (CMD_ARGC != 3) {
|
||||
command_print(CMD_CTX, "max32xxx protection_clr <bank> <addr> <size>");
|
||||
command_print(CMD, "max32xxx protection_clr <bank> <addr> <size>");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -867,7 +867,7 @@ COMMAND_HANDLER(max32xxx_handle_protection_clr_command)
|
||||
/* Convert the range to the page numbers */
|
||||
if (1 != sscanf(CMD_ARGV[1], "0x%"SCNx32, &addr)) {
|
||||
LOG_WARNING("Error parsing address");
|
||||
command_print(CMD_CTX, "max32xxx protection_clr <bank> <addr> <size>");
|
||||
command_print(CMD, "max32xxx protection_clr <bank> <addr> <size>");
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
/* Mask off the top portion on the address */
|
||||
@@ -875,7 +875,7 @@ COMMAND_HANDLER(max32xxx_handle_protection_clr_command)
|
||||
|
||||
if (1 != sscanf(CMD_ARGV[2], "0x%"SCNx32, &len)) {
|
||||
LOG_WARNING("Error parsing length");
|
||||
command_print(CMD_CTX, "max32xxx protection_clr <bank> <addr> <size>");
|
||||
command_print(CMD, "max32xxx protection_clr <bank> <addr> <size>");
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
@@ -896,9 +896,9 @@ COMMAND_HANDLER(max32xxx_handle_protection_clr_command)
|
||||
len = addr + (len / info->sector_size) - 1;
|
||||
|
||||
if (max32xxx_protect(bank, 0, addr, len) == ERROR_OK)
|
||||
command_print(CMD_CTX, "max32xxx protection clear complete");
|
||||
command_print(CMD, "max32xxx protection clear complete");
|
||||
else
|
||||
command_print(CMD_CTX, "max32xxx protection clear failed");
|
||||
command_print(CMD, "max32xxx protection clear failed");
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -911,7 +911,7 @@ COMMAND_HANDLER(max32xxx_handle_protection_check_command)
|
||||
int i;
|
||||
|
||||
if (CMD_ARGC < 1) {
|
||||
command_print(CMD_CTX, "max32xxx protection_check <bank>");
|
||||
command_print(CMD, "max32xxx protection_check <bank>");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -977,6 +977,7 @@ static const struct command_registration max32xxx_command_handlers[] = {
|
||||
.mode = COMMAND_EXEC,
|
||||
.help = "max32xxx flash command group",
|
||||
.chain = max32xxx_exec_command_handlers,
|
||||
.usage = "",
|
||||
},
|
||||
COMMAND_REGISTRATION_DONE
|
||||
};
|
||||
|
||||
+32
-32
@@ -425,9 +425,9 @@ COMMAND_HANDLER(niietcm4_handle_uflash_read_byte_command)
|
||||
retval = target_read_u32(target, UFMD, &uflash_data);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
command_print(CMD_CTX, "Read userflash %s region:\n"
|
||||
"address = 0x%04x,\n"
|
||||
"value = 0x%02x.", CMD_ARGV[0], uflash_addr, uflash_data);
|
||||
command_print(CMD, "Read userflash %s region:\n"
|
||||
"address = 0x%04x,\n"
|
||||
"value = 0x%02x.", CMD_ARGV[0], uflash_addr, uflash_data);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -467,10 +467,10 @@ COMMAND_HANDLER(niietcm4_handle_uflash_write_byte_command)
|
||||
|
||||
int page_num = uflash_addr/USERFLASH_PAGE_SIZE;
|
||||
|
||||
command_print(CMD_CTX, "Write userflash %s region:\n"
|
||||
"address = 0x%04x,\n"
|
||||
"value = 0x%02x.\n"
|
||||
"Please wait ... ", CMD_ARGV[0], uflash_addr, uflash_data);
|
||||
command_print(CMD, "Write userflash %s region:\n"
|
||||
"address = 0x%04x,\n"
|
||||
"value = 0x%02x.\n"
|
||||
"Please wait ... ", CMD_ARGV[0], uflash_addr, uflash_data);
|
||||
/* dump */
|
||||
uint32_t uflash_dump[USERFLASH_PAGE_SIZE];
|
||||
niietcm4_dump_uflash_page(bank, uflash_dump, page_num, mem_type);
|
||||
@@ -483,7 +483,7 @@ COMMAND_HANDLER(niietcm4_handle_uflash_write_byte_command)
|
||||
|
||||
/* write dump to userflash */
|
||||
niietcm4_load_uflash_page(bank, uflash_dump, page_num, mem_type);
|
||||
command_print(CMD_CTX, "done!");
|
||||
command_print(CMD, "done!");
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -520,7 +520,7 @@ COMMAND_HANDLER(niietcm4_handle_uflash_full_erase_command)
|
||||
retval = niietcm4_uopstatus_check(bank);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
command_print(CMD_CTX, "Userflash full erase done!");
|
||||
command_print(CMD, "Userflash full erase done!");
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -563,7 +563,7 @@ COMMAND_HANDLER(niietcm4_handle_uflash_erase_command)
|
||||
return retval;
|
||||
}
|
||||
|
||||
command_print(CMD_CTX, "Erase %s userflash pages %d through %d done!", CMD_ARGV[0], first, last);
|
||||
command_print(CMD, "Erase %s userflash pages %d through %d done!", CMD_ARGV[0], first, last);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -621,9 +621,9 @@ COMMAND_HANDLER(niietcm4_handle_uflash_protect_check_command)
|
||||
return retval;
|
||||
|
||||
if (uflash_data & INFOWORD3_LOCK_IFB_UF)
|
||||
command_print(CMD_CTX, "All sectors of info userflash are not protected!");
|
||||
command_print(CMD, "All sectors of info userflash are not protected!");
|
||||
else
|
||||
command_print(CMD_CTX, "All sectors of info userflash are protected!");
|
||||
command_print(CMD, "All sectors of info userflash are protected!");
|
||||
} else {
|
||||
uflash_addr = UF_LOCK_ADDR;
|
||||
uflash_cmd = UFMC_MAGIC_KEY | UFMC_READ_IFB;
|
||||
@@ -645,10 +645,10 @@ COMMAND_HANDLER(niietcm4_handle_uflash_protect_check_command)
|
||||
|
||||
for (j = 0; j < 8; j++) {
|
||||
if (uflash_data & 0x1)
|
||||
command_print(CMD_CTX, "Userflash sector #%03d: 0x%04x (0x100) is not protected!",
|
||||
command_print(CMD, "Userflash sector #%03d: 0x%04x (0x100) is not protected!",
|
||||
i*8+j, (i*8+j)*USERFLASH_PAGE_SIZE);
|
||||
else
|
||||
command_print(CMD_CTX, "Userflash sector #%03d: 0x%04x (0x100) is protected!",
|
||||
command_print(CMD, "Userflash sector #%03d: 0x%04x (0x100) is protected!",
|
||||
i*8+j, (i*8+j)*USERFLASH_PAGE_SIZE);
|
||||
uflash_data = uflash_data >> 1;
|
||||
}
|
||||
@@ -693,11 +693,11 @@ COMMAND_HANDLER(niietcm4_handle_uflash_protect_command)
|
||||
|
||||
int set;
|
||||
if (strcmp("on", CMD_ARGV[3]) == 0) {
|
||||
command_print(CMD_CTX, "Try to enable %s userflash sectors %d through %d protection. Please wait ... ",
|
||||
command_print(CMD, "Try to enable %s userflash sectors %d through %d protection. Please wait ... ",
|
||||
CMD_ARGV[0], first, last);
|
||||
set = 1;
|
||||
} else if (strcmp("off", CMD_ARGV[3]) == 0) {
|
||||
command_print(CMD_CTX, "Try to disable %s userflash sectors %d through %d protection. Please wait ... ",
|
||||
command_print(CMD, "Try to disable %s userflash sectors %d through %d protection. Please wait ... ",
|
||||
CMD_ARGV[0], first, last);
|
||||
set = 0;
|
||||
} else
|
||||
@@ -707,7 +707,7 @@ COMMAND_HANDLER(niietcm4_handle_uflash_protect_command)
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
command_print(CMD_CTX, "done!");
|
||||
command_print(CMD, "done!");
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -733,10 +733,10 @@ COMMAND_HANDLER(niietcm4_handle_bflash_info_remap_command)
|
||||
|
||||
int set;
|
||||
if (strcmp("on", CMD_ARGV[0]) == 0) {
|
||||
command_print(CMD_CTX, "Try to enable bootflash info region remap. Please wait ...");
|
||||
command_print(CMD, "Try to enable bootflash info region remap. Please wait ...");
|
||||
set = 1;
|
||||
} else if (strcmp("off", CMD_ARGV[0]) == 0) {
|
||||
command_print(CMD_CTX, "Try to disable bootflash info region remap. Please wait ...");
|
||||
command_print(CMD, "Try to disable bootflash info region remap. Please wait ...");
|
||||
set = 0;
|
||||
} else
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
@@ -756,7 +756,7 @@ COMMAND_HANDLER(niietcm4_handle_bflash_info_remap_command)
|
||||
|
||||
/* write dump to userflash */
|
||||
niietcm4_load_uflash_page(bank, uflash_dump, 0, 1);
|
||||
command_print(CMD_CTX, "done!");
|
||||
command_print(CMD, "done!");
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -814,11 +814,11 @@ COMMAND_HANDLER(niietcm4_handle_extmem_cfg_command)
|
||||
else
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
|
||||
command_print(CMD_CTX, "Try to configure external memory boot interface:\n"
|
||||
"port = %s\n"
|
||||
"pin = %s\n"
|
||||
"func = %s\n"
|
||||
"Please wait ...", CMD_ARGV[0], CMD_ARGV[1], CMD_ARGV[2]);
|
||||
command_print(CMD, "Try to configure external memory boot interface:\n"
|
||||
"port = %s\n"
|
||||
"pin = %s\n"
|
||||
"func = %s\n"
|
||||
"Please wait ...", CMD_ARGV[0], CMD_ARGV[1], CMD_ARGV[2]);
|
||||
/* dump */
|
||||
uint32_t uflash_dump[USERFLASH_PAGE_SIZE];
|
||||
niietcm4_dump_uflash_page(bank, uflash_dump, 0, 1);
|
||||
@@ -833,7 +833,7 @@ COMMAND_HANDLER(niietcm4_handle_extmem_cfg_command)
|
||||
|
||||
/* write dump to userflash */
|
||||
niietcm4_load_uflash_page(bank, uflash_dump, 0, 1);
|
||||
command_print(CMD_CTX, "done!");
|
||||
command_print(CMD, "done!");
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -861,10 +861,10 @@ COMMAND_HANDLER(niietcm4_handle_extmem_boot_command)
|
||||
int set;
|
||||
|
||||
if (strcmp("on", CMD_ARGV[0]) == 0) {
|
||||
command_print(CMD_CTX, "Try to enable boot from external memory. Please wait ...");
|
||||
command_print(CMD, "Try to enable boot from external memory. Please wait ...");
|
||||
set = 1;
|
||||
} else if (strcmp("off", CMD_ARGV[0]) == 0) {
|
||||
command_print(CMD_CTX, "Try to disable boot from external memory. Please wait ...");
|
||||
command_print(CMD, "Try to disable boot from external memory. Please wait ...");
|
||||
set = 0;
|
||||
} else
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
@@ -884,7 +884,7 @@ COMMAND_HANDLER(niietcm4_handle_extmem_boot_command)
|
||||
|
||||
/* write dump to userflash */
|
||||
niietcm4_load_uflash_page(bank, uflash_dump, 0, 1);
|
||||
command_print(CMD_CTX, "done!");
|
||||
command_print(CMD, "done!");
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -900,7 +900,7 @@ COMMAND_HANDLER(niietcm4_handle_service_mode_erase_command)
|
||||
return retval;
|
||||
struct target *target = bank->target;
|
||||
|
||||
command_print(CMD_CTX, "Try to perform service mode erase. Please wait ...");
|
||||
command_print(CMD, "Try to perform service mode erase. Please wait ...");
|
||||
|
||||
retval = target_write_u32(target, SERVICE_MODE_ERASE_ADDR, 1);
|
||||
if (retval != ERROR_OK)
|
||||
@@ -923,7 +923,7 @@ COMMAND_HANDLER(niietcm4_handle_service_mode_erase_command)
|
||||
}
|
||||
busy_sleep(1); /* can use busy sleep for short times. */
|
||||
}
|
||||
command_print(CMD_CTX, "done! All data erased.");
|
||||
command_print(CMD, "done! All data erased.");
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -938,7 +938,7 @@ COMMAND_HANDLER(niietcm4_handle_driver_info_command)
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
command_print(CMD_CTX, "niietcm4 flash driver\n"
|
||||
command_print(CMD, "niietcm4 flash driver\n"
|
||||
"version: %d.%d\n"
|
||||
"author: Bogdan Kolbov\n"
|
||||
"mail: kolbov@niiet.ru",
|
||||
|
||||
@@ -1118,6 +1118,7 @@ static const struct command_registration nrf5_exec_command_handlers[] = {
|
||||
.handler = nrf5_handle_mass_erase_command,
|
||||
.mode = COMMAND_EXEC,
|
||||
.help = "Erase all flash contents of the chip.",
|
||||
.usage = "",
|
||||
},
|
||||
COMMAND_REGISTRATION_DONE
|
||||
};
|
||||
|
||||
@@ -1827,11 +1827,11 @@ COMMAND_HANDLER(numicro_handle_chip_erase_command)
|
||||
|
||||
retval = numicro_fmc_cmd(target, ISPCMD_CHIPERASE, 0, 0, &rdat);
|
||||
if (retval != ERROR_OK) {
|
||||
command_print(CMD_CTX, "numicro chip_erase failed");
|
||||
command_print(CMD, "numicro chip_erase failed");
|
||||
return retval;
|
||||
}
|
||||
|
||||
command_print(CMD_CTX, "numicro chip_erase complete");
|
||||
command_print(CMD, "numicro chip_erase complete");
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -1856,6 +1856,7 @@ static const struct command_registration numicro_exec_command_handlers[] = {
|
||||
.handler = numicro_handle_chip_erase_command,
|
||||
.mode = COMMAND_EXEC,
|
||||
.help = "chip erase through ISP.",
|
||||
.usage = "",
|
||||
},
|
||||
COMMAND_REGISTRATION_DONE
|
||||
};
|
||||
|
||||
@@ -858,7 +858,7 @@ COMMAND_HANDLER(pic32mx_handle_pgm_word_command)
|
||||
return retval;
|
||||
|
||||
if (address < bank->base || address >= (bank->base + bank->size)) {
|
||||
command_print(CMD_CTX, "flash address '%s' is out of bounds", CMD_ARGV[0]);
|
||||
command_print(CMD, "flash address '%s' is out of bounds", CMD_ARGV[0]);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -870,9 +870,9 @@ COMMAND_HANDLER(pic32mx_handle_pgm_word_command)
|
||||
res = ERROR_FLASH_OPERATION_FAILED;
|
||||
|
||||
if (res == ERROR_OK)
|
||||
command_print(CMD_CTX, "pic32mx pgm word complete");
|
||||
command_print(CMD, "pic32mx pgm word complete");
|
||||
else
|
||||
command_print(CMD_CTX, "pic32mx pgm word failed (status = 0x%x)", status);
|
||||
command_print(CMD, "pic32mx pgm word failed (status = 0x%x)", status);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -885,7 +885,7 @@ COMMAND_HANDLER(pic32mx_handle_unlock_command)
|
||||
int timeout = 10;
|
||||
|
||||
if (CMD_ARGC < 1) {
|
||||
command_print(CMD_CTX, "pic32mx unlock <bank>");
|
||||
command_print(CMD, "pic32mx unlock <bank>");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
@@ -907,7 +907,7 @@ COMMAND_HANDLER(pic32mx_handle_unlock_command)
|
||||
mips_ejtag_drscan_8(ejtag_info, &mchip_cmd);
|
||||
if (mchip_cmd & (1 << 7)) {
|
||||
/* device is not locked */
|
||||
command_print(CMD_CTX, "pic32mx is already unlocked, erasing anyway");
|
||||
command_print(CMD, "pic32mx is already unlocked, erasing anyway");
|
||||
}
|
||||
|
||||
/* unlock/erase device */
|
||||
@@ -931,7 +931,7 @@ COMMAND_HANDLER(pic32mx_handle_unlock_command)
|
||||
/* select ejtag tap */
|
||||
mips_ejtag_set_instr(ejtag_info, MTAP_SW_ETAP);
|
||||
|
||||
command_print(CMD_CTX, "pic32mx unlocked.\n"
|
||||
command_print(CMD, "pic32mx unlocked.\n"
|
||||
"INFO: a reset or power cycle is required "
|
||||
"for the new settings to take effect.");
|
||||
|
||||
|
||||
@@ -913,9 +913,9 @@ COMMAND_HANDLER(psoc4_handle_mass_erase_command)
|
||||
|
||||
retval = psoc4_mass_erase(bank);
|
||||
if (retval == ERROR_OK)
|
||||
command_print(CMD_CTX, "psoc mass erase complete");
|
||||
command_print(CMD, "psoc mass erase complete");
|
||||
else
|
||||
command_print(CMD_CTX, "psoc mass erase failed");
|
||||
command_print(CMD, "psoc mass erase failed");
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -1501,9 +1501,9 @@ COMMAND_HANDLER(psoc5lp_handle_mass_erase_command)
|
||||
|
||||
retval = psoc5lp_spc_erase_all(bank->target);
|
||||
if (retval == ERROR_OK)
|
||||
command_print(CMD_CTX, "PSoC 5LP erase succeeded");
|
||||
command_print(CMD, "PSoC 5LP erase succeeded");
|
||||
else
|
||||
command_print(CMD_CTX, "PSoC 5LP erase failed");
|
||||
command_print(CMD, "PSoC 5LP erase failed");
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -1336,9 +1336,9 @@ COMMAND_HANDLER(stellaris_handle_mass_erase_command)
|
||||
for (i = 0; i < bank->num_sectors; i++)
|
||||
bank->sectors[i].is_erased = 1;
|
||||
|
||||
command_print(CMD_CTX, "stellaris mass erase complete");
|
||||
command_print(CMD, "stellaris mass erase complete");
|
||||
} else
|
||||
command_print(CMD_CTX, "stellaris mass erase failed");
|
||||
command_print(CMD, "stellaris mass erase failed");
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
+20
-20
@@ -1186,7 +1186,7 @@ COMMAND_HANDLER(stm32x_handle_lock_command)
|
||||
return retval;
|
||||
|
||||
if (stm32x_erase_options(bank) != ERROR_OK) {
|
||||
command_print(CMD_CTX, "stm32x failed to erase options");
|
||||
command_print(CMD, "stm32x failed to erase options");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -1194,11 +1194,11 @@ COMMAND_HANDLER(stm32x_handle_lock_command)
|
||||
stm32x_info->option_bytes.rdp = 0;
|
||||
|
||||
if (stm32x_write_options(bank) != ERROR_OK) {
|
||||
command_print(CMD_CTX, "stm32x failed to lock device");
|
||||
command_print(CMD, "stm32x failed to lock device");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
command_print(CMD_CTX, "stm32x locked");
|
||||
command_print(CMD, "stm32x locked");
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -1227,16 +1227,16 @@ COMMAND_HANDLER(stm32x_handle_unlock_command)
|
||||
return retval;
|
||||
|
||||
if (stm32x_erase_options(bank) != ERROR_OK) {
|
||||
command_print(CMD_CTX, "stm32x failed to erase options");
|
||||
command_print(CMD, "stm32x failed to erase options");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
if (stm32x_write_options(bank) != ERROR_OK) {
|
||||
command_print(CMD_CTX, "stm32x failed to unlock device");
|
||||
command_print(CMD, "stm32x failed to unlock device");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
command_print(CMD_CTX, "stm32x unlocked.\n"
|
||||
command_print(CMD, "stm32x unlocked.\n"
|
||||
"INFO: a reset or power cycle is required "
|
||||
"for the new settings to take effect.");
|
||||
|
||||
@@ -1281,30 +1281,30 @@ COMMAND_HANDLER(stm32x_handle_options_read_command)
|
||||
return retval;
|
||||
|
||||
if (optionbyte & (1 << OPT_ERROR))
|
||||
command_print(CMD_CTX, "option byte complement error");
|
||||
command_print(CMD, "option byte complement error");
|
||||
|
||||
command_print(CMD_CTX, "option byte register = 0x%" PRIx32 "", optionbyte);
|
||||
command_print(CMD_CTX, "write protection register = 0x%" PRIx32 "", protection);
|
||||
command_print(CMD, "option byte register = 0x%" PRIx32 "", optionbyte);
|
||||
command_print(CMD, "write protection register = 0x%" PRIx32 "", protection);
|
||||
|
||||
command_print(CMD_CTX, "read protection: %s",
|
||||
command_print(CMD, "read protection: %s",
|
||||
(optionbyte & (1 << OPT_READOUT)) ? "on" : "off");
|
||||
|
||||
/* user option bytes are offset depending on variant */
|
||||
optionbyte >>= stm32x_info->option_offset;
|
||||
|
||||
command_print(CMD_CTX, "watchdog: %sware",
|
||||
command_print(CMD, "watchdog: %sware",
|
||||
(optionbyte & (1 << OPT_RDWDGSW)) ? "soft" : "hard");
|
||||
|
||||
command_print(CMD_CTX, "stop mode: %sreset generated upon entry",
|
||||
command_print(CMD, "stop mode: %sreset generated upon entry",
|
||||
(optionbyte & (1 << OPT_RDRSTSTOP)) ? "no " : "");
|
||||
|
||||
command_print(CMD_CTX, "standby mode: %sreset generated upon entry",
|
||||
command_print(CMD, "standby mode: %sreset generated upon entry",
|
||||
(optionbyte & (1 << OPT_RDRSTSTDBY)) ? "no " : "");
|
||||
|
||||
if (stm32x_info->has_dual_banks)
|
||||
command_print(CMD_CTX, "boot: bank %d", (optionbyte & (1 << OPT_BFB2)) ? 0 : 1);
|
||||
command_print(CMD, "boot: bank %d", (optionbyte & (1 << OPT_BFB2)) ? 0 : 1);
|
||||
|
||||
command_print(CMD_CTX, "user data = 0x%02" PRIx16 "", user_data);
|
||||
command_print(CMD, "user data = 0x%02" PRIx16 "", user_data);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -1383,7 +1383,7 @@ COMMAND_HANDLER(stm32x_handle_options_write_command)
|
||||
}
|
||||
|
||||
if (stm32x_erase_options(bank) != ERROR_OK) {
|
||||
command_print(CMD_CTX, "stm32x failed to erase options");
|
||||
command_print(CMD, "stm32x failed to erase options");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -1391,11 +1391,11 @@ COMMAND_HANDLER(stm32x_handle_options_write_command)
|
||||
stm32x_info->option_bytes.data = useropt;
|
||||
|
||||
if (stm32x_write_options(bank) != ERROR_OK) {
|
||||
command_print(CMD_CTX, "stm32x failed to write options");
|
||||
command_print(CMD, "stm32x failed to write options");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
command_print(CMD_CTX, "stm32x write options complete.\n"
|
||||
command_print(CMD, "stm32x write options complete.\n"
|
||||
"INFO: %spower cycle is required "
|
||||
"for the new settings to take effect.",
|
||||
stm32x_info->can_load_options
|
||||
@@ -1504,9 +1504,9 @@ COMMAND_HANDLER(stm32x_handle_mass_erase_command)
|
||||
for (i = 0; i < bank->num_sectors; i++)
|
||||
bank->sectors[i].is_erased = 1;
|
||||
|
||||
command_print(CMD_CTX, "stm32x mass erase complete");
|
||||
command_print(CMD, "stm32x mass erase complete");
|
||||
} else
|
||||
command_print(CMD_CTX, "stm32x mass erase failed");
|
||||
command_print(CMD, "stm32x mass erase failed");
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
+28
-28
@@ -1415,7 +1415,7 @@ COMMAND_HANDLER(stm32x_handle_lock_command)
|
||||
}
|
||||
|
||||
if (stm32x_read_options(bank) != ERROR_OK) {
|
||||
command_print(CMD_CTX, "%s failed to read options", bank->driver->name);
|
||||
command_print(CMD, "%s failed to read options", bank->driver->name);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -1423,11 +1423,11 @@ COMMAND_HANDLER(stm32x_handle_lock_command)
|
||||
stm32x_info->option_bytes.RDP = 0;
|
||||
|
||||
if (stm32x_write_options(bank) != ERROR_OK) {
|
||||
command_print(CMD_CTX, "%s failed to lock device", bank->driver->name);
|
||||
command_print(CMD, "%s failed to lock device", bank->driver->name);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
command_print(CMD_CTX, "%s locked", bank->driver->name);
|
||||
command_print(CMD, "%s locked", bank->driver->name);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -1454,7 +1454,7 @@ COMMAND_HANDLER(stm32x_handle_unlock_command)
|
||||
}
|
||||
|
||||
if (stm32x_read_options(bank) != ERROR_OK) {
|
||||
command_print(CMD_CTX, "%s failed to read options", bank->driver->name);
|
||||
command_print(CMD, "%s failed to read options", bank->driver->name);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -1466,11 +1466,11 @@ COMMAND_HANDLER(stm32x_handle_unlock_command)
|
||||
}
|
||||
|
||||
if (stm32x_write_options(bank) != ERROR_OK) {
|
||||
command_print(CMD_CTX, "%s failed to unlock device", bank->driver->name);
|
||||
command_print(CMD, "%s failed to unlock device", bank->driver->name);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
command_print(CMD_CTX, "%s unlocked.\n"
|
||||
command_print(CMD, "%s unlocked.\n"
|
||||
"INFO: a reset or power cycle is required "
|
||||
"for the new settings to take effect.", bank->driver->name);
|
||||
|
||||
@@ -1525,7 +1525,7 @@ COMMAND_HANDLER(stm32x_handle_mass_erase_command)
|
||||
int i;
|
||||
|
||||
if (CMD_ARGC < 1) {
|
||||
command_print(CMD_CTX, "stm32x mass_erase <bank>");
|
||||
command_print(CMD, "stm32x mass_erase <bank>");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
@@ -1540,9 +1540,9 @@ COMMAND_HANDLER(stm32x_handle_mass_erase_command)
|
||||
for (i = 0; i < bank->num_sectors; i++)
|
||||
bank->sectors[i].is_erased = 1;
|
||||
|
||||
command_print(CMD_CTX, "stm32x mass erase complete");
|
||||
command_print(CMD, "stm32x mass erase complete");
|
||||
} else {
|
||||
command_print(CMD_CTX, "stm32x mass erase failed");
|
||||
command_print(CMD, "stm32x mass erase failed");
|
||||
}
|
||||
|
||||
return retval;
|
||||
@@ -1555,7 +1555,7 @@ COMMAND_HANDLER(stm32f2x_handle_options_read_command)
|
||||
struct stm32x_flash_bank *stm32x_info = NULL;
|
||||
|
||||
if (CMD_ARGC != 1) {
|
||||
command_print(CMD_CTX, "stm32f2x options_read <bank>");
|
||||
command_print(CMD, "stm32f2x options_read <bank>");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
@@ -1572,20 +1572,20 @@ COMMAND_HANDLER(stm32f2x_handle_options_read_command)
|
||||
if (stm32x_info->has_boot_addr) {
|
||||
uint32_t boot_addr = stm32x_info->option_bytes.boot_addr;
|
||||
|
||||
command_print(CMD_CTX, "stm32f2x user_options 0x%03X,"
|
||||
command_print(CMD, "stm32f2x user_options 0x%03X,"
|
||||
" boot_add0 0x%04X, boot_add1 0x%04X",
|
||||
stm32x_info->option_bytes.user_options,
|
||||
boot_addr & 0xffff, (boot_addr & 0xffff0000) >> 16);
|
||||
if (stm32x_info->has_optcr2_pcrop) {
|
||||
command_print(CMD_CTX, "stm32f2x optcr2_pcrop 0x%08X",
|
||||
command_print(CMD, "stm32f2x optcr2_pcrop 0x%08X",
|
||||
stm32x_info->option_bytes.optcr2_pcrop);
|
||||
}
|
||||
} else {
|
||||
command_print(CMD_CTX, "stm32f2x user_options 0x%03X",
|
||||
command_print(CMD, "stm32f2x user_options 0x%03X",
|
||||
stm32x_info->option_bytes.user_options);
|
||||
}
|
||||
} else {
|
||||
command_print(CMD_CTX, "stm32f2x user_options 0x%02X",
|
||||
command_print(CMD, "stm32f2x user_options 0x%02X",
|
||||
stm32x_info->option_bytes.user_options);
|
||||
|
||||
}
|
||||
@@ -1601,7 +1601,7 @@ COMMAND_HANDLER(stm32f2x_handle_options_write_command)
|
||||
uint16_t user_options, boot_addr0, boot_addr1, options_mask;
|
||||
|
||||
if (CMD_ARGC < 1) {
|
||||
command_print(CMD_CTX, "stm32f2x options_write <bank> ...");
|
||||
command_print(CMD, "stm32f2x options_write <bank> ...");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
@@ -1616,7 +1616,7 @@ COMMAND_HANDLER(stm32f2x_handle_options_write_command)
|
||||
stm32x_info = bank->driver_priv;
|
||||
if (stm32x_info->has_boot_addr) {
|
||||
if (CMD_ARGC != 4) {
|
||||
command_print(CMD_CTX, "stm32f2x options_write <bank> <user_options>"
|
||||
command_print(CMD, "stm32f2x options_write <bank> <user_options>"
|
||||
" <boot_addr0> <boot_addr1>");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
@@ -1625,7 +1625,7 @@ COMMAND_HANDLER(stm32f2x_handle_options_write_command)
|
||||
stm32x_info->option_bytes.boot_addr = boot_addr0 | (((uint32_t) boot_addr1) << 16);
|
||||
} else {
|
||||
if (CMD_ARGC != 2) {
|
||||
command_print(CMD_CTX, "stm32f2x options_write <bank> <user_options>");
|
||||
command_print(CMD, "stm32f2x options_write <bank> <user_options>");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
}
|
||||
@@ -1634,14 +1634,14 @@ COMMAND_HANDLER(stm32f2x_handle_options_write_command)
|
||||
options_mask = !stm32x_info->has_extra_options ? ~0xfc :
|
||||
~(((0xf00 << (stm32x_info->protection_bits - 12)) | 0xff) & 0xffc);
|
||||
if (user_options & options_mask) {
|
||||
command_print(CMD_CTX, "stm32f2x invalid user_options");
|
||||
command_print(CMD, "stm32f2x invalid user_options");
|
||||
return ERROR_COMMAND_ARGUMENT_INVALID;
|
||||
}
|
||||
|
||||
stm32x_info->option_bytes.user_options = user_options;
|
||||
|
||||
if (stm32x_write_options(bank) != ERROR_OK) {
|
||||
command_print(CMD_CTX, "stm32f2x failed to write options");
|
||||
command_print(CMD, "stm32f2x failed to write options");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -1649,7 +1649,7 @@ COMMAND_HANDLER(stm32f2x_handle_options_write_command)
|
||||
/* ... and reprogramming of whole flash */
|
||||
stm32x_info->probed = false;
|
||||
|
||||
command_print(CMD_CTX, "stm32f2x write options complete.\n"
|
||||
command_print(CMD, "stm32f2x write options complete.\n"
|
||||
"INFO: a reset or power cycle is required "
|
||||
"for the new settings to take effect.");
|
||||
return retval;
|
||||
@@ -1663,7 +1663,7 @@ COMMAND_HANDLER(stm32f2x_handle_optcr2_write_command)
|
||||
uint32_t optcr2_pcrop;
|
||||
|
||||
if (CMD_ARGC != 2) {
|
||||
command_print(CMD_CTX, "stm32f2x optcr2_write <bank> <optcr2_value>");
|
||||
command_print(CMD, "stm32f2x optcr2_write <bank> <optcr2_value>");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
@@ -1673,11 +1673,11 @@ COMMAND_HANDLER(stm32f2x_handle_optcr2_write_command)
|
||||
|
||||
stm32x_info = bank->driver_priv;
|
||||
if (!stm32x_info->has_optcr2_pcrop) {
|
||||
command_print(CMD_CTX, "no optcr2 register");
|
||||
command_print(CMD, "no optcr2 register");
|
||||
return ERROR_COMMAND_ARGUMENT_INVALID;
|
||||
}
|
||||
|
||||
command_print(CMD_CTX, "INFO: To disable PCROP, set PCROP_RDP"
|
||||
command_print(CMD, "INFO: To disable PCROP, set PCROP_RDP"
|
||||
" with PCROPi bits STILL SET, then\nlock device and"
|
||||
" finally unlock it. Clears PCROP and mass erases flash.");
|
||||
|
||||
@@ -1689,18 +1689,18 @@ COMMAND_HANDLER(stm32f2x_handle_optcr2_write_command)
|
||||
stm32x_info->option_bytes.optcr2_pcrop = optcr2_pcrop;
|
||||
|
||||
if (stm32x_write_options(bank) != ERROR_OK) {
|
||||
command_print(CMD_CTX, "stm32f2x failed to write options");
|
||||
command_print(CMD, "stm32f2x failed to write options");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
command_print(CMD_CTX, "stm32f2x optcr2_write complete.");
|
||||
command_print(CMD, "stm32f2x optcr2_write complete.");
|
||||
return retval;
|
||||
}
|
||||
|
||||
COMMAND_HANDLER(stm32x_handle_otp_command)
|
||||
{
|
||||
if (CMD_ARGC < 2) {
|
||||
command_print(CMD_CTX, "stm32x otp <bank> (enable|disable|show)");
|
||||
command_print(CMD, "stm32x otp <bank> (enable|disable|show)");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
@@ -1714,7 +1714,7 @@ COMMAND_HANDLER(stm32x_handle_otp_command)
|
||||
} else if (strcmp(CMD_ARGV[1], "disable") == 0) {
|
||||
stm32x_otp_disable(bank);
|
||||
} else if (strcmp(CMD_ARGV[1], "show") == 0) {
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"OTP memory bank #%d is %s for write commands.",
|
||||
bank->bank_number,
|
||||
stm32x_is_otp_unlocked(bank) ? "enabled" : "disabled");
|
||||
@@ -1722,7 +1722,7 @@ COMMAND_HANDLER(stm32x_handle_otp_command)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
} else {
|
||||
command_print(CMD_CTX, "Failed: not an OTP bank.");
|
||||
command_print(CMD, "Failed: not an OTP bank.");
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
||||
+52
-52
@@ -38,18 +38,18 @@
|
||||
#define FLASH_SR 0x10
|
||||
#define FLASH_CCR 0x14
|
||||
#define FLASH_OPTCR 0x18
|
||||
#define FLASH_OPTCUR 0x1C
|
||||
#define FLASH_OPTPRG 0x20
|
||||
#define FLASH_OPTSR_CUR 0x1C
|
||||
#define FLASH_OPTSR_PRG 0x20
|
||||
#define FLASH_OPTCCR 0x24
|
||||
#define FLASH_WPSNCUR 0x38
|
||||
#define FLASH_WPSNPRG 0x3C
|
||||
#define FLASH_WPSN_CUR 0x38
|
||||
#define FLASH_WPSN_PRG 0x3C
|
||||
|
||||
|
||||
/* FLASH_CR register bits */
|
||||
#define FLASH_LOCK (1 << 0)
|
||||
#define FLASH_PG (1 << 1)
|
||||
#define FLASH_SER (1 << 2)
|
||||
#define FLASH_BER_CMD (1 << 3)
|
||||
#define FLASH_BER (1 << 3)
|
||||
#define FLASH_PSIZE_8 (0 << 4)
|
||||
#define FLASH_PSIZE_16 (1 << 4)
|
||||
#define FLASH_PSIZE_32 (2 << 4)
|
||||
@@ -61,6 +61,7 @@
|
||||
|
||||
/* FLASH_SR register bits */
|
||||
#define FLASH_BSY (1 << 0) /* Operation in progress */
|
||||
#define FLASH_QW (1 << 2) /* Operation queue in progress */
|
||||
#define FLASH_WRPERR (1 << 17) /* Write protection error */
|
||||
#define FLASH_PGSERR (1 << 18) /* Programming sequence error */
|
||||
#define FLASH_STRBERR (1 << 19) /* Strobe error */
|
||||
@@ -114,7 +115,6 @@ struct stm32h7x_part_info {
|
||||
const struct stm32h7x_rev *revs;
|
||||
size_t num_revs;
|
||||
unsigned int page_size;
|
||||
unsigned int pages_per_sector;
|
||||
uint16_t max_flash_size_kb;
|
||||
uint8_t has_dual_bank;
|
||||
uint16_t first_bank_size_kb; /* Used when has_dual_bank is true */
|
||||
@@ -132,7 +132,7 @@ struct stm32h7x_flash_bank {
|
||||
};
|
||||
|
||||
static const struct stm32h7x_rev stm32_450_revs[] = {
|
||||
{ 0x1000, "A" }, { 0x1001, "Z" }, { 0x1003, "Y" },
|
||||
{ 0x1000, "A" }, { 0x1001, "Z" }, { 0x1003, "Y" }, { 0x2001, "X" },
|
||||
};
|
||||
|
||||
static const struct stm32h7x_part_info stm32h7x_parts[] = {
|
||||
@@ -140,7 +140,7 @@ static const struct stm32h7x_part_info stm32h7x_parts[] = {
|
||||
.id = 0x450,
|
||||
.revs = stm32_450_revs,
|
||||
.num_revs = ARRAY_SIZE(stm32_450_revs),
|
||||
.device_str = "STM32H7xx 2M",
|
||||
.device_str = "STM32H74x/75x",
|
||||
.page_size = 128, /* 128 KB */
|
||||
.max_flash_size_kb = 2048,
|
||||
.first_bank_size_kb = 1024,
|
||||
@@ -184,33 +184,33 @@ static inline int stm32x_get_flash_status(struct flash_bank *bank, uint32_t *sta
|
||||
return target_read_u32(target, stm32x_get_flash_reg(bank, FLASH_SR), status);
|
||||
}
|
||||
|
||||
static int stm32x_wait_status_busy(struct flash_bank *bank, int timeout)
|
||||
static int stm32x_wait_flash_op_queue(struct flash_bank *bank, int timeout)
|
||||
{
|
||||
struct target *target = bank->target;
|
||||
struct stm32h7x_flash_bank *stm32x_info = bank->driver_priv;
|
||||
uint32_t status;
|
||||
int retval;
|
||||
|
||||
/* wait for busy to clear */
|
||||
/* wait for flash operations completion */
|
||||
for (;;) {
|
||||
retval = stm32x_get_flash_status(bank, &status);
|
||||
if (retval != ERROR_OK) {
|
||||
LOG_INFO("wait_status_busy, target_read_u32 : error : remote address 0x%x", stm32x_info->flash_base);
|
||||
LOG_INFO("wait_flash_op_queue, target_read_u32 : error : remote address 0x%x", stm32x_info->flash_base);
|
||||
return retval;
|
||||
}
|
||||
|
||||
if ((status & FLASH_BSY) == 0)
|
||||
if ((status & FLASH_QW) == 0)
|
||||
break;
|
||||
|
||||
if (timeout-- <= 0) {
|
||||
LOG_INFO("wait_status_busy, time out expired, status: 0x%" PRIx32 "", status);
|
||||
LOG_INFO("wait_flash_op_queue, time out expired, status: 0x%" PRIx32 "", status);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
alive_sleep(1);
|
||||
}
|
||||
|
||||
if (status & FLASH_WRPERR) {
|
||||
LOG_INFO("wait_status_busy, WRPERR : error : remote address 0x%x", stm32x_info->flash_base);
|
||||
LOG_INFO("wait_flash_op_queue, WRPERR : error : remote address 0x%x", stm32x_info->flash_base);
|
||||
retval = ERROR_FAIL;
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ static int stm32x_read_options(struct flash_bank *bank)
|
||||
stm32x_info = bank->driver_priv;
|
||||
|
||||
/* read current option bytes */
|
||||
int retval = target_read_u32(target, FLASH_REG_BASE_B0 + FLASH_OPTCUR, &optiondata);
|
||||
int retval = target_read_u32(target, FLASH_REG_BASE_B0 + FLASH_OPTSR_CUR, &optiondata);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
@@ -321,19 +321,19 @@ static int stm32x_read_options(struct flash_bank *bank)
|
||||
stm32x_info->option_bytes.user_options = optiondata & 0xfc;
|
||||
stm32x_info->option_bytes.RDP = (optiondata >> 8) & 0xff;
|
||||
stm32x_info->option_bytes.user2_options = (optiondata >> 16) & 0xff;
|
||||
stm32x_info->option_bytes.user3_options = (optiondata >> 24) & 0x83;
|
||||
stm32x_info->option_bytes.user3_options = (optiondata >> 24) & 0xa3;
|
||||
|
||||
if (stm32x_info->option_bytes.RDP != 0xAA)
|
||||
LOG_INFO("Device Security Bit Set");
|
||||
|
||||
/* read current WPSN option bytes */
|
||||
retval = target_read_u32(target, FLASH_REG_BASE_B0 + FLASH_WPSNCUR, &optiondata);
|
||||
retval = target_read_u32(target, FLASH_REG_BASE_B0 + FLASH_WPSN_CUR, &optiondata);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
stm32x_info->option_bytes.protection = optiondata & 0xff;
|
||||
|
||||
/* read current WPSN2 option bytes */
|
||||
retval = target_read_u32(target, FLASH_REG_BASE_B1 + FLASH_WPSNCUR, &optiondata);
|
||||
retval = target_read_u32(target, FLASH_REG_BASE_B1 + FLASH_WPSN_CUR, &optiondata);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
stm32x_info->option_bytes.protection2 = optiondata & 0xff;
|
||||
@@ -357,30 +357,30 @@ static int stm32x_write_options(struct flash_bank *bank)
|
||||
optiondata = stm32x_info->option_bytes.user_options;
|
||||
optiondata |= (stm32x_info->option_bytes.RDP << 8);
|
||||
optiondata |= (stm32x_info->option_bytes.user2_options & 0xff) << 16;
|
||||
optiondata |= (stm32x_info->option_bytes.user3_options & 0x83) << 24;
|
||||
optiondata |= (stm32x_info->option_bytes.user3_options & 0xa3) << 24;
|
||||
|
||||
/* program options */
|
||||
retval = target_write_u32(target, FLASH_REG_BASE_B0 + FLASH_OPTPRG, optiondata);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
retval = target_write_u32(target, FLASH_REG_BASE_B0 + FLASH_OPTSR_PRG, optiondata);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
optiondata = stm32x_info->option_bytes.protection & 0xff;
|
||||
/* Program protection WPSNPRG */
|
||||
retval = target_write_u32(target, FLASH_REG_BASE_B0 + FLASH_WPSNPRG, optiondata);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
retval = target_write_u32(target, FLASH_REG_BASE_B0 + FLASH_WPSN_PRG, optiondata);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
optiondata = stm32x_info->option_bytes.protection2 & 0xff;
|
||||
/* Program protection WPSNPRG2 */
|
||||
retval = target_write_u32(target, FLASH_REG_BASE_B1 + FLASH_WPSNPRG, optiondata);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
retval = target_write_u32(target, FLASH_REG_BASE_B1 + FLASH_WPSN_PRG, optiondata);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
optiondata = 0x40000000;
|
||||
/* Remove OPT error flag before programming */
|
||||
retval = target_write_u32(target, FLASH_REG_BASE_B0 + FLASH_OPTCCR, optiondata);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
/* start programming cycle */
|
||||
retval = target_write_u32(target, FLASH_REG_BASE_B0 + FLASH_OPTCR, OPT_START);
|
||||
@@ -393,14 +393,14 @@ static int stm32x_write_options(struct flash_bank *bank)
|
||||
uint32_t status;
|
||||
retval = target_read_u32(target, FLASH_REG_BASE_B0 + FLASH_SR, &status);
|
||||
if (retval != ERROR_OK) {
|
||||
LOG_INFO("stm32x_write_options: wait_status_busy : error");
|
||||
LOG_INFO("stm32x_write_options: wait_flash_op_queue : error");
|
||||
return retval;
|
||||
}
|
||||
if ((status & FLASH_BSY) == 0)
|
||||
if ((status & FLASH_QW) == 0)
|
||||
break;
|
||||
|
||||
if (timeout-- <= 0) {
|
||||
LOG_INFO("wait_status_busy, time out expired, status: 0x%" PRIx32 "", status);
|
||||
LOG_INFO("wait_flash_op_queue, time out expired, status: 0x%" PRIx32 "", status);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
alive_sleep(1);
|
||||
@@ -459,12 +459,12 @@ static int stm32x_erase(struct flash_bank *bank, int first, int last)
|
||||
/*
|
||||
Sector Erase
|
||||
To erase a sector, follow the procedure below:
|
||||
1. Check that no Flash memory operation is ongoing by checking the BSY bit in the
|
||||
1. Check that no Flash memory operation is ongoing by checking the QW bit in the
|
||||
FLASH_SR register
|
||||
2. Set the SER bit and select the sector
|
||||
you wish to erase (SNB) in the FLASH_CR register
|
||||
3. Set the STRT bit in the FLASH_CR register
|
||||
4. Wait for the BSY bit to be cleared
|
||||
4. Wait for flash operations completion
|
||||
*/
|
||||
for (int i = first; i <= last; i++) {
|
||||
LOG_DEBUG("erase sector %d", i);
|
||||
@@ -480,7 +480,7 @@ static int stm32x_erase(struct flash_bank *bank, int first, int last)
|
||||
LOG_ERROR("Error erase sector %d", i);
|
||||
return retval;
|
||||
}
|
||||
retval = stm32x_wait_status_busy(bank, FLASH_ERASE_TIMEOUT);
|
||||
retval = stm32x_wait_flash_op_queue(bank, FLASH_ERASE_TIMEOUT);
|
||||
|
||||
if (retval != ERROR_OK) {
|
||||
LOG_ERROR("erase time-out or operation error sector %d", i);
|
||||
@@ -687,11 +687,11 @@ static int stm32x_write(struct flash_bank *bank, const uint8_t *buffer,
|
||||
/*
|
||||
Standard programming
|
||||
The Flash memory programming sequence is as follows:
|
||||
1. Check that no main Flash memory operation is ongoing by checking the BSY bit in the
|
||||
1. Check that no main Flash memory operation is ongoing by checking the QW bit in the
|
||||
FLASH_SR register.
|
||||
2. Set the PG bit in the FLASH_CR register
|
||||
3. 8 x Word access (or Force Write FW)
|
||||
4. Wait for the BSY bit to be cleared
|
||||
4. Wait for flash operations completion
|
||||
*/
|
||||
while (blocks_remaining > 0) {
|
||||
retval = target_write_u32(target, stm32x_get_flash_reg(bank, FLASH_CR), FLASH_PG | FLASH_PSIZE_64);
|
||||
@@ -702,7 +702,7 @@ static int stm32x_write(struct flash_bank *bank, const uint8_t *buffer,
|
||||
if (retval != ERROR_OK)
|
||||
goto flash_lock;
|
||||
|
||||
retval = stm32x_wait_status_busy(bank, FLASH_WRITE_TIMEOUT);
|
||||
retval = stm32x_wait_flash_op_queue(bank, FLASH_WRITE_TIMEOUT);
|
||||
if (retval != ERROR_OK)
|
||||
goto flash_lock;
|
||||
|
||||
@@ -725,7 +725,7 @@ static int stm32x_write(struct flash_bank *bank, const uint8_t *buffer,
|
||||
if (retval != ERROR_OK)
|
||||
goto flash_lock;
|
||||
|
||||
retval = stm32x_wait_status_busy(bank, FLASH_WRITE_TIMEOUT);
|
||||
retval = stm32x_wait_flash_op_queue(bank, FLASH_WRITE_TIMEOUT);
|
||||
if (retval != ERROR_OK)
|
||||
goto flash_lock;
|
||||
}
|
||||
@@ -951,7 +951,7 @@ COMMAND_HANDLER(stm32x_handle_lock_command)
|
||||
}
|
||||
|
||||
if (stm32x_read_options(bank) != ERROR_OK) {
|
||||
command_print(CMD_CTX, "%s failed to read options",
|
||||
command_print(CMD, "%s failed to read options",
|
||||
bank->driver->name);
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -959,11 +959,11 @@ COMMAND_HANDLER(stm32x_handle_lock_command)
|
||||
stm32x_info->option_bytes.RDP = 0;
|
||||
|
||||
if (stm32x_write_options(bank) != ERROR_OK) {
|
||||
command_print(CMD_CTX, "%s failed to lock device",
|
||||
command_print(CMD, "%s failed to lock device",
|
||||
bank->driver->name);
|
||||
return ERROR_OK;
|
||||
}
|
||||
command_print(CMD_CTX, "%s locked", bank->driver->name);
|
||||
command_print(CMD, "%s locked", bank->driver->name);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -997,7 +997,7 @@ COMMAND_HANDLER(stm32x_handle_unlock_command)
|
||||
}
|
||||
|
||||
if (stm32x_read_options(bank) != ERROR_OK) {
|
||||
command_print(CMD_CTX, "%s failed to read options", bank->driver->name);
|
||||
command_print(CMD, "%s failed to read options", bank->driver->name);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -1006,10 +1006,10 @@ COMMAND_HANDLER(stm32x_handle_unlock_command)
|
||||
stm32x_info->option_bytes.RDP = 0xAA;
|
||||
|
||||
if (stm32x_write_options(bank) != ERROR_OK) {
|
||||
command_print(CMD_CTX, "%s failed to unlock device", bank->driver->name);
|
||||
command_print(CMD, "%s failed to unlock device", bank->driver->name);
|
||||
return ERROR_OK;
|
||||
}
|
||||
command_print(CMD_CTX, "%s unlocked.\n", bank->driver->name);
|
||||
command_print(CMD, "%s unlocked.\n", bank->driver->name);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -1029,16 +1029,16 @@ static int stm32x_mass_erase(struct flash_bank *bank)
|
||||
return retval;
|
||||
|
||||
/* mass erase flash memory bank */
|
||||
retval = target_write_u32(target, stm32x_get_flash_reg(bank, FLASH_CR), FLASH_BER_CMD | FLASH_PSIZE_64);
|
||||
retval = target_write_u32(target, stm32x_get_flash_reg(bank, FLASH_CR), FLASH_BER | FLASH_PSIZE_64);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
retval = target_write_u32(target, stm32x_get_flash_reg(bank, FLASH_CR),
|
||||
FLASH_BER_CMD | FLASH_PSIZE_64 | FLASH_START);
|
||||
FLASH_BER | FLASH_PSIZE_64 | FLASH_START);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
retval = stm32x_wait_status_busy(bank, 30000);
|
||||
retval = stm32x_wait_flash_op_queue(bank, 30000);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
@@ -1055,7 +1055,7 @@ COMMAND_HANDLER(stm32x_handle_mass_erase_command)
|
||||
int i;
|
||||
|
||||
if (CMD_ARGC < 1) {
|
||||
command_print(CMD_CTX, "stm32h7x mass_erase <bank>");
|
||||
command_print(CMD, "stm32h7x mass_erase <bank>");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
@@ -1070,9 +1070,9 @@ COMMAND_HANDLER(stm32x_handle_mass_erase_command)
|
||||
for (i = 0; i < bank->num_sectors; i++)
|
||||
bank->sectors[i].is_erased = 1;
|
||||
|
||||
command_print(CMD_CTX, "stm32h7x mass erase complete");
|
||||
command_print(CMD, "stm32h7x mass erase complete");
|
||||
} else {
|
||||
command_print(CMD_CTX, "stm32h7x mass erase failed");
|
||||
command_print(CMD, "stm32h7x mass erase failed");
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
||||
+10
-10
@@ -835,7 +835,7 @@ COMMAND_HANDLER(stm32l4_handle_mass_erase_command)
|
||||
uint32_t action;
|
||||
|
||||
if (CMD_ARGC < 1) {
|
||||
command_print(CMD_CTX, "stm32l4x mass_erase <STM32L4 bank>");
|
||||
command_print(CMD, "stm32l4x mass_erase <STM32L4 bank>");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
@@ -851,9 +851,9 @@ COMMAND_HANDLER(stm32l4_handle_mass_erase_command)
|
||||
for (i = 0; i < bank->num_sectors; i++)
|
||||
bank->sectors[i].is_erased = 1;
|
||||
|
||||
command_print(CMD_CTX, "stm32l4x mass erase complete");
|
||||
command_print(CMD, "stm32l4x mass erase complete");
|
||||
} else {
|
||||
command_print(CMD_CTX, "stm32l4x mass erase failed");
|
||||
command_print(CMD, "stm32l4x mass erase failed");
|
||||
}
|
||||
|
||||
return retval;
|
||||
@@ -862,7 +862,7 @@ COMMAND_HANDLER(stm32l4_handle_mass_erase_command)
|
||||
COMMAND_HANDLER(stm32l4_handle_option_read_command)
|
||||
{
|
||||
if (CMD_ARGC < 2) {
|
||||
command_print(CMD_CTX, "stm32l4x option_read <STM32L4 bank> <option_reg offset>");
|
||||
command_print(CMD, "stm32l4x option_read <STM32L4 bank> <option_reg offset>");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
@@ -880,7 +880,7 @@ COMMAND_HANDLER(stm32l4_handle_option_read_command)
|
||||
if (ERROR_OK != retval)
|
||||
return retval;
|
||||
|
||||
command_print(CMD_CTX, "Option Register: <0x%" PRIx32 "> = 0x%" PRIx32 "", reg_addr, value);
|
||||
command_print(CMD, "Option Register: <0x%" PRIx32 "> = 0x%" PRIx32 "", reg_addr, value);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -888,7 +888,7 @@ COMMAND_HANDLER(stm32l4_handle_option_read_command)
|
||||
COMMAND_HANDLER(stm32l4_handle_option_write_command)
|
||||
{
|
||||
if (CMD_ARGC < 3) {
|
||||
command_print(CMD_CTX, "stm32l4x option_write <STM32L4 bank> <option_reg offset> <value> [mask]");
|
||||
command_print(CMD, "stm32l4x option_write <STM32L4 bank> <option_reg offset> <value> [mask]");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
@@ -906,7 +906,7 @@ COMMAND_HANDLER(stm32l4_handle_option_write_command)
|
||||
if (CMD_ARGC > 3)
|
||||
mask = strtoul(CMD_ARGV[3], NULL, 16);
|
||||
|
||||
command_print(CMD_CTX, "%s Option written.\n"
|
||||
command_print(CMD, "%s Option written.\n"
|
||||
"INFO: a reset or power cycle is required "
|
||||
"for the new settings to take effect.", bank->driver->name);
|
||||
|
||||
@@ -937,7 +937,7 @@ COMMAND_HANDLER(stm32l4_handle_option_load_command)
|
||||
/* Write the OBLLAUNCH bit in CR -> Cause device "POR" and option bytes reload */
|
||||
retval = target_write_u32(target, stm32l4_get_flash_reg(bank, STM32_FLASH_CR), FLASH_OBLLAUNCH);
|
||||
|
||||
command_print(CMD_CTX, "stm32l4x option load (POR) completed.");
|
||||
command_print(CMD, "stm32l4x option load (POR) completed.");
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -962,7 +962,7 @@ COMMAND_HANDLER(stm32l4_handle_lock_command)
|
||||
|
||||
/* set readout protection level 1 by erasing the RDP option byte */
|
||||
if (stm32l4_write_option(bank, STM32_FLASH_OPTR, 0, 0x000000FF) != ERROR_OK) {
|
||||
command_print(CMD_CTX, "%s failed to lock device", bank->driver->name);
|
||||
command_print(CMD, "%s failed to lock device", bank->driver->name);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -989,7 +989,7 @@ COMMAND_HANDLER(stm32l4_handle_unlock_command)
|
||||
}
|
||||
|
||||
if (stm32l4_write_option(bank, STM32_FLASH_OPTR, RDP_LEVEL_0, 0x000000FF) != ERROR_OK) {
|
||||
command_print(CMD_CTX, "%s failed to unlock device", bank->driver->name);
|
||||
command_print(CMD, "%s failed to unlock device", bank->driver->name);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -324,9 +324,9 @@ COMMAND_HANDLER(stm32lx_handle_mass_erase_command)
|
||||
for (i = 0; i < bank->num_sectors; i++)
|
||||
bank->sectors[i].is_erased = 1;
|
||||
|
||||
command_print(CMD_CTX, "stm32lx mass erase complete");
|
||||
command_print(CMD, "stm32lx mass erase complete");
|
||||
} else {
|
||||
command_print(CMD_CTX, "stm32lx mass erase failed");
|
||||
command_print(CMD, "stm32lx mass erase failed");
|
||||
}
|
||||
|
||||
return retval;
|
||||
@@ -345,9 +345,9 @@ COMMAND_HANDLER(stm32lx_handle_lock_command)
|
||||
retval = stm32lx_lock(bank);
|
||||
|
||||
if (retval == ERROR_OK)
|
||||
command_print(CMD_CTX, "STM32Lx locked, takes effect after power cycle.");
|
||||
command_print(CMD, "STM32Lx locked, takes effect after power cycle.");
|
||||
else
|
||||
command_print(CMD_CTX, "STM32Lx lock failed");
|
||||
command_print(CMD, "STM32Lx lock failed");
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -365,9 +365,9 @@ COMMAND_HANDLER(stm32lx_handle_unlock_command)
|
||||
retval = stm32lx_unlock(bank);
|
||||
|
||||
if (retval == ERROR_OK)
|
||||
command_print(CMD_CTX, "STM32Lx unlocked, takes effect after power cycle.");
|
||||
command_print(CMD, "STM32Lx unlocked, takes effect after power cycle.");
|
||||
else
|
||||
command_print(CMD_CTX, "STM32Lx unlock failed");
|
||||
command_print(CMD, "STM32Lx unlock failed");
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
+18
-17
@@ -746,7 +746,7 @@ COMMAND_HANDLER(str9xpec_handle_part_id_command)
|
||||
|
||||
idcode = buf_get_u32(buffer, 0, 32);
|
||||
|
||||
command_print(CMD_CTX, "str9xpec part id: 0x%8.8" PRIx32 "", idcode);
|
||||
command_print(CMD, "str9xpec part id: 0x%8.8" PRIx32 "", idcode);
|
||||
|
||||
free(buffer);
|
||||
|
||||
@@ -780,33 +780,33 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_read_command)
|
||||
|
||||
/* boot bank */
|
||||
if (buf_get_u32(str9xpec_info->options, STR9XPEC_OPT_CSMAPBIT, 1))
|
||||
command_print(CMD_CTX, "CS Map: bank1");
|
||||
command_print(CMD, "CS Map: bank1");
|
||||
else
|
||||
command_print(CMD_CTX, "CS Map: bank0");
|
||||
command_print(CMD, "CS Map: bank0");
|
||||
|
||||
/* OTP lock */
|
||||
if (buf_get_u32(str9xpec_info->options, STR9XPEC_OPT_OTPBIT, 1))
|
||||
command_print(CMD_CTX, "OTP Lock: OTP Locked");
|
||||
command_print(CMD, "OTP Lock: OTP Locked");
|
||||
else
|
||||
command_print(CMD_CTX, "OTP Lock: OTP Unlocked");
|
||||
command_print(CMD, "OTP Lock: OTP Unlocked");
|
||||
|
||||
/* LVD Threshold */
|
||||
if (buf_get_u32(str9xpec_info->options, STR9XPEC_OPT_LVDTHRESBIT, 1))
|
||||
command_print(CMD_CTX, "LVD Threshold: 2.7v");
|
||||
command_print(CMD, "LVD Threshold: 2.7v");
|
||||
else
|
||||
command_print(CMD_CTX, "LVD Threshold: 2.4v");
|
||||
command_print(CMD, "LVD Threshold: 2.4v");
|
||||
|
||||
/* LVD reset warning */
|
||||
if (buf_get_u32(str9xpec_info->options, STR9XPEC_OPT_LVDWARNBIT, 1))
|
||||
command_print(CMD_CTX, "LVD Reset Warning: VDD or VDDQ Inputs");
|
||||
command_print(CMD, "LVD Reset Warning: VDD or VDDQ Inputs");
|
||||
else
|
||||
command_print(CMD_CTX, "LVD Reset Warning: VDD Input Only");
|
||||
command_print(CMD, "LVD Reset Warning: VDD Input Only");
|
||||
|
||||
/* LVD reset select */
|
||||
if (buf_get_u32(str9xpec_info->options, STR9XPEC_OPT_LVDSELBIT, 1))
|
||||
command_print(CMD_CTX, "LVD Reset Selection: VDD or VDDQ Inputs");
|
||||
command_print(CMD, "LVD Reset Selection: VDD or VDDQ Inputs");
|
||||
else
|
||||
command_print(CMD_CTX, "LVD Reset Selection: VDD Input Only");
|
||||
command_print(CMD, "LVD Reset Selection: VDD Input Only");
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -885,7 +885,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_write_command)
|
||||
if ((status & ISC_STATUS_ERROR) != STR9XPEC_ISC_SUCCESS)
|
||||
return ERROR_FLASH_OPERATION_FAILED;
|
||||
|
||||
command_print(CMD_CTX, "str9xpec write options complete.\n"
|
||||
command_print(CMD, "str9xpec write options complete.\n"
|
||||
"INFO: a reset or power cycle is required "
|
||||
"for the new settings to take effect.");
|
||||
|
||||
@@ -1017,7 +1017,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_unlock_command)
|
||||
if ((status & ISC_STATUS_ERROR) != STR9XPEC_ISC_SUCCESS)
|
||||
return ERROR_FLASH_OPERATION_FAILED;
|
||||
|
||||
command_print(CMD_CTX, "str9xpec unlocked.\n"
|
||||
command_print(CMD, "str9xpec unlocked.\n"
|
||||
"INFO: a reset or power cycle is required "
|
||||
"for the new settings to take effect.");
|
||||
|
||||
@@ -1045,19 +1045,19 @@ COMMAND_HANDLER(str9xpec_handle_flash_enable_turbo_command)
|
||||
tap0 = str9xpec_info->tap;
|
||||
if (tap0 == NULL) {
|
||||
/* things are *WRONG* */
|
||||
command_print(CMD_CTX, "**STR9FLASH** (tap0) invalid chain?");
|
||||
command_print(CMD, "**STR9FLASH** (tap0) invalid chain?");
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
tap1 = tap0->next_tap;
|
||||
if (tap1 == NULL) {
|
||||
/* things are *WRONG* */
|
||||
command_print(CMD_CTX, "**STR9FLASH** (tap1) invalid chain?");
|
||||
command_print(CMD, "**STR9FLASH** (tap1) invalid chain?");
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
tap2 = tap1->next_tap;
|
||||
if (tap2 == NULL) {
|
||||
/* things are *WRONG* */
|
||||
command_print(CMD_CTX, "**STR9FLASH** (tap2) invalid chain?");
|
||||
command_print(CMD, "**STR9FLASH** (tap2) invalid chain?");
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
@@ -1177,9 +1177,10 @@ static const struct command_registration str9xpec_config_command_handlers[] = {
|
||||
},
|
||||
{
|
||||
.name = "part_id",
|
||||
.usage = "<bank>",
|
||||
.handler = str9xpec_handle_part_id_command,
|
||||
.mode = COMMAND_EXEC,
|
||||
.help = "print part id of str9xpec flash bank <num>",
|
||||
.help = "print part id of str9xpec flash bank",
|
||||
},
|
||||
COMMAND_REGISTRATION_DONE
|
||||
};
|
||||
|
||||
@@ -0,0 +1,211 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2019 Icenowy Zheng <icenowy@aosc.io> *
|
||||
* Copyright (C) 2019 Caleb Szalacinski <contact@skiboy.net> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "imp.h"
|
||||
#include <target/image.h>
|
||||
|
||||
#define SWM050_DELAY 100
|
||||
|
||||
#define SWM050_FLASH_PAGE_SIZE 0x200
|
||||
#define SWM050_FLASH_PAGES 16
|
||||
|
||||
#define SWM050_CPU_ID 0xE000ED00
|
||||
#define SWM050_CPU_ID_VAL 0x410CC200
|
||||
|
||||
#define SWM050_FLASH_REG1 0x1F000000
|
||||
#define SWM050_FLASH_REG2 0x1F000038
|
||||
#define SWM050_FLASH_KEY 0xAAAAAAAA
|
||||
|
||||
#define SWM050_SYSCTL_CFG_0 0x400F0000
|
||||
#define SWM050_SYSCTL_DBLF 0x400F0008
|
||||
|
||||
static int swm050_erase(struct flash_bank *bank, int first, int last)
|
||||
{
|
||||
struct target *target = bank->target;
|
||||
int retval, curr_page;
|
||||
uint32_t curr_addr;
|
||||
|
||||
if (target->state != TARGET_HALTED) {
|
||||
LOG_ERROR("Target not halted");
|
||||
return ERROR_TARGET_NOT_HALTED;
|
||||
}
|
||||
|
||||
/* Perform erase */
|
||||
retval = target_write_u32(target, SWM050_FLASH_REG1, 0x4);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
for (curr_page = first; curr_page <= last; curr_page++) {
|
||||
curr_addr = bank->base + (SWM050_FLASH_PAGE_SIZE * curr_page);
|
||||
/* Perform write */
|
||||
retval = target_write_u32(target, curr_addr, SWM050_FLASH_KEY);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
alive_sleep(SWM050_DELAY);
|
||||
}
|
||||
|
||||
/* Close flash interface */
|
||||
retval = target_write_u32(target, SWM050_FLASH_REG1, 0x0);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static int swm050_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
|
||||
{
|
||||
struct target *target = bank->target;
|
||||
int retval;
|
||||
|
||||
if (target->state != TARGET_HALTED) {
|
||||
LOG_ERROR("Target not halted");
|
||||
retval = ERROR_TARGET_NOT_HALTED;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Perform write */
|
||||
retval = target_write_u32(target, SWM050_FLASH_REG1, 0x1);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
retval = target_write_memory(target, bank->base + offset, 4, count/4, buffer);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
/* Close flash interface */
|
||||
retval = target_write_u32(target, SWM050_FLASH_REG1, 0x0);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static int swm050_probe(struct flash_bank *bank)
|
||||
{
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static int swm050_mass_erase(struct flash_bank *bank)
|
||||
{
|
||||
struct target *target = bank->target;
|
||||
int retval;
|
||||
|
||||
if (target->state != TARGET_HALTED) {
|
||||
LOG_ERROR("Target not halted");
|
||||
return ERROR_TARGET_NOT_HALTED;
|
||||
}
|
||||
|
||||
/* Perform mass erase */
|
||||
retval = target_write_u32(target, SWM050_FLASH_REG1, 0x6);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
retval = target_write_u32(target, SWM050_FLASH_REG2, 0x1);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
retval = target_write_u32(target, 0x0, SWM050_FLASH_KEY);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
alive_sleep(SWM050_DELAY);
|
||||
|
||||
/* Close flash interface */
|
||||
retval = target_write_u32(target, SWM050_FLASH_REG1, 0x0);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
COMMAND_HANDLER(swm050_handle_mass_erase_command)
|
||||
{
|
||||
if (CMD_ARGC < 1)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
|
||||
struct flash_bank *bank;
|
||||
int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
|
||||
if (ERROR_OK != retval)
|
||||
return retval;
|
||||
|
||||
retval = swm050_mass_erase(bank);
|
||||
if (retval == ERROR_OK)
|
||||
command_print(CMD, "swm050 mass erase complete");
|
||||
else
|
||||
command_print(CMD, "swm050 mass erase failed");
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
FLASH_BANK_COMMAND_HANDLER(swm050_flash_bank_command)
|
||||
{
|
||||
if (bank->sectors) {
|
||||
free(bank->sectors);
|
||||
bank->sectors = NULL;
|
||||
}
|
||||
bank->write_start_alignment = 4;
|
||||
bank->write_end_alignment = 4;
|
||||
bank->size = SWM050_FLASH_PAGE_SIZE * SWM050_FLASH_PAGES;
|
||||
|
||||
bank->num_sectors = SWM050_FLASH_PAGES;
|
||||
bank->sectors = alloc_block_array(0, SWM050_FLASH_PAGE_SIZE, SWM050_FLASH_PAGES);
|
||||
if (!bank->sectors)
|
||||
return ERROR_FAIL;
|
||||
|
||||
for (int i = 0; i < bank->num_sectors; i++)
|
||||
bank->sectors[i].is_protected = 0;
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static const struct command_registration swm050_exec_command_handlers[] = {
|
||||
{
|
||||
.name = "mass_erase",
|
||||
.handler = swm050_handle_mass_erase_command,
|
||||
.mode = COMMAND_EXEC,
|
||||
.usage = "bank_id",
|
||||
.help = "Erase entire flash device.",
|
||||
},
|
||||
COMMAND_REGISTRATION_DONE
|
||||
};
|
||||
|
||||
static const struct command_registration swm050_command_handlers[] = {
|
||||
{
|
||||
.name = "swm050",
|
||||
.mode = COMMAND_ANY,
|
||||
.help = "swm050 flash command group",
|
||||
.usage = "",
|
||||
.chain = swm050_exec_command_handlers,
|
||||
},
|
||||
COMMAND_REGISTRATION_DONE
|
||||
};
|
||||
|
||||
struct flash_driver swm050_flash = {
|
||||
.name = "swm050",
|
||||
.commands = swm050_command_handlers,
|
||||
.flash_bank_command = swm050_flash_bank_command,
|
||||
.erase = swm050_erase,
|
||||
.write = swm050_write,
|
||||
.read = default_flash_read,
|
||||
.probe = swm050_probe,
|
||||
.auto_probe = swm050_probe,
|
||||
.erase_check = default_flash_blank_check,
|
||||
.free_driver_priv = default_flash_free_driver_priv,
|
||||
};
|
||||
+33
-30
@@ -111,7 +111,7 @@ COMMAND_HANDLER(handle_flash_info_command)
|
||||
if (retval == ERROR_FLASH_OPER_UNSUPPORTED)
|
||||
LOG_WARNING("Flash protection check is not implemented.");
|
||||
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"#%d : %s at " TARGET_ADDR_FMT ", size 0x%8.8" PRIx32
|
||||
", buswidth %i, chipwidth %i",
|
||||
p->bank_number,
|
||||
@@ -140,7 +140,7 @@ COMMAND_HANDLER(handle_flash_info_command)
|
||||
else if (!show_sectors || !prot_block_available)
|
||||
protect_state = "protection state unknown";
|
||||
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"\t#%3i: 0x%8.8" PRIx32 " (0x%" PRIx32 " %" PRIi32 "kB) %s",
|
||||
j,
|
||||
block_array[j].offset,
|
||||
@@ -152,7 +152,7 @@ COMMAND_HANDLER(handle_flash_info_command)
|
||||
if (p->driver->info != NULL) {
|
||||
retval = p->driver->info(p, buf, sizeof(buf));
|
||||
if (retval == ERROR_OK)
|
||||
command_print(CMD_CTX, "%s", buf);
|
||||
command_print(CMD, "%s", buf);
|
||||
else
|
||||
LOG_ERROR("error retrieving flash info");
|
||||
}
|
||||
@@ -176,12 +176,12 @@ COMMAND_HANDLER(handle_flash_probe_command)
|
||||
if (p) {
|
||||
retval = p->driver->probe(p);
|
||||
if (retval == ERROR_OK)
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"flash '%s' found at " TARGET_ADDR_FMT,
|
||||
p->driver->name,
|
||||
p->base);
|
||||
} else {
|
||||
command_print(CMD_CTX, "flash bank '#%s' is out of bounds", CMD_ARGV[0]);
|
||||
command_print(CMD, "flash bank '#%s' is out of bounds", CMD_ARGV[0]);
|
||||
retval = ERROR_FAIL;
|
||||
}
|
||||
|
||||
@@ -202,9 +202,9 @@ COMMAND_HANDLER(handle_flash_erase_check_command)
|
||||
int j;
|
||||
retval = p->driver->erase_check(p);
|
||||
if (retval == ERROR_OK)
|
||||
command_print(CMD_CTX, "successfully checked erase state");
|
||||
command_print(CMD, "successfully checked erase state");
|
||||
else {
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"unknown error when checking erase state of flash bank #%s at "
|
||||
TARGET_ADDR_FMT,
|
||||
CMD_ARGV[0],
|
||||
@@ -222,7 +222,7 @@ COMMAND_HANDLER(handle_flash_erase_check_command)
|
||||
erase_state = "erase state unknown";
|
||||
|
||||
blank = false;
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"\t#%3i: 0x%8.8" PRIx32 " (0x%" PRIx32 " %" PRIi32 "kB) %s",
|
||||
j,
|
||||
p->sectors[j].offset,
|
||||
@@ -232,7 +232,7 @@ COMMAND_HANDLER(handle_flash_erase_check_command)
|
||||
}
|
||||
|
||||
if (blank)
|
||||
command_print(CMD_CTX, "\tBank is erased");
|
||||
command_print(CMD, "\tBank is erased");
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ COMMAND_HANDLER(handle_flash_erase_address_command)
|
||||
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], length);
|
||||
|
||||
if (length <= 0) {
|
||||
command_print(CMD_CTX, "Length must be >0");
|
||||
command_print(CMD, "Length must be >0");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ COMMAND_HANDLER(handle_flash_erase_address_command)
|
||||
retval = flash_erase_address_range(target, do_pad, address, length);
|
||||
|
||||
if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK)) {
|
||||
command_print(CMD_CTX, "erased address " TARGET_ADDR_FMT " (length %"
|
||||
command_print(CMD, "erased address " TARGET_ADDR_FMT " (length %"
|
||||
PRIi32 ")"
|
||||
" in %fs (%0.3f KiB/s)", address, length,
|
||||
duration_elapsed(&bench), duration_kbps(&bench, length));
|
||||
@@ -320,13 +320,13 @@ COMMAND_HANDLER(handle_flash_erase_command)
|
||||
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], last);
|
||||
|
||||
if (!(first <= last)) {
|
||||
command_print(CMD_CTX, "ERROR: "
|
||||
command_print(CMD, "ERROR: "
|
||||
"first sector must be <= last");
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
if (!(last <= (uint32_t)(p->num_sectors - 1))) {
|
||||
command_print(CMD_CTX, "ERROR: "
|
||||
command_print(CMD, "ERROR: "
|
||||
"last sector must be <= %" PRIu32,
|
||||
p->num_sectors - 1);
|
||||
return ERROR_FAIL;
|
||||
@@ -338,7 +338,7 @@ COMMAND_HANDLER(handle_flash_erase_command)
|
||||
retval = flash_driver_erase(p, first, last);
|
||||
|
||||
if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK)) {
|
||||
command_print(CMD_CTX, "erased sectors %" PRIu32 " "
|
||||
command_print(CMD, "erased sectors %" PRIu32 " "
|
||||
"through %" PRIu32 " on flash bank %d "
|
||||
"in %fs", first, last, p->bank_number, duration_elapsed(&bench));
|
||||
}
|
||||
@@ -377,14 +377,14 @@ COMMAND_HANDLER(handle_flash_protect_command)
|
||||
COMMAND_PARSE_ON_OFF(CMD_ARGV[3], set);
|
||||
|
||||
if (!(first <= last)) {
|
||||
command_print(CMD_CTX, "ERROR: "
|
||||
command_print(CMD, "ERROR: "
|
||||
"first %s must be <= last",
|
||||
(p->num_prot_blocks) ? "block" : "sector");
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
if (!(last <= (uint32_t)(num_blocks - 1))) {
|
||||
command_print(CMD_CTX, "ERROR: "
|
||||
command_print(CMD, "ERROR: "
|
||||
"last %s must be <= %" PRIu32,
|
||||
(p->num_prot_blocks) ? "block" : "sector",
|
||||
num_blocks - 1);
|
||||
@@ -393,7 +393,7 @@ COMMAND_HANDLER(handle_flash_protect_command)
|
||||
|
||||
retval = flash_driver_protect(p, set, first, last);
|
||||
if (retval == ERROR_OK) {
|
||||
command_print(CMD_CTX, "%s protection for %s %" PRIu32
|
||||
command_print(CMD, "%s protection for %s %" PRIu32
|
||||
" through %" PRIu32 " on flash bank %d",
|
||||
(set) ? "set" : "cleared",
|
||||
(p->num_prot_blocks) ? "blocks" : "sectors",
|
||||
@@ -421,12 +421,12 @@ COMMAND_HANDLER(handle_flash_write_image_command)
|
||||
auto_erase = 1;
|
||||
CMD_ARGV++;
|
||||
CMD_ARGC--;
|
||||
command_print(CMD_CTX, "auto erase enabled");
|
||||
command_print(CMD, "auto erase enabled");
|
||||
} else if (strcmp(CMD_ARGV[0], "unlock") == 0) {
|
||||
auto_unlock = true;
|
||||
CMD_ARGV++;
|
||||
CMD_ARGC--;
|
||||
command_print(CMD_CTX, "auto unlock enabled");
|
||||
command_print(CMD, "auto unlock enabled");
|
||||
} else
|
||||
break;
|
||||
}
|
||||
@@ -463,7 +463,7 @@ COMMAND_HANDLER(handle_flash_write_image_command)
|
||||
}
|
||||
|
||||
if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK)) {
|
||||
command_print(CMD_CTX, "wrote %" PRIu32 " bytes from file %s "
|
||||
command_print(CMD, "wrote %" PRIu32 " bytes from file %s "
|
||||
"in %fs (%0.3f KiB/s)", written, CMD_ARGV[0],
|
||||
duration_elapsed(&bench), duration_kbps(&bench, written));
|
||||
}
|
||||
@@ -602,7 +602,7 @@ COMMAND_HANDLER(handle_flash_fill_command)
|
||||
}
|
||||
|
||||
if ((retval == ERROR_OK) && (duration_measure(&bench) == ERROR_OK)) {
|
||||
command_print(CMD_CTX, "wrote %" PRIu32 " bytes to " TARGET_ADDR_FMT
|
||||
command_print(CMD, "wrote %" PRIu32 " bytes to " TARGET_ADDR_FMT
|
||||
" in %fs (%0.3f KiB/s)", size_bytes, address,
|
||||
duration_elapsed(&bench), duration_kbps(&bench, size_bytes));
|
||||
}
|
||||
@@ -716,7 +716,7 @@ COMMAND_HANDLER(handle_flash_write_bank_command)
|
||||
free(buffer);
|
||||
|
||||
if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK)) {
|
||||
command_print(CMD_CTX, "wrote %zu bytes from file %s to flash bank %u"
|
||||
command_print(CMD, "wrote %zu bytes from file %s to flash bank %u"
|
||||
" at offset 0x%8.8" PRIx32 " in %fs (%0.3f KiB/s)",
|
||||
length, CMD_ARGV[1], bank->bank_number, offset,
|
||||
duration_elapsed(&bench), duration_kbps(&bench, length));
|
||||
@@ -798,7 +798,7 @@ COMMAND_HANDLER(handle_flash_read_bank_command)
|
||||
}
|
||||
|
||||
if (duration_measure(&bench) == ERROR_OK)
|
||||
command_print(CMD_CTX, "wrote %zd bytes to file %s from flash bank %u"
|
||||
command_print(CMD, "wrote %zd bytes to file %s from flash bank %u"
|
||||
" at offset 0x%8.8" PRIx32 " in %fs (%0.3f KiB/s)",
|
||||
written, CMD_ARGV[1], p->bank_number, offset,
|
||||
duration_elapsed(&bench), duration_kbps(&bench, written));
|
||||
@@ -900,23 +900,23 @@ COMMAND_HANDLER(handle_flash_verify_bank_command)
|
||||
}
|
||||
|
||||
if (duration_measure(&bench) == ERROR_OK)
|
||||
command_print(CMD_CTX, "read %zd bytes from file %s and flash bank %u"
|
||||
command_print(CMD, "read %zd bytes from file %s and flash bank %u"
|
||||
" at offset 0x%8.8" PRIx32 " in %fs (%0.3f KiB/s)",
|
||||
length, CMD_ARGV[1], p->bank_number, offset,
|
||||
duration_elapsed(&bench), duration_kbps(&bench, length));
|
||||
|
||||
differ = memcmp(buffer_file, buffer_flash, length);
|
||||
command_print(CMD_CTX, "contents %s", differ ? "differ" : "match");
|
||||
command_print(CMD, "contents %s", differ ? "differ" : "match");
|
||||
if (differ) {
|
||||
uint32_t t;
|
||||
int diffs = 0;
|
||||
for (t = 0; t < length; t++) {
|
||||
if (buffer_flash[t] == buffer_file[t])
|
||||
continue;
|
||||
command_print(CMD_CTX, "diff %d address 0x%08x. Was 0x%02x instead of 0x%02x",
|
||||
command_print(CMD, "diff %d address 0x%08x. Was 0x%02x instead of 0x%02x",
|
||||
diffs, t + offset, buffer_flash[t], buffer_file[t]);
|
||||
if (diffs++ >= 127) {
|
||||
command_print(CMD_CTX, "More than 128 errors, the rest are not printed.");
|
||||
command_print(CMD, "More than 128 errors, the rest are not printed.");
|
||||
break;
|
||||
}
|
||||
keep_alive();
|
||||
@@ -952,7 +952,7 @@ COMMAND_HANDLER(handle_flash_padded_value_command)
|
||||
|
||||
COMMAND_PARSE_NUMBER(u8, CMD_ARGV[1], p->default_padded_value);
|
||||
|
||||
command_print(CMD_CTX, "Default padded value set to 0x%" PRIx8 " for flash bank %u", \
|
||||
command_print(CMD, "Default padded value set to 0x%" PRIx8 " for flash bank %u", \
|
||||
p->default_padded_value, p->bank_number);
|
||||
|
||||
return retval;
|
||||
@@ -985,7 +985,7 @@ static const struct command_registration flash_exec_command_handlers[] = {
|
||||
.name = "erase_sector",
|
||||
.handler = handle_flash_erase_command,
|
||||
.mode = COMMAND_EXEC,
|
||||
.usage = "bank_id first_sector_num last_sector_num",
|
||||
.usage = "bank_id first_sector_num (last_sector_num|'last')",
|
||||
.help = "Erase a range of sectors in a flash bank.",
|
||||
},
|
||||
{
|
||||
@@ -1167,7 +1167,7 @@ COMMAND_HANDLER(handle_flash_banks_command)
|
||||
|
||||
unsigned n = 0;
|
||||
for (struct flash_bank *p = flash_bank_list(); p; p = p->next, n++) {
|
||||
LOG_USER("#%d : %s (%s) at " TARGET_ADDR_FMT ", size 0x%8.8" PRIx32 ", "
|
||||
command_print(CMD, "#%d : %s (%s) at " TARGET_ADDR_FMT ", size 0x%8.8" PRIx32 ", "
|
||||
"buswidth %u, chipwidth %u", p->bank_number,
|
||||
p->name, p->driver->name, p->base, p->size,
|
||||
p->bus_width, p->chip_width);
|
||||
@@ -1239,12 +1239,14 @@ static const struct command_registration flash_config_command_handlers[] = {
|
||||
.mode = COMMAND_CONFIG,
|
||||
.handler = handle_flash_init_command,
|
||||
.help = "Initialize flash devices.",
|
||||
.usage = "",
|
||||
},
|
||||
{
|
||||
.name = "banks",
|
||||
.mode = COMMAND_ANY,
|
||||
.handler = handle_flash_banks_command,
|
||||
.help = "Display table with information about flash banks.",
|
||||
.usage = "",
|
||||
},
|
||||
{
|
||||
.name = "list",
|
||||
@@ -1260,6 +1262,7 @@ static const struct command_registration flash_command_handlers[] = {
|
||||
.mode = COMMAND_ANY,
|
||||
.help = "NOR flash command group",
|
||||
.chain = flash_config_command_handlers,
|
||||
.usage = "",
|
||||
},
|
||||
COMMAND_REGISTRATION_DONE
|
||||
};
|
||||
|
||||
@@ -301,7 +301,7 @@ COMMAND_HANDLER(tms470_handle_flash_keyset_command)
|
||||
int start = (0 == strncmp(CMD_ARGV[i], "0x", 2)) ? 2 : 0;
|
||||
|
||||
if (1 != sscanf(&CMD_ARGV[i][start], "%" SCNx32 "", &flashKeys[i])) {
|
||||
command_print(CMD_CTX, "could not process flash key %s",
|
||||
command_print(CMD, "could not process flash key %s",
|
||||
CMD_ARGV[i]);
|
||||
LOG_ERROR("could not process flash key %s", CMD_ARGV[i]);
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
@@ -310,19 +310,19 @@ COMMAND_HANDLER(tms470_handle_flash_keyset_command)
|
||||
|
||||
keysSet = 1;
|
||||
} else if (CMD_ARGC != 0) {
|
||||
command_print(CMD_CTX, "tms470 flash_keyset <key0> <key1> <key2> <key3>");
|
||||
command_print(CMD, "tms470 flash_keyset <key0> <key1> <key2> <key3>");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
if (keysSet) {
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"using flash keys 0x%08" PRIx32 ", 0x%08" PRIx32 ", 0x%08" PRIx32 ", 0x%08" PRIx32 "",
|
||||
flashKeys[0],
|
||||
flashKeys[1],
|
||||
flashKeys[2],
|
||||
flashKeys[3]);
|
||||
} else
|
||||
command_print(CMD_CTX, "flash keys not set");
|
||||
command_print(CMD, "flash keys not set");
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -352,12 +352,12 @@ COMMAND_HANDLER(tms470_handle_osc_megahertz_command)
|
||||
|
||||
if (oscMHz <= 0) {
|
||||
LOG_ERROR("osc_megahertz must be positive and non-zero!");
|
||||
command_print(CMD_CTX, "osc_megahertz must be positive and non-zero!");
|
||||
command_print(CMD, "osc_megahertz must be positive and non-zero!");
|
||||
oscMHz = 12;
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
command_print(CMD_CTX, "osc_megahertz=%d", oscMHz);
|
||||
command_print(CMD, "osc_megahertz=%d", oscMHz);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -375,7 +375,7 @@ COMMAND_HANDLER(tms470_handle_plldis_command)
|
||||
plldis = plldis ? 1 : 0;
|
||||
}
|
||||
|
||||
command_print(CMD_CTX, "plldis=%d", plldis);
|
||||
command_print(CMD, "plldis=%d", plldis);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -1284,9 +1284,9 @@ COMMAND_HANDLER(xmc4xxx_handle_flash_password_command)
|
||||
|
||||
fb->pw_set = true;
|
||||
|
||||
command_print(CMD_CTX, "XMC4xxx flash passwords set to:\n");
|
||||
command_print(CMD_CTX, "-0x%08"PRIx32"\n", fb->pw1);
|
||||
command_print(CMD_CTX, "-0x%08"PRIx32"\n", fb->pw2);
|
||||
command_print(CMD, "XMC4xxx flash passwords set to:\n");
|
||||
command_print(CMD, "-0x%08"PRIx32"\n", fb->pw1);
|
||||
command_print(CMD, "-0x%08"PRIx32"\n", fb->pw2);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -1329,7 +1329,8 @@ static const struct command_registration xmc4xxx_exec_command_handlers[] = {
|
||||
.usage = "bank_id user_level[0-1]",
|
||||
.help = "Permanently Removes flash protection (read and write) "
|
||||
"for the specified user level",
|
||||
}, COMMAND_REGISTRATION_DONE
|
||||
},
|
||||
COMMAND_REGISTRATION_DONE
|
||||
};
|
||||
|
||||
static const struct command_registration xmc4xxx_command_handlers[] = {
|
||||
|
||||
+2
-2
@@ -89,7 +89,7 @@ COMMAND_HANDLER(handle_hello_command)
|
||||
const char *sep, *name;
|
||||
int retval = CALL_COMMAND_HANDLER(handle_hello_args, &sep, &name);
|
||||
if (ERROR_OK == retval)
|
||||
command_print(CMD_CTX, "Greetings%s%s!", sep, name);
|
||||
command_print(CMD, "Greetings%s%s!", sep, name);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -105,8 +105,8 @@ const struct command_registration hello_command_handlers[] = {
|
||||
.name = "foo",
|
||||
.mode = COMMAND_ANY,
|
||||
.help = "example command handler skeleton",
|
||||
|
||||
.chain = foo_command_handlers,
|
||||
.usage = "",
|
||||
},
|
||||
COMMAND_REGISTRATION_DONE
|
||||
};
|
||||
|
||||
@@ -16,6 +16,7 @@ noinst_LTLIBRARIES += %D%/libhelper.la
|
||||
%D%/jep106.c \
|
||||
%D%/jim-nvp.c \
|
||||
%D%/binarybuffer.h \
|
||||
%D%/bits.h \
|
||||
%D%/configuration.h \
|
||||
%D%/ioutil.h \
|
||||
%D%/list.h \
|
||||
|
||||
@@ -118,7 +118,7 @@ static inline uint32_t buf_get_u32(const uint8_t *_buffer,
|
||||
uint32_t result = 0;
|
||||
for (unsigned i = first; i < first + num; i++) {
|
||||
if (((buffer[i / 8] >> (i % 8)) & 1) == 1)
|
||||
result |= 1 << (i - first);
|
||||
result |= 1U << (i - first);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (C) 2018, STMicroelectronics - All Rights Reserved
|
||||
* Author(s): Antonio Borneo <borneo.antonio@gmail.com> for STMicroelectronics
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The content of this file is mainly copied/inspired from Linux kernel
|
||||
* code in include/linux/types.h include/linux/bitmap.h include/linux/bitops.h
|
||||
*/
|
||||
|
||||
#ifndef OPENOCD_HELPER_BITS_H
|
||||
#define OPENOCD_HELPER_BITS_H
|
||||
|
||||
#include <helper/types.h>
|
||||
|
||||
#define BIT(nr) (1UL << (nr))
|
||||
#define BITS_PER_BYTE 8
|
||||
#define BITS_PER_LONG (BITS_PER_BYTE * sizeof(long))
|
||||
#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
|
||||
#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
|
||||
#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
|
||||
#define DECLARE_BITMAP(name, bits) unsigned long name[BITS_TO_LONGS(bits)]
|
||||
|
||||
/**
|
||||
* bitmap_zero - Clears all the bits in memory
|
||||
* @dst: the address of the bitmap
|
||||
* @nbits: the number of bits to clear
|
||||
*/
|
||||
static inline void bitmap_zero(unsigned long *dst, unsigned int nbits)
|
||||
{
|
||||
unsigned int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
|
||||
memset(dst, 0, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear_bit - Clear a bit in memory
|
||||
* @nr: the bit to set
|
||||
* @addr: the address to start counting from
|
||||
*/
|
||||
static inline void clear_bit(unsigned int nr, volatile unsigned long *addr)
|
||||
{
|
||||
unsigned long mask = BIT_MASK(nr);
|
||||
unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
|
||||
|
||||
*p &= ~mask;
|
||||
}
|
||||
|
||||
/**
|
||||
* set_bit - Set a bit in memory
|
||||
* @nr: the bit to set
|
||||
* @addr: the address to start counting from
|
||||
*/
|
||||
static inline void set_bit(unsigned int nr, volatile unsigned long *addr)
|
||||
{
|
||||
unsigned long mask = BIT_MASK(nr);
|
||||
unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
|
||||
|
||||
*p |= mask;
|
||||
}
|
||||
|
||||
/**
|
||||
* test_bit - Determine whether a bit is set
|
||||
* @nr: bit number to test
|
||||
* @addr: Address to start counting from
|
||||
*/
|
||||
static inline int test_bit(unsigned int nr, const volatile unsigned long *addr)
|
||||
{
|
||||
return 1UL & (addr[BIT_WORD(nr)] >> (nr % BITS_PER_LONG));
|
||||
}
|
||||
|
||||
#endif /* OPENOCD_HELPER_BITS_H */
|
||||
+104
-112
@@ -190,7 +190,7 @@ struct command_context *current_command_context(Jim_Interp *interp)
|
||||
}
|
||||
|
||||
static int script_command_run(Jim_Interp *interp,
|
||||
int argc, Jim_Obj * const *argv, struct command *c, bool capture)
|
||||
int argc, Jim_Obj * const *argv, struct command *c)
|
||||
{
|
||||
target_call_timer_callbacks_now();
|
||||
LOG_USER_N("%s", ""); /* Keep GDB connection alive*/
|
||||
@@ -200,15 +200,9 @@ static int script_command_run(Jim_Interp *interp,
|
||||
if (NULL == words)
|
||||
return JIM_ERR;
|
||||
|
||||
struct log_capture_state *state = NULL;
|
||||
if (capture)
|
||||
state = command_log_capture_start(interp);
|
||||
|
||||
struct command_context *cmd_ctx = current_command_context(interp);
|
||||
int retval = run_command(cmd_ctx, c, (const char **)words, nwords);
|
||||
|
||||
command_log_capture_finish(state);
|
||||
|
||||
script_command_args_free(words, nwords);
|
||||
return command_retval_set(interp, retval);
|
||||
}
|
||||
@@ -220,7 +214,7 @@ static int script_command(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
|
||||
struct command *c = interp->cmdPrivData;
|
||||
assert(c);
|
||||
script_debug(interp, c->name, argc, argv);
|
||||
return script_command_run(interp, argc, argv, c, true);
|
||||
return script_command_run(interp, argc, argv, c);
|
||||
}
|
||||
|
||||
static struct command *command_root(struct command *c)
|
||||
@@ -316,7 +310,7 @@ static struct command *command_new(struct command_context *cmd_ctx,
|
||||
* arguments.
|
||||
*/
|
||||
if ((cr->jim_handler == NULL) && (cr->usage == NULL)) {
|
||||
LOG_DEBUG("BUG: command '%s%s%s' does not have the "
|
||||
LOG_ERROR("BUG: command '%s%s%s' does not have the "
|
||||
"'.usage' field filled out",
|
||||
parent && parent->name ? parent->name : "",
|
||||
parent && parent->name ? " " : "",
|
||||
@@ -357,27 +351,11 @@ static int register_command_handler(struct command_context *cmd_ctx,
|
||||
struct command *c)
|
||||
{
|
||||
Jim_Interp *interp = cmd_ctx->interp;
|
||||
char *ocd_name = alloc_printf("ocd_%s", c->name);
|
||||
if (NULL == ocd_name)
|
||||
return JIM_ERR;
|
||||
|
||||
LOG_DEBUG("registering '%s'...", ocd_name);
|
||||
LOG_DEBUG("registering '%s'...", c->name);
|
||||
|
||||
Jim_CmdProc *func = c->handler ? &script_command : &command_unknown;
|
||||
int retval = Jim_CreateCommand(interp, ocd_name, func, c, NULL);
|
||||
free(ocd_name);
|
||||
if (JIM_OK != retval)
|
||||
return retval;
|
||||
|
||||
/* we now need to add an overrideable proc */
|
||||
char *override_name = alloc_printf(
|
||||
"proc %s {args} {eval ocd_bouncer %s $args}",
|
||||
c->name, c->name);
|
||||
if (NULL == override_name)
|
||||
return JIM_ERR;
|
||||
|
||||
retval = Jim_Eval_Named(interp, override_name, 0, 0);
|
||||
free(override_name);
|
||||
int retval = Jim_CreateCommand(interp, c->name, func, c, NULL);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -502,7 +480,7 @@ void command_output_text(struct command_context *context, const char *data)
|
||||
context->output_handler(context, data);
|
||||
}
|
||||
|
||||
void command_print_sameline(struct command_context *context, const char *format, ...)
|
||||
void command_print_sameline(struct command_invocation *cmd, const char *format, ...)
|
||||
{
|
||||
char *string;
|
||||
|
||||
@@ -510,13 +488,13 @@ void command_print_sameline(struct command_context *context, const char *format,
|
||||
va_start(ap, format);
|
||||
|
||||
string = alloc_vprintf(format, ap);
|
||||
if (string != NULL) {
|
||||
if (string != NULL && cmd) {
|
||||
/* we want this collected in the log + we also want to pick it up as a tcl return
|
||||
* value.
|
||||
*
|
||||
* The latter bit isn't precisely neat, but will do for now.
|
||||
*/
|
||||
LOG_USER_N("%s", string);
|
||||
Jim_AppendString(cmd->ctx->interp, cmd->output, string, -1);
|
||||
/* We already printed it above
|
||||
* command_output_text(context, string); */
|
||||
free(string);
|
||||
@@ -525,7 +503,7 @@ void command_print_sameline(struct command_context *context, const char *format,
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void command_print(struct command_context *context, const char *format, ...)
|
||||
void command_print(struct command_invocation *cmd, const char *format, ...)
|
||||
{
|
||||
char *string;
|
||||
|
||||
@@ -533,7 +511,7 @@ void command_print(struct command_context *context, const char *format, ...)
|
||||
va_start(ap, format);
|
||||
|
||||
string = alloc_vprintf(format, ap);
|
||||
if (string != NULL) {
|
||||
if (string != NULL && cmd) {
|
||||
strcat(string, "\n"); /* alloc_vprintf guaranteed the buffer to be at least one
|
||||
*char longer */
|
||||
/* we want this collected in the log + we also want to pick it up as a tcl return
|
||||
@@ -541,7 +519,7 @@ void command_print(struct command_context *context, const char *format, ...)
|
||||
*
|
||||
* The latter bit isn't precisely neat, but will do for now.
|
||||
*/
|
||||
LOG_USER_N("%s", string);
|
||||
Jim_AppendString(cmd->ctx->interp, cmd->output, string, -1);
|
||||
/* We already printed it above
|
||||
* command_output_text(context, string); */
|
||||
free(string);
|
||||
@@ -628,6 +606,9 @@ static int run_command(struct command_context *context,
|
||||
if (c->jim_handler_data)
|
||||
context->current_target_override = c->jim_handler_data;
|
||||
|
||||
cmd.output = Jim_NewEmptyStringObj(context->interp);
|
||||
Jim_IncrRefCount(cmd.output);
|
||||
|
||||
int retval = c->handler(&cmd);
|
||||
|
||||
if (c->jim_handler_data)
|
||||
@@ -642,15 +623,17 @@ static int run_command(struct command_context *context,
|
||||
}
|
||||
} else if (retval == ERROR_COMMAND_CLOSE_CONNECTION) {
|
||||
/* just fall through for a shutdown request */
|
||||
} else if (retval != ERROR_OK) {
|
||||
/* we do not print out an error message because the command *should*
|
||||
* have printed out an error
|
||||
*/
|
||||
char *full_name = command_name(c, ' ');
|
||||
LOG_DEBUG("Command '%s' failed with error code %d",
|
||||
full_name ? full_name : c->name, retval);
|
||||
free(full_name);
|
||||
} else {
|
||||
if (retval != ERROR_OK) {
|
||||
char *full_name = command_name(c, ' ');
|
||||
LOG_DEBUG("Command '%s' failed with error code %d",
|
||||
full_name ? full_name : c->name, retval);
|
||||
free(full_name);
|
||||
}
|
||||
/* Use the command output as the Tcl result */
|
||||
Jim_SetResult(context->interp, cmd.output);
|
||||
}
|
||||
Jim_DecrRefCount(context->interp, cmd.output);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -669,9 +652,11 @@ int command_run_line(struct command_context *context, char *line)
|
||||
* happen when the Jim Tcl interpreter is provided by eCos for
|
||||
* instance.
|
||||
*/
|
||||
struct target *saved_target_override = context->current_target_override;
|
||||
context->current_target_override = NULL;
|
||||
|
||||
Jim_Interp *interp = context->interp;
|
||||
struct command_context *old_context = Jim_GetAssocData(interp, "context");
|
||||
Jim_DeleteAssocData(interp, "context");
|
||||
retcode = Jim_SetAssocData(interp, "context", NULL, context);
|
||||
if (retcode == JIM_OK) {
|
||||
@@ -684,25 +669,19 @@ int command_run_line(struct command_context *context, char *line)
|
||||
Jim_DeleteAssocData(interp, "retval");
|
||||
}
|
||||
Jim_DeleteAssocData(interp, "context");
|
||||
int inner_retcode = Jim_SetAssocData(interp, "context", NULL, old_context);
|
||||
if (retcode == JIM_OK)
|
||||
retcode = inner_retcode;
|
||||
}
|
||||
context->current_target_override = saved_target_override;
|
||||
if (retcode == JIM_OK) {
|
||||
const char *result;
|
||||
int reslen;
|
||||
|
||||
result = Jim_GetString(Jim_GetResult(interp), &reslen);
|
||||
if (reslen > 0) {
|
||||
int i;
|
||||
char buff[256 + 1];
|
||||
for (i = 0; i < reslen; i += 256) {
|
||||
int chunk;
|
||||
chunk = reslen - i;
|
||||
if (chunk > 256)
|
||||
chunk = 256;
|
||||
strncpy(buff, result + i, chunk);
|
||||
buff[chunk] = 0;
|
||||
LOG_USER_N("%s", buff);
|
||||
}
|
||||
LOG_USER_N("\n");
|
||||
command_output_text(context, result);
|
||||
command_output_text(context, "\n");
|
||||
}
|
||||
retval = ERROR_OK;
|
||||
} else if (retcode == JIM_EXIT) {
|
||||
@@ -712,6 +691,7 @@ int command_run_line(struct command_context *context, char *line)
|
||||
return retcode;
|
||||
} else {
|
||||
Jim_MakeErrorMessage(interp);
|
||||
/* error is broadcast */
|
||||
LOG_USER("%s", Jim_GetString(Jim_GetResult(interp), NULL));
|
||||
|
||||
if (retval == ERROR_OK) {
|
||||
@@ -827,8 +807,6 @@ static COMMAND_HELPER(command_help_find, struct command *head,
|
||||
if (0 == CMD_ARGC)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
*out = command_find(head, CMD_ARGV[0]);
|
||||
if (NULL == *out && strncmp(CMD_ARGV[0], "ocd_", 4) == 0)
|
||||
*out = command_find(head, CMD_ARGV[0] + 4);
|
||||
if (NULL == *out)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
if (--CMD_ARGC == 0)
|
||||
@@ -982,34 +960,85 @@ COMMAND_HANDLER(handle_help_command)
|
||||
}
|
||||
|
||||
static int command_unknown_find(unsigned argc, Jim_Obj *const *argv,
|
||||
struct command *head, struct command **out, bool top_level)
|
||||
struct command *head, struct command **out)
|
||||
{
|
||||
if (0 == argc)
|
||||
return argc;
|
||||
const char *cmd_name = Jim_GetString(argv[0], NULL);
|
||||
struct command *c = command_find(head, cmd_name);
|
||||
if (NULL == c && top_level && strncmp(cmd_name, "ocd_", 4) == 0)
|
||||
c = command_find(head, cmd_name + 4);
|
||||
if (NULL == c)
|
||||
return argc;
|
||||
*out = c;
|
||||
return command_unknown_find(--argc, ++argv, (*out)->children, out, false);
|
||||
return command_unknown_find(--argc, ++argv, (*out)->children, out);
|
||||
}
|
||||
|
||||
static char *alloc_concatenate_strings(int argc, Jim_Obj * const *argv)
|
||||
{
|
||||
char *prev, *all;
|
||||
int i;
|
||||
|
||||
assert(argc >= 1);
|
||||
|
||||
all = strdup(Jim_GetString(argv[0], NULL));
|
||||
if (!all) {
|
||||
LOG_ERROR("Out of memory");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 1; i < argc; ++i) {
|
||||
prev = all;
|
||||
all = alloc_printf("%s %s", all, Jim_GetString(argv[i], NULL));
|
||||
free(prev);
|
||||
if (!all) {
|
||||
LOG_ERROR("Out of memory");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return all;
|
||||
}
|
||||
|
||||
static int run_usage(Jim_Interp *interp, int argc_valid, int argc, Jim_Obj * const *argv)
|
||||
{
|
||||
struct command_context *cmd_ctx = current_command_context(interp);
|
||||
char *command;
|
||||
int retval;
|
||||
|
||||
assert(argc_valid >= 1);
|
||||
assert(argc >= argc_valid);
|
||||
|
||||
command = alloc_concatenate_strings(argc_valid, argv);
|
||||
if (!command)
|
||||
return JIM_ERR;
|
||||
|
||||
retval = command_run_linef(cmd_ctx, "usage %s", command);
|
||||
if (retval != ERROR_OK) {
|
||||
LOG_ERROR("unable to execute command \"usage %s\"", command);
|
||||
return JIM_ERR;
|
||||
}
|
||||
|
||||
if (argc_valid == argc)
|
||||
LOG_ERROR("%s: command requires more arguments", command);
|
||||
else {
|
||||
free(command);
|
||||
command = alloc_concatenate_strings(argc - argc_valid, argv + argc_valid);
|
||||
if (!command)
|
||||
return JIM_ERR;
|
||||
LOG_ERROR("invalid subcommand \"%s\"", command);
|
||||
}
|
||||
|
||||
free(command);
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int command_unknown(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
|
||||
{
|
||||
const char *cmd_name = Jim_GetString(argv[0], NULL);
|
||||
if (strcmp(cmd_name, "unknown") == 0) {
|
||||
if (argc == 1)
|
||||
return JIM_OK;
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
script_debug(interp, cmd_name, argc, argv);
|
||||
|
||||
struct command_context *cmd_ctx = current_command_context(interp);
|
||||
struct command *c = cmd_ctx->commands;
|
||||
int remaining = command_unknown_find(argc, argv, c, &c, true);
|
||||
int remaining = command_unknown_find(argc, argv, c, &c);
|
||||
/* if nothing could be consumed, then it's really an unknown command */
|
||||
if (remaining == argc) {
|
||||
const char *cmd = Jim_GetString(argv[0], NULL);
|
||||
@@ -1017,7 +1046,6 @@ static int command_unknown(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
|
||||
return JIM_OK;
|
||||
}
|
||||
|
||||
bool found = true;
|
||||
Jim_Obj *const *start;
|
||||
unsigned count;
|
||||
if (c->handler || c->jim_handler) {
|
||||
@@ -1025,14 +1053,10 @@ static int command_unknown(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
|
||||
count = remaining + 1;
|
||||
start = argv + (argc - remaining - 1);
|
||||
} else {
|
||||
c = command_find(cmd_ctx->commands, "usage");
|
||||
if (NULL == c) {
|
||||
LOG_ERROR("unknown command, but usage is missing too");
|
||||
return JIM_ERR;
|
||||
}
|
||||
count = argc - remaining;
|
||||
start = argv;
|
||||
found = false;
|
||||
run_usage(interp, count, argc, start);
|
||||
return JIM_ERR;
|
||||
}
|
||||
/* pass the command through to the intended handler */
|
||||
if (c->jim_handler) {
|
||||
@@ -1043,7 +1067,7 @@ static int command_unknown(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
|
||||
return (*c->jim_handler)(interp, count, start);
|
||||
}
|
||||
|
||||
return script_command_run(interp, count, start, c, found);
|
||||
return script_command_run(interp, count, start, c);
|
||||
}
|
||||
|
||||
static int jim_command_mode(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
|
||||
@@ -1053,7 +1077,7 @@ static int jim_command_mode(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
|
||||
|
||||
if (argc > 1) {
|
||||
struct command *c = cmd_ctx->commands;
|
||||
int remaining = command_unknown_find(argc - 1, argv + 1, c, &c, true);
|
||||
int remaining = command_unknown_find(argc - 1, argv + 1, c, &c);
|
||||
/* if nothing could be consumed, then it's an unknown command */
|
||||
if (remaining == argc - 1) {
|
||||
Jim_SetResultString(interp, "unknown", -1);
|
||||
@@ -1082,32 +1106,6 @@ static int jim_command_mode(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
|
||||
return JIM_OK;
|
||||
}
|
||||
|
||||
static int jim_command_type(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
|
||||
{
|
||||
if (1 == argc)
|
||||
return JIM_ERR;
|
||||
|
||||
struct command_context *cmd_ctx = current_command_context(interp);
|
||||
struct command *c = cmd_ctx->commands;
|
||||
int remaining = command_unknown_find(argc - 1, argv + 1, c, &c, true);
|
||||
/* if nothing could be consumed, then it's an unknown command */
|
||||
if (remaining == argc - 1) {
|
||||
Jim_SetResultString(interp, "unknown", -1);
|
||||
return JIM_OK;
|
||||
}
|
||||
|
||||
if (c->jim_handler)
|
||||
Jim_SetResultString(interp, "native", -1);
|
||||
else if (c->handler)
|
||||
Jim_SetResultString(interp, "simple", -1);
|
||||
else if (remaining == 0)
|
||||
Jim_SetResultString(interp, "group", -1);
|
||||
else
|
||||
Jim_SetResultString(interp, "unknown", -1);
|
||||
|
||||
return JIM_OK;
|
||||
}
|
||||
|
||||
int help_add_command(struct command_context *cmd_ctx, struct command *parent,
|
||||
const char *cmd_name, const char *help_text, const char *usage)
|
||||
{
|
||||
@@ -1119,7 +1117,7 @@ int help_add_command(struct command_context *cmd_ctx, struct command *parent,
|
||||
.name = cmd_name,
|
||||
.mode = COMMAND_ANY,
|
||||
.help = help_text,
|
||||
.usage = usage,
|
||||
.usage = usage ? : "",
|
||||
};
|
||||
nc = register_command(cmd_ctx, parent, &cr);
|
||||
if (NULL == nc) {
|
||||
@@ -1144,8 +1142,9 @@ int help_add_command(struct command_context *cmd_ctx, struct command *parent,
|
||||
if (usage) {
|
||||
bool replaced = false;
|
||||
if (nc->usage) {
|
||||
if (*nc->usage)
|
||||
replaced = true;
|
||||
free(nc->usage);
|
||||
replaced = true;
|
||||
}
|
||||
nc->usage = strdup(usage);
|
||||
if (replaced)
|
||||
@@ -1227,15 +1226,6 @@ static const struct command_registration command_subcommand_handlers[] = {
|
||||
"Returns 'unknown' if an unknown command is given. "
|
||||
"Command can be multiple tokens.",
|
||||
},
|
||||
{
|
||||
.name = "type",
|
||||
.mode = COMMAND_ANY,
|
||||
.jim_handler = jim_command_type,
|
||||
.usage = "command_name [...]",
|
||||
.help = "Returns the type of built-in command:"
|
||||
"'native', 'simple', 'group', or 'unknown'. "
|
||||
"Command can be multiple tokens.",
|
||||
},
|
||||
COMMAND_REGISTRATION_DONE
|
||||
};
|
||||
|
||||
@@ -1294,6 +1284,7 @@ static const struct command_registration command_builtin_handlers[] = {
|
||||
.mode = COMMAND_ANY,
|
||||
.help = "core command group (introspection)",
|
||||
.chain = command_subcommand_handlers,
|
||||
.usage = "",
|
||||
},
|
||||
COMMAND_REGISTRATION_DONE
|
||||
};
|
||||
@@ -1403,6 +1394,7 @@ void process_jim_events(struct command_context *cmd_ctx)
|
||||
return ERROR_COMMAND_ARGUMENT_INVALID; \
|
||||
} \
|
||||
char *end; \
|
||||
errno = 0; \
|
||||
*ul = func(str, &end, 0); \
|
||||
if (*end) { \
|
||||
LOG_ERROR("Invalid command argument"); \
|
||||
|
||||
+11
-5
@@ -79,6 +79,7 @@ struct command_invocation {
|
||||
const char *name;
|
||||
unsigned argc;
|
||||
const char **argv;
|
||||
Jim_Obj *output;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -121,6 +122,11 @@ struct command_invocation {
|
||||
*/
|
||||
#define COMMAND_HELPER(name, extra ...) __COMMAND_HANDLER(name, extra)
|
||||
|
||||
/**
|
||||
* Use this macro to access the command being handled,
|
||||
* rather than accessing the variable directly. It may be moved.
|
||||
*/
|
||||
#define CMD (cmd)
|
||||
/**
|
||||
* Use this macro to access the context of the command being handled,
|
||||
* rather than accessing the variable directly. It may be moved.
|
||||
@@ -348,9 +354,9 @@ struct command_context *copy_command_context(struct command_context *cmd_ctx);
|
||||
*/
|
||||
void command_done(struct command_context *context);
|
||||
|
||||
void command_print(struct command_context *context, const char *format, ...)
|
||||
void command_print(struct command_invocation *cmd, const char *format, ...)
|
||||
__attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 2, 3)));
|
||||
void command_print_sameline(struct command_context *context, const char *format, ...)
|
||||
void command_print_sameline(struct command_invocation *cmd, const char *format, ...)
|
||||
__attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 2, 3)));
|
||||
int command_run_line(struct command_context *context, char *line);
|
||||
int command_run_linef(struct command_context *context, const char *format, ...)
|
||||
@@ -404,7 +410,7 @@ DECLARE_PARSE_WRAPPER(_target_addr, target_addr_t);
|
||||
do { \
|
||||
int retval_macro_tmp = parse_ ## type(in, &(out)); \
|
||||
if (ERROR_OK != retval_macro_tmp) { \
|
||||
command_print(CMD_CTX, stringify(out) \
|
||||
command_print(CMD, stringify(out) \
|
||||
" option value ('%s') is not valid", in); \
|
||||
return retval_macro_tmp; \
|
||||
} \
|
||||
@@ -424,9 +430,9 @@ DECLARE_PARSE_WRAPPER(_target_addr, target_addr_t);
|
||||
bool value; \
|
||||
int retval_macro_tmp = command_parse_bool_arg(in, &value); \
|
||||
if (ERROR_OK != retval_macro_tmp) { \
|
||||
command_print(CMD_CTX, stringify(out) \
|
||||
command_print(CMD, stringify(out) \
|
||||
" option value ('%s') is not valid", in); \
|
||||
command_print(CMD_CTX, " choices are '%s' or '%s'", \
|
||||
command_print(CMD, " choices are '%s' or '%s'", \
|
||||
on, off); \
|
||||
return retval_macro_tmp; \
|
||||
} \
|
||||
|
||||
+8
-7
@@ -113,10 +113,10 @@ COMMAND_HANDLER(handle_cat_command)
|
||||
|
||||
int retval = load_file(CMD_ARGV[0], &data, &len);
|
||||
if (retval == ERROR_OK) {
|
||||
command_print(CMD_CTX, "%s", data);
|
||||
command_print(CMD, "%s", data);
|
||||
free(data);
|
||||
} else
|
||||
command_print(CMD_CTX, "%s not found", CMD_ARGV[0]);
|
||||
command_print(CMD, "%s not found", CMD_ARGV[0]);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -146,10 +146,10 @@ COMMAND_HANDLER(handle_meminfo_command)
|
||||
info = mallinfo();
|
||||
|
||||
if (prev > 0)
|
||||
command_print(CMD_CTX, "Diff: %d", prev - info.fordblks);
|
||||
command_print(CMD, "Diff: %d", prev - info.fordblks);
|
||||
prev = info.fordblks;
|
||||
|
||||
command_print(CMD_CTX, "Available ram: %d", info.fordblks);
|
||||
command_print(CMD, "Available ram: %d", info.fordblks);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -217,7 +217,7 @@ COMMAND_HANDLER(handle_cp_command)
|
||||
if (retval != ERROR_OK)
|
||||
break;
|
||||
|
||||
command_print(CMD_CTX, "%zu", len - pos);
|
||||
command_print(CMD, "%zu", len - pos);
|
||||
|
||||
pos += chunk;
|
||||
|
||||
@@ -226,9 +226,9 @@ COMMAND_HANDLER(handle_cp_command)
|
||||
}
|
||||
|
||||
if (retval == ERROR_OK)
|
||||
command_print(CMD_CTX, "Copied %s to %s", CMD_ARGV[0], CMD_ARGV[1]);
|
||||
command_print(CMD, "Copied %s to %s", CMD_ARGV[0], CMD_ARGV[1]);
|
||||
else
|
||||
command_print(CMD_CTX, "copy failed");
|
||||
command_print(CMD, "copy failed");
|
||||
|
||||
if (data != NULL)
|
||||
free(data);
|
||||
@@ -472,6 +472,7 @@ static const struct command_registration ioutil_command_handlers[] = {
|
||||
.handler = handle_meminfo_command,
|
||||
.mode = COMMAND_ANY,
|
||||
.help = "display free heap space",
|
||||
.usage = "",
|
||||
},
|
||||
#endif
|
||||
{
|
||||
|
||||
+2
-2
@@ -213,7 +213,7 @@ COMMAND_HANDLER(handle_debug_level_command)
|
||||
} else if (CMD_ARGC > 1)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
|
||||
command_print(CMD_CTX, "debug_level: %i", debug_level);
|
||||
command_print(CMD, "debug_level: %i", debug_level);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -236,7 +236,7 @@ COMMAND_HANDLER(handle_log_output_command)
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static struct command_registration log_command_handlers[] = {
|
||||
static const struct command_registration log_command_handlers[] = {
|
||||
{
|
||||
.name = "log_output",
|
||||
.handler = handle_log_output_command,
|
||||
|
||||
@@ -269,19 +269,14 @@ int parse_cmdline_args(struct command_context *cmd_ctx, int argc, char *argv[])
|
||||
break;
|
||||
case 'd': /* --debug | -d */
|
||||
{
|
||||
char *command = alloc_printf("debug_level %s", optarg ? optarg : "3");
|
||||
int retval = command_run_line(cmd_ctx, command);
|
||||
free(command);
|
||||
int retval = command_run_linef(cmd_ctx, "debug_level %s", optarg ? optarg : "3");
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
break;
|
||||
}
|
||||
case 'l': /* --log_output | -l */
|
||||
if (optarg) {
|
||||
char *command = alloc_printf("log_output %s", optarg);
|
||||
command_run_line(cmd_ctx, command);
|
||||
free(command);
|
||||
}
|
||||
if (optarg)
|
||||
command_run_linef(cmd_ctx, "log_output %s", optarg);
|
||||
break;
|
||||
case 'c': /* --command | -c */
|
||||
if (optarg)
|
||||
|
||||
@@ -3,43 +3,6 @@
|
||||
# Embedded into OpenOCD executable
|
||||
#
|
||||
|
||||
|
||||
# We need to explicitly redirect this to the OpenOCD command
|
||||
# as Tcl defines the exit proc
|
||||
proc exit {} {
|
||||
ocd_throw exit
|
||||
}
|
||||
|
||||
# All commands are registered with an 'ocd_' prefix, while the "real"
|
||||
# command is a wrapper that calls this function. Its primary purpose is
|
||||
# to discard 'handler' command output.
|
||||
# Due to the two nested proc calls, this wrapper has to explicitly run
|
||||
# the wrapped command in the stack frame two levels above.
|
||||
proc ocd_bouncer {name args} {
|
||||
set cmd [format "ocd_%s" $name]
|
||||
set type [eval ocd_command type $cmd $args]
|
||||
set errcode error
|
||||
set skiplevel [expr [eval info level] > 1 ? 2 : 1]
|
||||
if {$type == "native"} {
|
||||
return [uplevel $skiplevel $cmd $args]
|
||||
} else {if {$type == "simple"} {
|
||||
set errcode [catch {uplevel $skiplevel $cmd $args}]
|
||||
if {$errcode == 0} {
|
||||
return ""
|
||||
} else {
|
||||
# 'classic' commands output error message as part of progress output
|
||||
set errmsg ""
|
||||
}
|
||||
} else {if {$type == "group"} {
|
||||
catch {eval ocd_usage $name $args}
|
||||
set errmsg [format "%s: command requires more arguments" \
|
||||
[concat $name " " $args]]
|
||||
} else {
|
||||
set errmsg [format "invalid subcommand \"%s\"" $args]
|
||||
}}}
|
||||
return -code $errcode $errmsg
|
||||
}
|
||||
|
||||
# Try flipping / and \ to find file if the filename does not
|
||||
# match the precise spelling
|
||||
proc find {filename} {
|
||||
|
||||
+12
-57
@@ -66,30 +66,6 @@ static int jim_adapter_name(Jim_Interp *interp, int argc, Jim_Obj * const *argv)
|
||||
return JIM_OK;
|
||||
}
|
||||
|
||||
static int default_khz(int khz, int *jtag_speed)
|
||||
{
|
||||
LOG_ERROR("Translation from khz to jtag_speed not implemented");
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
static int default_speed_div(int speed, int *khz)
|
||||
{
|
||||
LOG_ERROR("Translation from jtag_speed to khz not implemented");
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
static int default_power_dropout(int *dropout)
|
||||
{
|
||||
*dropout = 0; /* by default we can't detect power dropout */
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static int default_srst_asserted(int *srst_asserted)
|
||||
{
|
||||
*srst_asserted = 0; /* by default we can't detect srst asserted */
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
COMMAND_HANDLER(interface_transport_command)
|
||||
{
|
||||
char **transports;
|
||||
@@ -114,10 +90,10 @@ COMMAND_HANDLER(handle_interface_list_command)
|
||||
if (strcmp(CMD_NAME, "interface_list") == 0 && CMD_ARGC > 0)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
|
||||
command_print(CMD_CTX, "The following debug interfaces are available:");
|
||||
command_print(CMD, "The following debug interfaces are available:");
|
||||
for (unsigned i = 0; NULL != jtag_interfaces[i]; i++) {
|
||||
const char *name = jtag_interfaces[i]->name;
|
||||
command_print(CMD_CTX, "%u: %s", i + 1, name);
|
||||
command_print(CMD, "%u: %s", i + 1, name);
|
||||
}
|
||||
|
||||
return ERROR_OK;
|
||||
@@ -150,29 +126,7 @@ COMMAND_HANDLER(handle_interface_command)
|
||||
|
||||
jtag_interface = jtag_interfaces[i];
|
||||
|
||||
/* LEGACY SUPPORT ... adapter drivers must declare what
|
||||
* transports they allow. Until they all do so, assume
|
||||
* the legacy drivers are JTAG-only
|
||||
*/
|
||||
if (!jtag_interface->transports)
|
||||
LOG_WARNING("Adapter driver '%s' did not declare "
|
||||
"which transports it allows; assuming "
|
||||
"legacy JTAG-only", jtag_interface->name);
|
||||
retval = allow_transports(CMD_CTX, jtag_interface->transports
|
||||
? jtag_interface->transports : jtag_only);
|
||||
if (ERROR_OK != retval)
|
||||
return retval;
|
||||
|
||||
if (jtag_interface->khz == NULL)
|
||||
jtag_interface->khz = default_khz;
|
||||
if (jtag_interface->speed_div == NULL)
|
||||
jtag_interface->speed_div = default_speed_div;
|
||||
if (jtag_interface->power_dropout == NULL)
|
||||
jtag_interface->power_dropout = default_power_dropout;
|
||||
if (jtag_interface->srst_asserted == NULL)
|
||||
jtag_interface->srst_asserted = default_srst_asserted;
|
||||
|
||||
return ERROR_OK;
|
||||
return allow_transports(CMD_CTX, jtag_interface->transports);
|
||||
}
|
||||
|
||||
/* no valid interface was found (i.e. the configuration option,
|
||||
@@ -394,7 +348,7 @@ next:
|
||||
modes[5] = "";
|
||||
}
|
||||
|
||||
command_print(CMD_CTX, "%s %s%s%s%s%s",
|
||||
command_print(CMD, "%s %s%s%s%s%s",
|
||||
modes[0], modes[1],
|
||||
modes[2], modes[3], modes[4], modes[5]);
|
||||
|
||||
@@ -411,7 +365,7 @@ COMMAND_HANDLER(handle_adapter_nsrst_delay_command)
|
||||
|
||||
jtag_set_nsrst_delay(delay);
|
||||
}
|
||||
command_print(CMD_CTX, "adapter_nsrst_delay: %u", jtag_get_nsrst_delay());
|
||||
command_print(CMD, "adapter_nsrst_delay: %u", jtag_get_nsrst_delay());
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -425,7 +379,7 @@ COMMAND_HANDLER(handle_adapter_nsrst_assert_width_command)
|
||||
|
||||
jtag_set_nsrst_assert_width(width);
|
||||
}
|
||||
command_print(CMD_CTX, "adapter_nsrst_assert_width: %u", jtag_get_nsrst_assert_width());
|
||||
command_print(CMD, "adapter_nsrst_assert_width: %u", jtag_get_nsrst_assert_width());
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -450,9 +404,9 @@ COMMAND_HANDLER(handle_adapter_khz_command)
|
||||
return retval;
|
||||
|
||||
if (cur_speed)
|
||||
command_print(CMD_CTX, "adapter speed: %d kHz", cur_speed);
|
||||
command_print(CMD, "adapter speed: %d kHz", cur_speed);
|
||||
else
|
||||
command_print(CMD_CTX, "adapter speed: RCLK - adaptive");
|
||||
command_print(CMD, "adapter speed: RCLK - adaptive");
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -464,7 +418,7 @@ COMMAND_HANDLER(handle_usb_location_command)
|
||||
if (CMD_ARGC == 1)
|
||||
jtag_usb_set_location(CMD_ARGV[0]);
|
||||
|
||||
command_print(CMD_CTX, "adapter usb location: %s", jtag_usb_get_location());
|
||||
command_print(CMD, "adapter usb location: %s", jtag_usb_get_location());
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -476,8 +430,8 @@ static const struct command_registration adapter_usb_command_handlers[] = {
|
||||
.name = "location",
|
||||
.handler = &handle_usb_location_command,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "set the USB bus location of the USB device",
|
||||
.usage = "<bus>-port[.port]...",
|
||||
.help = "display or set the USB bus location of the USB device",
|
||||
.usage = "[<bus>-port[.port]...]",
|
||||
},
|
||||
#endif /* HAVE_LIBUSB_GET_PORT_NUMBERS */
|
||||
COMMAND_REGISTRATION_DONE
|
||||
@@ -555,6 +509,7 @@ static const struct command_registration interface_command_handlers[] = {
|
||||
.handler = handle_interface_list_command,
|
||||
.mode = COMMAND_ANY,
|
||||
.help = "List all built-in debug adapter interfaces (drivers)",
|
||||
.usage = "",
|
||||
},
|
||||
{
|
||||
.name = "reset_config",
|
||||
|
||||
@@ -150,7 +150,7 @@ static int aice_execute_reset(struct jtag_command *cmd)
|
||||
static int last_trst;
|
||||
int retval = ERROR_OK;
|
||||
|
||||
DEBUG_JTAG_IO("reset trst: %d", cmd->cmd.reset->trst);
|
||||
LOG_DEBUG_IO("reset trst: %d", cmd->cmd.reset->trst);
|
||||
|
||||
if (cmd->cmd.reset->trst != last_trst) {
|
||||
if (cmd->cmd.reset->trst)
|
||||
@@ -269,10 +269,10 @@ COMMAND_HANDLER(aice_handle_aice_info_command)
|
||||
{
|
||||
LOG_DEBUG("aice_handle_aice_info_command");
|
||||
|
||||
command_print(CMD_CTX, "Description: %s", param.device_desc);
|
||||
command_print(CMD_CTX, "Serial number: %s", param.serial);
|
||||
command_print(CMD, "Description: %s", param.device_desc);
|
||||
command_print(CMD, "Serial number: %s", param.serial);
|
||||
if (strncmp(aice_port->name, "aice_pipe", 9) == 0)
|
||||
command_print(CMD_CTX, "Adapter: %s", param.adapter_name);
|
||||
command_print(CMD, "Adapter: %s", param.adapter_name);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -165,9 +165,9 @@ COMMAND_HANDLER(handle_scan_chain_command)
|
||||
|
||||
aice_scan_jtag_chain();
|
||||
tap = jtag_all_taps();
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
" TapName Enabled IdCode Expected IrLen IrCap IrMask");
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"-- ------------------- -------- ---------- ---------- ----- ----- ------");
|
||||
|
||||
while (tap) {
|
||||
@@ -183,7 +183,7 @@ COMMAND_HANDLER(handle_scan_chain_command)
|
||||
expected = buf_get_u32(tap->expected, 0, tap->ir_length);
|
||||
expected_mask = buf_get_u32(tap->expected_mask, 0, tap->ir_length);
|
||||
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"%2d %-18s %c 0x%08x %s %5d 0x%02x 0x%02x",
|
||||
tap->abs_chain_position,
|
||||
tap->dotted_name,
|
||||
@@ -200,7 +200,7 @@ COMMAND_HANDLER(handle_scan_chain_command)
|
||||
if (tap->ignore_version)
|
||||
expected_id[2] = '*';
|
||||
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
" %s",
|
||||
expected_id);
|
||||
}
|
||||
|
||||
@@ -400,7 +400,7 @@ static int aice_usb_write(uint8_t *out_buffer, int out_length)
|
||||
result = usb_bulk_write_ex(aice_handler.usb_handle, aice_handler.usb_write_ep,
|
||||
(char *)out_buffer, out_length, AICE_USB_TIMEOUT);
|
||||
|
||||
DEBUG_JTAG_IO("aice_usb_write, out_length = %i, result = %i",
|
||||
LOG_DEBUG_IO("aice_usb_write, out_length = %i, result = %i",
|
||||
out_length, result);
|
||||
|
||||
return result;
|
||||
@@ -412,7 +412,7 @@ static int aice_usb_read(uint8_t *in_buffer, int expected_size)
|
||||
int32_t result = usb_bulk_read_ex(aice_handler.usb_handle, aice_handler.usb_read_ep,
|
||||
(char *)in_buffer, expected_size, AICE_USB_TIMEOUT);
|
||||
|
||||
DEBUG_JTAG_IO("aice_usb_read, result = %" PRId32, result);
|
||||
LOG_DEBUG_IO("aice_usb_read, result = %" PRId32, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -2812,7 +2812,7 @@ static int aice_issue_reset_hold(uint32_t coreid)
|
||||
/* set no_dbgi_pin to 0 */
|
||||
uint32_t pin_status;
|
||||
aice_read_ctrl(AICE_READ_CTRL_GET_JTAG_PIN_STATUS, &pin_status);
|
||||
if (pin_status | 0x4)
|
||||
if (pin_status & 0x4)
|
||||
aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_STATUS, pin_status & (~0x4));
|
||||
|
||||
/* issue restart */
|
||||
|
||||
+20
-20
@@ -193,33 +193,33 @@ int jtag_build_buffer(const struct scan_command *cmd, uint8_t **buffer)
|
||||
|
||||
bit_count = 0;
|
||||
|
||||
DEBUG_JTAG_IO("%s num_fields: %i",
|
||||
LOG_DEBUG_IO("%s num_fields: %i",
|
||||
cmd->ir_scan ? "IRSCAN" : "DRSCAN",
|
||||
cmd->num_fields);
|
||||
|
||||
for (i = 0; i < cmd->num_fields; i++) {
|
||||
if (cmd->fields[i].out_value) {
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
char *char_buf = buf_to_str(cmd->fields[i].out_value,
|
||||
(cmd->fields[i].num_bits > DEBUG_JTAG_IOZ)
|
||||
? DEBUG_JTAG_IOZ
|
||||
: cmd->fields[i].num_bits, 16);
|
||||
if (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO)) {
|
||||
char *char_buf = buf_to_str(cmd->fields[i].out_value,
|
||||
(cmd->fields[i].num_bits > DEBUG_JTAG_IOZ)
|
||||
? DEBUG_JTAG_IOZ
|
||||
: cmd->fields[i].num_bits, 16);
|
||||
|
||||
LOG_DEBUG("fields[%i].out_value[%i]: 0x%s", i,
|
||||
cmd->fields[i].num_bits, char_buf);
|
||||
free(char_buf);
|
||||
#endif
|
||||
LOG_DEBUG("fields[%i].out_value[%i]: 0x%s", i,
|
||||
cmd->fields[i].num_bits, char_buf);
|
||||
free(char_buf);
|
||||
}
|
||||
buf_set_buf(cmd->fields[i].out_value, 0, *buffer,
|
||||
bit_count, cmd->fields[i].num_bits);
|
||||
} else {
|
||||
DEBUG_JTAG_IO("fields[%i].out_value[%i]: NULL",
|
||||
LOG_DEBUG_IO("fields[%i].out_value[%i]: NULL",
|
||||
i, cmd->fields[i].num_bits);
|
||||
}
|
||||
|
||||
bit_count += cmd->fields[i].num_bits;
|
||||
}
|
||||
|
||||
/*DEBUG_JTAG_IO("bit_count totalling: %i", bit_count); */
|
||||
/*LOG_DEBUG_IO("bit_count totalling: %i", bit_count); */
|
||||
|
||||
return bit_count;
|
||||
}
|
||||
@@ -242,16 +242,16 @@ int jtag_read_buffer(uint8_t *buffer, const struct scan_command *cmd)
|
||||
uint8_t *captured = buf_set_buf(buffer, bit_count,
|
||||
malloc(DIV_ROUND_UP(num_bits, 8)), 0, num_bits);
|
||||
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
char *char_buf = buf_to_str(captured,
|
||||
(num_bits > DEBUG_JTAG_IOZ)
|
||||
if (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO)) {
|
||||
char *char_buf = buf_to_str(captured,
|
||||
(num_bits > DEBUG_JTAG_IOZ)
|
||||
? DEBUG_JTAG_IOZ
|
||||
: num_bits, 16);
|
||||
: num_bits, 16);
|
||||
|
||||
LOG_DEBUG("fields[%i].in_value[%i]: 0x%s",
|
||||
i, num_bits, char_buf);
|
||||
free(char_buf);
|
||||
#endif
|
||||
LOG_DEBUG("fields[%i].in_value[%i]: 0x%s",
|
||||
i, num_bits, char_buf);
|
||||
free(char_buf);
|
||||
}
|
||||
|
||||
if (cmd->fields[i].in_value)
|
||||
buf_cpy(captured, cmd->fields[i].in_value, num_bits);
|
||||
|
||||
+29
-24
@@ -1007,7 +1007,7 @@ static bool jtag_examine_chain_match_tap(const struct jtag_tap *tap)
|
||||
return true;
|
||||
|
||||
/* optionally ignore the JTAG version field - bits 28-31 of IDCODE */
|
||||
uint32_t mask = tap->ignore_version ? ~(0xf << 28) : ~0;
|
||||
uint32_t mask = tap->ignore_version ? ~(0xfU << 28) : ~0U;
|
||||
uint32_t idcode = tap->idcode & mask;
|
||||
|
||||
/* Loop over the expected identification codes and test for a match */
|
||||
@@ -1348,19 +1348,6 @@ int adapter_init(struct command_context *cmd_ctx)
|
||||
return retval;
|
||||
jtag = jtag_interface;
|
||||
|
||||
/* LEGACY SUPPORT ... adapter drivers must declare what
|
||||
* transports they allow. Until they all do so, assume
|
||||
* the legacy drivers are JTAG-only
|
||||
*/
|
||||
if (!transports_are_declared()) {
|
||||
LOG_ERROR("Adapter driver '%s' did not declare "
|
||||
"which transports it allows; assuming "
|
||||
"JTAG-only", jtag->name);
|
||||
retval = allow_transports(cmd_ctx, jtag_only);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
}
|
||||
|
||||
if (jtag->speed == NULL) {
|
||||
LOG_INFO("This adapter doesn't support configurable speed");
|
||||
return ERROR_OK;
|
||||
@@ -1611,14 +1598,18 @@ static int adapter_khz_to_speed(unsigned khz, int *speed)
|
||||
{
|
||||
LOG_DEBUG("convert khz to interface specific speed value");
|
||||
speed_khz = khz;
|
||||
if (jtag != NULL) {
|
||||
LOG_DEBUG("have interface set up");
|
||||
int speed_div1;
|
||||
int retval = jtag->khz(jtag_get_speed_khz(), &speed_div1);
|
||||
if (ERROR_OK != retval)
|
||||
return retval;
|
||||
*speed = speed_div1;
|
||||
if (!jtag)
|
||||
return ERROR_OK;
|
||||
LOG_DEBUG("have interface set up");
|
||||
if (!jtag->khz) {
|
||||
LOG_ERROR("Translation from khz to jtag_speed not implemented");
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
int speed_div1;
|
||||
int retval = jtag->khz(jtag_get_speed_khz(), &speed_div1);
|
||||
if (ERROR_OK != retval)
|
||||
return retval;
|
||||
*speed = speed_div1;
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -1681,7 +1672,13 @@ int jtag_get_speed_readable(int *khz)
|
||||
int retval = jtag_get_speed(&jtag_speed_var);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
return jtag ? jtag->speed_div(jtag_speed_var, khz) : ERROR_OK;
|
||||
if (!jtag)
|
||||
return ERROR_OK;
|
||||
if (!jtag->speed_div) {
|
||||
LOG_ERROR("Translation from jtag_speed to khz not implemented");
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
return jtag->speed_div(jtag_speed_var, khz);
|
||||
}
|
||||
|
||||
void jtag_set_verify(bool enable)
|
||||
@@ -1712,12 +1709,20 @@ int jtag_power_dropout(int *dropout)
|
||||
LOG_ERROR("No Valid JTAG Interface Configured.");
|
||||
exit(-1);
|
||||
}
|
||||
return jtag->power_dropout(dropout);
|
||||
if (jtag->power_dropout)
|
||||
return jtag->power_dropout(dropout);
|
||||
|
||||
*dropout = 0; /* by default we can't detect power dropout */
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
int jtag_srst_asserted(int *srst_asserted)
|
||||
{
|
||||
return jtag->srst_asserted(srst_asserted);
|
||||
if (jtag->srst_asserted)
|
||||
return jtag->srst_asserted(srst_asserted);
|
||||
|
||||
*srst_asserted = 0; /* by default we can't detect srst asserted */
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
enum reset_types jtag_get_reset_config(void)
|
||||
|
||||
@@ -343,35 +343,27 @@ static int amt_jtagaccel_execute_queue(void)
|
||||
while (cmd) {
|
||||
switch (cmd->type) {
|
||||
case JTAG_RESET:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("reset trst: %i srst %i",
|
||||
cmd->cmd.reset->trst,
|
||||
cmd->cmd.reset->srst);
|
||||
#endif
|
||||
LOG_DEBUG_IO("reset trst: %i srst %i",
|
||||
cmd->cmd.reset->trst,
|
||||
cmd->cmd.reset->srst);
|
||||
if (cmd->cmd.reset->trst == 1)
|
||||
tap_set_state(TAP_RESET);
|
||||
amt_jtagaccel_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
|
||||
break;
|
||||
case JTAG_RUNTEST:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("runtest %i cycles, end in %i",
|
||||
cmd->cmd.runtest->num_cycles,
|
||||
cmd->cmd.runtest->end_state);
|
||||
#endif
|
||||
LOG_DEBUG_IO("runtest %i cycles, end in %i",
|
||||
cmd->cmd.runtest->num_cycles,
|
||||
cmd->cmd.runtest->end_state);
|
||||
amt_jtagaccel_end_state(cmd->cmd.runtest->end_state);
|
||||
amt_jtagaccel_runtest(cmd->cmd.runtest->num_cycles);
|
||||
break;
|
||||
case JTAG_TLR_RESET:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("statemove end in %i", cmd->cmd.statemove->end_state);
|
||||
#endif
|
||||
LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
|
||||
amt_jtagaccel_end_state(cmd->cmd.statemove->end_state);
|
||||
amt_jtagaccel_state_move();
|
||||
break;
|
||||
case JTAG_SCAN:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("scan end in %i", cmd->cmd.scan->end_state);
|
||||
#endif
|
||||
LOG_DEBUG_IO("scan end in %i", cmd->cmd.scan->end_state);
|
||||
amt_jtagaccel_end_state(cmd->cmd.scan->end_state);
|
||||
scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
|
||||
type = jtag_scan_type(cmd->cmd.scan);
|
||||
@@ -382,9 +374,7 @@ static int amt_jtagaccel_execute_queue(void)
|
||||
free(buffer);
|
||||
break;
|
||||
case JTAG_SLEEP:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("sleep %" PRIi32, cmd->cmd.sleep->us);
|
||||
#endif
|
||||
LOG_DEBUG_IO("sleep %" PRIi32, cmd->cmd.sleep->us);
|
||||
jtag_sleep(cmd->cmd.sleep->us);
|
||||
break;
|
||||
default:
|
||||
@@ -548,7 +538,7 @@ COMMAND_HANDLER(amt_jtagaccel_handle_parport_port_command)
|
||||
}
|
||||
}
|
||||
|
||||
command_print(CMD_CTX, "parport port = %u", amt_jtagaccel_port);
|
||||
command_print(CMD, "parport port = %u", amt_jtagaccel_port);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -556,7 +546,7 @@ COMMAND_HANDLER(amt_jtagaccel_handle_parport_port_command)
|
||||
COMMAND_HANDLER(amt_jtagaccel_handle_rtck_command)
|
||||
{
|
||||
if (CMD_ARGC == 0) {
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"amt_jtagaccel RTCK feature %s",
|
||||
(rtck_enabled) ? "enabled" : "disabled");
|
||||
return ERROR_OK;
|
||||
@@ -596,6 +586,7 @@ static const struct command_registration amtjtagaccel_command_handlers[] = {
|
||||
|
||||
struct jtag_interface amt_jtagaccel_interface = {
|
||||
.name = "amt_jtagaccel",
|
||||
.transports = jtag_only,
|
||||
.commands = amtjtagaccel_command_handlers,
|
||||
|
||||
.init = amt_jtagaccel_init,
|
||||
|
||||
@@ -106,7 +106,7 @@ static int armjtagew_execute_queue(void)
|
||||
while (cmd != NULL) {
|
||||
switch (cmd->type) {
|
||||
case JTAG_RUNTEST:
|
||||
DEBUG_JTAG_IO("runtest %i cycles, end in %i",
|
||||
LOG_DEBUG_IO("runtest %i cycles, end in %i",
|
||||
cmd->cmd.runtest->num_cycles, \
|
||||
cmd->cmd.runtest->end_state);
|
||||
|
||||
@@ -115,14 +115,14 @@ static int armjtagew_execute_queue(void)
|
||||
break;
|
||||
|
||||
case JTAG_TLR_RESET:
|
||||
DEBUG_JTAG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
|
||||
LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
|
||||
|
||||
armjtagew_end_state(cmd->cmd.statemove->end_state);
|
||||
armjtagew_state_move();
|
||||
break;
|
||||
|
||||
case JTAG_PATHMOVE:
|
||||
DEBUG_JTAG_IO("pathmove: %i states, end in %i", \
|
||||
LOG_DEBUG_IO("pathmove: %i states, end in %i", \
|
||||
cmd->cmd.pathmove->num_states, \
|
||||
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
|
||||
|
||||
@@ -131,12 +131,12 @@ static int armjtagew_execute_queue(void)
|
||||
break;
|
||||
|
||||
case JTAG_SCAN:
|
||||
DEBUG_JTAG_IO("scan end in %i", cmd->cmd.scan->end_state);
|
||||
LOG_DEBUG_IO("scan end in %i", cmd->cmd.scan->end_state);
|
||||
|
||||
armjtagew_end_state(cmd->cmd.scan->end_state);
|
||||
|
||||
scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
|
||||
DEBUG_JTAG_IO("scan input, length = %d", scan_size);
|
||||
LOG_DEBUG_IO("scan input, length = %d", scan_size);
|
||||
|
||||
#ifdef _DEBUG_USB_COMMS_
|
||||
armjtagew_debug_buffer(buffer, (scan_size + 7) / 8);
|
||||
@@ -148,7 +148,7 @@ static int armjtagew_execute_queue(void)
|
||||
break;
|
||||
|
||||
case JTAG_RESET:
|
||||
DEBUG_JTAG_IO("reset trst: %i srst %i",
|
||||
LOG_DEBUG_IO("reset trst: %i srst %i",
|
||||
cmd->cmd.reset->trst,
|
||||
cmd->cmd.reset->srst);
|
||||
|
||||
@@ -160,7 +160,7 @@ static int armjtagew_execute_queue(void)
|
||||
break;
|
||||
|
||||
case JTAG_SLEEP:
|
||||
DEBUG_JTAG_IO("sleep %i", cmd->cmd.sleep->us);
|
||||
LOG_DEBUG_IO("sleep %i", cmd->cmd.sleep->us);
|
||||
armjtagew_tap_execute();
|
||||
jtag_sleep(cmd->cmd.sleep->us);
|
||||
break;
|
||||
@@ -490,6 +490,7 @@ static const struct command_registration armjtagew_command_handlers[] = {
|
||||
.handler = &armjtagew_handle_armjtagew_info_command,
|
||||
.mode = COMMAND_EXEC,
|
||||
.help = "query armjtagew info",
|
||||
.usage = "",
|
||||
},
|
||||
COMMAND_REGISTRATION_DONE
|
||||
};
|
||||
@@ -646,7 +647,7 @@ static int armjtagew_tap_execute(void)
|
||||
/* Copy to buffer */
|
||||
buf_set_buf(tdo_buffer, first, buffer, 0, length);
|
||||
|
||||
DEBUG_JTAG_IO("pending scan result, length = %d", length);
|
||||
LOG_DEBUG_IO("pending scan result, length = %d", length);
|
||||
|
||||
#ifdef _DEBUG_USB_COMMS_
|
||||
armjtagew_debug_buffer(buffer, byte_length);
|
||||
@@ -746,7 +747,7 @@ static int armjtagew_usb_write(struct armjtagew *armjtagew, int out_length)
|
||||
result = usb_bulk_write(armjtagew->usb_handle, ARMJTAGEW_EPT_BULK_OUT, \
|
||||
(char *)usb_out_buffer, out_length, ARMJTAGEW_USB_TIMEOUT);
|
||||
|
||||
DEBUG_JTAG_IO("armjtagew_usb_write, out_length = %d, result = %d", out_length, result);
|
||||
LOG_DEBUG_IO("armjtagew_usb_write, out_length = %d, result = %d", out_length, result);
|
||||
|
||||
#ifdef _DEBUG_USB_COMMS_
|
||||
armjtagew_debug_buffer(usb_out_buffer, out_length);
|
||||
@@ -760,7 +761,7 @@ static int armjtagew_usb_read(struct armjtagew *armjtagew, int exp_in_length)
|
||||
int result = usb_bulk_read(armjtagew->usb_handle, ARMJTAGEW_EPT_BULK_IN, \
|
||||
(char *)usb_in_buffer, exp_in_length, ARMJTAGEW_USB_TIMEOUT);
|
||||
|
||||
DEBUG_JTAG_IO("armjtagew_usb_read, result = %d", result);
|
||||
LOG_DEBUG_IO("armjtagew_usb_read, result = %d", result);
|
||||
|
||||
#ifdef _DEBUG_USB_COMMS_
|
||||
armjtagew_debug_buffer(usb_in_buffer, result);
|
||||
|
||||
@@ -183,7 +183,8 @@ static const struct command_registration at91rm9200_command_handlers[] = {
|
||||
.name = "at91rm9200_device",
|
||||
.handler = &at91rm9200_handle_device_command,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "query armjtagew info",
|
||||
.help = "Set at91rm9200 device [default \"rea_ecr\"]",
|
||||
.usage = "<device>",
|
||||
},
|
||||
COMMAND_REGISTRATION_DONE
|
||||
};
|
||||
@@ -191,6 +192,7 @@ static const struct command_registration at91rm9200_command_handlers[] = {
|
||||
struct jtag_interface at91rm9200_interface = {
|
||||
.name = "at91rm9200",
|
||||
.execute_queue = bitbang_execute_queue,
|
||||
.transports = jtag_only,
|
||||
.commands = at91rm9200_command_handlers,
|
||||
.init = at91rm9200_init,
|
||||
.quit = at91rm9200_quit,
|
||||
|
||||
@@ -199,7 +199,7 @@ COMMAND_HANDLER(bcm2835gpio_handle_jtag_gpionums)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"BCM2835 GPIO config: tck = %d, tms = %d, tdi = %d, tdo = %d",
|
||||
tck_gpio, tms_gpio, tdi_gpio, tdo_gpio);
|
||||
|
||||
@@ -211,7 +211,7 @@ COMMAND_HANDLER(bcm2835gpio_handle_jtag_gpionum_tck)
|
||||
if (CMD_ARGC == 1)
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], tck_gpio);
|
||||
|
||||
command_print(CMD_CTX, "BCM2835 GPIO config: tck = %d", tck_gpio);
|
||||
command_print(CMD, "BCM2835 GPIO config: tck = %d", tck_gpio);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ COMMAND_HANDLER(bcm2835gpio_handle_jtag_gpionum_tms)
|
||||
if (CMD_ARGC == 1)
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], tms_gpio);
|
||||
|
||||
command_print(CMD_CTX, "BCM2835 GPIO config: tms = %d", tms_gpio);
|
||||
command_print(CMD, "BCM2835 GPIO config: tms = %d", tms_gpio);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ COMMAND_HANDLER(bcm2835gpio_handle_jtag_gpionum_tdo)
|
||||
if (CMD_ARGC == 1)
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], tdo_gpio);
|
||||
|
||||
command_print(CMD_CTX, "BCM2835 GPIO config: tdo = %d", tdo_gpio);
|
||||
command_print(CMD, "BCM2835 GPIO config: tdo = %d", tdo_gpio);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ COMMAND_HANDLER(bcm2835gpio_handle_jtag_gpionum_tdi)
|
||||
if (CMD_ARGC == 1)
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], tdi_gpio);
|
||||
|
||||
command_print(CMD_CTX, "BCM2835 GPIO config: tdi = %d", tdi_gpio);
|
||||
command_print(CMD, "BCM2835 GPIO config: tdi = %d", tdi_gpio);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ COMMAND_HANDLER(bcm2835gpio_handle_jtag_gpionum_srst)
|
||||
if (CMD_ARGC == 1)
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], srst_gpio);
|
||||
|
||||
command_print(CMD_CTX, "BCM2835 GPIO config: srst = %d", srst_gpio);
|
||||
command_print(CMD, "BCM2835 GPIO config: srst = %d", srst_gpio);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ COMMAND_HANDLER(bcm2835gpio_handle_jtag_gpionum_trst)
|
||||
if (CMD_ARGC == 1)
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], trst_gpio);
|
||||
|
||||
command_print(CMD_CTX, "BCM2835 GPIO config: trst = %d", trst_gpio);
|
||||
command_print(CMD, "BCM2835 GPIO config: trst = %d", trst_gpio);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ COMMAND_HANDLER(bcm2835gpio_handle_swd_gpionums)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"BCM2835 GPIO nums: swclk = %d, swdio = %d",
|
||||
swclk_gpio, swdio_gpio);
|
||||
|
||||
@@ -281,7 +281,7 @@ COMMAND_HANDLER(bcm2835gpio_handle_swd_gpionum_swclk)
|
||||
if (CMD_ARGC == 1)
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], swclk_gpio);
|
||||
|
||||
command_print(CMD_CTX, "BCM2835 num: swclk = %d", swclk_gpio);
|
||||
command_print(CMD, "BCM2835 num: swclk = %d", swclk_gpio);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -290,7 +290,7 @@ COMMAND_HANDLER(bcm2835gpio_handle_swd_gpionum_swdio)
|
||||
if (CMD_ARGC == 1)
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], swdio_gpio);
|
||||
|
||||
command_print(CMD_CTX, "BCM2835 num: swdio = %d", swdio_gpio);
|
||||
command_print(CMD, "BCM2835 num: swdio = %d", swdio_gpio);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -300,6 +300,9 @@ COMMAND_HANDLER(bcm2835gpio_handle_speed_coeffs)
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], speed_coeff);
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[1], speed_offset);
|
||||
}
|
||||
|
||||
command_print(CMD, "BCM2835 GPIO: speed_coeffs = %d, speed_offset = %d",
|
||||
speed_coeff, speed_offset);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -307,6 +310,9 @@ COMMAND_HANDLER(bcm2835gpio_handle_peripheral_base)
|
||||
{
|
||||
if (CMD_ARGC == 1)
|
||||
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], bcm2835_peri_base);
|
||||
|
||||
command_print(CMD, "BCM2835 GPIO: peripheral_base = 0x%08x",
|
||||
bcm2835_peri_base);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -316,74 +322,84 @@ static const struct command_registration bcm2835gpio_command_handlers[] = {
|
||||
.handler = &bcm2835gpio_handle_jtag_gpionums,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "gpio numbers for tck, tms, tdi, tdo. (in that order)",
|
||||
.usage = "(tck tms tdi tdo)* ",
|
||||
.usage = "[tck tms tdi tdo]",
|
||||
},
|
||||
{
|
||||
.name = "bcm2835gpio_tck_num",
|
||||
.handler = &bcm2835gpio_handle_jtag_gpionum_tck,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "gpio number for tck.",
|
||||
.usage = "[tck]",
|
||||
},
|
||||
{
|
||||
.name = "bcm2835gpio_tms_num",
|
||||
.handler = &bcm2835gpio_handle_jtag_gpionum_tms,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "gpio number for tms.",
|
||||
.usage = "[tms]",
|
||||
},
|
||||
{
|
||||
.name = "bcm2835gpio_tdo_num",
|
||||
.handler = &bcm2835gpio_handle_jtag_gpionum_tdo,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "gpio number for tdo.",
|
||||
.usage = "[tdo]",
|
||||
},
|
||||
{
|
||||
.name = "bcm2835gpio_tdi_num",
|
||||
.handler = &bcm2835gpio_handle_jtag_gpionum_tdi,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "gpio number for tdi.",
|
||||
.usage = "[tdi]",
|
||||
},
|
||||
{
|
||||
.name = "bcm2835gpio_swd_nums",
|
||||
.handler = &bcm2835gpio_handle_swd_gpionums,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "gpio numbers for swclk, swdio. (in that order)",
|
||||
.usage = "(swclk swdio)* ",
|
||||
.usage = "[swclk swdio]",
|
||||
},
|
||||
{
|
||||
.name = "bcm2835gpio_swclk_num",
|
||||
.handler = &bcm2835gpio_handle_swd_gpionum_swclk,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "gpio number for swclk.",
|
||||
.usage = "[swclk]",
|
||||
},
|
||||
{
|
||||
.name = "bcm2835gpio_swdio_num",
|
||||
.handler = &bcm2835gpio_handle_swd_gpionum_swdio,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "gpio number for swdio.",
|
||||
.usage = "[swdio]",
|
||||
},
|
||||
{
|
||||
.name = "bcm2835gpio_srst_num",
|
||||
.handler = &bcm2835gpio_handle_jtag_gpionum_srst,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "gpio number for srst.",
|
||||
.usage = "[srst]",
|
||||
},
|
||||
{
|
||||
.name = "bcm2835gpio_trst_num",
|
||||
.handler = &bcm2835gpio_handle_jtag_gpionum_trst,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "gpio number for trst.",
|
||||
.usage = "[trst]",
|
||||
},
|
||||
{
|
||||
.name = "bcm2835gpio_speed_coeffs",
|
||||
.handler = &bcm2835gpio_handle_speed_coeffs,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "SPEED_COEFF and SPEED_OFFSET for delay calculations.",
|
||||
.usage = "[SPEED_COEFF SPEED_OFFSET]",
|
||||
},
|
||||
{
|
||||
.name = "bcm2835gpio_peripheral_base",
|
||||
.handler = &bcm2835gpio_handle_peripheral_base,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "peripheral base to access GPIOs (RPi1 0x20000000, RPi2 0x3F000000).",
|
||||
.usage = "[base]",
|
||||
},
|
||||
|
||||
COMMAND_REGISTRATION_DONE
|
||||
|
||||
@@ -100,7 +100,7 @@ static int bitbang_execute_tms(struct jtag_command *cmd)
|
||||
unsigned num_bits = cmd->cmd.tms->num_bits;
|
||||
const uint8_t *bits = cmd->cmd.tms->bits;
|
||||
|
||||
DEBUG_JTAG_IO("TMS: %d bits", num_bits);
|
||||
LOG_DEBUG_IO("TMS: %d bits", num_bits);
|
||||
|
||||
int tms = 0;
|
||||
for (unsigned i = 0; i < num_bits; i++) {
|
||||
@@ -315,11 +315,9 @@ int bitbang_execute_queue(void)
|
||||
while (cmd) {
|
||||
switch (cmd->type) {
|
||||
case JTAG_RESET:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("reset trst: %i srst %i",
|
||||
cmd->cmd.reset->trst,
|
||||
cmd->cmd.reset->srst);
|
||||
#endif
|
||||
LOG_DEBUG_IO("reset trst: %i srst %i",
|
||||
cmd->cmd.reset->trst,
|
||||
cmd->cmd.reset->srst);
|
||||
if ((cmd->cmd.reset->trst == 1) ||
|
||||
(cmd->cmd.reset->srst && (jtag_get_reset_config() & RESET_SRST_PULLS_TRST)))
|
||||
tap_set_state(TAP_RESET);
|
||||
@@ -328,11 +326,9 @@ int bitbang_execute_queue(void)
|
||||
return ERROR_FAIL;
|
||||
break;
|
||||
case JTAG_RUNTEST:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("runtest %i cycles, end in %s",
|
||||
LOG_DEBUG_IO("runtest %i cycles, end in %s",
|
||||
cmd->cmd.runtest->num_cycles,
|
||||
tap_state_name(cmd->cmd.runtest->end_state));
|
||||
#endif
|
||||
bitbang_end_state(cmd->cmd.runtest->end_state);
|
||||
if (bitbang_runtest(cmd->cmd.runtest->num_cycles) != ERROR_OK)
|
||||
return ERROR_FAIL;
|
||||
@@ -347,32 +343,26 @@ int bitbang_execute_queue(void)
|
||||
break;
|
||||
|
||||
case JTAG_TLR_RESET:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("statemove end in %s",
|
||||
LOG_DEBUG_IO("statemove end in %s",
|
||||
tap_state_name(cmd->cmd.statemove->end_state));
|
||||
#endif
|
||||
bitbang_end_state(cmd->cmd.statemove->end_state);
|
||||
if (bitbang_state_move(0) != ERROR_OK)
|
||||
return ERROR_FAIL;
|
||||
break;
|
||||
case JTAG_PATHMOVE:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("pathmove: %i states, end in %s",
|
||||
LOG_DEBUG_IO("pathmove: %i states, end in %s",
|
||||
cmd->cmd.pathmove->num_states,
|
||||
tap_state_name(cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]));
|
||||
#endif
|
||||
if (bitbang_path_move(cmd->cmd.pathmove) != ERROR_OK)
|
||||
return ERROR_FAIL;
|
||||
break;
|
||||
case JTAG_SCAN:
|
||||
bitbang_end_state(cmd->cmd.scan->end_state);
|
||||
scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("%s scan %d bits; end in %s",
|
||||
LOG_DEBUG_IO("%s scan %d bits; end in %s",
|
||||
(cmd->cmd.scan->ir_scan) ? "IR" : "DR",
|
||||
scan_size,
|
||||
tap_state_name(cmd->cmd.scan->end_state));
|
||||
#endif
|
||||
type = jtag_scan_type(cmd->cmd.scan);
|
||||
if (bitbang_scan(cmd->cmd.scan->ir_scan, type, buffer,
|
||||
scan_size) != ERROR_OK)
|
||||
@@ -383,9 +373,7 @@ int bitbang_execute_queue(void)
|
||||
free(buffer);
|
||||
break;
|
||||
case JTAG_SLEEP:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("sleep %" PRIi32, cmd->cmd.sleep->us);
|
||||
#endif
|
||||
LOG_DEBUG_IO("sleep %" PRIi32, cmd->cmd.sleep->us);
|
||||
jtag_sleep(cmd->cmd.sleep->us);
|
||||
break;
|
||||
case JTAG_TMS:
|
||||
|
||||
+8
-25
@@ -59,9 +59,7 @@ static void bitq_in_proc(void)
|
||||
|
||||
int tdo = bitq_interface->in();
|
||||
if (tdo < 0) {
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("bitq in EOF");
|
||||
#endif
|
||||
LOG_DEBUG_IO("bitq in EOF");
|
||||
return;
|
||||
}
|
||||
if (in_mask == 0x01)
|
||||
@@ -228,9 +226,7 @@ int bitq_execute_queue(void)
|
||||
while (cmd) {
|
||||
switch (cmd->type) {
|
||||
case JTAG_RESET:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst);
|
||||
#endif
|
||||
LOG_DEBUG_IO("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst);
|
||||
if ((cmd->cmd.reset->trst == 1) ||
|
||||
(cmd->cmd.reset->srst &&
|
||||
(jtag_get_reset_config() & RESET_SRST_PULLS_TRST)))
|
||||
@@ -241,37 +237,26 @@ int bitq_execute_queue(void)
|
||||
break;
|
||||
|
||||
case JTAG_RUNTEST:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->end_state);
|
||||
#endif
|
||||
LOG_DEBUG_IO("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->end_state);
|
||||
bitq_end_state(cmd->cmd.runtest->end_state);
|
||||
bitq_runtest(cmd->cmd.runtest->num_cycles);
|
||||
break;
|
||||
|
||||
case JTAG_TLR_RESET:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("statemove end in %i", cmd->cmd.statemove->end_state);
|
||||
#endif
|
||||
LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
|
||||
bitq_end_state(cmd->cmd.statemove->end_state);
|
||||
bitq_state_move(tap_get_end_state()); /* uncoditional TAP move */
|
||||
break;
|
||||
|
||||
case JTAG_PATHMOVE:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("pathmove: %i states, end in %i", cmd->cmd.pathmove->num_states,
|
||||
LOG_DEBUG_IO("pathmove: %i states, end in %i", cmd->cmd.pathmove->num_states,
|
||||
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
|
||||
#endif
|
||||
bitq_path_move(cmd->cmd.pathmove);
|
||||
break;
|
||||
|
||||
case JTAG_SCAN:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("scan end in %i", cmd->cmd.scan->end_state);
|
||||
if (cmd->cmd.scan->ir_scan)
|
||||
LOG_DEBUG("scan ir");
|
||||
else
|
||||
LOG_DEBUG("scan dr");
|
||||
#endif
|
||||
LOG_DEBUG_IO("scan end in %i", cmd->cmd.scan->end_state);
|
||||
LOG_DEBUG_IO("scan %s", cmd->cmd.scan->ir_scan ? "ir" : "dr");
|
||||
bitq_end_state(cmd->cmd.scan->end_state);
|
||||
bitq_scan(cmd->cmd.scan);
|
||||
if (tap_get_state() != tap_get_end_state())
|
||||
@@ -279,9 +264,7 @@ int bitq_execute_queue(void)
|
||||
break;
|
||||
|
||||
case JTAG_SLEEP:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("sleep %i", cmd->cmd.sleep->us);
|
||||
#endif
|
||||
LOG_DEBUG_IO("sleep %i", cmd->cmd.sleep->us);
|
||||
bitq_interface->sleep(cmd->cmd.sleep->us);
|
||||
if (bitq_interface->in_rdy())
|
||||
bitq_in_proc();
|
||||
|
||||
@@ -171,7 +171,7 @@ static int buspirate_execute_queue(void)
|
||||
while (cmd) {
|
||||
switch (cmd->type) {
|
||||
case JTAG_RUNTEST:
|
||||
DEBUG_JTAG_IO("runtest %i cycles, end in %s",
|
||||
LOG_DEBUG_IO("runtest %i cycles, end in %s",
|
||||
cmd->cmd.runtest->num_cycles,
|
||||
tap_state_name(cmd->cmd.runtest
|
||||
->end_state));
|
||||
@@ -181,7 +181,7 @@ static int buspirate_execute_queue(void)
|
||||
->num_cycles);
|
||||
break;
|
||||
case JTAG_TLR_RESET:
|
||||
DEBUG_JTAG_IO("statemove end in %s",
|
||||
LOG_DEBUG_IO("statemove end in %s",
|
||||
tap_state_name(cmd->cmd.statemove
|
||||
->end_state));
|
||||
buspirate_end_state(cmd->cmd.statemove
|
||||
@@ -189,7 +189,7 @@ static int buspirate_execute_queue(void)
|
||||
buspirate_state_move();
|
||||
break;
|
||||
case JTAG_PATHMOVE:
|
||||
DEBUG_JTAG_IO("pathmove: %i states, end in %s",
|
||||
LOG_DEBUG_IO("pathmove: %i states, end in %s",
|
||||
cmd->cmd.pathmove->num_states,
|
||||
tap_state_name(cmd->cmd.pathmove
|
||||
->path[cmd->cmd.pathmove
|
||||
@@ -199,7 +199,7 @@ static int buspirate_execute_queue(void)
|
||||
cmd->cmd.pathmove->path);
|
||||
break;
|
||||
case JTAG_SCAN:
|
||||
DEBUG_JTAG_IO("scan end in %s",
|
||||
LOG_DEBUG_IO("scan end in %s",
|
||||
tap_state_name(cmd->cmd.scan
|
||||
->end_state));
|
||||
|
||||
@@ -214,7 +214,7 @@ static int buspirate_execute_queue(void)
|
||||
|
||||
break;
|
||||
case JTAG_RESET:
|
||||
DEBUG_JTAG_IO("reset trst: %i srst %i",
|
||||
LOG_DEBUG_IO("reset trst: %i srst %i",
|
||||
cmd->cmd.reset->trst, cmd->cmd.reset->srst);
|
||||
|
||||
/* flush buffers, so we can reset */
|
||||
@@ -226,12 +226,12 @@ static int buspirate_execute_queue(void)
|
||||
cmd->cmd.reset->srst);
|
||||
break;
|
||||
case JTAG_SLEEP:
|
||||
DEBUG_JTAG_IO("sleep %i", cmd->cmd.sleep->us);
|
||||
LOG_DEBUG_IO("sleep %i", cmd->cmd.sleep->us);
|
||||
buspirate_tap_execute();
|
||||
jtag_sleep(cmd->cmd.sleep->us);
|
||||
break;
|
||||
case JTAG_STABLECLOCKS:
|
||||
DEBUG_JTAG_IO("stable clock %i cycles", cmd->cmd.stableclocks->num_cycles);
|
||||
LOG_DEBUG_IO("stable clock %i cycles", cmd->cmd.stableclocks->num_cycles);
|
||||
buspirate_stableclocks(cmd->cmd.stableclocks->num_cycles);
|
||||
break;
|
||||
default:
|
||||
@@ -491,6 +491,7 @@ static const struct command_registration buspirate_command_handlers[] = {
|
||||
.handler = &buspirate_handle_adc_command,
|
||||
.mode = COMMAND_EXEC,
|
||||
.help = "reads voltages on adc pins",
|
||||
.usage = "",
|
||||
},
|
||||
{
|
||||
.name = "buspirate_vreg",
|
||||
@@ -623,7 +624,7 @@ static void buspirate_runtest(int num_cycles)
|
||||
for (i = 0; i < num_cycles; i++)
|
||||
buspirate_tap_append(0, 0);
|
||||
|
||||
DEBUG_JTAG_IO("runtest: cur_state %s end_state %s",
|
||||
LOG_DEBUG_IO("runtest: cur_state %s end_state %s",
|
||||
tap_state_name(tap_get_state()),
|
||||
tap_state_name(tap_get_end_state()));
|
||||
|
||||
@@ -1311,7 +1312,7 @@ static int buspirate_swd_switch_seq(enum swd_special_seq seq)
|
||||
{
|
||||
const uint8_t *sequence;
|
||||
int sequence_len;
|
||||
uint8_t tmp[64];
|
||||
uint32_t no_bytes, sequence_offset;
|
||||
|
||||
switch (seq) {
|
||||
case LINE_RESET:
|
||||
@@ -1334,15 +1335,24 @@ static int buspirate_swd_switch_seq(enum swd_special_seq seq)
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
/* FIXME: all above sequences fit into one pirate command for now
|
||||
* but it may cause trouble later
|
||||
*/
|
||||
no_bytes = sequence_len;
|
||||
sequence_offset = 0;
|
||||
|
||||
tmp[0] = 0x10 + ((sequence_len - 1) & 0x0F);
|
||||
memcpy(tmp + 1, sequence, sequence_len);
|
||||
while (no_bytes) {
|
||||
uint8_t tmp[17];
|
||||
uint32_t to_send;
|
||||
|
||||
buspirate_serial_write(buspirate_fd, tmp, sequence_len + 1);
|
||||
buspirate_serial_read(buspirate_fd, tmp, sequence_len + 1);
|
||||
to_send = no_bytes > 16 ? 16 : no_bytes;
|
||||
|
||||
tmp[0] = 0x10 + ((to_send - 1) & 0x0F);
|
||||
memcpy(tmp + 1, &sequence[sequence_offset], to_send);
|
||||
|
||||
buspirate_serial_write(buspirate_fd, tmp, to_send + 1);
|
||||
buspirate_serial_read(buspirate_fd, tmp, to_send + 1);
|
||||
|
||||
no_bytes -= to_send;
|
||||
sequence_offset += to_send;
|
||||
}
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -1246,7 +1246,7 @@ static void cmsis_dap_flush(void)
|
||||
if (!queued_seq_count)
|
||||
return;
|
||||
|
||||
DEBUG_JTAG_IO("Flushing %d queued sequences (%d bytes) with %d pending scan results to capture",
|
||||
LOG_DEBUG_IO("Flushing %d queued sequences (%d bytes) with %d pending scan results to capture",
|
||||
queued_seq_count, queued_seq_buf_end, pending_scan_result_count);
|
||||
|
||||
/* prep CMSIS-DAP packet */
|
||||
@@ -1268,7 +1268,7 @@ static void cmsis_dap_flush(void)
|
||||
}
|
||||
|
||||
#ifdef CMSIS_DAP_JTAG_DEBUG
|
||||
DEBUG_JTAG_IO("USB response buf:");
|
||||
LOG_DEBUG_IO("USB response buf:");
|
||||
for (int c = 0; c < queued_seq_buf_end + 3; ++c)
|
||||
printf("%02X ", buffer[c]);
|
||||
printf("\n");
|
||||
@@ -1277,7 +1277,7 @@ static void cmsis_dap_flush(void)
|
||||
/* copy scan results into client buffers */
|
||||
for (int i = 0; i < pending_scan_result_count; ++i) {
|
||||
struct pending_scan_result *scan = &pending_scan_results[i];
|
||||
DEBUG_JTAG_IO("Copying pending_scan_result %d/%d: %d bits from byte %d -> buffer + %d bits",
|
||||
LOG_DEBUG_IO("Copying pending_scan_result %d/%d: %d bits from byte %d -> buffer + %d bits",
|
||||
i, pending_scan_result_count, scan->length, scan->first + 2, scan->buffer_offset);
|
||||
#ifdef CMSIS_DAP_JTAG_DEBUG
|
||||
for (uint32_t b = 0; b < DIV_ROUND_UP(scan->length, 8); ++b)
|
||||
@@ -1302,7 +1302,7 @@ static void cmsis_dap_flush(void)
|
||||
static void cmsis_dap_add_jtag_sequence(int s_len, const uint8_t *sequence, int s_offset,
|
||||
bool tms, uint8_t *tdo_buffer, int tdo_buffer_offset)
|
||||
{
|
||||
DEBUG_JTAG_IO("[at %d] %d bits, tms %s, seq offset %d, tdo buf %p, tdo offset %d",
|
||||
LOG_DEBUG_IO("[at %d] %d bits, tms %s, seq offset %d, tdo buf %p, tdo offset %d",
|
||||
queued_seq_buf_end,
|
||||
s_len, tms ? "HIGH" : "LOW", s_offset, tdo_buffer, tdo_buffer_offset);
|
||||
|
||||
@@ -1310,12 +1310,12 @@ static void cmsis_dap_add_jtag_sequence(int s_len, const uint8_t *sequence, int
|
||||
return;
|
||||
|
||||
if (s_len > 64) {
|
||||
DEBUG_JTAG_IO("START JTAG SEQ SPLIT");
|
||||
LOG_DEBUG_IO("START JTAG SEQ SPLIT");
|
||||
for (int offset = 0; offset < s_len; offset += 64) {
|
||||
int len = s_len - offset;
|
||||
if (len > 64)
|
||||
len = 64;
|
||||
DEBUG_JTAG_IO("Splitting long jtag sequence: %d-bit chunk starting at offset %d", len, offset);
|
||||
LOG_DEBUG_IO("Splitting long jtag sequence: %d-bit chunk starting at offset %d", len, offset);
|
||||
cmsis_dap_add_jtag_sequence(
|
||||
len,
|
||||
sequence,
|
||||
@@ -1325,7 +1325,7 @@ static void cmsis_dap_add_jtag_sequence(int s_len, const uint8_t *sequence, int
|
||||
tdo_buffer == NULL ? 0 : (tdo_buffer_offset + offset)
|
||||
);
|
||||
}
|
||||
DEBUG_JTAG_IO("END JTAG SEQ SPLIT");
|
||||
LOG_DEBUG_IO("END JTAG SEQ SPLIT");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1362,7 +1362,7 @@ static void cmsis_dap_add_jtag_sequence(int s_len, const uint8_t *sequence, int
|
||||
/* queue a sequence of bits to clock out TMS, executing if the buffer is full */
|
||||
static void cmsis_dap_add_tms_sequence(const uint8_t *sequence, int s_len)
|
||||
{
|
||||
DEBUG_JTAG_IO("%d bits: %02X", s_len, *sequence);
|
||||
LOG_DEBUG_IO("%d bits: %02X", s_len, *sequence);
|
||||
/* we use a series of CMD_DAP_JTAG_SEQ commands to toggle TMS,
|
||||
because even though it seems ridiculously inefficient, it
|
||||
allows us to combine TMS and scan sequences into the same
|
||||
@@ -1383,7 +1383,7 @@ static void cmsis_dap_state_move(void)
|
||||
tms_scan = tap_get_tms_path(tap_get_state(), tap_get_end_state());
|
||||
tms_scan_bits = tap_get_tms_path_len(tap_get_state(), tap_get_end_state());
|
||||
|
||||
DEBUG_JTAG_IO("state move from %s to %s: %d clocks, %02X on tms",
|
||||
LOG_DEBUG_IO("state move from %s to %s: %d clocks, %02X on tms",
|
||||
tap_state_name(tap_get_state()), tap_state_name(tap_get_end_state()),
|
||||
tms_scan_bits, tms_scan);
|
||||
cmsis_dap_add_tms_sequence(&tms_scan, tms_scan_bits);
|
||||
@@ -1395,7 +1395,7 @@ static void cmsis_dap_state_move(void)
|
||||
/* Execute a JTAG scan operation by queueing TMS and TDI/TDO sequences */
|
||||
static void cmsis_dap_execute_scan(struct jtag_command *cmd)
|
||||
{
|
||||
DEBUG_JTAG_IO("%s type:%d", cmd->cmd.scan->ir_scan ? "IRSCAN" : "DRSCAN",
|
||||
LOG_DEBUG_IO("%s type:%d", cmd->cmd.scan->ir_scan ? "IRSCAN" : "DRSCAN",
|
||||
jtag_scan_type(cmd->cmd.scan));
|
||||
|
||||
/* Make sure there are no trailing fields with num_bits == 0, or the logic below will fail. */
|
||||
@@ -1429,7 +1429,7 @@ static void cmsis_dap_execute_scan(struct jtag_command *cmd)
|
||||
|
||||
for (int i = 0; i < cmd->cmd.scan->num_fields; i++, field++) {
|
||||
scan_size += field->num_bits;
|
||||
DEBUG_JTAG_IO("%s%s field %d/%d %d bits",
|
||||
LOG_DEBUG_IO("%s%s field %d/%d %d bits",
|
||||
field->in_value ? "in" : "",
|
||||
field->out_value ? "out" : "",
|
||||
i,
|
||||
@@ -1437,7 +1437,7 @@ static void cmsis_dap_execute_scan(struct jtag_command *cmd)
|
||||
field->num_bits);
|
||||
|
||||
if (i == cmd->cmd.scan->num_fields - 1 && tap_get_state() != tap_get_end_state()) {
|
||||
DEBUG_JTAG_IO("Last field and have to move out of SHIFT state");
|
||||
LOG_DEBUG_IO("Last field and have to move out of SHIFT state");
|
||||
/* Last field, and we're leaving IRSHIFT/DRSHIFT. Clock last bit during tap
|
||||
* movement. This last field can't have length zero, it was checked above. */
|
||||
cmsis_dap_add_jtag_sequence(
|
||||
@@ -1471,7 +1471,7 @@ static void cmsis_dap_execute_scan(struct jtag_command *cmd)
|
||||
0);
|
||||
tap_set_state(tap_state_transition(tap_get_state(), 0));
|
||||
} else {
|
||||
DEBUG_JTAG_IO("Internal field, staying in SHIFT state afterwards");
|
||||
LOG_DEBUG_IO("Internal field, staying in SHIFT state afterwards");
|
||||
/* Clocking part of a sequence into DR or IR with TMS=0,
|
||||
leaving TMS=0 at the end so we can continue later */
|
||||
cmsis_dap_add_jtag_sequence(
|
||||
@@ -1489,7 +1489,7 @@ static void cmsis_dap_execute_scan(struct jtag_command *cmd)
|
||||
cmsis_dap_state_move();
|
||||
}
|
||||
|
||||
DEBUG_JTAG_IO("%s scan, %i bits, end in %s",
|
||||
LOG_DEBUG_IO("%s scan, %i bits, end in %s",
|
||||
(cmd->cmd.scan->ir_scan) ? "IR" : "DR", scan_size,
|
||||
tap_state_name(tap_get_end_state()));
|
||||
}
|
||||
@@ -1519,7 +1519,7 @@ static void cmsis_dap_pathmove(int num_states, tap_state_t *path)
|
||||
|
||||
static void cmsis_dap_execute_pathmove(struct jtag_command *cmd)
|
||||
{
|
||||
DEBUG_JTAG_IO("pathmove: %i states, end in %i",
|
||||
LOG_DEBUG_IO("pathmove: %i states, end in %i",
|
||||
cmd->cmd.pathmove->num_states,
|
||||
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
|
||||
|
||||
@@ -1557,7 +1557,7 @@ static void cmsis_dap_runtest(int num_cycles)
|
||||
|
||||
static void cmsis_dap_execute_runtest(struct jtag_command *cmd)
|
||||
{
|
||||
DEBUG_JTAG_IO("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles,
|
||||
LOG_DEBUG_IO("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles,
|
||||
cmd->cmd.runtest->end_state);
|
||||
|
||||
cmsis_dap_end_state(cmd->cmd.runtest->end_state);
|
||||
@@ -1566,13 +1566,13 @@ static void cmsis_dap_execute_runtest(struct jtag_command *cmd)
|
||||
|
||||
static void cmsis_dap_execute_stableclocks(struct jtag_command *cmd)
|
||||
{
|
||||
DEBUG_JTAG_IO("stableclocks %i cycles", cmd->cmd.runtest->num_cycles);
|
||||
LOG_DEBUG_IO("stableclocks %i cycles", cmd->cmd.runtest->num_cycles);
|
||||
cmsis_dap_stableclocks(cmd->cmd.runtest->num_cycles);
|
||||
}
|
||||
|
||||
static void cmsis_dap_execute_tms(struct jtag_command *cmd)
|
||||
{
|
||||
DEBUG_JTAG_IO("TMS: %d bits", cmd->cmd.tms->num_bits);
|
||||
LOG_DEBUG_IO("TMS: %d bits", cmd->cmd.tms->num_bits);
|
||||
cmsis_dap_cmd_DAP_SWJ_Sequence(cmd->cmd.tms->num_bits, cmd->cmd.tms->bits);
|
||||
}
|
||||
|
||||
@@ -1653,15 +1653,6 @@ static int cmsis_dap_khz(int khz, int *jtag_speed)
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static int_least32_t cmsis_dap_swd_frequency(int_least32_t hz)
|
||||
{
|
||||
if (hz > 0)
|
||||
cmsis_dap_speed(hz / 1000);
|
||||
|
||||
return hz;
|
||||
}
|
||||
|
||||
|
||||
COMMAND_HANDLER(cmsis_dap_handle_info_command)
|
||||
{
|
||||
if (cmsis_dap_get_version_info() == ERROR_OK)
|
||||
@@ -1790,7 +1781,6 @@ static const struct command_registration cmsis_dap_command_handlers[] = {
|
||||
|
||||
static const struct swd_driver cmsis_dap_swd_driver = {
|
||||
.init = cmsis_dap_swd_init,
|
||||
.frequency = cmsis_dap_swd_frequency,
|
||||
.switch_seq = cmsis_dap_swd_switch_seq,
|
||||
.read_reg = cmsis_dap_swd_read_reg,
|
||||
.write_reg = cmsis_dap_swd_write_reg,
|
||||
|
||||
@@ -136,8 +136,8 @@ static const struct command_registration dummy_command_handlers[] = {
|
||||
.name = "dummy",
|
||||
.mode = COMMAND_ANY,
|
||||
.help = "dummy interface driver commands",
|
||||
|
||||
.chain = hello_command_handlers,
|
||||
.usage = "",
|
||||
},
|
||||
COMMAND_REGISTRATION_DONE,
|
||||
};
|
||||
|
||||
@@ -55,6 +55,7 @@ struct jtag_interface ep93xx_interface = {
|
||||
|
||||
.supported = DEBUG_CAP_TMS_SEQ,
|
||||
.execute_queue = bitbang_execute_queue,
|
||||
.transports = jtag_only,
|
||||
|
||||
.init = ep93xx_init,
|
||||
.quit = ep93xx_quit,
|
||||
|
||||
@@ -442,7 +442,7 @@ COMMAND_HANDLER(ft232r_handle_jtag_nums_command)
|
||||
if (tdo_gpio < 0)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"FT232R nums: TCK = %d %s, TMS = %d %s, TDI = %d %s, TDO = %d %s",
|
||||
tck_gpio, ft232r_bit_number_to_name(tck_gpio),
|
||||
tms_gpio, ft232r_bit_number_to_name(tms_gpio),
|
||||
@@ -462,7 +462,7 @@ COMMAND_HANDLER(ft232r_handle_tck_num_command)
|
||||
if (tck_gpio < 0)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"FT232R num: TCK = %d %s", tck_gpio, ft232r_bit_number_to_name(tck_gpio));
|
||||
|
||||
return ERROR_OK;
|
||||
@@ -478,7 +478,7 @@ COMMAND_HANDLER(ft232r_handle_tms_num_command)
|
||||
if (tms_gpio < 0)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"FT232R num: TMS = %d %s", tms_gpio, ft232r_bit_number_to_name(tms_gpio));
|
||||
|
||||
return ERROR_OK;
|
||||
@@ -494,7 +494,7 @@ COMMAND_HANDLER(ft232r_handle_tdo_num_command)
|
||||
if (tdo_gpio < 0)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"FT232R num: TDO = %d %s", tdo_gpio, ft232r_bit_number_to_name(tdo_gpio));
|
||||
|
||||
return ERROR_OK;
|
||||
@@ -510,7 +510,7 @@ COMMAND_HANDLER(ft232r_handle_tdi_num_command)
|
||||
if (tdi_gpio < 0)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"FT232R num: TDI = %d %s", tdi_gpio, ft232r_bit_number_to_name(tdi_gpio));
|
||||
|
||||
return ERROR_OK;
|
||||
@@ -526,7 +526,7 @@ COMMAND_HANDLER(ft232r_handle_trst_num_command)
|
||||
if (ntrst_gpio < 0)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"FT232R num: TRST = %d %s", ntrst_gpio, ft232r_bit_number_to_name(ntrst_gpio));
|
||||
|
||||
return ERROR_OK;
|
||||
@@ -542,7 +542,7 @@ COMMAND_HANDLER(ft232r_handle_srst_num_command)
|
||||
if (nsysrst_gpio < 0)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"FT232R num: SRST = %d %s", nsysrst_gpio, ft232r_bit_number_to_name(nsysrst_gpio));
|
||||
|
||||
return ERROR_OK;
|
||||
@@ -555,7 +555,7 @@ COMMAND_HANDLER(ft232r_handle_restore_serial_command)
|
||||
else if (CMD_ARGC != 0)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"FT232R restore serial: 0x%04X (%s)",
|
||||
ft232r_restore_bitmode, ft232r_restore_bitmode == 0xFFFF ? "disabled" : "enabled");
|
||||
|
||||
@@ -675,7 +675,7 @@ static int syncbb_execute_tms(struct jtag_command *cmd)
|
||||
unsigned num_bits = cmd->cmd.tms->num_bits;
|
||||
const uint8_t *bits = cmd->cmd.tms->bits;
|
||||
|
||||
DEBUG_JTAG_IO("TMS: %d bits", num_bits);
|
||||
LOG_DEBUG_IO("TMS: %d bits", num_bits);
|
||||
|
||||
int tms = 0;
|
||||
for (unsigned i = 0; i < num_bits; i++) {
|
||||
|
||||
+18
-27
@@ -329,7 +329,7 @@ static void move_to_state(tap_state_t goal_state)
|
||||
int tms_count = tap_get_tms_path_len(start_state, goal_state);
|
||||
assert(tms_count <= 8);
|
||||
|
||||
DEBUG_JTAG_IO("start=%s goal=%s", tap_state_name(start_state), tap_state_name(goal_state));
|
||||
LOG_DEBUG_IO("start=%s goal=%s", tap_state_name(start_state), tap_state_name(goal_state));
|
||||
|
||||
/* Track state transitions step by step */
|
||||
for (int i = 0; i < tms_count; i++)
|
||||
@@ -391,7 +391,7 @@ static void ftdi_execute_runtest(struct jtag_command *cmd)
|
||||
int i;
|
||||
static const uint8_t zero;
|
||||
|
||||
DEBUG_JTAG_IO("runtest %i cycles, end in %s",
|
||||
LOG_DEBUG_IO("runtest %i cycles, end in %s",
|
||||
cmd->cmd.runtest->num_cycles,
|
||||
tap_state_name(cmd->cmd.runtest->end_state));
|
||||
|
||||
@@ -412,14 +412,14 @@ static void ftdi_execute_runtest(struct jtag_command *cmd)
|
||||
if (tap_get_state() != tap_get_end_state())
|
||||
move_to_state(tap_get_end_state());
|
||||
|
||||
DEBUG_JTAG_IO("runtest: %i, end in %s",
|
||||
LOG_DEBUG_IO("runtest: %i, end in %s",
|
||||
cmd->cmd.runtest->num_cycles,
|
||||
tap_state_name(tap_get_end_state()));
|
||||
}
|
||||
|
||||
static void ftdi_execute_statemove(struct jtag_command *cmd)
|
||||
{
|
||||
DEBUG_JTAG_IO("statemove end in %s",
|
||||
LOG_DEBUG_IO("statemove end in %s",
|
||||
tap_state_name(cmd->cmd.statemove->end_state));
|
||||
|
||||
ftdi_end_state(cmd->cmd.statemove->end_state);
|
||||
@@ -435,7 +435,7 @@ static void ftdi_execute_statemove(struct jtag_command *cmd)
|
||||
*/
|
||||
static void ftdi_execute_tms(struct jtag_command *cmd)
|
||||
{
|
||||
DEBUG_JTAG_IO("TMS: %d bits", cmd->cmd.tms->num_bits);
|
||||
LOG_DEBUG_IO("TMS: %d bits", cmd->cmd.tms->num_bits);
|
||||
|
||||
/* TODO: Missing tap state tracking, also missing from ft2232.c! */
|
||||
DO_CLOCK_TMS_CS_OUT(mpsse_ctx,
|
||||
@@ -451,7 +451,7 @@ static void ftdi_execute_pathmove(struct jtag_command *cmd)
|
||||
tap_state_t *path = cmd->cmd.pathmove->path;
|
||||
int num_states = cmd->cmd.pathmove->num_states;
|
||||
|
||||
DEBUG_JTAG_IO("pathmove: %i states, current: %s end: %s", num_states,
|
||||
LOG_DEBUG_IO("pathmove: %i states, current: %s end: %s", num_states,
|
||||
tap_state_name(tap_get_state()),
|
||||
tap_state_name(path[num_states-1]));
|
||||
|
||||
@@ -459,7 +459,7 @@ static void ftdi_execute_pathmove(struct jtag_command *cmd)
|
||||
unsigned bit_count = 0;
|
||||
uint8_t tms_byte = 0;
|
||||
|
||||
DEBUG_JTAG_IO("-");
|
||||
LOG_DEBUG_IO("-");
|
||||
|
||||
/* this loop verifies that the path is legal and logs each state in the path */
|
||||
while (num_states--) {
|
||||
@@ -499,18 +499,18 @@ static void ftdi_execute_pathmove(struct jtag_command *cmd)
|
||||
|
||||
static void ftdi_execute_scan(struct jtag_command *cmd)
|
||||
{
|
||||
DEBUG_JTAG_IO("%s type:%d", cmd->cmd.scan->ir_scan ? "IRSCAN" : "DRSCAN",
|
||||
LOG_DEBUG_IO("%s type:%d", cmd->cmd.scan->ir_scan ? "IRSCAN" : "DRSCAN",
|
||||
jtag_scan_type(cmd->cmd.scan));
|
||||
|
||||
/* Make sure there are no trailing fields with num_bits == 0, or the logic below will fail. */
|
||||
while (cmd->cmd.scan->num_fields > 0
|
||||
&& cmd->cmd.scan->fields[cmd->cmd.scan->num_fields - 1].num_bits == 0) {
|
||||
cmd->cmd.scan->num_fields--;
|
||||
DEBUG_JTAG_IO("discarding trailing empty field");
|
||||
LOG_DEBUG_IO("discarding trailing empty field");
|
||||
}
|
||||
|
||||
if (cmd->cmd.scan->num_fields == 0) {
|
||||
DEBUG_JTAG_IO("empty scan, doing nothing");
|
||||
LOG_DEBUG_IO("empty scan, doing nothing");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -529,7 +529,7 @@ static void ftdi_execute_scan(struct jtag_command *cmd)
|
||||
|
||||
for (int i = 0; i < cmd->cmd.scan->num_fields; i++, field++) {
|
||||
scan_size += field->num_bits;
|
||||
DEBUG_JTAG_IO("%s%s field %d/%d %d bits",
|
||||
LOG_DEBUG_IO("%s%s field %d/%d %d bits",
|
||||
field->in_value ? "in" : "",
|
||||
field->out_value ? "out" : "",
|
||||
i,
|
||||
@@ -579,14 +579,14 @@ static void ftdi_execute_scan(struct jtag_command *cmd)
|
||||
if (tap_get_state() != tap_get_end_state())
|
||||
move_to_state(tap_get_end_state());
|
||||
|
||||
DEBUG_JTAG_IO("%s scan, %i bits, end in %s",
|
||||
LOG_DEBUG_IO("%s scan, %i bits, end in %s",
|
||||
(cmd->cmd.scan->ir_scan) ? "IR" : "DR", scan_size,
|
||||
tap_state_name(tap_get_end_state()));
|
||||
}
|
||||
|
||||
static void ftdi_execute_reset(struct jtag_command *cmd)
|
||||
{
|
||||
DEBUG_JTAG_IO("reset trst: %i srst %i",
|
||||
LOG_DEBUG_IO("reset trst: %i srst %i",
|
||||
cmd->cmd.reset->trst, cmd->cmd.reset->srst);
|
||||
|
||||
if (cmd->cmd.reset->trst == 1
|
||||
@@ -622,17 +622,17 @@ static void ftdi_execute_reset(struct jtag_command *cmd)
|
||||
ftdi_set_signal(srst, 'z');
|
||||
}
|
||||
|
||||
DEBUG_JTAG_IO("trst: %i, srst: %i",
|
||||
LOG_DEBUG_IO("trst: %i, srst: %i",
|
||||
cmd->cmd.reset->trst, cmd->cmd.reset->srst);
|
||||
}
|
||||
|
||||
static void ftdi_execute_sleep(struct jtag_command *cmd)
|
||||
{
|
||||
DEBUG_JTAG_IO("sleep %" PRIi32, cmd->cmd.sleep->us);
|
||||
LOG_DEBUG_IO("sleep %" PRIi32, cmd->cmd.sleep->us);
|
||||
|
||||
mpsse_flush(mpsse_ctx);
|
||||
jtag_sleep(cmd->cmd.sleep->us);
|
||||
DEBUG_JTAG_IO("sleep %" PRIi32 " usec while in %s",
|
||||
LOG_DEBUG_IO("sleep %" PRIi32 " usec while in %s",
|
||||
cmd->cmd.sleep->us,
|
||||
tap_state_name(tap_get_state()));
|
||||
}
|
||||
@@ -656,7 +656,7 @@ static void ftdi_execute_stableclocks(struct jtag_command *cmd)
|
||||
num_cycles -= this_len;
|
||||
}
|
||||
|
||||
DEBUG_JTAG_IO("clocks %i while in %s",
|
||||
LOG_DEBUG_IO("clocks %i while in %s",
|
||||
cmd->cmd.stableclocks->num_cycles,
|
||||
tap_state_name(tap_get_state()));
|
||||
}
|
||||
@@ -1262,7 +1262,7 @@ COMMAND_HANDLER(ftdi_handle_tdo_sample_edge_command)
|
||||
}
|
||||
|
||||
n = Jim_Nvp_value2name_simple(nvp_ftdi_jtag_modes, ftdi_jtag_mode);
|
||||
command_print(CMD_CTX, "ftdi samples TDO on %s edge of TCK", n->name);
|
||||
command_print(CMD, "ftdi samples TDO on %s edge of TCK", n->name);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -1558,14 +1558,6 @@ static void ftdi_swd_write_reg(uint8_t cmd, uint32_t value, uint32_t ap_delay_cl
|
||||
ftdi_swd_queue_cmd(cmd, NULL, value, ap_delay_clk);
|
||||
}
|
||||
|
||||
static int_least32_t ftdi_swd_frequency(int_least32_t hz)
|
||||
{
|
||||
if (hz > 0)
|
||||
freq = mpsse_set_frequency(mpsse_ctx, hz);
|
||||
|
||||
return freq;
|
||||
}
|
||||
|
||||
static int ftdi_swd_switch_seq(enum swd_special_seq seq)
|
||||
{
|
||||
switch (seq) {
|
||||
@@ -1594,7 +1586,6 @@ static int ftdi_swd_switch_seq(enum swd_special_seq seq)
|
||||
|
||||
static const struct swd_driver ftdi_swd = {
|
||||
.init = ftdi_swd_init,
|
||||
.frequency = ftdi_swd_frequency,
|
||||
.switch_seq = ftdi_swd_switch_seq,
|
||||
.read_reg = ftdi_swd_read_reg,
|
||||
.write_reg = ftdi_swd_write_reg,
|
||||
|
||||
@@ -297,43 +297,33 @@ static int gw16012_execute_queue(void)
|
||||
while (cmd) {
|
||||
switch (cmd->type) {
|
||||
case JTAG_RESET:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst);
|
||||
#endif
|
||||
LOG_DEBUG_IO("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst);
|
||||
if (cmd->cmd.reset->trst == 1)
|
||||
tap_set_state(TAP_RESET);
|
||||
gw16012_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
|
||||
break;
|
||||
case JTAG_RUNTEST:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles,
|
||||
LOG_DEBUG_IO("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles,
|
||||
cmd->cmd.runtest->end_state);
|
||||
#endif
|
||||
gw16012_end_state(cmd->cmd.runtest->end_state);
|
||||
gw16012_runtest(cmd->cmd.runtest->num_cycles);
|
||||
break;
|
||||
case JTAG_TLR_RESET:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("statemove end in %i", cmd->cmd.statemove->end_state);
|
||||
#endif
|
||||
LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
|
||||
gw16012_end_state(cmd->cmd.statemove->end_state);
|
||||
gw16012_state_move();
|
||||
break;
|
||||
case JTAG_PATHMOVE:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("pathmove: %i states, end in %i", cmd->cmd.pathmove->num_states,
|
||||
LOG_DEBUG_IO("pathmove: %i states, end in %i", cmd->cmd.pathmove->num_states,
|
||||
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
|
||||
#endif
|
||||
gw16012_path_move(cmd->cmd.pathmove);
|
||||
break;
|
||||
case JTAG_SCAN:
|
||||
gw16012_end_state(cmd->cmd.scan->end_state);
|
||||
scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
|
||||
type = jtag_scan_type(cmd->cmd.scan);
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("%s scan (%i) %i bit end in %i", (cmd->cmd.scan->ir_scan) ? "ir" : "dr",
|
||||
LOG_DEBUG_IO("%s scan (%i) %i bit end in %i", (cmd->cmd.scan->ir_scan) ? "ir" : "dr",
|
||||
type, scan_size, cmd->cmd.scan->end_state);
|
||||
#endif
|
||||
gw16012_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size);
|
||||
if (jtag_read_buffer(buffer, cmd->cmd.scan) != ERROR_OK)
|
||||
retval = ERROR_JTAG_QUEUE_FAILED;
|
||||
@@ -341,9 +331,7 @@ static int gw16012_execute_queue(void)
|
||||
free(buffer);
|
||||
break;
|
||||
case JTAG_SLEEP:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("sleep %i", cmd->cmd.sleep->us);
|
||||
#endif
|
||||
LOG_DEBUG_IO("sleep %i", cmd->cmd.sleep->us);
|
||||
jtag_sleep(cmd->cmd.sleep->us);
|
||||
break;
|
||||
default:
|
||||
@@ -515,7 +503,7 @@ COMMAND_HANDLER(gw16012_handle_parport_port_command)
|
||||
}
|
||||
}
|
||||
|
||||
command_print(CMD_CTX, "parport port = %u", gw16012_port);
|
||||
command_print(CMD, "parport port = %u", gw16012_port);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -535,6 +523,7 @@ static const struct command_registration gw16012_command_handlers[] = {
|
||||
|
||||
struct jtag_interface gw16012_interface = {
|
||||
.name = "gw16012",
|
||||
.transports = jtag_only,
|
||||
.commands = gw16012_command_handlers,
|
||||
|
||||
.init = gw16012_init,
|
||||
|
||||
+28
-12
@@ -221,7 +221,7 @@ COMMAND_HANDLER(imx_gpio_handle_jtag_gpionums)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"imx_gpio GPIO config: tck = %d, tms = %d, tdi = %d, tdo = %d",
|
||||
tck_gpio, tms_gpio, tdi_gpio, tdo_gpio);
|
||||
|
||||
@@ -233,7 +233,7 @@ COMMAND_HANDLER(imx_gpio_handle_jtag_gpionum_tck)
|
||||
if (CMD_ARGC == 1)
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], tck_gpio);
|
||||
|
||||
command_print(CMD_CTX, "imx_gpio GPIO config: tck = %d", tck_gpio);
|
||||
command_print(CMD, "imx_gpio GPIO config: tck = %d", tck_gpio);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ COMMAND_HANDLER(imx_gpio_handle_jtag_gpionum_tms)
|
||||
if (CMD_ARGC == 1)
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], tms_gpio);
|
||||
|
||||
command_print(CMD_CTX, "imx_gpio GPIO config: tms = %d", tms_gpio);
|
||||
command_print(CMD, "imx_gpio GPIO config: tms = %d", tms_gpio);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ COMMAND_HANDLER(imx_gpio_handle_jtag_gpionum_tdo)
|
||||
if (CMD_ARGC == 1)
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], tdo_gpio);
|
||||
|
||||
command_print(CMD_CTX, "imx_gpio GPIO config: tdo = %d", tdo_gpio);
|
||||
command_print(CMD, "imx_gpio GPIO config: tdo = %d", tdo_gpio);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ COMMAND_HANDLER(imx_gpio_handle_jtag_gpionum_tdi)
|
||||
if (CMD_ARGC == 1)
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], tdi_gpio);
|
||||
|
||||
command_print(CMD_CTX, "imx_gpio GPIO config: tdi = %d", tdi_gpio);
|
||||
command_print(CMD, "imx_gpio GPIO config: tdi = %d", tdi_gpio);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ COMMAND_HANDLER(imx_gpio_handle_jtag_gpionum_srst)
|
||||
if (CMD_ARGC == 1)
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], srst_gpio);
|
||||
|
||||
command_print(CMD_CTX, "imx_gpio GPIO config: srst = %d", srst_gpio);
|
||||
command_print(CMD, "imx_gpio GPIO config: srst = %d", srst_gpio);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ COMMAND_HANDLER(imx_gpio_handle_jtag_gpionum_trst)
|
||||
if (CMD_ARGC == 1)
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], trst_gpio);
|
||||
|
||||
command_print(CMD_CTX, "imx_gpio GPIO config: trst = %d", trst_gpio);
|
||||
command_print(CMD, "imx_gpio GPIO config: trst = %d", trst_gpio);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -291,7 +291,7 @@ COMMAND_HANDLER(imx_gpio_handle_swd_gpionums)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"imx_gpio GPIO nums: swclk = %d, swdio = %d",
|
||||
swclk_gpio, swdio_gpio);
|
||||
|
||||
@@ -303,7 +303,7 @@ COMMAND_HANDLER(imx_gpio_handle_swd_gpionum_swclk)
|
||||
if (CMD_ARGC == 1)
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], swclk_gpio);
|
||||
|
||||
command_print(CMD_CTX, "imx_gpio num: swclk = %d", swclk_gpio);
|
||||
command_print(CMD, "imx_gpio num: swclk = %d", swclk_gpio);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -312,7 +312,7 @@ COMMAND_HANDLER(imx_gpio_handle_swd_gpionum_swdio)
|
||||
if (CMD_ARGC == 1)
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], swdio_gpio);
|
||||
|
||||
command_print(CMD_CTX, "imx_gpio num: swdio = %d", swdio_gpio);
|
||||
command_print(CMD, "imx_gpio num: swdio = %d", swdio_gpio);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -322,6 +322,9 @@ COMMAND_HANDLER(imx_gpio_handle_speed_coeffs)
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], speed_coeff);
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[1], speed_offset);
|
||||
}
|
||||
|
||||
command_print(CMD, "imx_gpio: speed_coeffs = %d, speed_offset = %d",
|
||||
speed_coeff, speed_offset);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -329,6 +332,9 @@ COMMAND_HANDLER(imx_gpio_handle_peripheral_base)
|
||||
{
|
||||
if (CMD_ARGC == 1)
|
||||
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], imx_gpio_peri_base);
|
||||
|
||||
command_print(CMD, "imx_gpio: peripheral_base = 0x%08x",
|
||||
imx_gpio_peri_base);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -338,74 +344,84 @@ static const struct command_registration imx_gpio_command_handlers[] = {
|
||||
.handler = &imx_gpio_handle_jtag_gpionums,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "gpio numbers for tck, tms, tdi, tdo. (in that order)",
|
||||
.usage = "(tck tms tdi tdo)* ",
|
||||
.usage = "[tck tms tdi tdo]",
|
||||
},
|
||||
{
|
||||
.name = "imx_gpio_tck_num",
|
||||
.handler = &imx_gpio_handle_jtag_gpionum_tck,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "gpio number for tck.",
|
||||
.usage = "[tck]",
|
||||
},
|
||||
{
|
||||
.name = "imx_gpio_tms_num",
|
||||
.handler = &imx_gpio_handle_jtag_gpionum_tms,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "gpio number for tms.",
|
||||
.usage = "[tms]",
|
||||
},
|
||||
{
|
||||
.name = "imx_gpio_tdo_num",
|
||||
.handler = &imx_gpio_handle_jtag_gpionum_tdo,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "gpio number for tdo.",
|
||||
.usage = "[tdo]",
|
||||
},
|
||||
{
|
||||
.name = "imx_gpio_tdi_num",
|
||||
.handler = &imx_gpio_handle_jtag_gpionum_tdi,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "gpio number for tdi.",
|
||||
.usage = "[tdi]",
|
||||
},
|
||||
{
|
||||
.name = "imx_gpio_swd_nums",
|
||||
.handler = &imx_gpio_handle_swd_gpionums,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "gpio numbers for swclk, swdio. (in that order)",
|
||||
.usage = "(swclk swdio)* ",
|
||||
.usage = "[swclk swdio]",
|
||||
},
|
||||
{
|
||||
.name = "imx_gpio_swclk_num",
|
||||
.handler = &imx_gpio_handle_swd_gpionum_swclk,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "gpio number for swclk.",
|
||||
.usage = "[swclk]",
|
||||
},
|
||||
{
|
||||
.name = "imx_gpio_swdio_num",
|
||||
.handler = &imx_gpio_handle_swd_gpionum_swdio,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "gpio number for swdio.",
|
||||
.usage = "[swdio]",
|
||||
},
|
||||
{
|
||||
.name = "imx_gpio_srst_num",
|
||||
.handler = &imx_gpio_handle_jtag_gpionum_srst,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "gpio number for srst.",
|
||||
.usage = "[srst]",
|
||||
},
|
||||
{
|
||||
.name = "imx_gpio_trst_num",
|
||||
.handler = &imx_gpio_handle_jtag_gpionum_trst,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "gpio number for trst.",
|
||||
.usage = "[trst]",
|
||||
},
|
||||
{
|
||||
.name = "imx_gpio_speed_coeffs",
|
||||
.handler = &imx_gpio_handle_speed_coeffs,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "SPEED_COEFF and SPEED_OFFSET for delay calculations.",
|
||||
.usage = "[SPEED_COEFF SPEED_OFFSET]",
|
||||
},
|
||||
{
|
||||
.name = "imx_gpio_peripheral_base",
|
||||
.handler = &imx_gpio_handle_peripheral_base,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "peripheral base to access GPIOs (0x0209c000 for most IMX).",
|
||||
.usage = "[base]",
|
||||
},
|
||||
|
||||
COMMAND_REGISTRATION_DONE
|
||||
|
||||
+128
-96
@@ -38,6 +38,7 @@
|
||||
#include <jtag/interface.h>
|
||||
#include <jtag/swd.h>
|
||||
#include <jtag/commands.h>
|
||||
#include <jtag/drivers/jtag_usb_common.h>
|
||||
|
||||
#include <libjaylink/libjaylink.h>
|
||||
|
||||
@@ -50,6 +51,7 @@ static uint8_t caps[JAYLINK_DEV_EXT_CAPS_SIZE];
|
||||
|
||||
static uint32_t serial_number;
|
||||
static bool use_serial_number;
|
||||
static bool use_usb_location;
|
||||
static enum jaylink_usb_address usb_address;
|
||||
static bool use_usb_address;
|
||||
static enum jaylink_target_interface iface = JAYLINK_TIF_JTAG;
|
||||
@@ -122,13 +124,13 @@ static int queued_retval;
|
||||
|
||||
static void jlink_execute_stableclocks(struct jtag_command *cmd)
|
||||
{
|
||||
DEBUG_JTAG_IO("stableclocks %i cycles", cmd->cmd.runtest->num_cycles);
|
||||
LOG_DEBUG_IO("stableclocks %i cycles", cmd->cmd.runtest->num_cycles);
|
||||
jlink_stableclocks(cmd->cmd.runtest->num_cycles);
|
||||
}
|
||||
|
||||
static void jlink_execute_runtest(struct jtag_command *cmd)
|
||||
{
|
||||
DEBUG_JTAG_IO("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles,
|
||||
LOG_DEBUG_IO("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles,
|
||||
cmd->cmd.runtest->end_state);
|
||||
|
||||
jlink_end_state(cmd->cmd.runtest->end_state);
|
||||
@@ -137,7 +139,7 @@ static void jlink_execute_runtest(struct jtag_command *cmd)
|
||||
|
||||
static void jlink_execute_statemove(struct jtag_command *cmd)
|
||||
{
|
||||
DEBUG_JTAG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
|
||||
LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
|
||||
|
||||
jlink_end_state(cmd->cmd.statemove->end_state);
|
||||
jlink_state_move();
|
||||
@@ -145,7 +147,7 @@ static void jlink_execute_statemove(struct jtag_command *cmd)
|
||||
|
||||
static void jlink_execute_pathmove(struct jtag_command *cmd)
|
||||
{
|
||||
DEBUG_JTAG_IO("pathmove: %i states, end in %i",
|
||||
LOG_DEBUG_IO("pathmove: %i states, end in %i",
|
||||
cmd->cmd.pathmove->num_states,
|
||||
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
|
||||
|
||||
@@ -154,7 +156,7 @@ static void jlink_execute_pathmove(struct jtag_command *cmd)
|
||||
|
||||
static void jlink_execute_scan(struct jtag_command *cmd)
|
||||
{
|
||||
DEBUG_JTAG_IO("%s type:%d", cmd->cmd.scan->ir_scan ? "IRSCAN" : "DRSCAN",
|
||||
LOG_DEBUG_IO("%s type:%d", cmd->cmd.scan->ir_scan ? "IRSCAN" : "DRSCAN",
|
||||
jtag_scan_type(cmd->cmd.scan));
|
||||
|
||||
/* Make sure there are no trailing fields with num_bits == 0, or the logic below will fail. */
|
||||
@@ -188,7 +190,7 @@ static void jlink_execute_scan(struct jtag_command *cmd)
|
||||
|
||||
for (int i = 0; i < cmd->cmd.scan->num_fields; i++, field++) {
|
||||
scan_size += field->num_bits;
|
||||
DEBUG_JTAG_IO("%s%s field %d/%d %d bits",
|
||||
LOG_DEBUG_IO("%s%s field %d/%d %d bits",
|
||||
field->in_value ? "in" : "",
|
||||
field->out_value ? "out" : "",
|
||||
i,
|
||||
@@ -240,14 +242,14 @@ static void jlink_execute_scan(struct jtag_command *cmd)
|
||||
jlink_state_move();
|
||||
}
|
||||
|
||||
DEBUG_JTAG_IO("%s scan, %i bits, end in %s",
|
||||
LOG_DEBUG_IO("%s scan, %i bits, end in %s",
|
||||
(cmd->cmd.scan->ir_scan) ? "IR" : "DR", scan_size,
|
||||
tap_state_name(tap_get_end_state()));
|
||||
}
|
||||
|
||||
static void jlink_execute_reset(struct jtag_command *cmd)
|
||||
{
|
||||
DEBUG_JTAG_IO("reset trst: %i srst %i", cmd->cmd.reset->trst,
|
||||
LOG_DEBUG_IO("reset trst: %i srst %i", cmd->cmd.reset->trst,
|
||||
cmd->cmd.reset->srst);
|
||||
|
||||
jlink_flush();
|
||||
@@ -257,7 +259,7 @@ static void jlink_execute_reset(struct jtag_command *cmd)
|
||||
|
||||
static void jlink_execute_sleep(struct jtag_command *cmd)
|
||||
{
|
||||
DEBUG_JTAG_IO("sleep %" PRIi32 "", cmd->cmd.sleep->us);
|
||||
LOG_DEBUG_IO("sleep %" PRIi32 "", cmd->cmd.sleep->us);
|
||||
jlink_flush();
|
||||
jtag_sleep(cmd->cmd.sleep->us);
|
||||
}
|
||||
@@ -534,6 +536,31 @@ static int jaylink_log_handler(const struct jaylink_context *ctx,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool jlink_usb_location_equal(struct jaylink_device *dev)
|
||||
{
|
||||
int retval;
|
||||
uint8_t bus;
|
||||
uint8_t *ports;
|
||||
size_t num_ports;
|
||||
bool equal = false;
|
||||
|
||||
retval = jaylink_device_get_usb_bus_ports(dev, &bus, &ports, &num_ports);
|
||||
|
||||
if (retval == JAYLINK_ERR_NOT_SUPPORTED) {
|
||||
return false;
|
||||
} else if (retval != JAYLINK_OK) {
|
||||
LOG_WARNING("jaylink_device_get_usb_bus_ports() failed: %s.",
|
||||
jaylink_strerror(retval));
|
||||
return false;
|
||||
}
|
||||
|
||||
equal = jtag_usb_location_equal(bus, ports, num_ports);
|
||||
free(ports);
|
||||
|
||||
return equal;
|
||||
}
|
||||
|
||||
|
||||
static int jlink_init(void)
|
||||
{
|
||||
int ret;
|
||||
@@ -595,7 +622,9 @@ static int jlink_init(void)
|
||||
return ERROR_JTAG_INIT_FAILED;
|
||||
}
|
||||
|
||||
if (!use_serial_number && !use_usb_address && num_devices > 1) {
|
||||
use_usb_location = (jtag_usb_get_location() != NULL);
|
||||
|
||||
if (!use_serial_number && !use_usb_address && !use_usb_location && num_devices > 1) {
|
||||
LOG_ERROR("Multiple devices found, specify the desired device.");
|
||||
jaylink_free_devices(devs, true);
|
||||
jaylink_exit(jayctx);
|
||||
@@ -605,8 +634,10 @@ static int jlink_init(void)
|
||||
found_device = false;
|
||||
|
||||
for (i = 0; devs[i]; i++) {
|
||||
struct jaylink_device *dev = devs[i];
|
||||
|
||||
if (use_serial_number) {
|
||||
ret = jaylink_device_get_serial_number(devs[i], &tmp);
|
||||
ret = jaylink_device_get_serial_number(dev, &tmp);
|
||||
|
||||
if (ret == JAYLINK_ERR_NOT_AVAILABLE) {
|
||||
continue;
|
||||
@@ -621,7 +652,7 @@ static int jlink_init(void)
|
||||
}
|
||||
|
||||
if (use_usb_address) {
|
||||
ret = jaylink_device_get_usb_address(devs[i], &address);
|
||||
ret = jaylink_device_get_usb_address(dev, &address);
|
||||
|
||||
if (ret == JAYLINK_ERR_NOT_SUPPORTED) {
|
||||
continue;
|
||||
@@ -635,7 +666,10 @@ static int jlink_init(void)
|
||||
continue;
|
||||
}
|
||||
|
||||
ret = jaylink_open(devs[i], &devh);
|
||||
if (use_usb_location && !jlink_usb_location_equal(dev))
|
||||
continue;
|
||||
|
||||
ret = jaylink_open(dev, &devh);
|
||||
|
||||
if (ret == JAYLINK_OK) {
|
||||
found_device = true;
|
||||
@@ -923,17 +957,17 @@ COMMAND_HANDLER(jlink_usb_command)
|
||||
int tmp;
|
||||
|
||||
if (CMD_ARGC != 1) {
|
||||
command_print(CMD_CTX, "Need exactly one argument for jlink usb.");
|
||||
command_print(CMD, "Need exactly one argument for jlink usb.");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
if (sscanf(CMD_ARGV[0], "%i", &tmp) != 1) {
|
||||
command_print(CMD_CTX, "Invalid USB address: %s.", CMD_ARGV[0]);
|
||||
command_print(CMD, "Invalid USB address: %s.", CMD_ARGV[0]);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
if (tmp < JAYLINK_USB_ADDRESS_0 || tmp > JAYLINK_USB_ADDRESS_3) {
|
||||
command_print(CMD_CTX, "Invalid USB address: %s.", CMD_ARGV[0]);
|
||||
command_print(CMD, "Invalid USB address: %s.", CMD_ARGV[0]);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
@@ -950,17 +984,17 @@ COMMAND_HANDLER(jlink_serial_command)
|
||||
int ret;
|
||||
|
||||
if (CMD_ARGC != 1) {
|
||||
command_print(CMD_CTX, "Need exactly one argument for jlink serial.");
|
||||
command_print(CMD, "Need exactly one argument for jlink serial.");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
ret = jaylink_parse_serial_number(CMD_ARGV[0], &serial_number);
|
||||
|
||||
if (ret == JAYLINK_ERR) {
|
||||
command_print(CMD_CTX, "Invalid serial number: %s.", CMD_ARGV[0]);
|
||||
command_print(CMD, "Invalid serial number: %s.", CMD_ARGV[0]);
|
||||
return ERROR_FAIL;
|
||||
} else if (ret != JAYLINK_OK) {
|
||||
command_print(CMD_CTX, "jaylink_parse_serial_number() failed: %s.",
|
||||
command_print(CMD, "jaylink_parse_serial_number() failed: %s.",
|
||||
jaylink_strerror(ret));
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
@@ -979,20 +1013,20 @@ COMMAND_HANDLER(jlink_handle_hwstatus_command)
|
||||
ret = jaylink_get_hardware_status(devh, &status);
|
||||
|
||||
if (ret != JAYLINK_OK) {
|
||||
command_print(CMD_CTX, "jaylink_get_hardware_status() failed: %s.",
|
||||
command_print(CMD, "jaylink_get_hardware_status() failed: %s.",
|
||||
jaylink_strerror(ret));
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
command_print(CMD_CTX, "VTarget = %u.%03u V",
|
||||
command_print(CMD, "VTarget = %u.%03u V",
|
||||
status.target_voltage / 1000, status.target_voltage % 1000);
|
||||
|
||||
command_print(CMD_CTX, "TCK = %u TDI = %u TDO = %u TMS = %u SRST = %u "
|
||||
command_print(CMD, "TCK = %u TDI = %u TDO = %u TMS = %u SRST = %u "
|
||||
"TRST = %u", status.tck, status.tdi, status.tdo, status.tms,
|
||||
status.tres, status.trst);
|
||||
|
||||
if (status.target_voltage < 1500)
|
||||
command_print(CMD_CTX, "Target voltage too low. Check target power.");
|
||||
command_print(CMD, "Target voltage too low. Check target power.");
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -1003,7 +1037,7 @@ COMMAND_HANDLER(jlink_handle_free_memory_command)
|
||||
uint32_t tmp;
|
||||
|
||||
if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_GET_FREE_MEMORY)) {
|
||||
command_print(CMD_CTX, "Retrieval of free memory is not supported by "
|
||||
command_print(CMD, "Retrieval of free memory is not supported by "
|
||||
"the device.");
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -1011,12 +1045,12 @@ COMMAND_HANDLER(jlink_handle_free_memory_command)
|
||||
ret = jaylink_get_free_memory(devh, &tmp);
|
||||
|
||||
if (ret != JAYLINK_OK) {
|
||||
command_print(CMD_CTX, "jaylink_get_free_memory() failed: %s.",
|
||||
command_print(CMD, "jaylink_get_free_memory() failed: %s.",
|
||||
jaylink_strerror(ret));
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
command_print(CMD_CTX, "Device has %u bytes of free memory.", tmp);
|
||||
command_print(CMD, "Device has %u bytes of free memory.", tmp);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -1038,10 +1072,10 @@ COMMAND_HANDLER(jlink_handle_jlink_jtag_command)
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
command_print(CMD_CTX, "JTAG command version: %i", version);
|
||||
command_print(CMD, "JTAG command version: %i", version);
|
||||
} else if (CMD_ARGC == 1) {
|
||||
if (sscanf(CMD_ARGV[0], "%i", &tmp) != 1) {
|
||||
command_print(CMD_CTX, "Invalid argument: %s.", CMD_ARGV[0]);
|
||||
command_print(CMD, "Invalid argument: %s.", CMD_ARGV[0]);
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
@@ -1053,11 +1087,11 @@ COMMAND_HANDLER(jlink_handle_jlink_jtag_command)
|
||||
jtag_command_version = JAYLINK_JTAG_VERSION_3;
|
||||
break;
|
||||
default:
|
||||
command_print(CMD_CTX, "Invalid argument: %s.", CMD_ARGV[0]);
|
||||
command_print(CMD, "Invalid argument: %s.", CMD_ARGV[0]);
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
} else {
|
||||
command_print(CMD_CTX, "Need exactly one argument for jlink jtag.");
|
||||
command_print(CMD, "Need exactly one argument for jlink jtag.");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
@@ -1070,13 +1104,13 @@ COMMAND_HANDLER(jlink_handle_target_power_command)
|
||||
int enable;
|
||||
|
||||
if (CMD_ARGC != 1) {
|
||||
command_print(CMD_CTX, "Need exactly one argument for jlink "
|
||||
command_print(CMD, "Need exactly one argument for jlink "
|
||||
"targetpower.");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_SET_TARGET_POWER)) {
|
||||
command_print(CMD_CTX, "Target power supply is not supported by the "
|
||||
command_print(CMD, "Target power supply is not supported by the "
|
||||
"device.");
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -1086,14 +1120,14 @@ COMMAND_HANDLER(jlink_handle_target_power_command)
|
||||
} else if (!strcmp(CMD_ARGV[0], "off")) {
|
||||
enable = false;
|
||||
} else {
|
||||
command_print(CMD_CTX, "Invalid argument: %s.", CMD_ARGV[0]);
|
||||
command_print(CMD, "Invalid argument: %s.", CMD_ARGV[0]);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
ret = jaylink_set_target_power(devh, enable);
|
||||
|
||||
if (ret != JAYLINK_OK) {
|
||||
command_print(CMD_CTX, "jaylink_set_target_power() failed: %s.",
|
||||
command_print(CMD, "jaylink_set_target_power() failed: %s.",
|
||||
jaylink_strerror(ret));
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
@@ -1101,49 +1135,49 @@ COMMAND_HANDLER(jlink_handle_target_power_command)
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static void show_config_usb_address(struct command_context *ctx)
|
||||
static void show_config_usb_address(struct command_invocation *cmd)
|
||||
{
|
||||
if (config.usb_address != tmp_config.usb_address)
|
||||
command_print(ctx, "USB address: %u [%u]", config.usb_address,
|
||||
command_print(cmd, "USB address: %u [%u]", config.usb_address,
|
||||
tmp_config.usb_address);
|
||||
else
|
||||
command_print(ctx, "USB address: %u", config.usb_address);
|
||||
command_print(cmd, "USB address: %u", config.usb_address);
|
||||
}
|
||||
|
||||
static void show_config_ip_address(struct command_context *ctx)
|
||||
static void show_config_ip_address(struct command_invocation *cmd)
|
||||
{
|
||||
if (!memcmp(config.ip_address, tmp_config.ip_address, 4))
|
||||
command_print(ctx, "IP address: %d.%d.%d.%d",
|
||||
command_print(cmd, "IP address: %d.%d.%d.%d",
|
||||
config.ip_address[3], config.ip_address[2],
|
||||
config.ip_address[1], config.ip_address[0]);
|
||||
else
|
||||
command_print(ctx, "IP address: %d.%d.%d.%d [%d.%d.%d.%d]",
|
||||
command_print(cmd, "IP address: %d.%d.%d.%d [%d.%d.%d.%d]",
|
||||
config.ip_address[3], config.ip_address[2],
|
||||
config.ip_address[1], config.ip_address[0],
|
||||
tmp_config.ip_address[3], tmp_config.ip_address[2],
|
||||
tmp_config.ip_address[1], tmp_config.ip_address[0]);
|
||||
|
||||
if (!memcmp(config.subnet_mask, tmp_config.subnet_mask, 4))
|
||||
command_print(ctx, "Subnet mask: %d.%d.%d.%d",
|
||||
command_print(cmd, "Subnet mask: %d.%d.%d.%d",
|
||||
config.subnet_mask[3], config.subnet_mask[2],
|
||||
config.subnet_mask[1], config.subnet_mask[0]);
|
||||
else
|
||||
command_print(ctx, "Subnet mask: %d.%d.%d.%d [%d.%d.%d.%d]",
|
||||
command_print(cmd, "Subnet mask: %d.%d.%d.%d [%d.%d.%d.%d]",
|
||||
config.subnet_mask[3], config.subnet_mask[2],
|
||||
config.subnet_mask[1], config.subnet_mask[0],
|
||||
tmp_config.subnet_mask[3], tmp_config.subnet_mask[2],
|
||||
tmp_config.subnet_mask[1], tmp_config.subnet_mask[0]);
|
||||
}
|
||||
|
||||
static void show_config_mac_address(struct command_context *ctx)
|
||||
static void show_config_mac_address(struct command_invocation *cmd)
|
||||
{
|
||||
if (!memcmp(config.mac_address, tmp_config.mac_address, 6))
|
||||
command_print(ctx, "MAC address: %.02x:%.02x:%.02x:%.02x:%.02x:%.02x",
|
||||
command_print(cmd, "MAC address: %.02x:%.02x:%.02x:%.02x:%.02x:%.02x",
|
||||
config.mac_address[5], config.mac_address[4],
|
||||
config.mac_address[3], config.mac_address[2],
|
||||
config.mac_address[1], config.mac_address[0]);
|
||||
else
|
||||
command_print(ctx, "MAC address: %.02x:%.02x:%.02x:%.02x:%.02x:%.02x "
|
||||
command_print(cmd, "MAC address: %.02x:%.02x:%.02x:%.02x:%.02x:%.02x "
|
||||
"[%.02x:%.02x:%.02x:%.02x:%.02x:%.02x]",
|
||||
config.mac_address[5], config.mac_address[4],
|
||||
config.mac_address[3], config.mac_address[2],
|
||||
@@ -1153,7 +1187,7 @@ static void show_config_mac_address(struct command_context *ctx)
|
||||
tmp_config.mac_address[1], tmp_config.mac_address[0]);
|
||||
}
|
||||
|
||||
static void show_config_target_power(struct command_context *ctx)
|
||||
static void show_config_target_power(struct command_invocation *cmd)
|
||||
{
|
||||
const char *target_power;
|
||||
const char *current_target_power;
|
||||
@@ -1169,24 +1203,24 @@ static void show_config_target_power(struct command_context *ctx)
|
||||
current_target_power = "on";
|
||||
|
||||
if (config.target_power != tmp_config.target_power)
|
||||
command_print(ctx, "Target power supply: %s [%s]", target_power,
|
||||
command_print(cmd, "Target power supply: %s [%s]", target_power,
|
||||
current_target_power);
|
||||
else
|
||||
command_print(ctx, "Target power supply: %s", target_power);
|
||||
command_print(cmd, "Target power supply: %s", target_power);
|
||||
}
|
||||
|
||||
static void show_config(struct command_context *ctx)
|
||||
static void show_config(struct command_invocation *cmd)
|
||||
{
|
||||
command_print(ctx, "J-Link device configuration:");
|
||||
command_print(cmd, "J-Link device configuration:");
|
||||
|
||||
show_config_usb_address(ctx);
|
||||
show_config_usb_address(cmd);
|
||||
|
||||
if (jaylink_has_cap(caps, JAYLINK_DEV_CAP_SET_TARGET_POWER))
|
||||
show_config_target_power(ctx);
|
||||
show_config_target_power(cmd);
|
||||
|
||||
if (jaylink_has_cap(caps, JAYLINK_DEV_CAP_ETHERNET)) {
|
||||
show_config_ip_address(ctx);
|
||||
show_config_mac_address(ctx);
|
||||
show_config_ip_address(cmd);
|
||||
show_config_mac_address(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1346,27 +1380,27 @@ COMMAND_HANDLER(jlink_handle_config_usb_address_command)
|
||||
uint8_t tmp;
|
||||
|
||||
if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_READ_CONFIG)) {
|
||||
command_print(CMD_CTX, "Reading configuration is not supported by the "
|
||||
command_print(CMD, "Reading configuration is not supported by the "
|
||||
"device.");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
if (!CMD_ARGC) {
|
||||
show_config_usb_address(CMD_CTX);
|
||||
show_config_usb_address(CMD);
|
||||
} else if (CMD_ARGC == 1) {
|
||||
if (sscanf(CMD_ARGV[0], "%" SCNd8, &tmp) != 1) {
|
||||
command_print(CMD_CTX, "Invalid USB address: %s.", CMD_ARGV[0]);
|
||||
command_print(CMD, "Invalid USB address: %s.", CMD_ARGV[0]);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
if (tmp > JAYLINK_USB_ADDRESS_3) {
|
||||
command_print(CMD_CTX, "Invalid USB address: %u.", tmp);
|
||||
command_print(CMD, "Invalid USB address: %u.", tmp);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
tmp_config.usb_address = tmp;
|
||||
} else {
|
||||
command_print(CMD_CTX, "Need exactly one argument for jlink config "
|
||||
command_print(CMD, "Need exactly one argument for jlink config "
|
||||
"usb.");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
@@ -1379,32 +1413,32 @@ COMMAND_HANDLER(jlink_handle_config_target_power_command)
|
||||
int enable;
|
||||
|
||||
if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_READ_CONFIG)) {
|
||||
command_print(CMD_CTX, "Reading configuration is not supported by the "
|
||||
command_print(CMD, "Reading configuration is not supported by the "
|
||||
"device.");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_SET_TARGET_POWER)) {
|
||||
command_print(CMD_CTX, "Target power supply is not supported by the "
|
||||
command_print(CMD, "Target power supply is not supported by the "
|
||||
"device.");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
if (!CMD_ARGC) {
|
||||
show_config_target_power(CMD_CTX);
|
||||
show_config_target_power(CMD);
|
||||
} else if (CMD_ARGC == 1) {
|
||||
if (!strcmp(CMD_ARGV[0], "on")) {
|
||||
enable = true;
|
||||
} else if (!strcmp(CMD_ARGV[0], "off")) {
|
||||
enable = false;
|
||||
} else {
|
||||
command_print(CMD_CTX, "Invalid argument: %s.", CMD_ARGV[0]);
|
||||
command_print(CMD, "Invalid argument: %s.", CMD_ARGV[0]);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
tmp_config.target_power = enable;
|
||||
} else {
|
||||
command_print(CMD_CTX, "Need exactly one argument for jlink config "
|
||||
command_print(CMD, "Need exactly one argument for jlink config "
|
||||
"targetpower.");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
@@ -1420,25 +1454,25 @@ COMMAND_HANDLER(jlink_handle_config_mac_address_command)
|
||||
const char *str;
|
||||
|
||||
if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_READ_CONFIG)) {
|
||||
command_print(CMD_CTX, "Reading configuration is not supported by the "
|
||||
command_print(CMD, "Reading configuration is not supported by the "
|
||||
"device.");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_ETHERNET)) {
|
||||
command_print(CMD_CTX, "Ethernet connectivity is not supported by the "
|
||||
command_print(CMD, "Ethernet connectivity is not supported by the "
|
||||
"device.");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
if (!CMD_ARGC) {
|
||||
show_config_mac_address(CMD_CTX);
|
||||
show_config_mac_address(CMD);
|
||||
} else if (CMD_ARGC == 1) {
|
||||
str = CMD_ARGV[0];
|
||||
|
||||
if ((strlen(str) != 17) || (str[2] != ':' || str[5] != ':' || \
|
||||
str[8] != ':' || str[11] != ':' || str[14] != ':')) {
|
||||
command_print(CMD_CTX, "Invalid MAC address format.");
|
||||
command_print(CMD, "Invalid MAC address format.");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
@@ -1448,18 +1482,18 @@ COMMAND_HANDLER(jlink_handle_config_mac_address_command)
|
||||
}
|
||||
|
||||
if (!(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5])) {
|
||||
command_print(CMD_CTX, "Invalid MAC address: zero address.");
|
||||
command_print(CMD, "Invalid MAC address: zero address.");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
if (!(0x01 & addr[0])) {
|
||||
command_print(CMD_CTX, "Invalid MAC address: multicast address.");
|
||||
command_print(CMD, "Invalid MAC address: multicast address.");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
memcpy(tmp_config.mac_address, addr, sizeof(addr));
|
||||
} else {
|
||||
command_print(CMD_CTX, "Need exactly one argument for jlink config "
|
||||
command_print(CMD, "Need exactly one argument for jlink config "
|
||||
" mac.");
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
@@ -1508,19 +1542,19 @@ COMMAND_HANDLER(jlink_handle_config_ip_address_command)
|
||||
uint8_t subnet_bits = 24;
|
||||
|
||||
if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_READ_CONFIG)) {
|
||||
command_print(CMD_CTX, "Reading configuration is not supported by the "
|
||||
command_print(CMD, "Reading configuration is not supported by the "
|
||||
"device.");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_ETHERNET)) {
|
||||
command_print(CMD_CTX, "Ethernet connectivity is not supported by the "
|
||||
command_print(CMD, "Ethernet connectivity is not supported by the "
|
||||
"device.");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
if (!CMD_ARGC) {
|
||||
show_config_ip_address(CMD_CTX);
|
||||
show_config_ip_address(CMD);
|
||||
} else {
|
||||
if (!string_to_ip(CMD_ARGV[0], ip_address, &i))
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
@@ -1565,19 +1599,19 @@ COMMAND_HANDLER(jlink_handle_config_write_command)
|
||||
int ret;
|
||||
|
||||
if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_READ_CONFIG)) {
|
||||
command_print(CMD_CTX, "Reading configuration is not supported by the "
|
||||
command_print(CMD, "Reading configuration is not supported by the "
|
||||
"device.");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_WRITE_CONFIG)) {
|
||||
command_print(CMD_CTX, "Writing configuration is not supported by the "
|
||||
command_print(CMD, "Writing configuration is not supported by the "
|
||||
"device.");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
if (!memcmp(&config, &tmp_config, sizeof(struct device_config))) {
|
||||
command_print(CMD_CTX, "Operation not performed due to no changes in "
|
||||
command_print(CMD, "Operation not performed due to no changes in "
|
||||
"the configuration.");
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -1602,7 +1636,7 @@ COMMAND_HANDLER(jlink_handle_config_write_command)
|
||||
}
|
||||
|
||||
memcpy(&tmp_config, &config, sizeof(struct device_config));
|
||||
command_print(CMD_CTX, "The new device configuration applies after power "
|
||||
command_print(CMD, "The new device configuration applies after power "
|
||||
"cycling the J-Link device.");
|
||||
|
||||
return ERROR_OK;
|
||||
@@ -1611,12 +1645,12 @@ COMMAND_HANDLER(jlink_handle_config_write_command)
|
||||
COMMAND_HANDLER(jlink_handle_config_command)
|
||||
{
|
||||
if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_READ_CONFIG)) {
|
||||
command_print(CMD_CTX, "Device doesn't support reading configuration.");
|
||||
command_print(CMD, "Device doesn't support reading configuration.");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
if (CMD_ARGC == 0)
|
||||
show_config(CMD_CTX);
|
||||
show_config(CMD);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -1732,7 +1766,7 @@ COMMAND_HANDLER(jlink_handle_emucom_read_command)
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
command_print(CMD_CTX, "%s", buf + length);
|
||||
command_print(CMD, "%s", buf + length);
|
||||
free(buf);
|
||||
|
||||
return ERROR_OK;
|
||||
@@ -1772,13 +1806,15 @@ static const struct command_registration jlink_config_subcommand_handlers[] = {
|
||||
.name = "reset",
|
||||
.handler = &jlink_handle_config_reset_command,
|
||||
.mode = COMMAND_EXEC,
|
||||
.help = "undo configuration changes"
|
||||
.help = "undo configuration changes",
|
||||
.usage = "",
|
||||
},
|
||||
{
|
||||
.name = "write",
|
||||
.handler = &jlink_handle_config_write_command,
|
||||
.mode = COMMAND_EXEC,
|
||||
.help = "write configuration to the device"
|
||||
.help = "write configuration to the device",
|
||||
.usage = "",
|
||||
},
|
||||
COMMAND_REGISTRATION_DONE
|
||||
};
|
||||
@@ -1820,13 +1856,15 @@ static const struct command_registration jlink_subcommand_handlers[] = {
|
||||
.name = "freemem",
|
||||
.handler = &jlink_handle_free_memory_command,
|
||||
.mode = COMMAND_EXEC,
|
||||
.help = "show free device memory"
|
||||
.help = "show free device memory",
|
||||
.usage = "",
|
||||
},
|
||||
{
|
||||
.name = "hwstatus",
|
||||
.handler = &jlink_handle_hwstatus_command,
|
||||
.mode = COMMAND_EXEC,
|
||||
.help = "show the hardware status"
|
||||
.help = "show the hardware status",
|
||||
.usage = "",
|
||||
},
|
||||
{
|
||||
.name = "usb",
|
||||
@@ -1849,12 +1887,14 @@ static const struct command_registration jlink_subcommand_handlers[] = {
|
||||
.help = "access the device configuration. If no argument is given "
|
||||
"this will show the device configuration",
|
||||
.chain = jlink_config_subcommand_handlers,
|
||||
.usage = "[<cmd>]",
|
||||
},
|
||||
{
|
||||
.name = "emucom",
|
||||
.mode = COMMAND_EXEC,
|
||||
.help = "access EMUCOM channel",
|
||||
.chain = jlink_emucom_subcommand_handlers
|
||||
.chain = jlink_emucom_subcommand_handlers,
|
||||
.usage = "",
|
||||
},
|
||||
COMMAND_REGISTRATION_DONE
|
||||
};
|
||||
@@ -1865,6 +1905,7 @@ static const struct command_registration jlink_command_handlers[] = {
|
||||
.mode = COMMAND_ANY,
|
||||
.help = "perform jlink management",
|
||||
.chain = jlink_subcommand_handlers,
|
||||
.usage = "",
|
||||
},
|
||||
COMMAND_REGISTRATION_DONE
|
||||
};
|
||||
@@ -1888,14 +1929,6 @@ static void jlink_swd_read_reg(uint8_t cmd, uint32_t *value, uint32_t ap_delay_c
|
||||
jlink_swd_queue_cmd(cmd, value, 0, ap_delay_clk);
|
||||
}
|
||||
|
||||
static int_least32_t jlink_swd_frequency(int_least32_t hz)
|
||||
{
|
||||
if (hz > 0)
|
||||
jlink_speed(hz / 1000);
|
||||
|
||||
return hz;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
/* J-Link tap functions */
|
||||
|
||||
@@ -1997,7 +2030,7 @@ static int jlink_flush(void)
|
||||
buf_set_buf(tdo_buffer, p->first, p->buffer,
|
||||
p->buffer_offset, p->length);
|
||||
|
||||
DEBUG_JTAG_IO("Pending scan result, length = %d.", p->length);
|
||||
LOG_DEBUG_IO("Pending scan result, length = %d.", p->length);
|
||||
}
|
||||
|
||||
jlink_tap_init();
|
||||
@@ -2171,7 +2204,6 @@ static void jlink_swd_queue_cmd(uint8_t cmd, uint32_t *dst, uint32_t data, uint3
|
||||
|
||||
static const struct swd_driver jlink_swd = {
|
||||
.init = &jlink_swd_init,
|
||||
.frequency = &jlink_swd_frequency,
|
||||
.switch_seq = &jlink_swd_switch_seq,
|
||||
.read_reg = &jlink_swd_read_reg,
|
||||
.write_reg = &jlink_swd_write_reg,
|
||||
|
||||
@@ -15,18 +15,18 @@ static char *jtag_usb_location;
|
||||
* ------
|
||||
* 16 chars
|
||||
*/
|
||||
#define JTAG_USB_MAX_LOCATION_LENGHT 16
|
||||
#define JTAG_USB_MAX_LOCATION_LENGTH 16
|
||||
|
||||
void jtag_usb_set_location(const char *location)
|
||||
{
|
||||
if (strnlen(location, JTAG_USB_MAX_LOCATION_LENGHT) ==
|
||||
JTAG_USB_MAX_LOCATION_LENGHT)
|
||||
if (strnlen(location, JTAG_USB_MAX_LOCATION_LENGTH) ==
|
||||
JTAG_USB_MAX_LOCATION_LENGTH)
|
||||
LOG_WARNING("usb location string is too long!!\n");
|
||||
|
||||
if (jtag_usb_location)
|
||||
free(jtag_usb_location);
|
||||
|
||||
jtag_usb_location = strndup(location, JTAG_USB_MAX_LOCATION_LENGHT);
|
||||
jtag_usb_location = strndup(location, JTAG_USB_MAX_LOCATION_LENGTH);
|
||||
}
|
||||
|
||||
const char *jtag_usb_get_location(void)
|
||||
@@ -37,13 +37,13 @@ const char *jtag_usb_get_location(void)
|
||||
bool jtag_usb_location_equal(uint8_t dev_bus, uint8_t *port_path,
|
||||
size_t path_len)
|
||||
{
|
||||
size_t path_step, string_lengh;
|
||||
size_t path_step, string_length;
|
||||
char *ptr, *loc;
|
||||
bool equal = false;
|
||||
|
||||
/* strtok need non const char */
|
||||
loc = strndup(jtag_usb_get_location(), JTAG_USB_MAX_LOCATION_LENGHT);
|
||||
string_lengh = strnlen(loc, JTAG_USB_MAX_LOCATION_LENGHT);
|
||||
loc = strndup(jtag_usb_get_location(), JTAG_USB_MAX_LOCATION_LENGTH);
|
||||
string_length = strnlen(loc, JTAG_USB_MAX_LOCATION_LENGTH);
|
||||
|
||||
ptr = strtok(loc, "-");
|
||||
if (ptr == NULL) {
|
||||
@@ -51,7 +51,7 @@ bool jtag_usb_location_equal(uint8_t dev_bus, uint8_t *port_path,
|
||||
goto done;
|
||||
}
|
||||
|
||||
string_lengh -= 1;
|
||||
string_length -= 1;
|
||||
/* check bus mismatch */
|
||||
if (atoi(ptr) != dev_bus)
|
||||
goto done;
|
||||
@@ -69,15 +69,12 @@ bool jtag_usb_location_equal(uint8_t dev_bus, uint8_t *port_path,
|
||||
break;
|
||||
|
||||
path_step++;
|
||||
string_lengh -= 2;
|
||||
string_length -= 2;
|
||||
};
|
||||
|
||||
/* walked the full path, all elements match */
|
||||
if (path_step == path_len && !string_lengh)
|
||||
if (path_step == path_len && !string_length)
|
||||
equal = true;
|
||||
else
|
||||
LOG_WARNING("excluded by device path option: %s\n",
|
||||
jtag_usb_get_location());
|
||||
|
||||
done:
|
||||
free(loc);
|
||||
|
||||
@@ -319,7 +319,7 @@ static int jtag_vpi_runtest(int cycles, tap_state_t state)
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
retval = jtag_vpi_queue_tdi(NULL, cycles, TAP_SHIFT);
|
||||
retval = jtag_vpi_queue_tdi(NULL, cycles, NO_TAP_SHIFT);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
@@ -328,7 +328,27 @@ static int jtag_vpi_runtest(int cycles, tap_state_t state)
|
||||
|
||||
static int jtag_vpi_stableclocks(int cycles)
|
||||
{
|
||||
return jtag_vpi_queue_tdi(NULL, cycles, TAP_SHIFT);
|
||||
uint8_t tms_bits[4];
|
||||
int cycles_remain = cycles;
|
||||
int nb_bits;
|
||||
int retval;
|
||||
const int CYCLES_ONE_BATCH = sizeof(tms_bits) * 8;
|
||||
|
||||
assert(cycles >= 0);
|
||||
|
||||
/* use TMS=1 in TAP RESET state, TMS=0 in all other stable states */
|
||||
memset(&tms_bits, (tap_get_state() == TAP_RESET) ? 0xff : 0x00, sizeof(tms_bits));
|
||||
|
||||
/* send the TMS bits */
|
||||
while (cycles_remain > 0) {
|
||||
nb_bits = (cycles_remain < CYCLES_ONE_BATCH) ? cycles_remain : CYCLES_ONE_BATCH;
|
||||
retval = jtag_vpi_tms_seq(tms_bits, nb_bits);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
cycles_remain -= nb_bits;
|
||||
}
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static int jtag_vpi_execute_queue(void)
|
||||
|
||||
+32
-36
@@ -30,26 +30,22 @@
|
||||
#define LIBUSB_CALL
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
#define DEBUG_IO(expr...) LOG_DEBUG(expr)
|
||||
#define DEBUG_PRINT_BUF(buf, len) \
|
||||
do { \
|
||||
char buf_string[32 * 3 + 1]; \
|
||||
int buf_string_pos = 0; \
|
||||
for (int i = 0; i < len; i++) { \
|
||||
buf_string_pos += sprintf(buf_string + buf_string_pos, " %02x", buf[i]); \
|
||||
if (i % 32 == 32 - 1) { \
|
||||
LOG_DEBUG("%s", buf_string); \
|
||||
buf_string_pos = 0; \
|
||||
if (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO)) { \
|
||||
char buf_string[32 * 3 + 1]; \
|
||||
int buf_string_pos = 0; \
|
||||
for (int i = 0; i < len; i++) { \
|
||||
buf_string_pos += sprintf(buf_string + buf_string_pos, " %02x", buf[i]); \
|
||||
if (i % 32 == 32 - 1) { \
|
||||
LOG_DEBUG_IO("%s", buf_string); \
|
||||
buf_string_pos = 0; \
|
||||
} \
|
||||
} \
|
||||
if (buf_string_pos > 0) \
|
||||
LOG_DEBUG_IO("%s", buf_string);\
|
||||
} \
|
||||
if (buf_string_pos > 0) \
|
||||
LOG_DEBUG("%s", buf_string);\
|
||||
} while (0)
|
||||
#else
|
||||
#define DEBUG_IO(expr...) do {} while (0)
|
||||
#define DEBUG_PRINT_BUF(buf, len) do {} while (0)
|
||||
#endif
|
||||
|
||||
#define FTDI_DEVICE_OUT_REQTYPE (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE)
|
||||
#define FTDI_DEVICE_IN_REQTYPE (0x80 | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE)
|
||||
@@ -459,7 +455,7 @@ static unsigned buffer_read_space(struct mpsse_ctx *ctx)
|
||||
|
||||
static void buffer_write_byte(struct mpsse_ctx *ctx, uint8_t data)
|
||||
{
|
||||
DEBUG_IO("%02x", data);
|
||||
LOG_DEBUG_IO("%02x", data);
|
||||
assert(ctx->write_count < ctx->write_size);
|
||||
ctx->write_buffer[ctx->write_count++] = data;
|
||||
}
|
||||
@@ -467,7 +463,7 @@ static void buffer_write_byte(struct mpsse_ctx *ctx, uint8_t data)
|
||||
static unsigned buffer_write(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_offset,
|
||||
unsigned bit_count)
|
||||
{
|
||||
DEBUG_IO("%d bits", bit_count);
|
||||
LOG_DEBUG_IO("%d bits", bit_count);
|
||||
assert(ctx->write_count + DIV_ROUND_UP(bit_count, 8) <= ctx->write_size);
|
||||
bit_copy(ctx->write_buffer + ctx->write_count, 0, out, out_offset, bit_count);
|
||||
ctx->write_count += DIV_ROUND_UP(bit_count, 8);
|
||||
@@ -477,7 +473,7 @@ static unsigned buffer_write(struct mpsse_ctx *ctx, const uint8_t *out, unsigned
|
||||
static unsigned buffer_add_read(struct mpsse_ctx *ctx, uint8_t *in, unsigned in_offset,
|
||||
unsigned bit_count, unsigned offset)
|
||||
{
|
||||
DEBUG_IO("%d bits, offset %d", bit_count, offset);
|
||||
LOG_DEBUG_IO("%d bits, offset %d", bit_count, offset);
|
||||
assert(ctx->read_count + DIV_ROUND_UP(bit_count, 8) <= ctx->read_size);
|
||||
bit_copy_queued(&ctx->read_queue, in, in_offset, ctx->read_buffer + ctx->read_count, offset,
|
||||
bit_count);
|
||||
@@ -501,10 +497,10 @@ void mpsse_clock_data(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_of
|
||||
unsigned in_offset, unsigned length, uint8_t mode)
|
||||
{
|
||||
/* TODO: Fix MSB first modes */
|
||||
DEBUG_IO("%s%s %d bits", in ? "in" : "", out ? "out" : "", length);
|
||||
LOG_DEBUG_IO("%s%s %d bits", in ? "in" : "", out ? "out" : "", length);
|
||||
|
||||
if (ctx->retval != ERROR_OK) {
|
||||
DEBUG_IO("Ignoring command due to previous error");
|
||||
LOG_DEBUG_IO("Ignoring command due to previous error");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -577,11 +573,11 @@ void mpsse_clock_tms_cs_out(struct mpsse_ctx *ctx, const uint8_t *out, unsigned
|
||||
void mpsse_clock_tms_cs(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_offset, uint8_t *in,
|
||||
unsigned in_offset, unsigned length, bool tdi, uint8_t mode)
|
||||
{
|
||||
DEBUG_IO("%sout %d bits, tdi=%d", in ? "in" : "", length, tdi);
|
||||
LOG_DEBUG_IO("%sout %d bits, tdi=%d", in ? "in" : "", length, tdi);
|
||||
assert(out);
|
||||
|
||||
if (ctx->retval != ERROR_OK) {
|
||||
DEBUG_IO("Ignoring command due to previous error");
|
||||
LOG_DEBUG_IO("Ignoring command due to previous error");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -627,10 +623,10 @@ void mpsse_clock_tms_cs(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_
|
||||
|
||||
void mpsse_set_data_bits_low_byte(struct mpsse_ctx *ctx, uint8_t data, uint8_t dir)
|
||||
{
|
||||
DEBUG_IO("-");
|
||||
LOG_DEBUG_IO("-");
|
||||
|
||||
if (ctx->retval != ERROR_OK) {
|
||||
DEBUG_IO("Ignoring command due to previous error");
|
||||
LOG_DEBUG_IO("Ignoring command due to previous error");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -644,10 +640,10 @@ void mpsse_set_data_bits_low_byte(struct mpsse_ctx *ctx, uint8_t data, uint8_t d
|
||||
|
||||
void mpsse_set_data_bits_high_byte(struct mpsse_ctx *ctx, uint8_t data, uint8_t dir)
|
||||
{
|
||||
DEBUG_IO("-");
|
||||
LOG_DEBUG_IO("-");
|
||||
|
||||
if (ctx->retval != ERROR_OK) {
|
||||
DEBUG_IO("Ignoring command due to previous error");
|
||||
LOG_DEBUG_IO("Ignoring command due to previous error");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -661,10 +657,10 @@ void mpsse_set_data_bits_high_byte(struct mpsse_ctx *ctx, uint8_t data, uint8_t
|
||||
|
||||
void mpsse_read_data_bits_low_byte(struct mpsse_ctx *ctx, uint8_t *data)
|
||||
{
|
||||
DEBUG_IO("-");
|
||||
LOG_DEBUG_IO("-");
|
||||
|
||||
if (ctx->retval != ERROR_OK) {
|
||||
DEBUG_IO("Ignoring command due to previous error");
|
||||
LOG_DEBUG_IO("Ignoring command due to previous error");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -677,10 +673,10 @@ void mpsse_read_data_bits_low_byte(struct mpsse_ctx *ctx, uint8_t *data)
|
||||
|
||||
void mpsse_read_data_bits_high_byte(struct mpsse_ctx *ctx, uint8_t *data)
|
||||
{
|
||||
DEBUG_IO("-");
|
||||
LOG_DEBUG_IO("-");
|
||||
|
||||
if (ctx->retval != ERROR_OK) {
|
||||
DEBUG_IO("Ignoring command due to previous error");
|
||||
LOG_DEBUG_IO("Ignoring command due to previous error");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -695,7 +691,7 @@ static void single_byte_boolean_helper(struct mpsse_ctx *ctx, bool var, uint8_t
|
||||
uint8_t val_if_false)
|
||||
{
|
||||
if (ctx->retval != ERROR_OK) {
|
||||
DEBUG_IO("Ignoring command due to previous error");
|
||||
LOG_DEBUG_IO("Ignoring command due to previous error");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -716,7 +712,7 @@ void mpsse_set_divisor(struct mpsse_ctx *ctx, uint16_t divisor)
|
||||
LOG_DEBUG("%d", divisor);
|
||||
|
||||
if (ctx->retval != ERROR_OK) {
|
||||
DEBUG_IO("Ignoring command due to previous error");
|
||||
LOG_DEBUG_IO("Ignoring command due to previous error");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -818,7 +814,7 @@ static LIBUSB_CALL void read_cb(struct libusb_transfer *transfer)
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_IO("raw chunk %d, transferred %d of %d", transfer->actual_length, res->transferred,
|
||||
LOG_DEBUG_IO("raw chunk %d, transferred %d of %d", transfer->actual_length, res->transferred,
|
||||
ctx->read_count);
|
||||
|
||||
if (!res->done)
|
||||
@@ -833,7 +829,7 @@ static LIBUSB_CALL void write_cb(struct libusb_transfer *transfer)
|
||||
|
||||
res->transferred += transfer->actual_length;
|
||||
|
||||
DEBUG_IO("transferred %d of %d", res->transferred, ctx->write_count);
|
||||
LOG_DEBUG_IO("transferred %d of %d", res->transferred, ctx->write_count);
|
||||
|
||||
DEBUG_PRINT_BUF(transfer->buffer, transfer->actual_length);
|
||||
|
||||
@@ -852,13 +848,13 @@ int mpsse_flush(struct mpsse_ctx *ctx)
|
||||
int retval = ctx->retval;
|
||||
|
||||
if (retval != ERROR_OK) {
|
||||
DEBUG_IO("Ignoring flush due to previous error");
|
||||
LOG_DEBUG_IO("Ignoring flush due to previous error");
|
||||
assert(ctx->write_count == 0 && ctx->read_count == 0);
|
||||
ctx->retval = ERROR_OK;
|
||||
return retval;
|
||||
}
|
||||
|
||||
DEBUG_IO("write %d%s, read %d", ctx->write_count, ctx->read_count ? "+1" : "",
|
||||
LOG_DEBUG_IO("write %d%s, read %d", ctx->write_count, ctx->read_count ? "+1" : "",
|
||||
ctx->read_count);
|
||||
assert(ctx->write_count > 0 || ctx->read_count == 0); /* No read data without write data */
|
||||
|
||||
|
||||
+15
-13
@@ -185,7 +185,7 @@ COMMAND_HANDLER(opendous_handle_opendous_hw_jtag_command)
|
||||
{
|
||||
switch (CMD_ARGC) {
|
||||
case 0:
|
||||
command_print(CMD_CTX, "opendous hw jtag %i", opendous_hw_jtag_version);
|
||||
command_print(CMD, "opendous hw jtag %i", opendous_hw_jtag_version);
|
||||
break;
|
||||
|
||||
case 1: {
|
||||
@@ -215,6 +215,7 @@ static const struct command_registration opendous_command_handlers[] = {
|
||||
.handler = &opendous_handle_opendous_info_command,
|
||||
.mode = COMMAND_EXEC,
|
||||
.help = "show opendous info",
|
||||
.usage = "",
|
||||
},
|
||||
{
|
||||
.name = "opendous_hw_jtag",
|
||||
@@ -235,6 +236,7 @@ static const struct command_registration opendous_command_handlers[] = {
|
||||
|
||||
struct jtag_interface opendous_interface = {
|
||||
.name = "opendous",
|
||||
.transports = jtag_only,
|
||||
.commands = opendous_command_handlers,
|
||||
.execute_queue = opendous_execute_queue,
|
||||
.init = opendous_init,
|
||||
@@ -251,7 +253,7 @@ static int opendous_execute_queue(void)
|
||||
while (cmd != NULL) {
|
||||
switch (cmd->type) {
|
||||
case JTAG_RUNTEST:
|
||||
DEBUG_JTAG_IO("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, \
|
||||
LOG_DEBUG_IO("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, \
|
||||
cmd->cmd.runtest->end_state);
|
||||
|
||||
if (cmd->cmd.runtest->end_state != -1)
|
||||
@@ -260,7 +262,7 @@ static int opendous_execute_queue(void)
|
||||
break;
|
||||
|
||||
case JTAG_TLR_RESET:
|
||||
DEBUG_JTAG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
|
||||
LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
|
||||
|
||||
if (cmd->cmd.statemove->end_state != -1)
|
||||
opendous_end_state(cmd->cmd.statemove->end_state);
|
||||
@@ -268,7 +270,7 @@ static int opendous_execute_queue(void)
|
||||
break;
|
||||
|
||||
case JTAG_PATHMOVE:
|
||||
DEBUG_JTAG_IO("pathmove: %i states, end in %i", \
|
||||
LOG_DEBUG_IO("pathmove: %i states, end in %i", \
|
||||
cmd->cmd.pathmove->num_states, \
|
||||
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
|
||||
|
||||
@@ -276,13 +278,13 @@ static int opendous_execute_queue(void)
|
||||
break;
|
||||
|
||||
case JTAG_SCAN:
|
||||
DEBUG_JTAG_IO("scan end in %i", cmd->cmd.scan->end_state);
|
||||
LOG_DEBUG_IO("scan end in %i", cmd->cmd.scan->end_state);
|
||||
|
||||
if (cmd->cmd.scan->end_state != -1)
|
||||
opendous_end_state(cmd->cmd.scan->end_state);
|
||||
|
||||
scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
|
||||
DEBUG_JTAG_IO("scan input, length = %d", scan_size);
|
||||
LOG_DEBUG_IO("scan input, length = %d", scan_size);
|
||||
|
||||
#ifdef _DEBUG_USB_COMMS_
|
||||
opendous_debug_buffer(buffer, (scan_size + 7) / 8);
|
||||
@@ -292,7 +294,7 @@ static int opendous_execute_queue(void)
|
||||
break;
|
||||
|
||||
case JTAG_RESET:
|
||||
DEBUG_JTAG_IO("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst);
|
||||
LOG_DEBUG_IO("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst);
|
||||
|
||||
opendous_tap_execute();
|
||||
|
||||
@@ -302,7 +304,7 @@ static int opendous_execute_queue(void)
|
||||
break;
|
||||
|
||||
case JTAG_SLEEP:
|
||||
DEBUG_JTAG_IO("sleep %" PRIi32, cmd->cmd.sleep->us);
|
||||
LOG_DEBUG_IO("sleep %" PRIi32, cmd->cmd.sleep->us);
|
||||
opendous_tap_execute();
|
||||
jtag_sleep(cmd->cmd.sleep->us);
|
||||
break;
|
||||
@@ -527,7 +529,7 @@ void opendous_simple_command(uint8_t command, uint8_t _data)
|
||||
{
|
||||
int result;
|
||||
|
||||
DEBUG_JTAG_IO("0x%02x 0x%02x", command, _data);
|
||||
LOG_DEBUG_IO("0x%02x 0x%02x", command, _data);
|
||||
|
||||
usb_out_buffer[0] = 2;
|
||||
usb_out_buffer[1] = 0;
|
||||
@@ -596,7 +598,7 @@ void opendous_tap_append_step(int tms, int tdi)
|
||||
|
||||
void opendous_tap_append_scan(int length, uint8_t *buffer, struct scan_command *command)
|
||||
{
|
||||
DEBUG_JTAG_IO("append scan, length = %d", length);
|
||||
LOG_DEBUG_IO("append scan, length = %d", length);
|
||||
|
||||
struct pending_scan_result *pending_scan_result = &pending_scan_results_buffer[pending_scan_results_length];
|
||||
int i;
|
||||
@@ -678,7 +680,7 @@ int opendous_tap_execute(void)
|
||||
/* Copy to buffer */
|
||||
buf_set_buf(tdo_buffer, first, buffer, 0, length);
|
||||
|
||||
DEBUG_JTAG_IO("pending scan result, length = %d", length);
|
||||
LOG_DEBUG_IO("pending scan result, length = %d", length);
|
||||
|
||||
#ifdef _DEBUG_USB_COMMS_
|
||||
opendous_debug_buffer(buffer, byte_length_out);
|
||||
@@ -769,7 +771,7 @@ int opendous_usb_write(struct opendous_jtag *opendous_jtag, int out_length)
|
||||
LOG_DEBUG("USB write end: %d bytes", result);
|
||||
#endif
|
||||
|
||||
DEBUG_JTAG_IO("opendous_usb_write, out_length = %d, result = %d", out_length, result);
|
||||
LOG_DEBUG_IO("opendous_usb_write, out_length = %d, result = %d", out_length, result);
|
||||
|
||||
#ifdef _DEBUG_USB_COMMS_
|
||||
opendous_debug_buffer(usb_out_buffer, out_length);
|
||||
@@ -795,7 +797,7 @@ int opendous_usb_read(struct opendous_jtag *opendous_jtag)
|
||||
#ifdef _DEBUG_USB_COMMS_
|
||||
LOG_DEBUG("USB read end: %d bytes", result);
|
||||
#endif
|
||||
DEBUG_JTAG_IO("opendous_usb_read, result = %d", result);
|
||||
LOG_DEBUG_IO("opendous_usb_read, result = %d", result);
|
||||
|
||||
#ifdef _DEBUG_USB_COMMS_
|
||||
opendous_debug_buffer(usb_in_buffer, result);
|
||||
|
||||
+11
-10
@@ -292,7 +292,7 @@ static int openjtag_buf_read_standard(
|
||||
qty - *bytes_read);
|
||||
if (retval < 0) {
|
||||
*bytes_read = 0;
|
||||
DEBUG_JTAG_IO("ftdi_read_data: %s",
|
||||
LOG_DEBUG_IO("ftdi_read_data: %s",
|
||||
ftdi_get_error_string(&ftdic));
|
||||
return ERROR_JTAG_DEVICE_ERROR;
|
||||
}
|
||||
@@ -574,7 +574,7 @@ static int openjtag_execute_tap_queue(void)
|
||||
|
||||
while (len > 0) {
|
||||
if (len <= 8 && openjtag_variant != OPENJTAG_VARIANT_CY7C65215) {
|
||||
DEBUG_JTAG_IO("bits < 8 buf = 0x%X, will be 0x%X",
|
||||
LOG_DEBUG_IO("bits < 8 buf = 0x%X, will be 0x%X",
|
||||
usb_rx_buf[rx_offs], usb_rx_buf[rx_offs] >> (8 - len));
|
||||
buffer[count] = usb_rx_buf[rx_offs] >> (8 - len);
|
||||
len = 0;
|
||||
@@ -609,8 +609,8 @@ static void openjtag_add_byte(char buf)
|
||||
{
|
||||
|
||||
if (usb_tx_buf_offs == OPENJTAG_BUFFER_SIZE) {
|
||||
DEBUG_JTAG_IO("Forcing execute_tap_queue");
|
||||
DEBUG_JTAG_IO("TX Buff offs=%d", usb_tx_buf_offs);
|
||||
LOG_DEBUG_IO("Forcing execute_tap_queue");
|
||||
LOG_DEBUG_IO("TX Buff offs=%d", usb_tx_buf_offs);
|
||||
openjtag_execute_tap_queue();
|
||||
}
|
||||
|
||||
@@ -624,8 +624,8 @@ static void openjtag_add_scan(uint8_t *buffer, int length, struct scan_command *
|
||||
/* Ensure space to send long chains */
|
||||
/* We add two byte for each eight (or less) bits, one for command, one for data */
|
||||
if (usb_tx_buf_offs + (DIV_ROUND_UP(length, 8) * 2) >= OPENJTAG_BUFFER_SIZE) {
|
||||
DEBUG_JTAG_IO("Forcing execute_tap_queue from scan");
|
||||
DEBUG_JTAG_IO("TX Buff offs=%d len=%d", usb_tx_buf_offs, DIV_ROUND_UP(length, 8) * 2);
|
||||
LOG_DEBUG_IO("Forcing execute_tap_queue from scan");
|
||||
LOG_DEBUG_IO("TX Buff offs=%d len=%d", usb_tx_buf_offs, DIV_ROUND_UP(length, 8) * 2);
|
||||
openjtag_execute_tap_queue();
|
||||
}
|
||||
|
||||
@@ -670,7 +670,7 @@ static void openjtag_add_scan(uint8_t *buffer, int length, struct scan_command *
|
||||
static void openjtag_execute_reset(struct jtag_command *cmd)
|
||||
{
|
||||
|
||||
DEBUG_JTAG_IO("reset trst: %i srst %i",
|
||||
LOG_DEBUG_IO("reset trst: %i srst %i",
|
||||
cmd->cmd.reset->trst, cmd->cmd.reset->srst);
|
||||
|
||||
uint8_t buf = 0x00;
|
||||
@@ -703,7 +703,7 @@ static void openjtag_set_state(uint8_t openocd_state)
|
||||
|
||||
static void openjtag_execute_statemove(struct jtag_command *cmd)
|
||||
{
|
||||
DEBUG_JTAG_IO("state move to %i", cmd->cmd.statemove->end_state);
|
||||
LOG_DEBUG_IO("state move to %i", cmd->cmd.statemove->end_state);
|
||||
|
||||
tap_set_end_state(cmd->cmd.statemove->end_state);
|
||||
|
||||
@@ -719,7 +719,7 @@ static void openjtag_execute_scan(struct jtag_command *cmd)
|
||||
int scan_size, old_state;
|
||||
uint8_t *buffer;
|
||||
|
||||
DEBUG_JTAG_IO("scan ends in %s", tap_state_name(cmd->cmd.scan->end_state));
|
||||
LOG_DEBUG_IO("scan ends in %s", tap_state_name(cmd->cmd.scan->end_state));
|
||||
|
||||
/* get scan info */
|
||||
tap_set_end_state(cmd->cmd.scan->end_state);
|
||||
@@ -778,7 +778,7 @@ static void openjtag_execute_runtest(struct jtag_command *cmd)
|
||||
|
||||
static void openjtag_execute_command(struct jtag_command *cmd)
|
||||
{
|
||||
DEBUG_JTAG_IO("openjtag_execute_command %i", cmd->type);
|
||||
LOG_DEBUG_IO("openjtag_execute_command %i", cmd->type);
|
||||
switch (cmd->type) {
|
||||
case JTAG_RESET:
|
||||
openjtag_execute_reset(cmd);
|
||||
@@ -894,6 +894,7 @@ static const struct command_registration openjtag_command_handlers[] = {
|
||||
|
||||
struct jtag_interface openjtag_interface = {
|
||||
.name = "openjtag",
|
||||
.transports = jtag_only,
|
||||
.commands = openjtag_command_handlers,
|
||||
|
||||
.execute_queue = openjtag_execute_queue,
|
||||
|
||||
@@ -413,7 +413,7 @@ COMMAND_HANDLER(parport_handle_parport_port_command)
|
||||
}
|
||||
}
|
||||
|
||||
command_print(CMD_CTX, "parport port = 0x%" PRIx16 "", parport_port);
|
||||
command_print(CMD, "parport port = 0x%" PRIx16 "", parport_port);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -470,7 +470,7 @@ COMMAND_HANDLER(parport_handle_parport_toggling_time_command)
|
||||
}
|
||||
}
|
||||
|
||||
command_print(CMD_CTX, "parport toggling time = %" PRIu32 " ns",
|
||||
command_print(CMD, "parport toggling time = %" PRIu32 " ns",
|
||||
parport_toggling_time_ns);
|
||||
|
||||
return ERROR_OK;
|
||||
@@ -517,6 +517,7 @@ static const struct command_registration parport_command_handlers[] = {
|
||||
struct jtag_interface parport_interface = {
|
||||
.name = "parport",
|
||||
.supported = DEBUG_CAP_TMS_SEQ,
|
||||
.transports = jtag_only,
|
||||
.commands = parport_command_handlers,
|
||||
|
||||
.init = parport_init,
|
||||
|
||||
@@ -563,6 +563,7 @@ static int presto_jtag_quit(void)
|
||||
|
||||
struct jtag_interface presto_interface = {
|
||||
.name = "presto",
|
||||
.transports = jtag_only,
|
||||
.commands = presto_command_handlers,
|
||||
|
||||
.execute_queue = bitq_execute_queue,
|
||||
|
||||
@@ -345,6 +345,7 @@ static const struct command_registration remote_bitbang_command_handlers[] = {
|
||||
struct jtag_interface remote_bitbang_interface = {
|
||||
.name = "remote_bitbang",
|
||||
.execute_queue = &bitbang_execute_queue,
|
||||
.transports = jtag_only,
|
||||
.commands = remote_bitbang_command_handlers,
|
||||
.init = &remote_bitbang_init,
|
||||
.quit = &remote_bitbang_quit,
|
||||
|
||||
+11
-22
@@ -1299,11 +1299,9 @@ static int rlink_execute_queue(void)
|
||||
|
||||
switch (cmd->type) {
|
||||
case JTAG_RESET:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("reset trst: %i srst %i",
|
||||
LOG_DEBUG_IO("reset trst: %i srst %i",
|
||||
cmd->cmd.reset->trst,
|
||||
cmd->cmd.reset->srst);
|
||||
#endif
|
||||
if ((cmd->cmd.reset->trst == 1) ||
|
||||
(cmd->cmd.reset->srst &&
|
||||
(jtag_get_reset_config() & RESET_SRST_PULLS_TRST)))
|
||||
@@ -1311,37 +1309,29 @@ static int rlink_execute_queue(void)
|
||||
rlink_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
|
||||
break;
|
||||
case JTAG_RUNTEST:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("runtest %i cycles, end in %i",
|
||||
LOG_DEBUG_IO("runtest %i cycles, end in %i",
|
||||
cmd->cmd.runtest->num_cycles,
|
||||
cmd->cmd.runtest->end_state);
|
||||
#endif
|
||||
if (cmd->cmd.runtest->end_state != -1)
|
||||
rlink_end_state(cmd->cmd.runtest->end_state);
|
||||
rlink_runtest(cmd->cmd.runtest->num_cycles);
|
||||
break;
|
||||
case JTAG_TLR_RESET:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("statemove end in %i", cmd->cmd.statemove->end_state);
|
||||
#endif
|
||||
LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
|
||||
if (cmd->cmd.statemove->end_state != -1)
|
||||
rlink_end_state(cmd->cmd.statemove->end_state);
|
||||
rlink_state_move();
|
||||
break;
|
||||
case JTAG_PATHMOVE:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("pathmove: %i states, end in %i",
|
||||
cmd->cmd.pathmove->num_states,
|
||||
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
|
||||
#endif
|
||||
LOG_DEBUG_IO("pathmove: %i states, end in %i",
|
||||
cmd->cmd.pathmove->num_states,
|
||||
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
|
||||
rlink_path_move(cmd->cmd.pathmove);
|
||||
break;
|
||||
case JTAG_SCAN:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("%s scan end in %i",
|
||||
(cmd->cmd.scan->ir_scan) ? "IR" : "DR",
|
||||
cmd->cmd.scan->end_state);
|
||||
#endif
|
||||
LOG_DEBUG_IO("%s scan end in %i",
|
||||
(cmd->cmd.scan->ir_scan) ? "IR" : "DR",
|
||||
cmd->cmd.scan->end_state);
|
||||
if (cmd->cmd.scan->end_state != -1)
|
||||
rlink_end_state(cmd->cmd.scan->end_state);
|
||||
scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
|
||||
@@ -1350,9 +1340,7 @@ static int rlink_execute_queue(void)
|
||||
retval = ERROR_FAIL;
|
||||
break;
|
||||
case JTAG_SLEEP:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("sleep %i", cmd->cmd.sleep->us);
|
||||
#endif
|
||||
LOG_DEBUG_IO("sleep %i", cmd->cmd.sleep->us);
|
||||
jtag_sleep(cmd->cmd.sleep->us);
|
||||
break;
|
||||
default:
|
||||
@@ -1674,6 +1662,7 @@ static int rlink_quit(void)
|
||||
|
||||
struct jtag_interface rlink_interface = {
|
||||
.name = "rlink",
|
||||
.transports = jtag_only,
|
||||
.init = rlink_init,
|
||||
.quit = rlink_quit,
|
||||
.speed = rlink_speed,
|
||||
|
||||
@@ -356,7 +356,7 @@ COMMAND_HANDLER(sysfsgpio_handle_jtag_gpionums)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"SysfsGPIO nums: tck = %d, tms = %d, tdi = %d, tdo = %d",
|
||||
tck_gpio, tms_gpio, tdi_gpio, tdo_gpio);
|
||||
|
||||
@@ -368,7 +368,7 @@ COMMAND_HANDLER(sysfsgpio_handle_jtag_gpionum_tck)
|
||||
if (CMD_ARGC == 1)
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], tck_gpio);
|
||||
|
||||
command_print(CMD_CTX, "SysfsGPIO num: tck = %d", tck_gpio);
|
||||
command_print(CMD, "SysfsGPIO num: tck = %d", tck_gpio);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -377,7 +377,7 @@ COMMAND_HANDLER(sysfsgpio_handle_jtag_gpionum_tms)
|
||||
if (CMD_ARGC == 1)
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], tms_gpio);
|
||||
|
||||
command_print(CMD_CTX, "SysfsGPIO num: tms = %d", tms_gpio);
|
||||
command_print(CMD, "SysfsGPIO num: tms = %d", tms_gpio);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -386,7 +386,7 @@ COMMAND_HANDLER(sysfsgpio_handle_jtag_gpionum_tdo)
|
||||
if (CMD_ARGC == 1)
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], tdo_gpio);
|
||||
|
||||
command_print(CMD_CTX, "SysfsGPIO num: tdo = %d", tdo_gpio);
|
||||
command_print(CMD, "SysfsGPIO num: tdo = %d", tdo_gpio);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -395,7 +395,7 @@ COMMAND_HANDLER(sysfsgpio_handle_jtag_gpionum_tdi)
|
||||
if (CMD_ARGC == 1)
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], tdi_gpio);
|
||||
|
||||
command_print(CMD_CTX, "SysfsGPIO num: tdi = %d", tdi_gpio);
|
||||
command_print(CMD, "SysfsGPIO num: tdi = %d", tdi_gpio);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -404,7 +404,7 @@ COMMAND_HANDLER(sysfsgpio_handle_jtag_gpionum_srst)
|
||||
if (CMD_ARGC == 1)
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], srst_gpio);
|
||||
|
||||
command_print(CMD_CTX, "SysfsGPIO num: srst = %d", srst_gpio);
|
||||
command_print(CMD, "SysfsGPIO num: srst = %d", srst_gpio);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -413,7 +413,7 @@ COMMAND_HANDLER(sysfsgpio_handle_jtag_gpionum_trst)
|
||||
if (CMD_ARGC == 1)
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], trst_gpio);
|
||||
|
||||
command_print(CMD_CTX, "SysfsGPIO num: trst = %d", trst_gpio);
|
||||
command_print(CMD, "SysfsGPIO num: trst = %d", trst_gpio);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -426,7 +426,7 @@ COMMAND_HANDLER(sysfsgpio_handle_swd_gpionums)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
command_print(CMD_CTX,
|
||||
command_print(CMD,
|
||||
"SysfsGPIO nums: swclk = %d, swdio = %d",
|
||||
swclk_gpio, swdio_gpio);
|
||||
|
||||
@@ -438,7 +438,7 @@ COMMAND_HANDLER(sysfsgpio_handle_swd_gpionum_swclk)
|
||||
if (CMD_ARGC == 1)
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], swclk_gpio);
|
||||
|
||||
command_print(CMD_CTX, "SysfsGPIO num: swclk = %d", swclk_gpio);
|
||||
command_print(CMD, "SysfsGPIO num: swclk = %d", swclk_gpio);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -447,7 +447,7 @@ COMMAND_HANDLER(sysfsgpio_handle_swd_gpionum_swdio)
|
||||
if (CMD_ARGC == 1)
|
||||
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], swdio_gpio);
|
||||
|
||||
command_print(CMD_CTX, "SysfsGPIO num: swdio = %d", swdio_gpio);
|
||||
command_print(CMD, "SysfsGPIO num: swdio = %d", swdio_gpio);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
+81
-109
@@ -187,12 +187,7 @@ void ulink_clear_queue(struct ulink *device);
|
||||
int ulink_append_queue(struct ulink *device, struct ulink_cmd *ulink_cmd);
|
||||
int ulink_execute_queued_commands(struct ulink *device, int timeout);
|
||||
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
const char *ulink_cmd_id_string(uint8_t id);
|
||||
void ulink_print_command(struct ulink_cmd *ulink_cmd);
|
||||
void ulink_print_queue(struct ulink *device);
|
||||
static int ulink_calculate_frequency(enum ulink_delay_type type, int delay, long *f);
|
||||
#endif
|
||||
static void ulink_print_queue(struct ulink *device);
|
||||
|
||||
int ulink_append_scan_cmd(struct ulink *device,
|
||||
enum scan_type scan_type,
|
||||
@@ -708,9 +703,8 @@ int ulink_execute_queued_commands(struct ulink *device, int timeout)
|
||||
int ret, i, index_out, index_in, count_out, count_in, transferred;
|
||||
uint8_t buffer[64];
|
||||
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
ulink_print_queue(device);
|
||||
#endif
|
||||
if (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO))
|
||||
ulink_print_queue(device);
|
||||
|
||||
index_out = 0;
|
||||
count_out = 0;
|
||||
@@ -759,71 +753,69 @@ int ulink_execute_queued_commands(struct ulink *device, int timeout)
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
|
||||
/**
|
||||
* Convert an OpenULINK command ID (\a id) to a human-readable string.
|
||||
*
|
||||
* @param id the OpenULINK command ID.
|
||||
* @return the corresponding human-readable string.
|
||||
*/
|
||||
const char *ulink_cmd_id_string(uint8_t id)
|
||||
static const char *ulink_cmd_id_string(uint8_t id)
|
||||
{
|
||||
switch (id) {
|
||||
case CMD_SCAN_IN:
|
||||
return "CMD_SCAN_IN";
|
||||
break;
|
||||
case CMD_SLOW_SCAN_IN:
|
||||
return "CMD_SLOW_SCAN_IN";
|
||||
break;
|
||||
case CMD_SCAN_OUT:
|
||||
return "CMD_SCAN_OUT";
|
||||
break;
|
||||
case CMD_SLOW_SCAN_OUT:
|
||||
return "CMD_SLOW_SCAN_OUT";
|
||||
break;
|
||||
case CMD_SCAN_IO:
|
||||
return "CMD_SCAN_IO";
|
||||
break;
|
||||
case CMD_SLOW_SCAN_IO:
|
||||
return "CMD_SLOW_SCAN_IO";
|
||||
break;
|
||||
case CMD_CLOCK_TMS:
|
||||
return "CMD_CLOCK_TMS";
|
||||
break;
|
||||
case CMD_SLOW_CLOCK_TMS:
|
||||
return "CMD_SLOW_CLOCK_TMS";
|
||||
break;
|
||||
case CMD_CLOCK_TCK:
|
||||
return "CMD_CLOCK_TCK";
|
||||
break;
|
||||
case CMD_SLOW_CLOCK_TCK:
|
||||
return "CMD_SLOW_CLOCK_TCK";
|
||||
break;
|
||||
case CMD_SLEEP_US:
|
||||
return "CMD_SLEEP_US";
|
||||
break;
|
||||
case CMD_SLEEP_MS:
|
||||
return "CMD_SLEEP_MS";
|
||||
break;
|
||||
case CMD_GET_SIGNALS:
|
||||
return "CMD_GET_SIGNALS";
|
||||
break;
|
||||
case CMD_SET_SIGNALS:
|
||||
return "CMD_SET_SIGNALS";
|
||||
break;
|
||||
case CMD_CONFIGURE_TCK_FREQ:
|
||||
return "CMD_CONFIGURE_TCK_FREQ";
|
||||
break;
|
||||
case CMD_SET_LEDS:
|
||||
return "CMD_SET_LEDS";
|
||||
break;
|
||||
case CMD_TEST:
|
||||
return "CMD_TEST";
|
||||
break;
|
||||
default:
|
||||
return "CMD_UNKNOWN";
|
||||
break;
|
||||
case CMD_SCAN_IN:
|
||||
return "CMD_SCAN_IN";
|
||||
break;
|
||||
case CMD_SLOW_SCAN_IN:
|
||||
return "CMD_SLOW_SCAN_IN";
|
||||
break;
|
||||
case CMD_SCAN_OUT:
|
||||
return "CMD_SCAN_OUT";
|
||||
break;
|
||||
case CMD_SLOW_SCAN_OUT:
|
||||
return "CMD_SLOW_SCAN_OUT";
|
||||
break;
|
||||
case CMD_SCAN_IO:
|
||||
return "CMD_SCAN_IO";
|
||||
break;
|
||||
case CMD_SLOW_SCAN_IO:
|
||||
return "CMD_SLOW_SCAN_IO";
|
||||
break;
|
||||
case CMD_CLOCK_TMS:
|
||||
return "CMD_CLOCK_TMS";
|
||||
break;
|
||||
case CMD_SLOW_CLOCK_TMS:
|
||||
return "CMD_SLOW_CLOCK_TMS";
|
||||
break;
|
||||
case CMD_CLOCK_TCK:
|
||||
return "CMD_CLOCK_TCK";
|
||||
break;
|
||||
case CMD_SLOW_CLOCK_TCK:
|
||||
return "CMD_SLOW_CLOCK_TCK";
|
||||
break;
|
||||
case CMD_SLEEP_US:
|
||||
return "CMD_SLEEP_US";
|
||||
break;
|
||||
case CMD_SLEEP_MS:
|
||||
return "CMD_SLEEP_MS";
|
||||
break;
|
||||
case CMD_GET_SIGNALS:
|
||||
return "CMD_GET_SIGNALS";
|
||||
break;
|
||||
case CMD_SET_SIGNALS:
|
||||
return "CMD_SET_SIGNALS";
|
||||
break;
|
||||
case CMD_CONFIGURE_TCK_FREQ:
|
||||
return "CMD_CONFIGURE_TCK_FREQ";
|
||||
break;
|
||||
case CMD_SET_LEDS:
|
||||
return "CMD_SET_LEDS";
|
||||
break;
|
||||
case CMD_TEST:
|
||||
return "CMD_TEST";
|
||||
break;
|
||||
default:
|
||||
return "CMD_UNKNOWN";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -832,7 +824,7 @@ const char *ulink_cmd_id_string(uint8_t id)
|
||||
*
|
||||
* @param ulink_cmd pointer to OpenULINK command.
|
||||
*/
|
||||
void ulink_print_command(struct ulink_cmd *ulink_cmd)
|
||||
static void ulink_print_command(struct ulink_cmd *ulink_cmd)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -850,7 +842,7 @@ void ulink_print_command(struct ulink_cmd *ulink_cmd)
|
||||
*
|
||||
* @param device pointer to struct ulink identifying ULINK driver instance.
|
||||
*/
|
||||
void ulink_print_queue(struct ulink *device)
|
||||
static void ulink_print_queue(struct ulink *device)
|
||||
{
|
||||
struct ulink_cmd *current;
|
||||
|
||||
@@ -860,8 +852,6 @@ void ulink_print_queue(struct ulink *device)
|
||||
ulink_print_command(current);
|
||||
}
|
||||
|
||||
#endif /* _DEBUG_JTAG_IO_ */
|
||||
|
||||
/**
|
||||
* Perform JTAG scan
|
||||
*
|
||||
@@ -1367,7 +1357,6 @@ int ulink_calculate_delay(enum ulink_delay_type type, long f, int *delay)
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
/**
|
||||
* Calculate frequency for a given delay value.
|
||||
*
|
||||
@@ -1378,16 +1367,14 @@ int ulink_calculate_delay(enum ulink_delay_type type, long f, int *delay)
|
||||
*
|
||||
* @param type for which command to calculate the delay value.
|
||||
* @param delay delay value for which to calculate the resulting TCK frequency.
|
||||
* @param f where to store the resulting TCK frequency.
|
||||
* @return on success: ERROR_OK
|
||||
* @return on failure: ERROR_FAIL
|
||||
* @return the resulting TCK frequency
|
||||
*/
|
||||
static int ulink_calculate_frequency(enum ulink_delay_type type, int delay, long *f)
|
||||
static long ulink_calculate_frequency(enum ulink_delay_type type, int delay)
|
||||
{
|
||||
float t, f_float, f_rounded;
|
||||
float t, f_float;
|
||||
|
||||
if (delay > 255)
|
||||
return ERROR_FAIL;
|
||||
return 0;
|
||||
|
||||
switch (type) {
|
||||
case DELAY_CLOCK_TCK:
|
||||
@@ -1421,17 +1408,12 @@ static int ulink_calculate_frequency(enum ulink_delay_type type, int delay, long
|
||||
t = (float)(4E-6) * (float)(delay) + (float)(1.3132E-5);
|
||||
break;
|
||||
default:
|
||||
return ERROR_FAIL;
|
||||
break;
|
||||
return 0;
|
||||
}
|
||||
|
||||
f_float = 1.0 / t;
|
||||
f_rounded = roundf(f_float);
|
||||
*f = (long)f_rounded;
|
||||
|
||||
return ERROR_OK;
|
||||
return roundf(f_float);
|
||||
}
|
||||
#endif
|
||||
|
||||
/******************* Interface between OpenULINK and OpenOCD ******************/
|
||||
|
||||
@@ -2065,31 +2047,21 @@ static int ulink_khz(int khz, int *jtag_speed)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
long f_tck = 0, f_tms = 0, f_scan_in = 0, f_scan_out = 0, f_scan_io = 0;
|
||||
|
||||
ulink_calculate_frequency(DELAY_CLOCK_TCK, ulink_handle->delay_clock_tck,
|
||||
&f_tck);
|
||||
ulink_calculate_frequency(DELAY_CLOCK_TMS, ulink_handle->delay_clock_tms,
|
||||
&f_tms);
|
||||
ulink_calculate_frequency(DELAY_SCAN_IN, ulink_handle->delay_scan_in,
|
||||
&f_scan_in);
|
||||
ulink_calculate_frequency(DELAY_SCAN_OUT, ulink_handle->delay_scan_out,
|
||||
&f_scan_out);
|
||||
ulink_calculate_frequency(DELAY_SCAN_IO, ulink_handle->delay_scan_io,
|
||||
&f_scan_io);
|
||||
|
||||
DEBUG_JTAG_IO("ULINK TCK setup: delay_tck = %i (%li Hz),",
|
||||
ulink_handle->delay_clock_tck, f_tck);
|
||||
DEBUG_JTAG_IO(" delay_tms = %i (%li Hz),",
|
||||
ulink_handle->delay_clock_tms, f_tms);
|
||||
DEBUG_JTAG_IO(" delay_scan_in = %i (%li Hz),",
|
||||
ulink_handle->delay_scan_in, f_scan_in);
|
||||
DEBUG_JTAG_IO(" delay_scan_out = %i (%li Hz),",
|
||||
ulink_handle->delay_scan_out, f_scan_out);
|
||||
DEBUG_JTAG_IO(" delay_scan_io = %i (%li Hz),",
|
||||
ulink_handle->delay_scan_io, f_scan_io);
|
||||
#endif
|
||||
LOG_DEBUG_IO("ULINK TCK setup: delay_tck = %i (%li Hz),",
|
||||
ulink_handle->delay_clock_tck,
|
||||
ulink_calculate_frequency(DELAY_CLOCK_TCK, ulink_handle->delay_clock_tck));
|
||||
LOG_DEBUG_IO(" delay_tms = %i (%li Hz),",
|
||||
ulink_handle->delay_clock_tms,
|
||||
ulink_calculate_frequency(DELAY_CLOCK_TMS, ulink_handle->delay_clock_tms));
|
||||
LOG_DEBUG_IO(" delay_scan_in = %i (%li Hz),",
|
||||
ulink_handle->delay_scan_in,
|
||||
ulink_calculate_frequency(DELAY_SCAN_IN, ulink_handle->delay_scan_in));
|
||||
LOG_DEBUG_IO(" delay_scan_out = %i (%li Hz),",
|
||||
ulink_handle->delay_scan_out,
|
||||
ulink_calculate_frequency(DELAY_SCAN_OUT, ulink_handle->delay_scan_out));
|
||||
LOG_DEBUG_IO(" delay_scan_io = %i (%li Hz),",
|
||||
ulink_handle->delay_scan_io,
|
||||
ulink_calculate_frequency(DELAY_SCAN_IO, ulink_handle->delay_scan_io));
|
||||
|
||||
/* Configure the ULINK device with the new delay values */
|
||||
ret = ulink_append_configure_tck_cmd(ulink_handle,
|
||||
|
||||
@@ -174,7 +174,7 @@ static int ublast_buf_read(uint8_t *buf, unsigned size, uint32_t *bytes_read)
|
||||
int ret = info.drv->read(info.drv, buf, size, bytes_read);
|
||||
char *str = hexdump(buf, *bytes_read);
|
||||
|
||||
DEBUG_JTAG_IO("(size=%d, buf=[%s]) -> %u", size, str,
|
||||
LOG_DEBUG_IO("(size=%d, buf=[%s]) -> %u", size, str,
|
||||
*bytes_read);
|
||||
free(str);
|
||||
return ret;
|
||||
@@ -185,7 +185,7 @@ static int ublast_buf_write(uint8_t *buf, int size, uint32_t *bytes_written)
|
||||
int ret = info.drv->write(info.drv, buf, size, bytes_written);
|
||||
char *str = hexdump(buf, *bytes_written);
|
||||
|
||||
DEBUG_JTAG_IO("(size=%d, buf=[%s]) -> %u", size, str,
|
||||
LOG_DEBUG_IO("(size=%d, buf=[%s]) -> %u", size, str,
|
||||
*bytes_written);
|
||||
free(str);
|
||||
return ret;
|
||||
@@ -266,7 +266,7 @@ static void ublast_queue_byte(uint8_t abyte)
|
||||
info.buf[info.bufidx++] = abyte;
|
||||
if (nb_buf_remaining() == 0)
|
||||
ublast_flush_buffer();
|
||||
DEBUG_JTAG_IO("(byte=0x%02x)", abyte);
|
||||
LOG_DEBUG_IO("(byte=0x%02x)", abyte);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -337,7 +337,7 @@ static void ublast_clock_tms(int tms)
|
||||
{
|
||||
uint8_t out;
|
||||
|
||||
DEBUG_JTAG_IO("(tms=%d)", !!tms);
|
||||
LOG_DEBUG_IO("(tms=%d)", !!tms);
|
||||
info.tms = !!tms;
|
||||
info.tdi = 0;
|
||||
out = ublast_build_out(SCAN_OUT);
|
||||
@@ -354,7 +354,7 @@ static void ublast_idle_clock(void)
|
||||
{
|
||||
uint8_t out = ublast_build_out(SCAN_OUT);
|
||||
|
||||
DEBUG_JTAG_IO(".");
|
||||
LOG_DEBUG_IO(".");
|
||||
ublast_queue_byte(out);
|
||||
}
|
||||
|
||||
@@ -375,7 +375,7 @@ static void ublast_clock_tdi(int tdi, enum scan_type type)
|
||||
{
|
||||
uint8_t out;
|
||||
|
||||
DEBUG_JTAG_IO("(tdi=%d)", !!tdi);
|
||||
LOG_DEBUG_IO("(tdi=%d)", !!tdi);
|
||||
info.tdi = !!tdi;
|
||||
|
||||
out = ublast_build_out(SCAN_OUT);
|
||||
@@ -400,7 +400,7 @@ static void ublast_clock_tdi_flip_tms(int tdi, enum scan_type type)
|
||||
{
|
||||
uint8_t out;
|
||||
|
||||
DEBUG_JTAG_IO("(tdi=%d)", !!tdi);
|
||||
LOG_DEBUG_IO("(tdi=%d)", !!tdi);
|
||||
info.tdi = !!tdi;
|
||||
info.tms = !info.tms;
|
||||
|
||||
@@ -430,7 +430,7 @@ static void ublast_queue_bytes(uint8_t *bytes, int nb_bytes)
|
||||
info.bufidx + nb_bytes);
|
||||
exit(-1);
|
||||
}
|
||||
DEBUG_JTAG_IO("(nb_bytes=%d, bytes=[0x%02x, ...])", nb_bytes,
|
||||
LOG_DEBUG_IO("(nb_bytes=%d, bytes=[0x%02x, ...])", nb_bytes,
|
||||
bytes ? bytes[0] : 0);
|
||||
if (bytes)
|
||||
memcpy(&info.buf[info.bufidx], bytes, nb_bytes);
|
||||
@@ -457,7 +457,7 @@ static void ublast_tms_seq(const uint8_t *bits, int nb_bits, int skip)
|
||||
{
|
||||
int i;
|
||||
|
||||
DEBUG_JTAG_IO("(bits=%02x..., nb_bits=%d)", bits[0], nb_bits);
|
||||
LOG_DEBUG_IO("(bits=%02x..., nb_bits=%d)", bits[0], nb_bits);
|
||||
for (i = skip; i < nb_bits; i++)
|
||||
ublast_clock_tms((bits[i / 8] >> (i % 8)) & 0x01);
|
||||
ublast_idle_clock();
|
||||
@@ -469,7 +469,7 @@ static void ublast_tms_seq(const uint8_t *bits, int nb_bits, int skip)
|
||||
*/
|
||||
static void ublast_tms(struct tms_command *cmd)
|
||||
{
|
||||
DEBUG_JTAG_IO("(num_bits=%d)", cmd->num_bits);
|
||||
LOG_DEBUG_IO("(num_bits=%d)", cmd->num_bits);
|
||||
ublast_tms_seq(cmd->bits, cmd->num_bits, 0);
|
||||
}
|
||||
|
||||
@@ -487,7 +487,7 @@ static void ublast_path_move(struct pathmove_command *cmd)
|
||||
{
|
||||
int i;
|
||||
|
||||
DEBUG_JTAG_IO("(num_states=%d, last_state=%d)",
|
||||
LOG_DEBUG_IO("(num_states=%d, last_state=%d)",
|
||||
cmd->num_states, cmd->path[cmd->num_states - 1]);
|
||||
for (i = 0; i < cmd->num_states; i++) {
|
||||
if (tap_state_transition(tap_get_state(), false) == cmd->path[i])
|
||||
@@ -512,7 +512,7 @@ static void ublast_state_move(tap_state_t state, int skip)
|
||||
uint8_t tms_scan;
|
||||
int tms_len;
|
||||
|
||||
DEBUG_JTAG_IO("(from %s to %s)", tap_state_name(tap_get_state()),
|
||||
LOG_DEBUG_IO("(from %s to %s)", tap_state_name(tap_get_state()),
|
||||
tap_state_name(state));
|
||||
if (tap_get_state() == state)
|
||||
return;
|
||||
@@ -541,7 +541,7 @@ static int ublast_read_byteshifted_tdos(uint8_t *buf, int nb_bytes)
|
||||
unsigned int retlen;
|
||||
int ret = ERROR_OK;
|
||||
|
||||
DEBUG_JTAG_IO("%s(buf=%p, num_bits=%d)", __func__, buf, nb_bytes * 8);
|
||||
LOG_DEBUG_IO("%s(buf=%p, num_bits=%d)", __func__, buf, nb_bytes * 8);
|
||||
ublast_flush_buffer();
|
||||
while (ret == ERROR_OK && nb_bytes > 0) {
|
||||
ret = ublast_buf_read(buf, nb_bytes, &retlen);
|
||||
@@ -573,7 +573,7 @@ static int ublast_read_bitbang_tdos(uint8_t *buf, int nb_bits)
|
||||
unsigned int retlen;
|
||||
uint8_t tmp[8];
|
||||
|
||||
DEBUG_JTAG_IO("%s(buf=%p, num_bits=%d)", __func__, buf, nb_bits);
|
||||
LOG_DEBUG_IO("%s(buf=%p, num_bits=%d)", __func__, buf, nb_bits);
|
||||
|
||||
/*
|
||||
* Ensure all previous bitbang writes were issued to the dongle, so that
|
||||
@@ -688,7 +688,7 @@ static void ublast_queue_tdi(uint8_t *bits, int nb_bits, enum scan_type scan)
|
||||
|
||||
static void ublast_runtest(int cycles, tap_state_t state)
|
||||
{
|
||||
DEBUG_JTAG_IO("%s(cycles=%i, end_state=%d)", __func__, cycles, state);
|
||||
LOG_DEBUG_IO("%s(cycles=%i, end_state=%d)", __func__, cycles, state);
|
||||
|
||||
ublast_state_move(TAP_IDLE, 0);
|
||||
ublast_queue_tdi(NULL, cycles, SCAN_OUT);
|
||||
@@ -697,7 +697,7 @@ static void ublast_runtest(int cycles, tap_state_t state)
|
||||
|
||||
static void ublast_stableclocks(int cycles)
|
||||
{
|
||||
DEBUG_JTAG_IO("%s(cycles=%i)", __func__, cycles);
|
||||
LOG_DEBUG_IO("%s(cycles=%i)", __func__, cycles);
|
||||
ublast_queue_tdi(NULL, cycles, SCAN_OUT);
|
||||
}
|
||||
|
||||
@@ -727,7 +727,7 @@ static int ublast_scan(struct scan_command *cmd)
|
||||
ublast_state_move(TAP_DRSHIFT, 0);
|
||||
|
||||
log_buf = hexdump(buf, DIV_ROUND_UP(scan_bits, 8));
|
||||
DEBUG_JTAG_IO("%s(scan=%s, type=%s, bits=%d, buf=[%s], end_state=%d)", __func__,
|
||||
LOG_DEBUG_IO("%s(scan=%s, type=%s, bits=%d, buf=[%s], end_state=%d)", __func__,
|
||||
cmd->ir_scan ? "IRSCAN" : "DRSCAN",
|
||||
type2str[type],
|
||||
scan_bits, log_buf, cmd->end_state);
|
||||
@@ -749,7 +749,7 @@ static int ublast_scan(struct scan_command *cmd)
|
||||
|
||||
static void ublast_usleep(int us)
|
||||
{
|
||||
DEBUG_JTAG_IO("%s(us=%d)", __func__, us);
|
||||
LOG_DEBUG_IO("%s(us=%d)", __func__, us);
|
||||
jtag_sleep(us);
|
||||
}
|
||||
|
||||
@@ -1068,6 +1068,7 @@ static const struct command_registration ublast_command_handlers[] = {
|
||||
|
||||
struct jtag_interface usb_blaster_interface = {
|
||||
.name = "usb_blaster",
|
||||
.transports = jtag_only,
|
||||
.commands = ublast_command_handlers,
|
||||
.supported = DEBUG_CAP_TMS_SEQ,
|
||||
|
||||
|
||||
+46
-59
@@ -103,62 +103,50 @@ static int usbprog_execute_queue(void)
|
||||
|
||||
while (cmd) {
|
||||
switch (cmd->type) {
|
||||
case JTAG_RESET:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("reset trst: %i srst %i",
|
||||
cmd->cmd.reset->trst,
|
||||
cmd->cmd.reset->srst);
|
||||
#endif
|
||||
if (cmd->cmd.reset->trst == 1)
|
||||
tap_set_state(TAP_RESET);
|
||||
usbprog_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
|
||||
break;
|
||||
case JTAG_RUNTEST:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("runtest %i cycles, end in %i",
|
||||
cmd->cmd.runtest->num_cycles,
|
||||
cmd->cmd.runtest->end_state);
|
||||
#endif
|
||||
usbprog_end_state(cmd->cmd.runtest->end_state);
|
||||
usbprog_runtest(cmd->cmd.runtest->num_cycles);
|
||||
break;
|
||||
case JTAG_TLR_RESET:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("statemove end in %i", cmd->cmd.statemove->end_state);
|
||||
#endif
|
||||
usbprog_end_state(cmd->cmd.statemove->end_state);
|
||||
usbprog_state_move();
|
||||
break;
|
||||
case JTAG_PATHMOVE:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("pathmove: %i states, end in %i",
|
||||
cmd->cmd.pathmove->num_states,
|
||||
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
|
||||
#endif
|
||||
usbprog_path_move(cmd->cmd.pathmove);
|
||||
break;
|
||||
case JTAG_SCAN:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("scan end in %i", cmd->cmd.scan->end_state);
|
||||
#endif
|
||||
usbprog_end_state(cmd->cmd.scan->end_state);
|
||||
scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
|
||||
type = jtag_scan_type(cmd->cmd.scan);
|
||||
usbprog_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size);
|
||||
if (jtag_read_buffer(buffer, cmd->cmd.scan) != ERROR_OK)
|
||||
return ERROR_JTAG_QUEUE_FAILED;
|
||||
if (buffer)
|
||||
free(buffer);
|
||||
break;
|
||||
case JTAG_SLEEP:
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("sleep %i", cmd->cmd.sleep->us);
|
||||
#endif
|
||||
jtag_sleep(cmd->cmd.sleep->us);
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("BUG: unknown JTAG command type encountered");
|
||||
exit(-1);
|
||||
case JTAG_RESET:
|
||||
LOG_DEBUG_IO("reset trst: %i srst %i",
|
||||
cmd->cmd.reset->trst,
|
||||
cmd->cmd.reset->srst);
|
||||
if (cmd->cmd.reset->trst == 1)
|
||||
tap_set_state(TAP_RESET);
|
||||
usbprog_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
|
||||
break;
|
||||
case JTAG_RUNTEST:
|
||||
LOG_DEBUG_IO("runtest %i cycles, end in %i",
|
||||
cmd->cmd.runtest->num_cycles,
|
||||
cmd->cmd.runtest->end_state);
|
||||
usbprog_end_state(cmd->cmd.runtest->end_state);
|
||||
usbprog_runtest(cmd->cmd.runtest->num_cycles);
|
||||
break;
|
||||
case JTAG_TLR_RESET:
|
||||
LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
|
||||
usbprog_end_state(cmd->cmd.statemove->end_state);
|
||||
usbprog_state_move();
|
||||
break;
|
||||
case JTAG_PATHMOVE:
|
||||
LOG_DEBUG_IO("pathmove: %i states, end in %i",
|
||||
cmd->cmd.pathmove->num_states,
|
||||
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
|
||||
usbprog_path_move(cmd->cmd.pathmove);
|
||||
break;
|
||||
case JTAG_SCAN:
|
||||
LOG_DEBUG_IO("scan end in %i", cmd->cmd.scan->end_state);
|
||||
usbprog_end_state(cmd->cmd.scan->end_state);
|
||||
scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
|
||||
type = jtag_scan_type(cmd->cmd.scan);
|
||||
usbprog_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size);
|
||||
if (jtag_read_buffer(buffer, cmd->cmd.scan) != ERROR_OK)
|
||||
return ERROR_JTAG_QUEUE_FAILED;
|
||||
if (buffer)
|
||||
free(buffer);
|
||||
break;
|
||||
case JTAG_SLEEP:
|
||||
LOG_DEBUG_IO("sleep %i", cmd->cmd.sleep->us);
|
||||
jtag_sleep(cmd->cmd.sleep->us);
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("BUG: unknown JTAG command type encountered");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
cmd = cmd->next;
|
||||
@@ -270,10 +258,8 @@ static void usbprog_runtest(int num_cycles)
|
||||
usbprog_write(0, 0, 0);
|
||||
}
|
||||
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
LOG_DEBUG("runtest: cur_state %s end_state %s", tap_state_name(
|
||||
LOG_DEBUG_IO("runtest: cur_state %s end_state %s", tap_state_name(
|
||||
tap_get_state()), tap_state_name(tap_get_end_state()));
|
||||
#endif
|
||||
|
||||
/* finish in end_state */
|
||||
/*
|
||||
@@ -612,6 +598,7 @@ static void usbprog_jtag_tms_send(struct usbprog_jtag *usbprog_jtag)
|
||||
|
||||
struct jtag_interface usbprog_interface = {
|
||||
.name = "usbprog",
|
||||
.transports = jtag_only,
|
||||
|
||||
.execute_queue = usbprog_execute_queue,
|
||||
.init = usbprog_init,
|
||||
|
||||
+30
-27
@@ -82,9 +82,7 @@ struct vsllink {
|
||||
static int vsllink_usb_open(struct vsllink *vsllink);
|
||||
static void vsllink_usb_close(struct vsllink *vsllink);
|
||||
|
||||
#if defined _DEBUG_JTAG_IO_
|
||||
static void vsllink_debug_buffer(uint8_t *buffer, int length);
|
||||
#endif
|
||||
|
||||
static int tap_length;
|
||||
static int tap_buffer_size;
|
||||
@@ -103,14 +101,14 @@ static int vsllink_execute_queue(void)
|
||||
enum scan_type type;
|
||||
uint8_t *buffer;
|
||||
|
||||
DEBUG_JTAG_IO("-------------------------------------"
|
||||
LOG_DEBUG_IO("-------------------------------------"
|
||||
" vsllink "
|
||||
"-------------------------------------");
|
||||
|
||||
while (cmd != NULL) {
|
||||
switch (cmd->type) {
|
||||
case JTAG_RUNTEST:
|
||||
DEBUG_JTAG_IO("runtest %i cycles, end in %s",
|
||||
LOG_DEBUG_IO("runtest %i cycles, end in %s",
|
||||
cmd->cmd.runtest->num_cycles,
|
||||
tap_state_name(cmd->cmd.runtest->end_state));
|
||||
|
||||
@@ -119,7 +117,7 @@ static int vsllink_execute_queue(void)
|
||||
break;
|
||||
|
||||
case JTAG_TLR_RESET:
|
||||
DEBUG_JTAG_IO("statemove end in %s",
|
||||
LOG_DEBUG_IO("statemove end in %s",
|
||||
tap_state_name(cmd->cmd.statemove->end_state));
|
||||
|
||||
vsllink_end_state(cmd->cmd.statemove->end_state);
|
||||
@@ -127,7 +125,7 @@ static int vsllink_execute_queue(void)
|
||||
break;
|
||||
|
||||
case JTAG_PATHMOVE:
|
||||
DEBUG_JTAG_IO("pathmove: %i states, end in %s",
|
||||
LOG_DEBUG_IO("pathmove: %i states, end in %s",
|
||||
cmd->cmd.pathmove->num_states,
|
||||
tap_state_name(cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]));
|
||||
|
||||
@@ -135,7 +133,7 @@ static int vsllink_execute_queue(void)
|
||||
break;
|
||||
|
||||
case JTAG_SCAN:
|
||||
DEBUG_JTAG_IO("JTAG Scan...");
|
||||
LOG_DEBUG_IO("JTAG Scan...");
|
||||
|
||||
vsllink_end_state(cmd->cmd.scan->end_state);
|
||||
|
||||
@@ -143,23 +141,21 @@ static int vsllink_execute_queue(void)
|
||||
cmd->cmd.scan, &buffer);
|
||||
|
||||
if (cmd->cmd.scan->ir_scan)
|
||||
DEBUG_JTAG_IO(
|
||||
LOG_DEBUG_IO(
|
||||
"JTAG Scan write IR(%d bits), "
|
||||
"end in %s:",
|
||||
scan_size,
|
||||
tap_state_name(cmd->cmd.scan->end_state));
|
||||
|
||||
else
|
||||
DEBUG_JTAG_IO(
|
||||
LOG_DEBUG_IO(
|
||||
"JTAG Scan write DR(%d bits), "
|
||||
"end in %s:",
|
||||
scan_size,
|
||||
tap_state_name(cmd->cmd.scan->end_state));
|
||||
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
vsllink_debug_buffer(buffer,
|
||||
DIV_ROUND_UP(scan_size, 8));
|
||||
#endif
|
||||
if (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO))
|
||||
vsllink_debug_buffer(buffer, DIV_ROUND_UP(scan_size, 8));
|
||||
|
||||
type = jtag_scan_type(cmd->cmd.scan);
|
||||
|
||||
@@ -169,7 +165,7 @@ static int vsllink_execute_queue(void)
|
||||
break;
|
||||
|
||||
case JTAG_RESET:
|
||||
DEBUG_JTAG_IO("reset trst: %i srst %i",
|
||||
LOG_DEBUG_IO("reset trst: %i srst %i",
|
||||
cmd->cmd.reset->trst,
|
||||
cmd->cmd.reset->srst);
|
||||
|
||||
@@ -183,13 +179,13 @@ static int vsllink_execute_queue(void)
|
||||
break;
|
||||
|
||||
case JTAG_SLEEP:
|
||||
DEBUG_JTAG_IO("sleep %i", cmd->cmd.sleep->us);
|
||||
LOG_DEBUG_IO("sleep %i", cmd->cmd.sleep->us);
|
||||
vsllink_tap_execute();
|
||||
jtag_sleep(cmd->cmd.sleep->us);
|
||||
break;
|
||||
|
||||
case JTAG_STABLECLOCKS:
|
||||
DEBUG_JTAG_IO("add %d clocks",
|
||||
LOG_DEBUG_IO("add %d clocks",
|
||||
cmd->cmd.stableclocks->num_cycles);
|
||||
|
||||
switch (tap_get_state()) {
|
||||
@@ -219,7 +215,7 @@ static int vsllink_execute_queue(void)
|
||||
break;
|
||||
|
||||
case JTAG_TMS:
|
||||
DEBUG_JTAG_IO("add %d jtag tms",
|
||||
LOG_DEBUG_IO("add %d jtag tms",
|
||||
cmd->cmd.tms->num_bits);
|
||||
|
||||
vsllink_tms(cmd->cmd.tms->num_bits, cmd->cmd.tms->bits);
|
||||
@@ -681,13 +677,11 @@ static int vsllink_jtag_execute(void)
|
||||
command = pending_scan_result->command;
|
||||
buf_set_buf(tdo_buffer, src_first, buffer, dest_first, length);
|
||||
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
DEBUG_JTAG_IO(
|
||||
LOG_DEBUG_IO(
|
||||
"JTAG scan read(%d bits, from src %d bits to dest %d bits):",
|
||||
length, src_first, dest_first);
|
||||
vsllink_debug_buffer(buffer + dest_first / 8,
|
||||
DIV_ROUND_UP(length, 7));
|
||||
#endif
|
||||
if (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO))
|
||||
vsllink_debug_buffer(buffer + dest_first / 8, DIV_ROUND_UP(length, 7));
|
||||
|
||||
if (last) {
|
||||
if (jtag_read_buffer(buffer, command)
|
||||
@@ -895,7 +889,6 @@ static void vsllink_usb_close(struct vsllink *vsllink)
|
||||
|
||||
#define BYTES_PER_LINE 16
|
||||
|
||||
#if defined _DEBUG_JTAG_IO_
|
||||
static void vsllink_debug_buffer(uint8_t *buffer, int length)
|
||||
{
|
||||
char line[81];
|
||||
@@ -904,46 +897,57 @@ static void vsllink_debug_buffer(uint8_t *buffer, int length)
|
||||
int j;
|
||||
|
||||
for (i = 0; i < length; i += BYTES_PER_LINE) {
|
||||
snprintf(line, 5, "%04x", i);
|
||||
snprintf(line, 5, "%04x", i & 0xffff);
|
||||
for (j = i; j < i + BYTES_PER_LINE && j < length; j++) {
|
||||
snprintf(s, 4, " %02x", buffer[j]);
|
||||
strcat(line, s);
|
||||
}
|
||||
LOG_DEBUG("%s", line);
|
||||
LOG_DEBUG_IO("%s", line);
|
||||
}
|
||||
}
|
||||
#endif /* _DEBUG_JTAG_IO_ */
|
||||
|
||||
static const struct command_registration vsllink_command_handlers[] = {
|
||||
{
|
||||
.name = "vsllink_usb_vid",
|
||||
.handler = &vsllink_handle_usb_vid_command,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "Set USB VID",
|
||||
.usage = "<vid>",
|
||||
},
|
||||
{
|
||||
.name = "vsllink_usb_pid",
|
||||
.handler = &vsllink_handle_usb_pid_command,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "Set USB PID",
|
||||
.usage = "<pid>",
|
||||
},
|
||||
{
|
||||
.name = "vsllink_usb_serial",
|
||||
.handler = &vsllink_handle_usb_serial_command,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "Set or disable check for USB serial",
|
||||
.usage = "[<serial>]",
|
||||
},
|
||||
{
|
||||
.name = "vsllink_usb_bulkin",
|
||||
.handler = &vsllink_handle_usb_bulkin_command,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "Set USB input endpoint",
|
||||
.usage = "<ep_in>",
|
||||
},
|
||||
{
|
||||
.name = "vsllink_usb_bulkout",
|
||||
.handler = &vsllink_handle_usb_bulkout_command,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "Set USB output endpoint",
|
||||
.usage = "<ep_out>",
|
||||
},
|
||||
{
|
||||
.name = "vsllink_usb_interface",
|
||||
.handler = &vsllink_handle_usb_interface_command,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "Set USB output interface",
|
||||
.usage = "<interface>",
|
||||
},
|
||||
COMMAND_REGISTRATION_DONE
|
||||
};
|
||||
@@ -952,7 +956,6 @@ static const char * const vsllink_transports[] = {"jtag", "swd", NULL};
|
||||
|
||||
static const struct swd_driver vsllink_swd_driver = {
|
||||
.init = vsllink_swd_init,
|
||||
.frequency = vsllink_swd_frequency,
|
||||
.switch_seq = vsllink_swd_switch_seq,
|
||||
.read_reg = vsllink_swd_read_reg,
|
||||
.write_reg = vsllink_swd_write_reg,
|
||||
|
||||
@@ -1925,13 +1925,6 @@ static int xds110_khz(int khz, int *jtag_speed)
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static int_least32_t xds110_swd_frequency(int_least32_t hz)
|
||||
{
|
||||
if (hz > 0)
|
||||
xds110_speed(hz / 1000);
|
||||
return hz;
|
||||
}
|
||||
|
||||
COMMAND_HANDLER(xds110_handle_info_command)
|
||||
{
|
||||
xds110_show_info();
|
||||
@@ -2032,7 +2025,6 @@ static const struct command_registration xds110_command_handlers[] = {
|
||||
|
||||
static const struct swd_driver xds110_swd_driver = {
|
||||
.init = xds110_swd_init,
|
||||
.frequency = xds110_swd_frequency,
|
||||
.switch_seq = xds110_swd_switch_seq,
|
||||
.read_reg = xds110_swd_read_reg,
|
||||
.write_reg = xds110_swd_write_reg,
|
||||
|
||||
@@ -376,15 +376,13 @@ tap_state_t tap_state_by_name(const char *name)
|
||||
return TAP_INVALID;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
|
||||
#define JTAG_DEBUG_STATE_APPEND(buf, len, bit) \
|
||||
do { buf[len] = bit ? '1' : '0'; } while (0)
|
||||
#define JTAG_DEBUG_STATE_PRINT(a, b, astr, bstr) \
|
||||
DEBUG_JTAG_IO("TAP/SM: %9s -> %5s\tTMS: %s\tTDI: %s", \
|
||||
LOG_DEBUG_IO("TAP/SM: %9s -> %5s\tTMS: %s\tTDI: %s", \
|
||||
tap_state_name(a), tap_state_name(b), astr, bstr)
|
||||
|
||||
tap_state_t jtag_debug_state_machine(const void *tms_buf, const void *tdi_buf,
|
||||
tap_state_t jtag_debug_state_machine_(const void *tms_buf, const void *tdi_buf,
|
||||
unsigned tap_bits, tap_state_t next_state)
|
||||
{
|
||||
const uint8_t *tms_buffer;
|
||||
@@ -401,13 +399,13 @@ tap_state_t jtag_debug_state_machine(const void *tms_buf, const void *tdi_buf,
|
||||
|
||||
/* set startstate (and possibly last, if tap_bits == 0) */
|
||||
last_state = next_state;
|
||||
DEBUG_JTAG_IO("TAP/SM: START state: %s", tap_state_name(next_state));
|
||||
LOG_DEBUG_IO("TAP/SM: START state: %s", tap_state_name(next_state));
|
||||
|
||||
tms_buffer = (const uint8_t *)tms_buf;
|
||||
tdi_buffer = (const uint8_t *)tdi_buf;
|
||||
|
||||
tap_bytes = DIV_ROUND_UP(tap_bits, 8);
|
||||
DEBUG_JTAG_IO("TAP/SM: TMS bits: %u (bytes: %u)", tap_bits, tap_bytes);
|
||||
LOG_DEBUG_IO("TAP/SM: TMS bits: %u (bytes: %u)", tap_bits, tap_bytes);
|
||||
|
||||
tap_out_bits = 0;
|
||||
for (cur_byte = 0; cur_byte < tap_bytes; cur_byte++) {
|
||||
@@ -452,11 +450,10 @@ tap_state_t jtag_debug_state_machine(const void *tms_buf, const void *tdi_buf,
|
||||
JTAG_DEBUG_STATE_PRINT(last_state, next_state, tms_str, tdi_str);
|
||||
}
|
||||
|
||||
DEBUG_JTAG_IO("TAP/SM: FINAL state: %s", tap_state_name(next_state));
|
||||
LOG_DEBUG_IO("TAP/SM: FINAL state: %s", tap_state_name(next_state));
|
||||
|
||||
return next_state;
|
||||
}
|
||||
#endif /* _DEBUG_JTAG_IO_ */
|
||||
|
||||
void tap_use_new_tms_table(bool use_new)
|
||||
{
|
||||
|
||||
+10
-14
@@ -56,18 +56,11 @@ void tap_set_state_impl(tap_state_t new_state);
|
||||
* @param new_state The state we think the TAPs are currently in (or
|
||||
* are about to enter).
|
||||
*/
|
||||
#if defined(_DEBUG_JTAG_IO_)
|
||||
#define tap_set_state(new_state) \
|
||||
do { \
|
||||
LOG_DEBUG("tap_set_state(%s)", tap_state_name(new_state)); \
|
||||
LOG_DEBUG_IO("tap_set_state(%s)", tap_state_name(new_state)); \
|
||||
tap_set_state_impl(new_state); \
|
||||
} while (0)
|
||||
#else
|
||||
static inline void tap_set_state(tap_state_t new_state)
|
||||
{
|
||||
tap_set_state_impl(new_state);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This function gets the state of the "state follower" which tracks the
|
||||
@@ -164,7 +157,7 @@ void tap_use_new_tms_table(bool use_new);
|
||||
/** @returns True if new TMS table is active; false otherwise. */
|
||||
bool tap_uses_new_tms_table(void);
|
||||
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
|
||||
/**
|
||||
* @brief Prints verbose TAP state transitions for the given TMS/TDI buffers.
|
||||
* @param tms_buf must points to a buffer containing the TMS bitstream.
|
||||
@@ -173,15 +166,18 @@ bool tap_uses_new_tms_table(void);
|
||||
* @param start_tap_state must specify the current TAP state.
|
||||
* @returns the final TAP state; pass as @a start_tap_state in following call.
|
||||
*/
|
||||
tap_state_t jtag_debug_state_machine(const void *tms_buf, const void *tdi_buf,
|
||||
unsigned tap_len, tap_state_t start_tap_state);
|
||||
#else
|
||||
static inline tap_state_t jtag_debug_state_machine(const void *tms_buf,
|
||||
const void *tdi_buf, unsigned tap_len, tap_state_t start_tap_state)
|
||||
{
|
||||
return start_tap_state;
|
||||
/* Private declaration */
|
||||
tap_state_t jtag_debug_state_machine_(const void *tms_buf, const void *tdi_buf,
|
||||
unsigned tap_len, tap_state_t start_tap_state);
|
||||
|
||||
if (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO))
|
||||
return jtag_debug_state_machine_(tms_buf, tdi_buf, tap_len, start_tap_state);
|
||||
else
|
||||
return start_tap_state;
|
||||
}
|
||||
#endif /* _DEBUG_JTAG_IO_ */
|
||||
|
||||
/**
|
||||
* Represents a driver for a debugging interface.
|
||||
|
||||
@@ -25,14 +25,6 @@
|
||||
#include <helper/binarybuffer.h>
|
||||
#include <helper/log.h>
|
||||
|
||||
#ifdef _DEBUG_JTAG_IO_
|
||||
#define DEBUG_JTAG_IO(expr ...) \
|
||||
do { if (1) LOG_DEBUG(expr); } while (0)
|
||||
#else
|
||||
#define DEBUG_JTAG_IO(expr ...) \
|
||||
do { if (0) LOG_DEBUG(expr); } while (0)
|
||||
#endif
|
||||
|
||||
#ifndef DEBUG_JTAG_IOZ
|
||||
#define DEBUG_JTAG_IOZ 64
|
||||
#endif
|
||||
|
||||
@@ -28,6 +28,7 @@ struct jtag_interface minidummy_interface = {
|
||||
.name = "minidummy",
|
||||
.execute_queue = NULL,
|
||||
.speed = NULL,
|
||||
.transports = jtag_only,
|
||||
.commands = NULL,
|
||||
.init = NULL,
|
||||
.quit = NULL,
|
||||
|
||||
@@ -232,24 +232,6 @@ struct swd_driver {
|
||||
*/
|
||||
int (*init)(void);
|
||||
|
||||
/**
|
||||
* Set the SWCLK frequency of the SWD link.
|
||||
*
|
||||
* The driver should round the desired value, downwards if possible, to
|
||||
* the nearest supported frequency. A negative value should be ignored
|
||||
* and can be used to query the current setting. If the driver does not
|
||||
* support a variable frequency a fixed, nominal, value should be
|
||||
* returned.
|
||||
*
|
||||
* If the frequency is increased, it must not apply before the currently
|
||||
* queued transactions are executed. If the frequency is lowered, it may
|
||||
* apply immediately.
|
||||
*
|
||||
* @param hz The desired frequency in Hz.
|
||||
* @return The actual resulting frequency after rounding.
|
||||
*/
|
||||
int_least32_t (*frequency)(int_least32_t hz);
|
||||
|
||||
/**
|
||||
* Queue a special SWDIO sequence.
|
||||
*
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user