OpenOCD
jtagspi.c File Reference
Include dependency graph for jtagspi.c:

Go to the source code of this file.

Data Structures

struct  jtagspi_flash_bank
 

Macros

#define JTAGSPI_MAX_TIMEOUT   3000
 

Functions

 COMMAND_HANDLER (jtagspi_handle_always_4byte)
 
 COMMAND_HANDLER (jtagspi_handle_cmd)
 
 COMMAND_HANDLER (jtagspi_handle_set)
 
static uint8_t * fill_addr (uint32_t addr, unsigned int addr_len, uint8_t *buffer)
 
 FLASH_BANK_COMMAND_HANDLER (jtagspi_flash_bank_command)
 
static void flip_u8 (const uint8_t *in, uint8_t *out, unsigned int len)
 
static int jtagspi_auto_probe (struct flash_bank *bank)
 
static int jtagspi_bulk_erase (struct flash_bank *bank)
 
static int jtagspi_cmd (struct flash_bank *bank, uint8_t cmd, uint8_t *write_buffer, unsigned int write_len, uint8_t *data_buffer, int data_len)
 
static int jtagspi_erase (struct flash_bank *bank, unsigned int first, unsigned int last)
 
static int jtagspi_info (struct flash_bank *bank, struct command_invocation *cmd)
 
