23 #define ADUC702X_FLASH 0xfffff800
24 #define ADUC702X_FLASH_FEESTA (0*4)
25 #define ADUC702X_FLASH_FEEMOD (1*4)
26 #define ADUC702X_FLASH_FEECON (2*4)
27 #define ADUC702X_FLASH_FEEDAT (3*4)
28 #define ADUC702X_FLASH_FEEADR (4*4)
29 #define ADUC702X_FLASH_FEESIGN (5*4)
30 #define ADUC702X_FLASH_FEEPRO (6*4)
31 #define ADUC702X_FLASH_FEEHIDE (7*4)
52 bank->num_sectors =
bank->size / 512;
54 for (
unsigned int i = 0; i <
bank->num_sectors; ++i) {
56 bank->sectors[i].size = 512;
58 bank->sectors[i].is_erased = -1;
59 bank->sectors[i].is_protected = 0;
77 if (((first | last) == 0) || ((first == 0) && (last >=
bank->num_sectors))) {
94 count = last - first + 1;
95 for (x = 0; x <
count; ++x) {
96 adr =
bank->base + ((first + x) * 512);
102 LOG_ERROR(
"failed to erase sector at address 0x%08lX", adr);
107 LOG_DEBUG(
"erased sector at address 0x%08lX", adr);
127 uint32_t buffer_size = 7000;
136 LOG_ERROR(
"write block must be multiple of two bytes in offset & length");
154 static const uint32_t aduc702x_flash_write_code[] = {
180 LOG_WARNING(
"no working area available, can't do block memory writes");
184 uint8_t code[
sizeof(aduc702x_flash_write_code)];
186 aduc702x_flash_write_code);
194 if (buffer_size <= 256) {
199 LOG_WARNING(
"no large enough working area available, can't do block memory writes");
215 uint32_t thisrun_count = (
count > buffer_size) ? buffer_size :
count;
222 buf_set_u32(reg_params[1].value, 0, 32, thisrun_count/2);
224 buf_set_u32(reg_params[4].value, 0, 32, 0xFFFFF800);
227 reg_params, write_algorithm->
address,
229 sizeof(aduc702x_flash_write_code) - 4,
232 LOG_ERROR(
"error executing aduc702x flash write algorithm");
236 if ((
buf_get_u32(reg_params[3].value, 0, 32) & 1) != 1) {
238 LOG_ERROR(
"aduc702x detected error writing flash");
244 address += thisrun_count;
245 count -= thisrun_count;
273 for (x = 0; x <
count; x += 2) {
278 if ((x + 1) ==
count) {
290 LOG_ERROR(
"single write failed for address 0x%08lX",
291 (
unsigned long)(
offset + x));
314 LOG_WARNING(
"couldn't use block writes, falling back to single memory accesses");
364 else if ((v & 3) == 0)
372 .flash_bank_command = aduc702x_flash_bank_command,
#define ADUC702X_FLASH_FEECON
#define ADUC702X_FLASH_FEEDAT
#define ADUC702X_FLASH_FEEMOD
static int aduc702x_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
static int aduc702x_check_flash_completion(struct target *target, unsigned int timeout_ms)
static int aduc702x_write_single(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
static int aduc702x_set_write_enable(struct target *target, int enable)
static int aduc702x_probe(struct flash_bank *bank)
#define ADUC702X_FLASH_FEESTA
#define ADUC702X_FLASH_FEEADR
static int aduc702x_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
const struct flash_driver aduc702x_flash
static int aduc702x_write_block(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
static int aduc702x_build_sector_list(struct flash_bank *bank)
FLASH_BANK_COMMAND_HANDLER(aduc702x_flash_bank_command)
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)
Holds the interface to ARM cores.
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.
#define ERROR_FLASH_SECTOR_NOT_ERASED
#define ERROR_FLASH_OPERATION_FAILED
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 alive_sleep(uint64_t ms)
#define LOG_WARNING(expr ...)
#define LOG_ERROR(expr ...)
#define LOG_DEBUG(expr ...)
unsigned int common_magic
enum arm_state core_state
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_write_u8(struct target *target, target_addr_t address, uint8_t value)
int target_write_u16(struct target *target, target_addr_t address, uint16_t value)
int target_read_u8(struct target *target, target_addr_t address, uint8_t *value)
int target_alloc_working_area(struct target *target, uint32_t size, struct working_area **area)
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_alloc_working_area_try(struct target *target, uint32_t size, struct working_area **area)
void target_buffer_set_u32_array(struct target *target, uint8_t *buffer, uint32_t count, const uint32_t *srcbuf)
#define ERROR_TARGET_RESOURCE_NOT_AVAILABLE
#define ARRAY_SIZE(x)
Compute the number of elements of a variable length array.