18 #define FLASH_TIMEOUT 5000
27 #include "../../../contrib/loaders/flash/cc3220sf/cc3220sf.inc"
110 long long elapsed_ms;
122 if ((first == 0) && (last == (
bank->num_sectors - 1))) {
128 for (
unsigned int i = first; i <= last; i++) {
156 if (elapsed_ms > 500)
180 uint32_t algo_base_address;
181 uint32_t algo_buffer_address;
182 uint32_t algo_buffer_size;
209 algo_base_address = algo_working_area->
address;
210 algo_buffer_address = buffer_working_area->
address;
211 algo_buffer_size = buffer_working_area->
size;
215 if (algo_buffer_size > 0x80)
216 algo_buffer_size &= ~0x7f;
248 if (0 != (address & 0x3)) {
252 uint32_t head_offset = address & 0x03;
255 uint32_t head_address = address & 0xfffffffc;
262 while ((remaining > 0) && (head_offset < 4)) {
263 head[head_offset] = *
buffer;
289 LOG_ERROR(
"cc3220sf: Flash algorithm failed to run");
295 LOG_ERROR(
"cc3220sf: Flash operation failed");
301 uint32_t tail_count = remaining & 0x03;
303 remaining -= tail_count;
305 while ((retval ==
ERROR_OK) && (remaining > 0)) {
311 if (remaining >= algo_buffer_size) {
314 algo_buffer_size,
buffer);
319 words = algo_buffer_size / 4;
322 address += algo_buffer_size;
323 buffer += algo_buffer_size;
324 remaining -= algo_buffer_size;
333 words = remaining / 4;
334 if (0 != (remaining % 4))
338 address += remaining;
351 LOG_ERROR(
"cc3220sf: Flash algorithm failed to run");
359 LOG_ERROR(
"cc3220sf: Flash operation failed");
367 if ((retval ==
ERROR_OK) && (tail_count != 0)) {
371 uint32_t tail_offset = 0;
378 while (tail_count > 0) {
379 tail[tail_offset] = *
buffer;
403 LOG_ERROR(
"cc3220sf: Flash algorithm failed to run");
409 LOG_ERROR(
"cc3220sf: Flash operation failed");
430 unsigned int num_sectors;
444 bank->write_start_alignment = 0;
445 bank->write_end_alignment = 0;
446 bank->num_sectors = num_sectors;
448 for (
unsigned int i = 0; i < num_sectors; i++) {
451 bank->sectors[i].is_erased = -1;
452 bank->sectors[i].is_protected = 0;
483 .flash_bank_command = cc3220sf_flash_bank_command,
#define FLASH_SECTOR_SIZE
void init_reg_param(struct reg_param *param, char *reg_name, uint32_t size, enum param_direction direction)
void destroy_reg_param(struct reg_param *param)
#define ARMV7M_COMMON_MAGIC
Support functions to access arbitrary bits in a byte array.
static uint32_t buf_get_u32(const uint8_t *_buffer, unsigned first, unsigned num)
Retrieves num bits from _buffer, starting at the first bit, returning the bits in a 32-bit word.
static void buf_set_u32(uint8_t *_buffer, unsigned first, unsigned num, uint32_t value)
Sets num bits in _buffer, starting at the first bit, using the bits in value.
static const uint8_t cc3220sf_algo[]
static int cc3220sf_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
const struct flash_driver cc3220sf_flash
static int cc3220sf_auto_probe(struct flash_bank *bank)
static int cc3220sf_probe(struct flash_bank *bank)
static int cc3220sf_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
static int cc3220sf_mass_erase(struct flash_bank *bank)
static int cc3220sf_info(struct flash_bank *bank, struct command_invocation *cmd)
FLASH_BANK_COMMAND_HANDLER(cc3220sf_flash_bank_command)
#define FLASH_NUM_SECTORS
#define FMC_REGISTER_ADDR
#define FMA_REGISTER_ADDR
void command_print_sameline(struct command_invocation *cmd, const char *format,...)
#define ERROR_COMMAND_SYNTAX_ERROR
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
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.
#define LOG_ERROR(expr ...)
size_t size
Size of the control block search area.
unsigned int common_magic
struct armv7m_algorithm armv7m_info
When run_command is called, a new instance will be created on the stack, filled with the proper value...
Provides details of a flash bank, available either on-chip or through a major interface.
Provides the implementation-independent structure that defines all of the callbacks required by OpenO...
const char * name
Gives a human-readable name of this flash driver, This field is used to select and initialize the dri...
Describes the geometry and status of a single flash sector within a flash bank.
int target_write_buffer(struct target *target, target_addr_t address, uint32_t size, const uint8_t *buffer)
int target_read_buffer(struct target *target, target_addr_t address, uint32_t size, uint8_t *buffer)
uint32_t target_get_working_area_avail(struct target *target)
int target_alloc_working_area(struct target *target, uint32_t size, struct working_area **area)
int target_write_u32(struct target *target, target_addr_t address, uint32_t value)
int target_free_working_area(struct target *target, struct working_area *area)
Free a working area.
int target_run_algorithm(struct target *target, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_param, target_addr_t entry_point, target_addr_t exit_point, int timeout_ms, void *arch_info)
Downloads a target-specific native code algorithm to the target, and executes it.
int target_read_u32(struct target *target, target_addr_t address, uint32_t *value)
#define ERROR_TARGET_NOT_HALTED