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

Go to the source code of this file.

Data Structures

struct  rsl10_info::rsl10_bank
 
struct  rsl10_info
 

Macros

#define ALGO_STACK_POINTER_ADDR   0x20002000
 
#define FLASH_SECTOR_SIZE   0x2000
 
#define RSL10_FLASH_ADDRESS_LOCK_INFO_SETTING   0x00081040
 
#define RSL10_FLASH_ADDRESS_MAIN   0x00100000
 
#define RSL10_FLASH_ADDRESS_NVR1   0x00080000
 
#define RSL10_FLASH_ADDRESS_NVR2   0x00080800
 
#define RSL10_FLASH_ADDRESS_NVR3   0x00081000
 
#define RSL10_FLASH_ADDRESS_NVR4   0x00081800
 
#define RSL10_FLASH_KEY_MAIN   0xDBC8264E
 
#define RSL10_FLASH_KEY_NVR   0x71B371F5
 
#define RSL10_FLASH_REG_DEBUG_UNLOCK_KEY1   0x400000F0
 
#define RSL10_FLASH_REG_DEBUG_UNLOCK_KEY2   0x400000F4
 
#define RSL10_FLASH_REG_DEBUG_UNLOCK_KEY3   0x400000F8
 
#define RSL10_FLASH_REG_DEBUG_UNLOCK_KEY4   0x400000FC
 
#define RSL10_FLASH_REG_IF_STATUS   0x40000538
 
#define RSL10_FLASH_REG_MAIN_CTRL   0x40000508
 
#define RSL10_FLASH_REG_MAIN_CTRL_HIGH_W_ENABLE   BIT(2)
 
#define RSL10_FLASH_REG_MAIN_CTRL_LOW_W_ENABLE   BIT(0)
 
#define RSL10_FLASH_REG_MAIN_CTRL_MIDDLE_W_ENABLE   BIT(1)
 
#define RSL10_FLASH_REG_MAIN_WRITE_UNLOCK   0x40000504
 
#define RSL10_FLASH_REG_NVR_CTRL   0x4000054C
 
#define RSL10_FLASH_REG_NVR_CTRL_NVR1_W_ENABLE   BIT(1)
 
#define RSL10_FLASH_REG_NVR_CTRL_NVR2_W_ENABLE   BIT(2)
 
#define RSL10_FLASH_REG_NVR_CTRL_NVR3_W_ENABLE   BIT(3)
 
#define RSL10_FLASH_REG_NVR_WRITE_UNLOCK   0x40000548
 
#define RSL10_FLASH_REG_STATUS_HIGH_W_UNLOCKED   BIT(2)
 
#define RSL10_FLASH_REG_STATUS_LOW_W_UNLOCKED   BIT(0)
 
#define RSL10_FLASH_REG_STATUS_MIDDLE_W_UNLOCKED   BIT(1)
 
#define RSL10_FLASH_REG_STATUS_NVR1_W_UNLOCKED   BIT(4)
 
#define RSL10_FLASH_REG_STATUS_NVR2_W_UNLOCKED   BIT(5)
 
#define RSL10_FLASH_REG_STATUS_NVR3_W_UNLOCKED   BIT(6)
 
#define RSL10_ID   0x09010106
 
#define RSL10_KEY_DEBUG_LOCK   0x4C6F634B
 
#define RSL10_NVR3_USER_KEY_OFFSET   0x40
 
#define RSL10_REG_ID   0x1FFFFFFC
 
#define RSL10_ROM_CMD_ERASE_ALL   0x48
 
#define RSL10_ROM_CMD_ERASE_SECTOR   0x44
 
#define RSL10_ROM_CMD_WRITE_BUFFER   0x40
 
#define RSL10_ROM_CMD_WRITE_BUFFER_MAX_SIZE   FLASH_SECTOR_SIZE
 
#define RSL10_ROM_CMD_WRITE_WORD_PAIR   0x3C
 

Enumerations

enum  rsl10_flash_status {
  RSL10_FLASH_ERR_NONE = 0x0 , RSL10_FLASH_ERR_GENERAL_FAILURE = 0x1 , RSL10_FLASH_ERR_WRITE_NOT_ENABLED = 0x2 , RSL10_FLASH_ERR_BAD_ADDRESS = 0x3 ,
  RSL10_FLASH_ERR_ERASE_FAILED = 0x4 , RSL10_FLASH_ERR_BAD_LENGTH = 0x5 , RSL10_FLASH_ERR_INACCESSIBLE = 0x6 , RSL10_FLASH_ERR_COPIER_BUSY = 0x7 ,
  RSL10_FLASH_ERR_PROG_FAILED = 0x8 , RSL10_FLASH_MAX_ERR_CODES
}
 

