27 #define CFI_MAX_INTEL_CODESIZE 256
30 #define AT49BV6416 0x00d6
31 #define AT49BV6416T 0x00d2
96 f->fixup(
bank, f->param);
111 if (!
bank->sectors) {
112 LOG_ERROR(
"BUG: sector list not yet built");
154 for (
unsigned int i =
bank->bus_width; i > 0; i--)
155 *cmd_buf++ = (i & (
bank->chip_width - 1)) ? 0x0 :
cmd;
157 for (
unsigned int i = 1; i <=
bank->bus_width; i++)
158 *cmd_buf++ = (i & (
bank->chip_width - 1)) ? 0x0 :
cmd;
188 *val = data[
bank->bus_width - 1];
209 for (
unsigned int i = 0; i <
bank->bus_width /
bank->chip_width; i++)
215 for (
unsigned int i = 0; i <
bank->bus_width /
bank->chip_width; i++)
216 value |= data[
bank->bus_width - 1 - i];
230 for (uint8_t i = 0; i < 2; i++) {
232 1, &data[i *
bank->bus_width]);
244 *val = data[0] | data[
bank->bus_width] << 8;
246 *val = data[
bank->bus_width - 1] | data[(2 *
bank->bus_width) - 1] << 8;
258 for (uint8_t i = 0; i < 4; i++) {
260 1, &data[i *
bank->bus_width]);
272 *val = data[0] | data[
bank->bus_width] << 8 |
273 data[
bank->bus_width * 2] << 16 | data[
bank->bus_width * 3] << 24;
275 *val = data[
bank->bus_width - 1] | data[(2 *
bank->bus_width) - 1] << 8 |
276 data[(3 *
bank->bus_width) - 1] << 16 |
277 data[(4 *
bank->bus_width) - 1] << 24;
320 LOG_ERROR(
"timeout while waiting for WSM to become ready");
342 LOG_ERROR(
"Block Lock-Bit Detected, Operation Abort");
346 LOG_ERROR(
"Low Programming Voltage Detected, Operation Aborted");
348 LOG_ERROR(
"Program Error / Error in Setting Lock-Bit");
350 LOG_ERROR(
"Error in Block Erasure or Clear Lock-Bits");
365 uint8_t
status, oldstatus;
379 if ((
status ^ oldstatus) & 0x40) {
387 if ((
status ^ oldstatus) & 0x40) {
434 if ((pri_ext->
pri[0] !=
'P') || (pri_ext->
pri[1] !=
'R') || (pri_ext->
pri[2] !=
'I')) {
438 LOG_ERROR(
"Could not read bank flash bank information");
449 LOG_DEBUG(
"pri: '%c%c%c', version: %c.%c", pri_ext->
pri[0], pri_ext->
pri[1],
462 LOG_DEBUG(
"feature_support: 0x%" PRIx32
", suspend_cmd_support: "
463 "0x%x, blk_status_reg_mask: 0x%x",
475 LOG_DEBUG(
"Vcc opt: %x.%x, Vpp opt: %u.%x",
483 LOG_WARNING(
"expected one protection register field, but found %i",
497 LOG_DEBUG(
"protection_fields: %i, prot_reg_addr: 0x%x, "
498 "factory pre-programmed: %i, user programmable: %i",
535 if ((pri_ext->
pri[0] !=
'P') || (pri_ext->
pri[1] !=
'R') || (pri_ext->
pri[2] !=
'I')) {
539 LOG_ERROR(
"Could not read spansion bank information");
550 LOG_DEBUG(
"pri: '%c%c%c', version: %c.%c", pri_ext->
pri[0], pri_ext->
pri[1],
587 LOG_DEBUG(
"Silicon Revision: 0x%x, Erase Suspend: 0x%x, Block protect: 0x%x",
590 LOG_DEBUG(
"Temporary Unprotect: 0x%x, Block Protect Scheme: 0x%x, "
597 LOG_DEBUG(
"Vpp min: %u.%x, Vpp max: %u.%x",
640 if ((atmel_pri_ext.
pri[0] !=
'P') || (atmel_pri_ext.
pri[1] !=
'R')
641 || (atmel_pri_ext.
pri[2] !=
'I')) {
645 LOG_ERROR(
"Could not read atmel bank information");
649 pri_ext->
pri[0] = atmel_pri_ext.
pri[0];
650 pri_ext->
pri[1] = atmel_pri_ext.
pri[1];
651 pri_ext->
pri[2] = atmel_pri_ext.
pri[2];
660 LOG_DEBUG(
"pri: '%c%c%c', version: %c.%c", atmel_pri_ext.
pri[0],
661 atmel_pri_ext.
pri[1], atmel_pri_ext.
pri[2],
681 "features: 0x%2.2x, bottom_boot: 0x%2.2x, burst_mode: 0x%2.2x, page_mode: 0x%2.2x",
728 pri_ext->
pri[0], pri_ext->
pri[1], pri_ext->
pri[2],
761 "suspend_cmd_support: 0x%x, blk_status_reg_mask: 0x%x\n",
771 "factory pre-programmed: %i, user programmable: %i\n",
781 bool bus_swap =
false;
793 || (
bank->chip_width == 0)
794 || (
bank->bus_width == 0)
795 || (
bank->chip_width & (
bank->chip_width - 1))
796 || (
bank->bus_width & (
bank->bus_width - 1))
797 || (
bank->chip_width >
bank->bus_width)) {
798 LOG_ERROR(
"chip and bus width have to specified in bytes");
804 LOG_ERROR(
"No memory for flash bank info");
807 bank->driver_priv = cfi_info;
809 for (
unsigned int i = 6; i < argc; i++) {
810 if (strcmp(argv[i],
"x16_as_x8") == 0)
812 else if (strcmp(argv[i],
"data_swap") == 0)
814 else if (strcmp(argv[i],
"bus_swap") == 0)
816 else if (strcmp(argv[i],
"jedec_probe") == 0)
828 cfi_info->
qry[0] = 0xff;
848 for (
unsigned int i = first; i <= last; i++) {
867 LOG_ERROR(
"couldn't erase block %u of flash bank at base "
900 for (
unsigned int i = first; i <= last; i++) {
922 LOG_ERROR(
"couldn't erase block %i of flash bank at base "
941 if ((last < first) || (last >=
bank->num_sectors))
944 if (cfi_info->
qry[0] !=
'Q')
947 switch (cfi_info->
pri_id) {
962 unsigned int first,
unsigned int last)
973 LOG_ERROR(
"lock/unlock not supported on flash");
979 for (
unsigned int i = first; i <= last; i++) {
987 bank->sectors[i].is_protected = 1;
992 bank->sectors[i].is_protected = 0;
1004 uint8_t block_status;
1013 if ((block_status & 0x1) != set) {
1015 "couldn't change block lock status (set = %i, block_status = 0x%2.2x)",
1050 for (
unsigned int i = 0; i <
bank->num_sectors; i++) {
1051 if (
bank->sectors[i].is_protected == 1) {
1083 if (cfi_info->
qry[0] !=
'Q')
1086 switch (cfi_info->
pri_id) {
1091 LOG_WARNING(
"protect: cfi primary command set %i unsupported", cfi_info->
pri_id);
1102 switch (
bank->bus_width) {
1110 LOG_ERROR(
"Unsupported bank buswidth %u, can't do block memory writes",
1117 uint32_t address, uint32_t
count)
1124 uint32_t buffer_size = 32768;
1125 uint32_t write_command_val, busy_pattern_val, error_pattern_val;
1138 static const uint32_t word_32_code[] = {
1156 static const uint32_t word_16_code[] = {
1174 static const uint32_t word_8_code[] = {
1191 const uint32_t *target_code_src;
1192 uint32_t target_code_size;
1216 switch (
bank->bus_width) {
1218 target_code_src = word_8_code;
1219 target_code_size =
sizeof(word_8_code);
1222 target_code_src = word_16_code;
1223 target_code_size =
sizeof(word_16_code);
1226 target_code_src = word_32_code;
1227 target_code_size =
sizeof(word_32_code);
1230 LOG_ERROR(
"Unsupported bank buswidth %u, can't do block memory writes",
1236 if (target_code_size >
sizeof(target_code)) {
1237 LOG_WARNING(
"Internal error - target code buffer to small. "
1238 "Increase CFI_MAX_INTEL_CODESIZE and recompile.");
1249 LOG_WARNING(
"No working area available, can't do block memory writes");
1255 target_code_size, target_code);
1257 LOG_ERROR(
"Unable to write block write code to target");
1266 if (buffer_size <= 256) {
1268 "no large enough working area available, can't do block memory writes");
1289 source->address, buffer_size);
1293 uint32_t thisrun_count = (
count > buffer_size) ? buffer_size :
count;
1302 buf_set_u32(reg_params[2].value, 0, 32, thisrun_count /
bank->bus_width);
1304 buf_set_u32(reg_params[3].value, 0, 32, write_command_val);
1305 buf_set_u32(reg_params[5].value, 0, 32, busy_pattern_val);
1306 buf_set_u32(reg_params[6].value, 0, 32, error_pattern_val);
1308 LOG_DEBUG(
"Write 0x%04" PRIx32
" bytes to flash at 0x%08" PRIx32,
1314 write_algorithm->
address + target_code_size -
1323 "Execution of flash algorithm failed. Can't fall back. Please report.");
1332 wsm_error =
buf_get_u32(reg_params[4].value, 0, 32) & error_pattern_val;
1344 count -= thisrun_count;
1375 uint32_t buffer_size = 32768;
1396 static const uint32_t mips_word_16_code[] = {
1447 int target_code_size = 0;
1448 const uint32_t *target_code_src =
NULL;
1450 switch (
bank->bus_width) {
1454 target_code_src = mips_word_16_code;
1455 target_code_size =
sizeof(mips_word_16_code);
1464 LOG_ERROR(
"Unsupported bank buswidth %u, can't do block memory writes",
1470 uint8_t *target_code;
1473 target_code = malloc(target_code_size);
1491 target_code_size, target_code);
1503 if (buffer_size <= 256) {
1509 "not enough working area available, can't do block memory writes");
1526 uint32_t thisrun_count = (
count > buffer_size) ? buffer_size :
count;
1534 buf_set_u32(reg_params[2].value, 0, 32, thisrun_count /
bank->bus_width);
1538 buf_set_u32(reg_params[7].value, 0, 32, 0xaaaaaaaa);
1540 buf_set_u32(reg_params[9].value, 0, 32, 0x55555555);
1544 write_algorithm->
address + ((target_code_size) - 4),
1545 10000, &mips32_info);
1558 count -= thisrun_count;
1589 uint32_t buffer_size = 32768;
1611 static const uint32_t armv4_5_word_32_code[] = {
1643 static const uint32_t armv4_5_word_16_code[] = {
1675 static const uint32_t armv7m_word_16_code[] = {
1697 static const uint32_t armv7m_word_16_code_dq7only[] = {
1726 static const uint32_t armv4_5_word_16_code_dq7only[] = {
1750 static const uint32_t armv4_5_word_8_code[] = {
1787 arm_algo = &armv7m_algo;
1793 arm_algo = &armv4_5_algo;
1799 int target_code_size = 0;
1800 const uint32_t *target_code_src =
NULL;
1802 switch (
bank->bus_width) {
1808 target_code_src = armv4_5_word_8_code;
1809 target_code_size =
sizeof(armv4_5_word_8_code);
1816 target_code_src = armv7m_word_16_code;
1817 target_code_size =
sizeof(armv7m_word_16_code);
1819 target_code_src = armv4_5_word_16_code;
1820 target_code_size =
sizeof(armv4_5_word_16_code);
1826 target_code_src = armv7m_word_16_code_dq7only;
1827 target_code_size =
sizeof(armv7m_word_16_code_dq7only);
1829 target_code_src = armv4_5_word_16_code_dq7only;
1830 target_code_size =
sizeof(armv4_5_word_16_code_dq7only);
1839 target_code_src = armv4_5_word_32_code;
1840 target_code_size =
sizeof(armv4_5_word_32_code);
1843 LOG_ERROR(
"Unsupported bank buswidth %u, can't do block memory writes",
1849 uint8_t *target_code;
1852 target_code = malloc(target_code_size);
1870 target_code_size, target_code);
1882 if (buffer_size <= 256) {
1888 "not enough working area available, can't do block memory writes");
1905 uint32_t thisrun_count = (
count > buffer_size) ? buffer_size :
count;
1913 buf_set_u32(reg_params[2].value, 0, 32, thisrun_count /
bank->bus_width);
1917 buf_set_u32(reg_params[7].value, 0, 32, 0xaaaaaaaa);
1919 buf_set_u32(reg_params[9].value, 0, 32, 0x55555555);
1923 write_algorithm->
address + ((target_code_size) - 4),
1937 count -= thisrun_count;
1980 ", address 0x%" PRIx32,
1981 bank->base, address);
1989 uint32_t wordcount, uint32_t address)
1997 uint32_t buffersize =
1999 uint32_t buffermask = buffersize-1;
2000 uint32_t bufferwsize = buffersize /
bank->bus_width;
2003 if (address & buffermask) {
2005 PRIx32
" not aligned to 2^%d boundary",
2011 if (wordcount > bufferwsize) {
2012 LOG_ERROR(
"Number of data words %" PRIu32
" exceeds available buffersize %" PRIu32,
2013 wordcount, buffersize);
2035 ", address 0x%" PRIx32,
2065 ", address 0x%" PRIx32
" failed.",
bank->base, address);
2096 ", address 0x%" PRIx32,
bank->base, address);
2104 uint32_t wordcount, uint32_t address)
2112 uint32_t buffersize =
2114 uint32_t buffermask = buffersize-1;
2115 uint32_t bufferwsize = buffersize /
bank->bus_width;
2118 if (address & buffermask) {
2120 ", address 0x%" PRIx32
" not aligned to 2^%d boundary",
2126 if (wordcount > bufferwsize) {
2127 LOG_ERROR(
"Number of data words %" PRIu32
" exceeds available buffersize %"
2128 PRIu32, wordcount, buffersize);
2162 ", address 0x%" PRIx32
", size 0x%" PRIx32,
bank->base, address,
2174 switch (cfi_info->
pri_id) {
2181 LOG_ERROR(
"cfi primary command set %i unsupported", cfi_info->
pri_id);
2189 uint32_t wordcount, uint32_t address)
2195 LOG_DEBUG(
"Buffer Writes Not Supported");
2199 switch (cfi_info->
pri_id) {
2206 LOG_ERROR(
"cfi primary command set %i unsupported", cfi_info->
pri_id);
2232 if (cfi_info->
qry[0] !=
'Q')
2236 read_p = address & ~(
bank->bus_width - 1);
2237 align = address - read_p;
2239 LOG_INFO(
"Fixup %d unaligned read head bytes", align);
2247 for (
unsigned int i = align; (i <
bank->bus_width) && (
count > 0); i++,
count--)
2248 *
buffer++ = current_word[i];
2250 read_p +=
bank->bus_width;
2259 read_p += align *
bank->bus_width;
2265 LOG_INFO(
"Fixup %" PRIu32
" unaligned read tail bytes",
count);
2273 for (
unsigned int i = 0; (i <
bank->bus_width) && (
count > 0); i++,
count--)
2274 *
buffer++ = current_word[i];
2289 uint8_t *swapped_buffer =
NULL;
2290 const uint8_t *real_buffer =
NULL;
2301 if (cfi_info->
qry[0] !=
'Q')
2305 write_p = address & ~(
bank->bus_width - 1);
2306 align = address - write_p;
2308 LOG_INFO(
"Fixup %d unaligned head bytes", align);
2316 for (
unsigned int i = align; (i <
bank->bus_width) && (
count > 0); i++,
count--)
2319 current_word[
bank->bus_width - i] = *
buffer++;
2321 current_word[i] = *
buffer++;
2326 write_p +=
bank->bus_width;
2330 swapped_buffer = malloc(
count & ~(
bank->bus_width - 1));
2331 switch (
bank->bus_width) {
2346 blk_count =
count & ~(
bank->bus_width - 1);
2347 switch (cfi_info->
pri_id) {
2357 LOG_ERROR(
"cfi primary command set %i unsupported", cfi_info->
pri_id);
2364 write_p += blk_count;
2371 uint32_t buffersize =
2374 (
bank->bus_width /
bank->chip_width);
2375 uint32_t buffermask = buffersize-1;
2376 uint32_t bufferwsize = buffersize /
bank->bus_width;
2379 while (
count >= (uint32_t)
bank->bus_width) {
2381 if ((write_p & 0xff) == 0) {
2382 LOG_INFO(
"Programming at 0x%08" PRIx32
", count 0x%08"
2383 PRIx32
" bytes remaining", write_p,
count);
2386 if ((bufferwsize > 0) && (
count >= buffersize) &&
2387 !(write_p & buffermask)) {
2391 write_p += buffersize;
2392 count -= buffersize;
2399 for (
unsigned int i = 0; i <
bank->bus_width; i++)
2400 current_word[i] = *
buffer++;
2406 write_p +=
bank->bus_width;
2414 if (swapped_buffer) {
2416 free(swapped_buffer);
2434 for (
unsigned int i = 0; (i <
bank->bus_width) && (
count > 0); i++,
count--)
2437 current_word[
bank->bus_width - i] = *
buffer++;
2439 current_word[i] = *
buffer++;
2466 LOG_DEBUG(
"swapping reversed erase region information on cmdset 0002 device");
2517 LOG_DEBUG(
"CFI qry returned: 0x%2.2x 0x%2.2x 0x%2.2x",
2518 cfi_info->
qry[0], cfi_info->
qry[1], cfi_info->
qry[2]);
2520 if ((cfi_info->
qry[0] !=
'Q') || (cfi_info->
qry[1] !=
'R') || (cfi_info->
qry[2] !=
'Y')) {
2524 LOG_ERROR(
"Could not probe bank: no QRY");
2535 unsigned int num_sectors = 0;
2537 uint32_t unlock1 = 0x555;
2538 uint32_t unlock2 = 0x2aa;
2547 cfi_info->
probed =
false;
2550 free(
bank->sectors);
2583 switch (
bank->chip_width) {
2597 LOG_ERROR(
"Unsupported bank chipwidth %u, can't probe memory",
2602 LOG_INFO(
"Flash Manufacturer/Device: 0x%04x 0x%04x",
2632 LOG_USER(
"Try workaround w/0x555 instead of 0x55 to get QRY.");
2651 LOG_DEBUG(
"qry: '%c%c%c', pri_id: 0x%4.4x, pri_addr: 0x%4.4x, alt_id: "
2652 "0x%4.4x, alt_addr: 0x%4.4x", cfi_info->
qry[0], cfi_info->
qry[1],
2710 LOG_DEBUG(
"size: 0x%" PRIx32
", interface desc: %i, max buffer write size: 0x%x",
2725 "erase region[%i]: %" PRIu32
" blocks of size 0x%" PRIx32
"",
2736 switch (cfi_info->
pri_id) {
2754 LOG_ERROR(
"cfi primary command set %i unsupported", cfi_info->
pri_id);
2766 LOG_DEBUG(
"Vcc min: %x.%x, Vcc max: %x.%x, Vpp min: %u.%x, Vpp max: %u.%x",
2772 LOG_DEBUG(
"typ. word write timeout: %u us, typ. buf write timeout: %u us, "
2773 "typ. block erase timeout: %u ms, typ. chip erase timeout: %u ms",
2777 LOG_DEBUG(
"max. word write timeout: %u us, max. buf write timeout: %u us, "
2778 "max. block erase timeout: %u ms, max. chip erase timeout: %u ms",
2794 LOG_DEBUG(
"calculated word write timeout: %u ms, buf write timeout: %u ms, "
2795 "block erase timeout: %u ms, chip erase timeout: %u ms",
2800 switch (cfi_info->
pri_id) {
2811 LOG_ERROR(
"cfi primary command set %i unsupported", cfi_info->
pri_id);
2816 LOG_WARNING(
"configuration specifies 0x%" PRIx32
" size, but a 0x%" PRIx32
2817 " size flash was found",
bank->size, cfi_info->
dev_size);
2822 bank->num_sectors = 1;
2825 bank->sectors[sector].offset = 0x0;
2826 bank->sectors[sector].size =
bank->size;
2827 bank->sectors[sector].is_erased = -1;
2828 bank->sectors[sector].is_protected = -1;
2835 bank->num_sectors = num_sectors;
2841 bank->sectors[sector].size =
2843 *
bank->bus_width /
bank->chip_width;
2845 bank->sectors[sector].is_erased = -1;
2846 bank->sectors[sector].is_protected = -1;
2852 "CFI size is 0x%" PRIx32
", but total sector size is 0x%" PRIx32
"",
2885 for (
unsigned int i = 0; i <
bank->num_sectors; i++) {
2886 uint8_t block_status;
2891 if (block_status & 1)
2892 bank->sectors[i].is_protected = 1;
2894 bank->sectors[i].is_protected = 0;
2914 for (
unsigned int i = 0; i <
bank->num_sectors; i++) {
2915 uint8_t block_status;
2920 if (block_status & 1)
2921 bank->sectors[i].is_protected = 1;
2923 bank->sectors[i].is_protected = 0;
2938 if (cfi_info->
qry[0] !=
'Q')
2941 switch (cfi_info->
pri_id) {
2948 LOG_ERROR(
"cfi primary command set %i unsupported", cfi_info->
pri_id);
2959 if (cfi_info->
qry[0] == 0xff) {
2973 "0x%4.4x, alt_id: 0x%4.4x, alt_addr: 0x%4.4x\n",
2974 cfi_info->
qry[0], cfi_info->
qry[1], cfi_info->
qry[2],
2978 "Vpp min: %u.%x, Vpp max: %u.%x\n",
2985 "typ. buf write timeout: %u us, "
2986 "typ. block erase timeout: %u ms, "
2987 "typ. chip erase timeout: %u ms\n",
2994 "max. buf write timeout: %u us, max. "
2995 "block erase timeout: %u ms, max. chip erase timeout: %u ms\n",
3008 "max buffer write size: 0x%x\n",
3013 switch (cfi_info->
pri_id) {
3022 LOG_ERROR(
"cfi primary command set %i unsupported", cfi_info->
pri_id);
3039 .flash_bank_command = cfi_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.
static bool is_arm(struct arm *arm)
static struct arm * target_to_arm(const struct target *target)
Convert target handle to generic ARM target state handle.
static struct armv7m_common * target_to_armv7m(struct target *target)
#define ARMV7M_COMMON_MAGIC
static bool is_armv7m(const struct armv7m_common *armv7m)
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 int cfi_query_u32(struct flash_bank *bank, int sector, uint32_t offset, uint32_t *val)
static int cfi_intel_info(struct flash_bank *bank, struct command_invocation *cmd)
static int cfi_intel_write_words(struct flash_bank *bank, const uint8_t *word, uint32_t wordcount, uint32_t address)
static int cfi_query_string(struct flash_bank *bank, int address)
static int cfi_intel_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
static int cfi_target_write_memory(struct flash_bank *bank, target_addr_t addr, uint32_t count, const uint8_t *buffer)
static int cfi_read_intel_pri_ext(struct flash_bank *bank)
static int cfi_spansion_info(struct flash_bank *bank, struct command_invocation *cmd)
static void cfi_fixup_0002_polling_bits(struct flash_bank *bank, const void *param)
#define CFI_MAX_INTEL_CODESIZE
static const struct cfi_fixup cfi_0002_fixups[]
static int cfi_intel_protect(struct flash_bank *bank, int set, unsigned int first, unsigned int last)
static int cfi_intel_protect_check(struct flash_bank *bank)
static int cfi_read(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
static void cfi_fixup(struct flash_bank *bank, const struct cfi_fixup *fixups)
uint32_t cfi_flash_address(struct flash_bank *bank, int sector, uint32_t offset)
static uint32_t cfi_command_val(struct flash_bank *bank, uint8_t cmd)
int cfi_write_word(struct flash_bank *bank, uint8_t *word, uint32_t address)
static int cfi_spansion_write_word(struct flash_bank *bank, uint8_t *word, uint32_t address)
int cfi_protect_check(struct flash_bank *bank)
int cfi_probe(struct flash_bank *bank)
static int cfi_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
static int cfi_query_u8(struct flash_bank *bank, int sector, uint32_t offset, uint8_t *val)
int cfi_auto_probe(struct flash_bank *bank)
static void cfi_fixup_0002_unlock_addresses(struct flash_bank *bank, const void *param)
int cfi_get_info(struct flash_bank *bank, struct command_invocation *cmd)
static void cfi_fixup_0002_erase_regions(struct flash_bank *bank, const void *param)
int cfi_reset(struct flash_bank *bank)
static int cfi_spansion_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
static int cfi_query_u16(struct flash_bank *bank, int sector, uint32_t offset, uint16_t *val)
int cfi_target_read_memory(struct flash_bank *bank, target_addr_t addr, uint32_t count, uint8_t *buffer)
static int cfi_spansion_protect_check(struct flash_bank *bank)
static int cfi_read_0002_pri_ext(struct flash_bank *bank)
static int cfi_spansion_write_block_mips(struct flash_bank *bank, const uint8_t *buffer, uint32_t address, uint32_t count)
int cfi_protect(struct flash_bank *bank, int set, unsigned int first, unsigned int last)
FLASH_BANK_COMMAND_HANDLER(cfi_flash_bank_command)
int cfi_send_command(struct flash_bank *bank, uint8_t cmd, uint32_t address)
int cfi_flash_bank_cmd(struct flash_bank *bank, unsigned int argc, const char **argv)
static int cfi_get_u8(struct flash_bank *bank, int sector, uint32_t offset, uint8_t *val)
static void cfi_command(struct flash_bank *bank, uint8_t cmd, uint8_t *cmd_buf)
static void cfi_fixup_reversed_erase_regions(struct flash_bank *bank, const void *param)
static void cfi_intel_clear_status_register(struct flash_bank *bank)
static int cfi_intel_write_word(struct flash_bank *bank, uint8_t *word, uint32_t address)
const struct flash_driver cfi_flash
static int cfi_spansion_write_block(struct flash_bank *bank, const uint8_t *buffer, uint32_t address, uint32_t count)
int cfi_spansion_wait_status_busy(struct flash_bank *bank, int timeout)
static void cfi_fixup_0002_write_buffer(struct flash_bank *bank, const void *param)
static int cfi_intel_write_block(struct flash_bank *bank, const uint8_t *buffer, uint32_t address, uint32_t count)
static int cfi_write_words(struct flash_bank *bank, const uint8_t *word, uint32_t wordcount, uint32_t address)
int cfi_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
int cfi_spansion_unlock_seq(struct flash_bank *bank)
static int cfi_read_spansion_pri_ext(struct flash_bank *bank)
static int cfi_spansion_write_words(struct flash_bank *bank, const uint8_t *word, uint32_t wordcount, uint32_t address)
static int cfi_read_atmel_pri_ext(struct flash_bank *bank)
static const struct cfi_fixup cfi_0001_fixups[]
static const int cfi_status_poll_mask_dq6_dq7
static int cfi_intel_wait_status_busy(struct flash_bank *bank, int timeout, uint8_t *val)
#define CFI_STATUS_POLL_MASK_DQ6_DQ7
#define CFI_MAX_BUS_WIDTH
#define CFI_MAX_CHIP_WIDTH
#define CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
void command_print_sameline(struct command_invocation *cmd, const char *format,...)
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
#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...
#define ERROR_FLASH_OPER_UNSUPPORTED
#define ERROR_FLASH_BANK_INVALID
#define ERROR_FLASH_SECTOR_INVALID
#define ERROR_FLASH_BANK_NOT_PROBED
#define ERROR_FLASH_OPERATION_FAILED
#define ERROR_FLASH_DST_OUT_OF_BANK
int default_flash_blank_check(struct flash_bank *bank)
Provides default erased-bank check handling.
void default_flash_free_driver_priv(struct flash_bank *bank)
Deallocates bank->driver_priv.
void alive_sleep(uint64_t ms)
#define LOG_USER(expr ...)
#define LOG_WARNING(expr ...)
#define LOG_ERROR(expr ...)
#define LOG_INFO(expr ...)
#define LOG_DEBUG(expr ...)
#define MIPS32_ADDI(isa, tar, src, val)
#define MIPS32_SRL(isa, reg, src, off)
#define MIPS32_XOR(isa, reg, val1, val2)
#define MIPS32_COMMON_MAGIC
#define MIPS32_SDBBP(isa)
#define MIPS32_BNE(isa, src, tar, off)
#define MIPS32_BEQ(isa, src, tar, off)
#define MIPS32_LHU(isa, reg, off, base)
#define MIPS32_SH(isa, reg, off, base)
#define MIPS32_LUI(isa, reg, val)
#define MIPS32_AND(isa, dst, src, tar)
#define MIPS32_ORI(isa, tar, src, val)
#define MIPS32_B(isa, off)
void cfi_fixup_non_cfi(struct flash_bank *bank)
target_addr_t addr
Start address to search for the control block.
unsigned int common_magic
enum arm_state core_state
unsigned int common_magic
void(* fixup)(struct flash_bank *bank, const void *param)
uint8_t block_erase_timeout_typ
unsigned int buf_write_timeout
uint8_t num_erase_regions
int(* read_mem)(struct flash_bank *bank, target_addr_t addr, uint32_t count, uint8_t *buffer)
uint8_t chip_erase_timeout_max
uint16_t max_buf_write_size
unsigned int block_erase_timeout
uint32_t * erase_region_info
uint8_t word_write_timeout_max
uint8_t word_write_timeout_typ
unsigned int chip_erase_timeout
enum target_endianness endianness
uint8_t buf_write_timeout_typ
uint8_t chip_erase_timeout_typ
uint8_t buf_write_timeout_max
int(* write_mem)(struct flash_bank *bank, target_addr_t addr, uint32_t count, const uint8_t *buffer)
uint8_t block_erase_timeout_max
unsigned int word_write_timeout
uint16_t blk_status_reg_mask
uint8_t user_prot_reg_size
uint8_t fact_prot_reg_size
uint8_t num_protection_fields
uint8_t suspend_cmd_support
uint8_t tmp_blk_unprotected
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.
enum mips32_isa_mode isa_mode
unsigned int common_magic
void target_free_all_working_areas(struct target *target)
int target_write_buffer(struct target *target, target_addr_t address, uint32_t size, const 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.
int target_write_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
Write count items of size bytes to the memory of target at the address given.
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_alloc_working_area_try(struct target *target, uint32_t size, struct working_area **area)
uint16_t target_buffer_get_u16(struct target *target, const uint8_t *buffer)
int target_read_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer)
Read count items of size bytes from the memory of target at the address given.
void target_buffer_set_u32_array(struct target *target, uint8_t *buffer, uint32_t count, const uint32_t *srcbuf)
uint32_t target_buffer_get_u32(struct target *target, const uint8_t *buffer)
const char * target_type_name(const struct target *target)
Get the target type name.
#define ERROR_TARGET_NOT_HALTED
#define ERROR_TARGET_RESOURCE_NOT_AVAILABLE
static void buf_bswap16(uint8_t *dst, const uint8_t *src, size_t len)
Byte-swap buffer 16-bit.
#define DIV_ROUND_UP(m, n)
Rounds m up to the nearest multiple of n using division.
static void buf_bswap32(uint8_t *dst, const uint8_t *src, size_t len)
Byte-swap buffer 32-bit.