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

Go to the source code of this file.

Data Structures

struct  stldr_dev_info
 
struct  stldr_dev_sector
 
struct  stldr_flash_bank
 
struct  stldr_func_args
 
struct  stldr_loader
 
struct  stldr_section
 

Macros

#define DEVICE_SECTORS_COUNT_OFFSET   0
 
#define DEVICE_SECTORS_SIZE   8
 
#define DEVICE_SECTORS_SIZE_OFFSET   4
 
#define STACK_OFFSET   0x400
 
#define STLDR_FUNC_ADDR_UNKNOWN   0xFFFFFFFF
 
#define STLDR_FUNC_FAILURE   0
 
#define STLDR_FUNC_SUCCESS   1
 
#define STLDR_INIT_TIMEOUT_MS   100000
 
#define STLDR_MASS_ERASE_EXT_TIMEOUT_MS   600000
 
#define STLDR_MASS_ERASE_INT_TIMEOUT_MS   10000
 
#define STLDR_READ_TIMEOUT_MS   1000
 
#define STLDR_SECTOR_ERASE_TIMEOUT_MS   1000000
 
#define STLDR_WRITE_TIMEOUT_MS   1000
 
#define STORAGE_INFO_BASE_ADDR_OFFSET   (STORAGE_INFO_TYPE_OFFSET + 4)
 
#define STORAGE_INFO_ERASE_VALUE_OFFSET   (STORAGE_INFO_PAGE_SIZE_OFFSET + 4)
 
#define STORAGE_INFO_NAME_OFFSET   0
 
#define STORAGE_INFO_NAME_SIZE   100
 
#define STORAGE_INFO_PAGE_SIZE_OFFSET   (STORAGE_INFO_SIZE_OFFSET + 4)
 
#define STORAGE_INFO_SECTORS_MAX_ITEMS   10
 
#define STORAGE_INFO_SECTORS_OFFSET   (STORAGE_INFO_ERASE_VALUE_OFFSET + 4)
 
#define STORAGE_INFO_SIZE_OFFSET   (STORAGE_INFO_BASE_ADDR_OFFSET + 4)
 
#define STORAGE_INFO_TYPE_OFFSET   (STORAGE_INFO_NAME_OFFSET + STORAGE_INFO_NAME_SIZE)
 

Enumerations

enum  stldr_func_id {
  FUNC_ID_INIT , FUNC_ID_READ , FUNC_ID_SECTOR_ERASE , FUNC_ID_MASS_ERASE ,
  FUNC_ID_WRITE , FUNC_ID_CHECKSUM , FUNC_ID_VERIFY , FUNC_ID_COUNT
}
 
enum  stldr_func_type { STLDR_FUNC_OPTIONAL , STLDR_FUNC_MANDATORY }
 
enum  stldr_type {
  STLDR_TYPE_MCU_FLASH = 1 , STLDR_TYPE_NAND_FLASH , STLDR_TYPE_NOR_FLASH , STLDR_TYPE_SRAM ,
  STLDR_TYPE_PSRAM , STLDR_TYPE_PC_CARD , STLDR_TYPE_SPI_FLASH , STLDR_TYPE_I2C_FLASH ,
  STLDR_TYPE_SDRAM , STLDR_TYPE_I2C_EEPROM
}
 

Functions

 COMMAND_HANDLER (stldr_handle_init_command)
 
 COMMAND_HANDLER (stldr_handle_mass_erase_command)
 
 COMMAND_HANDLER (stldr_handle_set_loader_command)
 
 COMMAND_HANDLER (stldr_handle_set_size_command)
 
 FLASH_BANK_COMMAND_HANDLER (stldr_flash_bank_command)
 
static int stldr_auto_probe (struct flash_bank *bank)
 
static int stldr_erase (struct flash_bank *bank, unsigned int first, unsigned int last)
 
static int stldr_exec_function (struct flash_bank *bank, enum stldr_func_id func_id, unsigned int timeout_ms, struct stldr_func_args *args)
 
static int stldr_exec_function_deinit (struct flash_bank *bank)
 
static int stldr_exec_function_init (struct flash_bank *bank)
 
static int stldr_exec_function_mass_erase (struct flash_bank *bank)
 
static int stldr_exec_function_read (struct flash_bank *bank, uint32_t addr, uint32_t size, uint32_t buffer_addr)
 
static int stldr_exec_function_sector_erase (struct flash_bank *bank, uint32_t start_addr, uint32_t end_addr)
 
static int stldr_exec_function_write (struct flash_bank *bank, uint32_t addr, uint32_t size, uint32_t buffer_addr)
 
static void stldr_free_driver_priv (struct flash_bank *bank)
 
static void stldr_free_sections (struct stldr_flash_bank *stldr_info)
 
