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

Go to the source code of this file.

Data Structures

struct  avrf_flash_bank
 
struct  avrf_type
 

Macros

#define AVR_JTAG_INS_AVR_RESET   0x0C
 
#define AVR_JTAG_INS_BYPASS   0x0F
 
#define AVR_JTAG_INS_EXTEST   0x00
 
#define AVR_JTAG_INS_IDCODE   0x01
 
#define AVR_JTAG_INS_LEN   4
 
#define AVR_JTAG_INS_PROG_COMMANDS   0x05
 
#define AVR_JTAG_INS_PROG_ENABLE   0x04
 
#define AVR_JTAG_INS_PROG_PAGELOAD   0x06
 
#define AVR_JTAG_INS_PROG_PAGEREAD   0x07
 
#define AVR_JTAG_INS_SAMPLE_PRELOAD   0x02
 
#define AVR_JTAG_REG_BYPASS_LEN   1
 
#define AVR_JTAG_REG_DEVICEID_LEN   32
 
#define AVR_JTAG_REG_FLASH_DATA_BYTE_LEN   16
 
#define AVR_JTAG_REG_JTAGID_LEN   32
 
#define AVR_JTAG_REG_PROGRAMMING_COMMAND_LEN   15
 
#define AVR_JTAG_REG_PROGRAMMING_ENABLE_LEN   16
 
#define AVR_JTAG_REG_RESET_LEN   1
 
#define EXTRACT_MFG(X)   (((X) & 0xffe) >> 1)
 
#define EXTRACT_PART(X)   (((X) & 0xffff000) >> 12)
 
#define EXTRACT_VER(X)   (((X) & 0xf0000000) >> 28)
 

Functions

static int avr_jtag_read_jtagid (struct avr_common *avr, uint32_t *id)
 
static int avr_jtag_reset (struct avr_common *avr, uint32_t reset)
 
static int avr_jtagprg_chiperase (struct avr_common *avr)
 
static int avr_jtagprg_enterprogmode (struct avr_common *avr)
 
static int avr_jtagprg_leaveprogmode (struct avr_common *avr)
 
static int avr_jtagprg_writeflashpage (struct avr_common *avr, const bool ext_addressing, const uint8_t *page_buf, uint32_t buf_size, uint32_t addr, uint32_t page_size)
 
static int avrf_auto_probe (struct flash_bank *bank)
 
static int avrf_erase (struct flash_bank *bank, unsigned int first, unsigned int last)
 
static int avrf_info (struct flash_bank *bank, struct command_invocation *cmd)
 
static int avrf_mass_erase (struct flash_bank *bank)
 
static int avrf_probe (struct flash_bank *bank)
 
