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

Go to the source code of this file.

Data Structures

struct  em357_flash_bank
 
struct  em357_options
 

Macros

#define EM357_FLASH_ACR   0x40008000
 
#define EM357_FLASH_AR   0x40008014
 
#define EM357_FLASH_CR   0x40008010
 
#define EM357_FLASH_KEYR   0x40008004
 
#define EM357_FLASH_OBR   0x4000801C
 
#define EM357_FLASH_OPTKEYR   0x40008008
 
#define EM357_FLASH_SR   0x4000800C
 
#define EM357_FLASH_WRPR   0x40008020
 
#define EM357_FPEC_CLK   0x4000402c
 
#define EM357_OB_RDP   0x08040800
 
#define EM357_OB_WRP0   0x08040808
 
#define EM357_OB_WRP1   0x0804080A
 
#define EM357_OB_WRP2   0x0804080C
 
#define FLASH_BSY   (1 << 0)
 
#define FLASH_EOP   (1 << 5)
 
#define FLASH_LOCK   (1 << 7)
 
#define FLASH_MER   (1 << 2)
 
#define FLASH_OPTER   (1 << 5)
 
#define FLASH_OPTPG   (1 << 4)
 
#define FLASH_OPTWRE   (1 << 9)
 
#define FLASH_PER   (1 << 1)
 
#define FLASH_PG   (1 << 0)
 
#define FLASH_PGERR   (1 << 2)
 
#define FLASH_STRT   (1 << 6)
 
#define FLASH_WRPRTERR   (1 << 4)
 
#define KEY1   0x45670123
 
#define KEY2   0xCDEF89AB
 
#define OPT_ERROR   0
 
#define OPT_READOUT   1
 

Functions

 COMMAND_HANDLER (em357_handle_lock_command)
 
 COMMAND_HANDLER (em357_handle_mass_erase_command)
 
 COMMAND_HANDLER (em357_handle_unlock_command)
 
static int em357_auto_probe (struct flash_bank *bank)
 
static int em357_erase (struct flash_bank *bank, unsigned int first, unsigned int last)
 
static int em357_erase_options (struct flash_bank *bank)
 
static int em357_get_flash_status (struct flash_bank *bank, uint32_t *status)
 
static int em357_mass_erase (struct flash_bank *bank)
 
static int em357_probe (struct flash_bank *bank)
 
static int em357_protect (struct flash_bank *bank, int set, unsigned int first, unsigned int last)
 
static int em357_protect_check (struct flash_bank *bank)
 
static int em357_read_options (struct flash_bank *bank)
 
static int em357_wait_status_busy (struct flash_bank *bank, int timeout)
 