Functions

 COMMAND_HANDLER (rsl10_lock_command)
 
 COMMAND_HANDLER (rsl10_mass_erase_command)
 
 COMMAND_HANDLER (rsl10_unlock_command)
 
 FLASH_BANK_COMMAND_HANDLER (rsl10_flash_bank_command)
 
static int rsl10_auto_probe (struct flash_bank *bank)
 
static bool rsl10_bank_is_probed (const struct flash_bank *bank)
 
static int rsl10_check_device (struct flash_bank *bank)
 
static int rsl10_erase (struct flash_bank *bank, unsigned int first, unsigned int last)
 
const char * rsl10_error (enum rsl10_flash_status x)
 
static void rsl10_free_driver_priv (struct flash_bank *bank)
 
static struct rsl10_inforsl10_get_chip (struct target *target)
 
static int rsl10_get_probed_chip_if_halted (struct flash_bank *bank, struct rsl10_info **chip)
 
static int rsl10_ll_flash_erase (struct rsl10_info *chip, uint32_t address)
 
static int rsl10_ll_flash_write (struct rsl10_info *chip, uint32_t address, const uint8_t *buffer, uint32_t bytes)
 
static int rsl10_mass_erase (struct target *target)
 
static int rsl10_probe (struct flash_bank *bank)
 
static int rsl10_protect (struct flash_bank *bank, int set, unsigned int first, unsigned int last)
 
static int rsl10_protect_check (struct flash_bank *bank)
 