static int avrf_write (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 
 COMMAND_HANDLER (avrf_handle_mass_erase_command)
 
 FLASH_BANK_COMMAND_HANDLER (avrf_flash_bank_command)
 

Variables

static const struct avrf_type avft_chips_info []
 
const struct flash_driver avr_flash
 
static const struct command_registration avrf_command_handlers []
 
static const struct command_registration avrf_exec_command_handlers []
 

Macro Definition Documentation

◆ AVR_JTAG_INS_AVR_RESET

#define AVR_JTAG_INS_AVR_RESET   0x0C

Definition at line 23 of file avrf.c.

◆ AVR_JTAG_INS_BYPASS

#define AVR_JTAG_INS_BYPASS   0x0F

Definition at line 21 of file avrf.c.

◆ AVR_JTAG_INS_EXTEST

#define AVR_JTAG_INS_EXTEST   0x00

Definition at line 18 of file avrf.c.

◆ AVR_JTAG_INS_IDCODE

#define AVR_JTAG_INS_IDCODE   0x01

Definition at line 19 of file avrf.c.

◆ AVR_JTAG_INS_LEN

#define AVR_JTAG_INS_LEN   4

Definition at line 16 of file avrf.c.

◆ AVR_JTAG_INS_PROG_COMMANDS

#define AVR_JTAG_INS_PROG_COMMANDS   0x05

Definition at line 25 of file avrf.c.

◆ AVR_JTAG_INS_PROG_ENABLE

#define AVR_JTAG_INS_PROG_ENABLE   0x04

Definition at line 24 of file avrf.c.

◆ AVR_JTAG_INS_PROG_PAGELOAD

#define AVR_JTAG_INS_PROG_PAGELOAD   0x06

Definition at line 26 of file avrf.c.

◆ AVR_JTAG_INS_PROG_PAGEREAD

#define AVR_JTAG_INS_PROG_PAGEREAD   0x07

Definition at line 27 of file avrf.c.

◆ AVR_JTAG_INS_SAMPLE_PRELOAD

#define AVR_JTAG_INS_SAMPLE_PRELOAD   0x02

Definition at line 20 of file avrf.c.

◆ AVR_JTAG_REG_BYPASS_LEN

#define AVR_JTAG_REG_BYPASS_LEN   1

Definition at line 30 of file avrf.c.

◆ AVR_JTAG_REG_DEVICEID_LEN

#define AVR_JTAG_REG_DEVICEID_LEN   32

Definition at line 31 of file avrf.c.

◆ AVR_JTAG_REG_FLASH_DATA_BYTE_LEN

#define AVR_JTAG_REG_FLASH_DATA_BYTE_LEN   16

Definition at line 37 of file avrf.c.

◆ AVR_JTAG_REG_JTAGID_LEN

#define AVR_JTAG_REG_JTAGID_LEN   32

Definition at line 34 of file avrf.c.

◆ AVR_JTAG_REG_PROGRAMMING_COMMAND_LEN

#define AVR_JTAG_REG_PROGRAMMING_COMMAND_LEN   15

Definition at line 36 of file avrf.c.

◆ AVR_JTAG_REG_PROGRAMMING_ENABLE_LEN

#define AVR_JTAG_REG_PROGRAMMING_ENABLE_LEN   16

Definition at line 35 of file avrf.c.

◆ AVR_JTAG_REG_RESET_LEN

#define AVR_JTAG_REG_RESET_LEN   1

Definition at line 33 of file avrf.c.

◆ EXTRACT_MFG

#define EXTRACT_MFG (   X)    (((X) & 0xffe) >> 1)

Definition at line 288 of file avrf.c.

◆ EXTRACT_PART

#define EXTRACT_PART (   X)    (((X) & 0xffff000) >> 12)

Definition at line 289 of file avrf.c.

◆ EXTRACT_VER

#define EXTRACT_VER (   X)    (((X) & 0xf0000000) >> 28)

Definition at line 290 of file avrf.c.

Function Documentation

◆ avr_jtag_read_jtagid()

static int avr_jtag_read_jtagid ( struct avr_common avr,
uint32_t *  id 
)
static

◆ avr_jtag_reset()

static int avr_jtag_reset ( struct avr_common avr,
uint32_t  reset 
)
static

◆ avr_jtagprg_chiperase()

◆ avr_jtagprg_enterprogmode()

static int avr_jtagprg_enterprogmode ( struct avr_common avr)
static

◆ avr_jtagprg_leaveprogmode()

◆ avr_jtagprg_writeflashpage()

static int avr_jtagprg_writeflashpage ( struct avr_common avr,
const bool  ext_addressing,
const uint8_t *  page_buf,
uint32_t  buf_size,
uint32_t  addr,
uint32_t  page_size 
)
static

◆ avrf_auto_probe()

static int avrf_auto_probe ( struct flash_bank bank)
static

Definition at line 352 of file avrf.c.

References avrf_info(), avrf_probe(), bank, and ERROR_OK.

◆ avrf_erase()

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

◆ avrf_info()

◆ avrf_mass_erase()

◆ avrf_probe()

◆ avrf_write()

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

◆ COMMAND_HANDLER()

COMMAND_HANDLER ( avrf_handle_mass_erase_command  )

Definition at line 421 of file avrf.c.

◆ FLASH_BANK_COMMAND_HANDLER()

FLASH_BANK_COMMAND_HANDLER ( avrf_flash_bank_command  )

Definition at line 196 of file avrf.c.

References avrf_info(), bank, CMD_ARGC, ERROR_COMMAND_SYNTAX_ERROR, and ERROR_OK.

Variable Documentation

◆ avft_chips_info

const struct avrf_type avft_chips_info[]
static
Initial value:
= {
{"atmega128", 0x9702, 256, 512, 8, 512},
{"atmega128rfa1", 0xa701, 128, 512, 8, 512},
{"atmega256rfr2", 0xa802, 256, 1024, 8, 1024},
{"at90can128", 0x9781, 256, 512, 8, 512},
{"at90usb128", 0x9782, 256, 512, 8, 512},
{"atmega164p", 0x940a, 128, 128, 4, 128},
{"atmega324p", 0x9508, 128, 256, 4, 256},
{"atmega324pa", 0x9511, 128, 256, 4, 256},
{"atmega644p", 0x960a, 256, 256, 8, 256},
{"atmega1284p", 0x9705, 256, 512, 8, 512},
{"atmega32u4", 0x9587, 128, 256, 4, 256},
}

Definition at line 1 of file avrf.c.

Referenced by avrf_info(), and avrf_probe().

◆ avr_flash

const struct flash_driver avr_flash
Initial value:
= {
.name = "avr",
.commands = avrf_command_handlers,
.flash_bank_command = avrf_flash_bank_command,
.erase = avrf_erase,
.write = avrf_write,
.probe = avrf_probe,
.auto_probe = avrf_auto_probe,
.erase_check = default_flash_blank_check,
.info = avrf_info,
.free_driver_priv = default_flash_free_driver_priv,
}
static int avrf_auto_probe(struct flash_bank *bank)
Definition: avrf.c:352
static int avrf_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: avrf.c:236
static const struct command_registration avrf_command_handlers[]
Definition: avrf.c:450
static int avrf_info(struct flash_bank *bank, struct command_invocation *cmd)
Definition: avrf.c:360
static int avrf_probe(struct flash_bank *bank)
Definition: avrf.c:292
static int avrf_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
Definition: avrf.c:211
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 421 of file avrf.c.

◆ avrf_command_handlers

const struct command_registration avrf_command_handlers[]
static
Initial value:
= {
{
.name = "avrf",
.mode = COMMAND_ANY,
.help = "AVR flash command group",
.usage = "",
},
}
static const struct command_registration avrf_exec_command_handlers[]
Definition: avrf.c:440
#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

Definition at line 421 of file avrf.c.

◆ avrf_exec_command_handlers

const struct command_registration avrf_exec_command_handlers[]
static
Initial value:
= {
{
.name = "mass_erase",
.usage = "<bank>",
.handler = avrf_handle_mass_erase_command,
.mode = COMMAND_EXEC,
.help = "erase entire device",
},
}
@ COMMAND_EXEC
Definition: command.h:40

Definition at line 421 of file avrf.c.