static void stldr_func_args_init (struct stldr_func_args *args)
 
static void stldr_func_args_set (struct stldr_func_args *args, uint32_t arg_0, uint32_t arg_1, uint32_t arg_2, uint32_t arg_3)
 
static int stldr_get_info (struct flash_bank *bank, struct command_invocation *cmd)
 
static int stldr_parse (struct flash_bank *bank, const char *stldr_path)
 
static int stldr_parse_dev_info (struct flash_bank *bank, uint8_t *data, int size)
 
static int stldr_probe (struct flash_bank *bank)
 
static int stldr_read (struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
 
static int stldr_write (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 
static int stldr_write_loader (struct flash_bank *bank)
 

Variables

static const struct command_registration stldr_command_handlers []
 
const struct flash_driver stldr_flash
 
struct {
   enum stldr_func_id   id
 
   const char *   name
 
   enum stldr_func_type   type
 
} stldr_functions []
 
static const struct command_registration stldr_subcommand_handlers []
 

Macro Definition Documentation

◆ DEVICE_SECTORS_COUNT_OFFSET

#define DEVICE_SECTORS_COUNT_OFFSET   0

Definition at line 58 of file stldr.c.

◆ DEVICE_SECTORS_SIZE

#define DEVICE_SECTORS_SIZE   8

Definition at line 57 of file stldr.c.

◆ DEVICE_SECTORS_SIZE_OFFSET

#define DEVICE_SECTORS_SIZE_OFFSET   4

Definition at line 59 of file stldr.c.

◆ STACK_OFFSET

#define STACK_OFFSET   0x400

Definition at line 35 of file stldr.c.

◆ STLDR_FUNC_ADDR_UNKNOWN

#define STLDR_FUNC_ADDR_UNKNOWN   0xFFFFFFFF

Definition at line 32 of file stldr.c.

◆ STLDR_FUNC_FAILURE

#define STLDR_FUNC_FAILURE   0

Definition at line 29 of file stldr.c.

◆ STLDR_FUNC_SUCCESS

#define STLDR_FUNC_SUCCESS   1

Definition at line 30 of file stldr.c.

◆ STLDR_INIT_TIMEOUT_MS

#define STLDR_INIT_TIMEOUT_MS   100000

Definition at line 38 of file stldr.c.

◆ STLDR_MASS_ERASE_EXT_TIMEOUT_MS

#define STLDR_MASS_ERASE_EXT_TIMEOUT_MS   600000

Definition at line 41 of file stldr.c.

◆ STLDR_MASS_ERASE_INT_TIMEOUT_MS

#define STLDR_MASS_ERASE_INT_TIMEOUT_MS   10000

Definition at line 40 of file stldr.c.

◆ STLDR_READ_TIMEOUT_MS

#define STLDR_READ_TIMEOUT_MS   1000

Definition at line 42 of file stldr.c.

◆ STLDR_SECTOR_ERASE_TIMEOUT_MS

#define STLDR_SECTOR_ERASE_TIMEOUT_MS   1000000

Definition at line 39 of file stldr.c.

◆ STLDR_WRITE_TIMEOUT_MS

#define STLDR_WRITE_TIMEOUT_MS   1000

Definition at line 43 of file stldr.c.

◆ STORAGE_INFO_BASE_ADDR_OFFSET

#define STORAGE_INFO_BASE_ADDR_OFFSET   (STORAGE_INFO_TYPE_OFFSET + 4)

Definition at line 49 of file stldr.c.

◆ STORAGE_INFO_ERASE_VALUE_OFFSET

#define STORAGE_INFO_ERASE_VALUE_OFFSET   (STORAGE_INFO_PAGE_SIZE_OFFSET + 4)

Definition at line 52 of file stldr.c.

◆ STORAGE_INFO_NAME_OFFSET

#define STORAGE_INFO_NAME_OFFSET   0

Definition at line 46 of file stldr.c.

◆ STORAGE_INFO_NAME_SIZE

#define STORAGE_INFO_NAME_SIZE   100

Definition at line 47 of file stldr.c.

◆ STORAGE_INFO_PAGE_SIZE_OFFSET

#define STORAGE_INFO_PAGE_SIZE_OFFSET   (STORAGE_INFO_SIZE_OFFSET + 4)

Definition at line 51 of file stldr.c.

◆ STORAGE_INFO_SECTORS_MAX_ITEMS

#define STORAGE_INFO_SECTORS_MAX_ITEMS   10

Definition at line 54 of file stldr.c.

◆ STORAGE_INFO_SECTORS_OFFSET

#define STORAGE_INFO_SECTORS_OFFSET   (STORAGE_INFO_ERASE_VALUE_OFFSET + 4)

Definition at line 53 of file stldr.c.

◆ STORAGE_INFO_SIZE_OFFSET

#define STORAGE_INFO_SIZE_OFFSET   (STORAGE_INFO_BASE_ADDR_OFFSET + 4)

Definition at line 50 of file stldr.c.

◆ STORAGE_INFO_TYPE_OFFSET

#define STORAGE_INFO_TYPE_OFFSET   (STORAGE_INFO_NAME_OFFSET + STORAGE_INFO_NAME_SIZE)

Definition at line 48 of file stldr.c.

Enumeration Type Documentation

◆ stldr_func_id

Enumerator
FUNC_ID_INIT 
FUNC_ID_READ 
FUNC_ID_SECTOR_ERASE 
FUNC_ID_MASS_ERASE 
FUNC_ID_WRITE 
FUNC_ID_CHECKSUM 
FUNC_ID_VERIFY 
FUNC_ID_COUNT 

Definition at line 61 of file stldr.c.

◆ stldr_func_type

Enumerator
STLDR_FUNC_OPTIONAL 
STLDR_FUNC_MANDATORY 

Definition at line 72 of file stldr.c.

◆ stldr_type

enum stldr_type
Enumerator
STLDR_TYPE_MCU_FLASH 
STLDR_TYPE_NAND_FLASH 
STLDR_TYPE_NOR_FLASH 
STLDR_TYPE_SRAM 
STLDR_TYPE_PSRAM 
STLDR_TYPE_PC_CARD 
STLDR_TYPE_SPI_FLASH 
STLDR_TYPE_I2C_FLASH 
STLDR_TYPE_SDRAM 
STLDR_TYPE_I2C_EEPROM 

Definition at line 114 of file stldr.c.

Function Documentation

◆ COMMAND_HANDLER() [1/4]

COMMAND_HANDLER ( stldr_handle_init_command  )

◆ COMMAND_HANDLER() [2/4]

COMMAND_HANDLER ( stldr_handle_mass_erase_command  )

◆ COMMAND_HANDLER() [3/4]

COMMAND_HANDLER ( stldr_handle_set_loader_command  )

◆ COMMAND_HANDLER() [4/4]

◆ FLASH_BANK_COMMAND_HANDLER()

◆ stldr_auto_probe()

static int stldr_auto_probe ( struct flash_bank *  bank)
static

Definition at line 1014 of file stldr.c.

References bank, ERROR_OK, stldr_flash_bank::probed, and stldr_probe().

◆ stldr_erase()

static int stldr_erase ( struct flash_bank *  bank,
unsigned int  first,
unsigned int  last 
)
static

◆ stldr_exec_function()

◆ stldr_exec_function_deinit()

static int stldr_exec_function_deinit ( struct flash_bank *  bank)
static

◆ stldr_exec_function_init()

◆ stldr_exec_function_mass_erase()

◆ stldr_exec_function_read()

static int stldr_exec_function_read ( struct flash_bank *  bank,
uint32_t  addr,
uint32_t  size,
uint32_t  buffer_addr 
)
static

◆ stldr_exec_function_sector_erase()

static int stldr_exec_function_sector_erase ( struct flash_bank *  bank,
uint32_t  start_addr,
uint32_t  end_addr 
)
static

◆ stldr_exec_function_write()

static int stldr_exec_function_write ( struct flash_bank *  bank,
uint32_t  addr,
uint32_t  size,
uint32_t  buffer_addr 
)
static

◆ stldr_free_driver_priv()

static void stldr_free_driver_priv ( struct flash_bank *  bank)
static

◆ stldr_free_sections()

◆ stldr_func_args_init()

static void stldr_func_args_init ( struct stldr_func_args *  args)
inlinestatic

Definition at line 168 of file stldr.c.

References stldr_func_args_set().

Referenced by stldr_exec_function_init(), and stldr_exec_function_mass_erase().

◆ stldr_func_args_set()

static void stldr_func_args_set ( struct stldr_func_args *  args,
uint32_t  arg_0,
uint32_t  arg_1,
uint32_t  arg_2,
uint32_t  arg_3 
)
inlinestatic

◆ stldr_get_info()

static int stldr_get_info ( struct flash_bank *  bank,
struct command_invocation *  cmd 
)
static

◆ stldr_parse()

◆ stldr_parse_dev_info()

◆ stldr_probe()

◆ stldr_read()

◆ stldr_write()

◆ stldr_write_loader()

Variable Documentation

◆ id

enum stldr_func_id id

Definition at line 1100 of file stldr.c.

◆ name

const char* name

Definition at line 79 of file stldr.c.

Referenced by stldr_exec_function(), and stldr_parse().

◆ stldr_command_handlers

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

Definition at line 1100 of file stldr.c.

◆ stldr_flash

const struct flash_driver stldr_flash
Initial value:
= {
.name = "stldr",
.flash_bank_command = stldr_flash_bank_command,
.erase = stldr_erase,
.write = stldr_write,
.read = stldr_read,
.probe = stldr_probe,
.auto_probe = stldr_auto_probe,
.erase_check = default_flash_blank_check,
.info = stldr_get_info,
.free_driver_priv = stldr_free_driver_priv
}
int default_flash_blank_check(struct flash_bank *bank)
Provides default erased-bank check handling.
static int stldr_probe(struct flash_bank *bank)
Definition: stldr.c:965
static int stldr_read(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: stldr.c:910
static int stldr_auto_probe(struct flash_bank *bank)
Definition: stldr.c:1014
static int stldr_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: stldr.c:846
static const struct command_registration stldr_command_handlers[]
Definition: stldr.c:1149
static int stldr_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
Definition: stldr.c:827
static void stldr_free_driver_priv(struct flash_bank *bank)
Definition: stldr.c:590
static int stldr_get_info(struct flash_bank *bank, struct command_invocation *cmd)
Definition: stldr.c:1024

Definition at line 1100 of file stldr.c.

◆ 

const { ... } stldr_functions[]
Initial value:
= {
}
@ STLDR_FUNC_OPTIONAL
Definition: stldr.c:73
@ STLDR_FUNC_MANDATORY
Definition: stldr.c:74
@ FUNC_ID_READ
Definition: stldr.c:63
@ FUNC_ID_MASS_ERASE
Definition: stldr.c:65
@ FUNC_ID_INIT
Definition: stldr.c:62
@ FUNC_ID_SECTOR_ERASE
Definition: stldr.c:64
@ FUNC_ID_VERIFY
Definition: stldr.c:68
@ FUNC_ID_CHECKSUM
Definition: stldr.c:67
@ FUNC_ID_WRITE
Definition: stldr.c:66

Referenced by stldr_exec_function(), and stldr_parse().

◆ stldr_subcommand_handlers

const struct command_registration stldr_subcommand_handlers[]
static

Definition at line 1100 of file stldr.c.

◆ type

uint8_t type

Definition at line 79 of file stldr.c.

Referenced by aarch64_set_context_breakpoint(), aarch64_set_hybrid_breakpoint(), amt_jtagaccel_execute_queue(), amt_jtagaccel_scan(), angie_jtag_execute_scan(), arc_deinit_target(), arc_jtag_read_registers(), arc_jtag_write_registers(), arc_reg_add(), arm11_examine(), armjtagew_execute_queue(), bitbang_execute_queue(), bitbang_scan(), breakpoint_add(), breakpoint_add_internal(), buspirate_execute_queue(), ch347_cmd_has_variable_data_size(), ch347_cmd_start_next(), ch347_is_single_cmd_type(), ch347_read_scan(), ch347_scratchpad_add_scan(), ch347_scratchpad_check_full(), cmapi_read_dap_reg(), cmapi_write_dap_reg(), COMMAND_HANDLER(), COMMAND_HELPER(), context_breakpoint_add(), context_breakpoint_add_internal(), cortex_a_set_context_breakpoint(), cortex_a_set_hybrid_breakpoint(), cortex_m_step(), dtc_load_from_buffer(), dtc_queue_enqueue_reply(), evaluate_extend(), evaluate_media(), evaluate_p_add_sub(), fileio_open(), find_next_free_trigger(), gdb_breakpoint_watchpoint_packet(), gdb_generate_reg_type_description(), gdb_get_reg_type_name(), get_trigger_types(), gw16012_execute_queue(), gw16012_scan(), hybrid_breakpoint_add(), hybrid_breakpoint_add_internal(), jtag_set_reset_config(), opendous_execute_queue(), openjtag_debug_buffer(), read_flash_id(), read_rtt_channel(), riscv_trigger_detect_hit_bits(), rlink_execute_queue(), rlink_scan(), rtos_swbp_target(), semihosting_common(), set_trigger(), stldr_parse(), stlink_usb_mode_enter(), stlink_usb_mode_leave(), syncbb_scan(), target_init_one(), target_register_timer_callback(), target_rtt_read_channel_info(), ublast_build_out(), ublast_clock_tdi(), ublast_clock_tdi_flip_tms(), ublast_scan(), ulink_calculate_delay(), ulink_calculate_frequency(), ulink_queue_scan(), usbprog_execute_queue(), usbprog_scan(), usbtoxxx_add_command(), usbtoxxx_execute_command(), versaloon_add_pending(), vsllink_execute_queue(), xds110_legacy_read_reg(), xds110_legacy_write_reg(), xds110_swd_queue_cmd(), xlnx_xvc_execute_scan(), xtensa_build_reg_cache(), xtensa_fetch_all_regs(), xtensa_get_gdb_reg_list(), xtensa_get_mem_config(), and xtensa_write_dirty_registers().