static int rsl10_write (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 

Variables

static const struct command_registration rsl10_command_handlers []
 
static const char *const rsl10_error_list []
 
static const struct command_registration rsl10_exec_command_handlers []
 
const struct flash_driver rsl10_flash
 
static const uint8_t rsl10_rom_launcher_code []
 

Macro Definition Documentation

◆ ALGO_STACK_POINTER_ADDR

#define ALGO_STACK_POINTER_ADDR   0x20002000

Definition at line 75 of file rsl10.c.

◆ FLASH_SECTOR_SIZE

#define FLASH_SECTOR_SIZE   0x2000

Definition at line 71 of file rsl10.c.

◆ RSL10_FLASH_ADDRESS_LOCK_INFO_SETTING

#define RSL10_FLASH_ADDRESS_LOCK_INFO_SETTING   0x00081040

Definition at line 29 of file rsl10.c.

◆ RSL10_FLASH_ADDRESS_MAIN

#define RSL10_FLASH_ADDRESS_MAIN   0x00100000

Definition at line 24 of file rsl10.c.

◆ RSL10_FLASH_ADDRESS_NVR1

#define RSL10_FLASH_ADDRESS_NVR1   0x00080000

Definition at line 25 of file rsl10.c.

◆ RSL10_FLASH_ADDRESS_NVR2

#define RSL10_FLASH_ADDRESS_NVR2   0x00080800

Definition at line 26 of file rsl10.c.

◆ RSL10_FLASH_ADDRESS_NVR3

#define RSL10_FLASH_ADDRESS_NVR3   0x00081000

Definition at line 27 of file rsl10.c.

◆ RSL10_FLASH_ADDRESS_NVR4

#define RSL10_FLASH_ADDRESS_NVR4   0x00081800

Definition at line 28 of file rsl10.c.

◆ RSL10_FLASH_KEY_MAIN

#define RSL10_FLASH_KEY_MAIN   0xDBC8264E

Definition at line 47 of file rsl10.c.

◆ RSL10_FLASH_KEY_NVR

#define RSL10_FLASH_KEY_NVR   0x71B371F5

Definition at line 48 of file rsl10.c.

◆ RSL10_FLASH_REG_DEBUG_UNLOCK_KEY1

#define RSL10_FLASH_REG_DEBUG_UNLOCK_KEY1   0x400000F0

Definition at line 39 of file rsl10.c.

◆ RSL10_FLASH_REG_DEBUG_UNLOCK_KEY2

#define RSL10_FLASH_REG_DEBUG_UNLOCK_KEY2   0x400000F4

Definition at line 40 of file rsl10.c.

◆ RSL10_FLASH_REG_DEBUG_UNLOCK_KEY3

#define RSL10_FLASH_REG_DEBUG_UNLOCK_KEY3   0x400000F8

Definition at line 41 of file rsl10.c.

◆ RSL10_FLASH_REG_DEBUG_UNLOCK_KEY4

#define RSL10_FLASH_REG_DEBUG_UNLOCK_KEY4   0x400000FC

Definition at line 42 of file rsl10.c.

◆ RSL10_FLASH_REG_IF_STATUS

#define RSL10_FLASH_REG_IF_STATUS   0x40000538

Definition at line 35 of file rsl10.c.

◆ RSL10_FLASH_REG_MAIN_CTRL

#define RSL10_FLASH_REG_MAIN_CTRL   0x40000508

Definition at line 34 of file rsl10.c.

◆ RSL10_FLASH_REG_MAIN_CTRL_HIGH_W_ENABLE

#define RSL10_FLASH_REG_MAIN_CTRL_HIGH_W_ENABLE   BIT(2)

Definition at line 53 of file rsl10.c.

◆ RSL10_FLASH_REG_MAIN_CTRL_LOW_W_ENABLE

#define RSL10_FLASH_REG_MAIN_CTRL_LOW_W_ENABLE   BIT(0)

Definition at line 51 of file rsl10.c.

◆ RSL10_FLASH_REG_MAIN_CTRL_MIDDLE_W_ENABLE

#define RSL10_FLASH_REG_MAIN_CTRL_MIDDLE_W_ENABLE   BIT(1)

Definition at line 52 of file rsl10.c.

◆ RSL10_FLASH_REG_MAIN_WRITE_UNLOCK

#define RSL10_FLASH_REG_MAIN_WRITE_UNLOCK   0x40000504

Definition at line 33 of file rsl10.c.

◆ RSL10_FLASH_REG_NVR_CTRL

#define RSL10_FLASH_REG_NVR_CTRL   0x4000054C

Definition at line 37 of file rsl10.c.

◆ RSL10_FLASH_REG_NVR_CTRL_NVR1_W_ENABLE

#define RSL10_FLASH_REG_NVR_CTRL_NVR1_W_ENABLE   BIT(1)

Definition at line 55 of file rsl10.c.

◆ RSL10_FLASH_REG_NVR_CTRL_NVR2_W_ENABLE

#define RSL10_FLASH_REG_NVR_CTRL_NVR2_W_ENABLE   BIT(2)

Definition at line 56 of file rsl10.c.

◆ RSL10_FLASH_REG_NVR_CTRL_NVR3_W_ENABLE

#define RSL10_FLASH_REG_NVR_CTRL_NVR3_W_ENABLE   BIT(3)

Definition at line 57 of file rsl10.c.

◆ RSL10_FLASH_REG_NVR_WRITE_UNLOCK

#define RSL10_FLASH_REG_NVR_WRITE_UNLOCK   0x40000548

Definition at line 36 of file rsl10.c.

◆ RSL10_FLASH_REG_STATUS_HIGH_W_UNLOCKED

#define RSL10_FLASH_REG_STATUS_HIGH_W_UNLOCKED   BIT(2)

Definition at line 61 of file rsl10.c.

◆ RSL10_FLASH_REG_STATUS_LOW_W_UNLOCKED

#define RSL10_FLASH_REG_STATUS_LOW_W_UNLOCKED   BIT(0)

Definition at line 59 of file rsl10.c.

◆ RSL10_FLASH_REG_STATUS_MIDDLE_W_UNLOCKED

#define RSL10_FLASH_REG_STATUS_MIDDLE_W_UNLOCKED   BIT(1)

Definition at line 60 of file rsl10.c.

◆ RSL10_FLASH_REG_STATUS_NVR1_W_UNLOCKED

#define RSL10_FLASH_REG_STATUS_NVR1_W_UNLOCKED   BIT(4)

Definition at line 62 of file rsl10.c.

◆ RSL10_FLASH_REG_STATUS_NVR2_W_UNLOCKED

#define RSL10_FLASH_REG_STATUS_NVR2_W_UNLOCKED   BIT(5)

Definition at line 63 of file rsl10.c.

◆ RSL10_FLASH_REG_STATUS_NVR3_W_UNLOCKED

#define RSL10_FLASH_REG_STATUS_NVR3_W_UNLOCKED   BIT(6)

Definition at line 64 of file rsl10.c.

◆ RSL10_ID

#define RSL10_ID   0x09010106

Definition at line 46 of file rsl10.c.

◆ RSL10_KEY_DEBUG_LOCK

#define RSL10_KEY_DEBUG_LOCK   0x4C6F634B

Definition at line 49 of file rsl10.c.

◆ RSL10_NVR3_USER_KEY_OFFSET

#define RSL10_NVR3_USER_KEY_OFFSET   0x40

Definition at line 44 of file rsl10.c.

◆ RSL10_REG_ID

#define RSL10_REG_ID   0x1FFFFFFC

Definition at line 31 of file rsl10.c.

◆ RSL10_ROM_CMD_ERASE_ALL

#define RSL10_ROM_CMD_ERASE_ALL   0x48

Definition at line 69 of file rsl10.c.

◆ RSL10_ROM_CMD_ERASE_SECTOR

#define RSL10_ROM_CMD_ERASE_SECTOR   0x44

Definition at line 68 of file rsl10.c.

◆ RSL10_ROM_CMD_WRITE_BUFFER

#define RSL10_ROM_CMD_WRITE_BUFFER   0x40

Definition at line 67 of file rsl10.c.

◆ RSL10_ROM_CMD_WRITE_BUFFER_MAX_SIZE

#define RSL10_ROM_CMD_WRITE_BUFFER_MAX_SIZE   FLASH_SECTOR_SIZE

Definition at line 73 of file rsl10.c.

◆ RSL10_ROM_CMD_WRITE_WORD_PAIR

#define RSL10_ROM_CMD_WRITE_WORD_PAIR   0x3C

Definition at line 66 of file rsl10.c.

Enumeration Type Documentation

◆ rsl10_flash_status

Enumerator
RSL10_FLASH_ERR_NONE 
RSL10_FLASH_ERR_GENERAL_FAILURE 
RSL10_FLASH_ERR_WRITE_NOT_ENABLED 
RSL10_FLASH_ERR_BAD_ADDRESS 
RSL10_FLASH_ERR_ERASE_FAILED 
RSL10_FLASH_ERR_BAD_LENGTH 
RSL10_FLASH_ERR_INACCESSIBLE 
RSL10_FLASH_ERR_COPIER_BUSY 
RSL10_FLASH_ERR_PROG_FAILED 
RSL10_FLASH_MAX_ERR_CODES 

Definition at line 86 of file rsl10.c.

Function Documentation

◆ COMMAND_HANDLER() [1/3]

◆ COMMAND_HANDLER() [2/3]

COMMAND_HANDLER ( rsl10_mass_erase_command  )

◆ COMMAND_HANDLER() [3/3]

◆ FLASH_BANK_COMMAND_HANDLER()

◆ rsl10_auto_probe()

static int rsl10_auto_probe ( struct flash_bank bank)
static

Definition at line 332 of file rsl10.c.

References bank, ERROR_OK, rsl10_bank_is_probed(), and rsl10_probe().

◆ rsl10_bank_is_probed()

static bool rsl10_bank_is_probed ( const struct flash_bank bank)
static

Definition at line 131 of file rsl10.c.

References bank.

Referenced by rsl10_auto_probe(), and rsl10_get_probed_chip_if_halted().

◆ rsl10_check_device()

static int rsl10_check_device ( struct flash_bank bank)
static

Definition at line 260 of file rsl10.c.

References bank, ERROR_OK, ERROR_TARGET_INVALID, LOG_ERROR, RSL10_ID, RSL10_REG_ID, and target_read_u32().

Referenced by rsl10_probe().

◆ rsl10_erase()

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

Definition at line 565 of file rsl10.c.

References bank, ERROR_OK, LOG_INFO, rsl10_get_probed_chip_if_halted(), and rsl10_ll_flash_erase().

Referenced by COMMAND_HANDLER().

◆ rsl10_error()

const char* rsl10_error ( enum rsl10_flash_status  x)

◆ rsl10_free_driver_priv()

static void rsl10_free_driver_priv ( struct flash_bank bank)
static

Definition at line 584 of file rsl10.c.

References bank, NULL, and rsl10_info::refcount.

◆ rsl10_get_chip()

static struct rsl10_info* rsl10_get_chip ( struct target target)
static

◆ rsl10_get_probed_chip_if_halted()

static int rsl10_get_probed_chip_if_halted ( struct flash_bank bank,
struct rsl10_info **  chip 
)
static

◆ rsl10_ll_flash_erase()

◆ rsl10_ll_flash_write()

◆ rsl10_mass_erase()

◆ rsl10_probe()

◆ rsl10_protect()

◆ rsl10_protect_check()

◆ rsl10_write()

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

Definition at line 554 of file rsl10.c.

References bank, buffer, count, ERROR_OK, offset, rsl10_get_probed_chip_if_halted(), and rsl10_ll_flash_write().

Referenced by COMMAND_HANDLER().

Variable Documentation

◆ rsl10_command_handlers

const struct command_registration rsl10_command_handlers[]
static
Initial value:
= {
{
.name = "rsl10",
.mode = COMMAND_ANY,
.help = "rsl10 flash 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 rsl10_exec_command_handlers[]
Definition: rsl10.c:796

Definition at line 781 of file rsl10.c.

◆ rsl10_error_list

const char* const rsl10_error_list[]
static
Initial value:
= {
[RSL10_FLASH_ERR_GENERAL_FAILURE] = "general failure",
[RSL10_FLASH_ERR_WRITE_NOT_ENABLED] = "write not enabled, protected",
[RSL10_FLASH_ERR_BAD_ADDRESS] = "bad address",
[RSL10_FLASH_ERR_ERASE_FAILED] = "erase failed",
[RSL10_FLASH_ERR_BAD_LENGTH] = "bad length",
[RSL10_FLASH_ERR_INACCESSIBLE] = "inaccessible: not powered up, or isolated",
[RSL10_FLASH_ERR_COPIER_BUSY] = "copier busy",
[RSL10_FLASH_ERR_PROG_FAILED] = "prog failed",
}
@ RSL10_FLASH_ERR_INACCESSIBLE
Definition: rsl10.c:93
@ RSL10_FLASH_ERR_WRITE_NOT_ENABLED
Definition: rsl10.c:89
@ RSL10_FLASH_ERR_BAD_LENGTH
Definition: rsl10.c:92
@ RSL10_FLASH_ERR_PROG_FAILED
Definition: rsl10.c:95
@ RSL10_FLASH_ERR_BAD_ADDRESS
Definition: rsl10.c:90
@ RSL10_FLASH_ERR_GENERAL_FAILURE
Definition: rsl10.c:88
@ RSL10_FLASH_ERR_COPIER_BUSY
Definition: rsl10.c:94
@ RSL10_FLASH_ERR_ERASE_FAILED
Definition: rsl10.c:91

Definition at line 99 of file rsl10.c.

Referenced by rsl10_error().

◆ rsl10_exec_command_handlers

const struct command_registration rsl10_exec_command_handlers[]
static
Initial value:
= {
{
.name = "lock",
.handler = rsl10_lock_command,
.mode = COMMAND_EXEC,
.help = "Lock rsl10 debug, with passed keys",
.usage = "key1 key2 key3 key4",
},
{
.name = "unlock",
.handler = rsl10_unlock_command,
.mode = COMMAND_EXEC,
.help = "Unlock rsl10 debug, with passed keys",
.usage = "key1 key2 key3 key4",
},
{
.name = "mass_erase",
.handler = rsl10_mass_erase_command,
.mode = COMMAND_EXEC,
.help = "Mass erase all unprotected flash areas",
.usage = "",
},
@ COMMAND_EXEC
Definition: command.h:40

Definition at line 781 of file rsl10.c.

◆ rsl10_flash

const struct flash_driver rsl10_flash
Initial value:
= {
.name = "rsl10",
.flash_bank_command = rsl10_flash_bank_command,
.erase = rsl10_erase,
.protect = rsl10_protect,
.write = rsl10_write,
.probe = rsl10_probe,
.auto_probe = rsl10_auto_probe,
.erase_check = default_flash_blank_check,
.protect_check = rsl10_protect_check,
.free_driver_priv = rsl10_free_driver_priv,
}
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.
static void rsl10_free_driver_priv(struct flash_bank *bank)
Definition: rsl10.c:584
static int rsl10_protect_check(struct flash_bank *bank)
Definition: rsl10.c:156
static int rsl10_auto_probe(struct flash_bank *bank)
Definition: rsl10.c:332
static const struct command_registration rsl10_command_handlers[]
Definition: rsl10.c:820
static int rsl10_protect(struct flash_bank *bank, int set, unsigned int first, unsigned int last)
Definition: rsl10.c:194
static int rsl10_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
Definition: rsl10.c:565
static int rsl10_probe(struct flash_bank *bank)
Definition: rsl10.c:274
static int rsl10_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: rsl10.c:554

Definition at line 110 of file rsl10.c.

Referenced by rsl10_get_chip().

◆ rsl10_rom_launcher_code

const uint8_t rsl10_rom_launcher_code[]
static
Initial value:
= {
}

Definition at line 82 of file rsl10.c.

Referenced by rsl10_ll_flash_erase(), rsl10_ll_flash_write(), and rsl10_mass_erase().