static int jtagspi_page_write (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 
static int jtagspi_probe (struct flash_bank *bank)
 
static int jtagspi_protect (struct flash_bank *bank, int set, unsigned int first, unsigned int last)
 
static int jtagspi_read (struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
 
static int jtagspi_read_status (struct flash_bank *bank, uint32_t *status)
 
static int jtagspi_sector_erase (struct flash_bank *bank, unsigned int sector)
 
static void jtagspi_set_ir (struct flash_bank *bank)
 
static int jtagspi_wait (struct flash_bank *bank, int timeout_ms)
 
static int jtagspi_write (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 
static int jtagspi_write_enable (struct flash_bank *bank)
 

Variables

static const struct command_registration jtagspi_command_handlers []
 
static const struct command_registration jtagspi_exec_command_handlers []
 
const struct flash_driver jtagspi_flash
 

Macro Definition Documentation

◆ JTAGSPI_MAX_TIMEOUT

#define JTAGSPI_MAX_TIMEOUT   3000

Definition at line 16 of file jtagspi.c.

Function Documentation

◆ COMMAND_HANDLER() [1/3]

COMMAND_HANDLER ( jtagspi_handle_always_4byte  )

◆ COMMAND_HANDLER() [2/3]

COMMAND_HANDLER ( jtagspi_handle_cmd  )

◆ COMMAND_HANDLER() [3/3]

◆ fill_addr()

static uint8_t* fill_addr ( uint32_t  addr,
unsigned int  addr_len,
uint8_t *  buffer 
)
static

Definition at line 530 of file jtagspi.c.

References addr, jtagspi_flash_bank::addr_len, and buffer.

Referenced by jtagspi_page_write(), jtagspi_read(), and jtagspi_sector_erase().

◆ FLASH_BANK_COMMAND_HANDLER()

FLASH_BANK_COMMAND_HANDLER ( jtagspi_flash_bank_command  )

◆ flip_u8()

static void flip_u8 ( const uint8_t *  in,
uint8_t *  out,
unsigned int  len 
)
static

Definition at line 65 of file jtagspi.c.

References flip_u32().

Referenced by jtagspi_cmd().

◆ jtagspi_auto_probe()

static int jtagspi_auto_probe ( struct flash_bank bank)
static

Definition at line 448 of file jtagspi.c.

References bank, ERROR_OK, info, and jtagspi_probe().

◆ jtagspi_bulk_erase()

static int jtagspi_bulk_erase ( struct flash_bank bank)
static

◆ jtagspi_cmd()

static int jtagspi_cmd ( struct flash_bank bank,
uint8_t  cmd,
uint8_t *  write_buffer,
unsigned int  write_len,
uint8_t *  data_buffer,
int  data_len 
)
static

◆ jtagspi_erase()

static int jtagspi_erase ( struct flash_bank bank,
unsigned int  first,
unsigned int  last 
)
static

◆ jtagspi_info()

static int jtagspi_info ( struct flash_bank bank,
struct command_invocation cmd 
)
static

Definition at line 716 of file jtagspi.c.

Referenced by COMMAND_HANDLER().

◆ jtagspi_page_write()

static int jtagspi_page_write ( struct flash_bank bank,
const uint8_t *  buffer,
uint32_t  offset,
uint32_t  count 
)
static

◆ jtagspi_probe()

◆ jtagspi_protect()

static int jtagspi_protect ( struct flash_bank bank,
int  set,
unsigned int  first,
unsigned int  last 
)
static

Definition at line 614 of file jtagspi.c.

References bank, and ERROR_OK.

◆ jtagspi_read()

static int jtagspi_read ( struct flash_bank bank,
uint8_t *  buffer,
uint32_t  offset,
uint32_t  count 
)
static

◆ jtagspi_read_status()

static int jtagspi_read_status ( struct flash_bank bank,
uint32_t *  status 
)
static

Definition at line 457 of file jtagspi.c.

References bank, ERROR_OK, jtagspi_cmd(), LOG_DEBUG, NULL, SPIFLASH_READ_STATUS, and status.

Referenced by jtagspi_wait(), and jtagspi_write_enable().

◆ jtagspi_sector_erase()

static int jtagspi_sector_erase ( struct flash_bank bank,
unsigned int  sector 
)
static

◆ jtagspi_set_ir()

static void jtagspi_set_ir ( struct flash_bank bank)
static

◆ jtagspi_wait()

static int jtagspi_wait ( struct flash_bank bank,
int  timeout_ms 
)
static

◆ jtagspi_write()

static int jtagspi_write ( struct flash_bank bank,
const uint8_t *  buffer,
uint32_t  offset,
uint32_t  count 
)
static

◆ jtagspi_write_enable()

static int jtagspi_write_enable ( struct flash_bank bank)
static

Variable Documentation

◆ jtagspi_command_handlers

const struct command_registration jtagspi_command_handlers[]
static
Initial value:
= {
{
.name = "jtagspi",
.mode = COMMAND_ANY,
.help = "jtagspi command group",
.usage = "",
},
}
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:247
@ COMMAND_ANY
Definition: command.h:42
static const struct command_registration jtagspi_exec_command_handlers[]
Definition: jtagspi.c:743

Definition at line 716 of file jtagspi.c.

◆ jtagspi_exec_command_handlers

const struct command_registration jtagspi_exec_command_handlers[]
static
Initial value:
= {
{
.name = "set",
.handler = jtagspi_handle_set,
.mode = COMMAND_EXEC,
.usage = "bank_id name chip_size page_size read_cmd unused pprg_cmd "
"[ mass_erase_cmd ] [ sector_size sector_erase_cmd ]",
.help = "Set device parameters if not autodetected.",
},
{
.name = "cmd",
.handler = jtagspi_handle_cmd,
.mode = COMMAND_EXEC,
.usage = "bank_id num_resp cmd_byte ...",
.help = "Send low-level command cmd_byte and following bytes, read num_bytes.",
},
{
.name = "always_4byte",
.handler = jtagspi_handle_always_4byte,
.mode = COMMAND_EXEC,
.usage = "bank_id [ on | off ]",
.help = "Use always 4-byte address except for basic 0x03.",
},
}
@ COMMAND_EXEC
Definition: command.h:40

Definition at line 716 of file jtagspi.c.

◆ jtagspi_flash

const struct flash_driver jtagspi_flash
Initial value:
= {
.name = "jtagspi",
.flash_bank_command = jtagspi_flash_bank_command,
.erase = jtagspi_erase,
.protect = jtagspi_protect,
.write = jtagspi_write,
.read = jtagspi_read,
.probe = jtagspi_probe,
.auto_probe = jtagspi_auto_probe,
.erase_check = default_flash_blank_check,
.info = jtagspi_info,
.free_driver_priv = default_flash_free_driver_priv,
}
int default_flash_blank_check(struct flash_bank *bank)
Provides default erased-bank check handling.
void default_flash_free_driver_priv(struct flash_bank *bank)
Deallocates bank->driver_priv.
static int jtagspi_auto_probe(struct flash_bank *bank)
Definition: jtagspi.c:448
static int jtagspi_protect(struct flash_bank *bank, int set, unsigned int first, unsigned int last)
Definition: jtagspi.c:614
static const struct command_registration jtagspi_command_handlers[]
Definition: jtagspi.c:770
static int jtagspi_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
Definition: jtagspi.c:564
static int jtagspi_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: jtagspi.c:683
static int jtagspi_read(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: jtagspi.c:622
static int jtagspi_probe(struct flash_bank *bank)
Definition: jtagspi.c:370
static int jtagspi_info(struct flash_bank *bank, struct command_invocation *cmd)
Definition: jtagspi.c:716

Definition at line 716 of file jtagspi.c.