18 #define FLASH_TIMEOUT 5000
27 #include "../../../contrib/loaders/flash/cc3220sf/cc3220sf.inc"
109 long long elapsed_ms;
121 if ((first == 0) && (last == (
bank->num_sectors - 1))) {
127 for (
unsigned int i = first; i <= last; i++) {
155 if (elapsed_ms > 500)
179 uint32_t algo_base_address;
180 uint32_t algo_buffer_address;
181 uint32_t algo_buffer_size;
208 algo_base_address = algo_working_area->
address;
209 algo_buffer_address = buffer_working_area->
address;
210 algo_buffer_size = buffer_working_area->
size;
214 if (algo_buffer_size > 0x80)
215 algo_buffer_size &= ~0x7f;
247 if (0 != (address & 0x3)) {
251 uint32_t head_offset = address & 0x03;
254 uint32_t head_address = address & 0xfffffffc;
261 while ((remaining > 0) && (head_offset < 4)) {
262 head[head_offset] = *
buffer;
288 LOG_ERROR(
"cc3220sf: Flash algorithm failed to run");
294 LOG_ERROR(
"cc3220sf: Flash operation failed");
300 uint32_t tail_count = remaining & 0x03;
302 remaining -= tail_count;
304 while ((retval ==
ERROR_OK) && (remaining > 0)) {
310 if (remaining >= algo_buffer_size) {
313 algo_buffer_size,
buffer);
318 words = algo_buffer_size / 4;
321 address += algo_buffer_size;
322 buffer += algo_buffer_size;
323 remaining -= algo_buffer_size;
332 words = remaining / 4;
333 if (0 != (remaining % 4))
337 address += remaining;
350 LOG_ERROR(
"cc3220sf: Flash algorithm failed to run");
358 LOG_ERROR(
"cc3220sf: Flash operation failed");
366 if ((retval ==
ERROR_OK) && (tail_count != 0)) {
370 uint32_t tail_offset = 0;
377 while (tail_count > 0) {
378 tail[tail_offset] = *
buffer;
402 LOG_ERROR(
"cc3220sf: Flash algorithm failed to run");
408 LOG_ERROR(
"cc3220sf: Flash operation failed");
429 unsigned int num_sectors;
443 bank->write_start_alignment = 0;
444 bank->write_end_alignment = 0;
445 bank->num_sectors = num_sectors;
447 for (
unsigned int i = 0; i < num_sectors; i++) {
450 bank->sectors[i].is_erased = -1;
451 bank->sectors[i].is_protected = 0;
482 .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 int first, unsigned int 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 int first, unsigned int 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)
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, unsigned int timeout_ms, void *arch_info)
Downloads a target-specific native code algorithm to the target, and executes it.
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_read_u32(struct target *target, target_addr_t address, uint32_t *value)
#define ERROR_TARGET_NOT_HALTED