static int em357_write (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 
static int em357_write_block (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 
static int em357_write_options (struct flash_bank *bank)
 
 FLASH_BANK_COMMAND_HANDLER (em357_flash_bank_command)
 

Variables

static const struct command_registration em357_command_handlers []
 
static const struct command_registration em357_exec_command_handlers []
 
const struct flash_driver em357_flash
 

Macro Definition Documentation

◆ EM357_FLASH_ACR

#define EM357_FLASH_ACR   0x40008000

Definition at line 25 of file em357.c.

◆ EM357_FLASH_AR

#define EM357_FLASH_AR   0x40008014

Definition at line 30 of file em357.c.

◆ EM357_FLASH_CR

#define EM357_FLASH_CR   0x40008010

Definition at line 29 of file em357.c.

◆ EM357_FLASH_KEYR

#define EM357_FLASH_KEYR   0x40008004

Definition at line 26 of file em357.c.

◆ EM357_FLASH_OBR

#define EM357_FLASH_OBR   0x4000801C

Definition at line 31 of file em357.c.

◆ EM357_FLASH_OPTKEYR

#define EM357_FLASH_OPTKEYR   0x40008008

Definition at line 27 of file em357.c.

◆ EM357_FLASH_SR

#define EM357_FLASH_SR   0x4000800C

Definition at line 28 of file em357.c.

◆ EM357_FLASH_WRPR

#define EM357_FLASH_WRPR   0x40008020

Definition at line 32 of file em357.c.

◆ EM357_FPEC_CLK

#define EM357_FPEC_CLK   0x4000402c

Definition at line 34 of file em357.c.

◆ EM357_OB_RDP

#define EM357_OB_RDP   0x08040800

Definition at line 37 of file em357.c.

◆ EM357_OB_WRP0

#define EM357_OB_WRP0   0x08040808

Definition at line 38 of file em357.c.

◆ EM357_OB_WRP1

#define EM357_OB_WRP1   0x0804080A

Definition at line 39 of file em357.c.

◆ EM357_OB_WRP2

#define EM357_OB_WRP2   0x0804080C

Definition at line 40 of file em357.c.

◆ FLASH_BSY

#define FLASH_BSY   (1 << 0)

Definition at line 55 of file em357.c.

◆ FLASH_EOP

#define FLASH_EOP   (1 << 5)

Definition at line 58 of file em357.c.

◆ FLASH_LOCK

#define FLASH_LOCK   (1 << 7)

Definition at line 50 of file em357.c.

◆ FLASH_MER

#define FLASH_MER   (1 << 2)

Definition at line 46 of file em357.c.

◆ FLASH_OPTER

#define FLASH_OPTER   (1 << 5)

Definition at line 48 of file em357.c.

◆ FLASH_OPTPG

#define FLASH_OPTPG   (1 << 4)

Definition at line 47 of file em357.c.

◆ FLASH_OPTWRE

#define FLASH_OPTWRE   (1 << 9)

Definition at line 51 of file em357.c.

◆ FLASH_PER

#define FLASH_PER   (1 << 1)

Definition at line 45 of file em357.c.

◆ FLASH_PG

#define FLASH_PG   (1 << 0)

Definition at line 44 of file em357.c.

◆ FLASH_PGERR

#define FLASH_PGERR   (1 << 2)

Definition at line 56 of file em357.c.

◆ FLASH_STRT

#define FLASH_STRT   (1 << 6)

Definition at line 49 of file em357.c.

◆ FLASH_WRPRTERR

#define FLASH_WRPRTERR   (1 << 4)

Definition at line 57 of file em357.c.

◆ KEY1

#define KEY1   0x45670123

Definition at line 67 of file em357.c.

◆ KEY2

#define KEY2   0xCDEF89AB

Definition at line 68 of file em357.c.

◆ OPT_ERROR

#define OPT_ERROR   0

Definition at line 62 of file em357.c.

◆ OPT_READOUT

#define OPT_READOUT   1

Definition at line 63 of file em357.c.

Function Documentation

◆ COMMAND_HANDLER() [1/3]

◆ COMMAND_HANDLER() [2/3]

COMMAND_HANDLER ( em357_handle_mass_erase_command  )

◆ COMMAND_HANDLER() [3/3]

◆ em357_auto_probe()

static int em357_auto_probe ( struct flash_bank bank)
static

Definition at line 733 of file em357.c.

References bank, em357_probe(), ERROR_OK, and em357_flash_bank::probed.

◆ em357_erase()

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

◆ em357_erase_options()

◆ em357_get_flash_status()

static int em357_get_flash_status ( struct flash_bank bank,
uint32_t *  status 
)
inlinestatic

Definition at line 101 of file em357.c.

References bank, EM357_FLASH_SR, status, and target_read_u32().

Referenced by em357_wait_status_busy().

◆ em357_mass_erase()

◆ em357_probe()

static int em357_probe ( struct flash_bank bank)
static

◆ em357_protect()

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

◆ em357_protect_check()

static int em357_protect_check ( struct flash_bank bank)
static

◆ em357_read_options()

◆ em357_wait_status_busy()

static int em357_wait_status_busy ( struct flash_bank bank,
int  timeout 
)
static

◆ em357_write()

◆ em357_write_block()

◆ em357_write_options()

◆ FLASH_BANK_COMMAND_HANDLER()

FLASH_BANK_COMMAND_HANDLER ( em357_flash_bank_command  )

Definition at line 86 of file em357.c.

References bank, CMD_ARGC, ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, and em357_flash_bank::probed.

Variable Documentation

◆ em357_command_handlers

const struct command_registration em357_command_handlers[]
static
Initial value:
= {
{
.name = "em357",
.mode = COMMAND_ANY,
.help = "em357 flash command group",
.usage = "",
},
}
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:253
@ COMMAND_ANY
Definition: command.h:42
static const struct command_registration em357_exec_command_handlers[]
Definition: em357.c:875

Definition at line 856 of file em357.c.

◆ em357_exec_command_handlers

const struct command_registration em357_exec_command_handlers[]
static
Initial value:
= {
{
.name = "lock",
.usage = "<bank>",
.handler = em357_handle_lock_command,
.mode = COMMAND_EXEC,
.help = "Lock entire flash device.",
},
{
.name = "unlock",
.usage = "<bank>",
.handler = em357_handle_unlock_command,
.mode = COMMAND_EXEC,
.help = "Unlock entire protected flash device.",
},
{
.name = "mass_erase",
.usage = "<bank>",
.handler = em357_handle_mass_erase_command,
.mode = COMMAND_EXEC,
.help = "Erase entire flash device.",
},
}
@ COMMAND_EXEC
Definition: command.h:40

Definition at line 856 of file em357.c.

◆ em357_flash

const struct flash_driver em357_flash
Initial value:
= {
.name = "em357",
.flash_bank_command = em357_flash_bank_command,
.erase = em357_erase,
.protect = em357_protect,
.write = em357_write,
.probe = em357_probe,
.auto_probe = em357_auto_probe,
.erase_check = default_flash_blank_check,
.protect_check = em357_protect_check,
.free_driver_priv = default_flash_free_driver_priv,
}
static int em357_probe(struct flash_bank *bank)
Definition: em357.c:661
static const struct command_registration em357_command_handlers[]
Definition: em357.c:900
static int em357_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
Definition: em357.c:335
static int em357_protect_check(struct flash_bank *bank)
Definition: em357.c:300
static int em357_protect(struct flash_bank *bank, int set, unsigned int first, unsigned int last)
Definition: em357.c:383
static int em357_auto_probe(struct flash_bank *bank)
Definition: em357.c:733
static int em357_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: em357.c:571
int default_flash_blank_check(struct flash_bank *bank)
Provides default erased-bank check handling.
int default_flash_read(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
Provides default read implementation for flash memory.
void default_flash_free_driver_priv(struct flash_bank *bank)
Deallocates bank->driver_priv.

Definition at line 856 of file em357.c.