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 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);
2222 LOG_DEBUG(
"reading buffer of %i byte at 0x%8.8x",
2233 if (cfi_info->
qry[0] !=
'Q')
2237 read_p = address & ~(
bank->bus_width - 1);
2238 align = address - read_p;
2240 LOG_INFO(
"Fixup %d unaligned read head bytes", align);
2248 for (
unsigned int i = align; (i <
bank->bus_width) && (
count > 0); i++,
count--)
2249 *
buffer++ = current_word[i];
2251 read_p +=
bank->bus_width;
2260 read_p += align *
bank->bus_width;
2266 LOG_INFO(
"Fixup %" PRIu32
" unaligned read tail bytes",
count);
2274 for (
unsigned int i = 0; (i <
bank->bus_width) && (
count > 0); i++,
count--)
2275 *
buffer++ = current_word[i];
2290 uint8_t *swapped_buffer =
NULL;
2291 const uint8_t *real_buffer =
NULL;
2302 if (cfi_info->
qry[0] !=
'Q')
2306 write_p = address & ~(
bank->bus_width - 1);
2307 align = address - write_p;
2309 LOG_INFO(
"Fixup %d unaligned head bytes", align);
2317 for (
unsigned int i = align; (i <
bank->bus_width) && (
count > 0); i++,
count--)
2320 current_word[
bank->bus_width - i] = *
buffer++;
2322 current_word[i] = *
buffer++;
2327 write_p +=
bank->bus_width;
2331 swapped_buffer = malloc(
count & ~(
bank->bus_width - 1));
2332 switch (
bank->bus_width) {
2347 blk_count =
count & ~(
bank->bus_width - 1);
2348 switch (cfi_info->
pri_id) {
2358 LOG_ERROR(
"cfi primary command set %i unsupported", cfi_info->
pri_id);
2365 write_p += blk_count;
2372 uint32_t buffersize =
2375 (
bank->bus_width /
bank->chip_width);
2376 uint32_t buffermask = buffersize-1;
2377 uint32_t bufferwsize = buffersize /
bank->bus_width;
2380 while (
count >= (uint32_t)
bank->bus_width) {
2382 if ((write_p & 0xff) == 0) {
2383 LOG_INFO(
"Programming at 0x%08" PRIx32
", count 0x%08"
2384 PRIx32
" bytes remaining", write_p,
count);
2387 if ((bufferwsize > 0) && (
count >= buffersize) &&
2388 !(write_p & buffermask)) {
2392 write_p += buffersize;
2393 count -= buffersize;
2400 for (
unsigned int i = 0; i <
bank->bus_width; i++)
2401 current_word[i] = *
buffer++;
2407 write_p +=
bank->bus_width;
2415 if (swapped_buffer) {
2417 free(swapped_buffer);
2435 for (
unsigned int i = 0; (i <
bank->bus_width) && (
count > 0); i++,
count--)
2438 current_word[
bank->bus_width - i] = *
buffer++;
2440 current_word[i] = *
buffer++;
2467 LOG_DEBUG(
"swapping reversed erase region information on cmdset 0002 device");
2518 LOG_DEBUG(
"CFI qry returned: 0x%2.2x 0x%2.2x 0x%2.2x",
2519 cfi_info->
qry[0], cfi_info->
qry[1], cfi_info->
qry[2]);
2521 if ((cfi_info->
qry[0] !=
'Q') || (cfi_info->
qry[1] !=
'R') || (cfi_info->
qry[2] !=
'Y')) {
2525 LOG_ERROR(
"Could not probe bank: no QRY");
2536 unsigned int num_sectors = 0;
2538 uint32_t unlock1 = 0x555;
2539 uint32_t unlock2 = 0x2aa;
2548 cfi_info->
probed =
false;
2551 free(
bank->sectors);
2584 switch (
bank->chip_width) {
2598 LOG_ERROR(
"Unsupported bank chipwidth %u, can't probe memory",
2603 LOG_INFO(
"Flash Manufacturer/Device: 0x%04x 0x%04x",
2633 LOG_USER(
"Try workaround w/0x555 instead of 0x55 to get QRY.");
2652 LOG_DEBUG(
"qry: '%c%c%c', pri_id: 0x%4.4x, pri_addr: 0x%4.4x, alt_id: "
2653 "0x%4.4x, alt_addr: 0x%4.4x", cfi_info->
qry[0], cfi_info->
qry[1],
2711 LOG_DEBUG(
"size: 0x%" PRIx32
", interface desc: %i, max buffer write size: 0x%x",
2726 "erase region[%i]: %" PRIu32
" blocks of size 0x%" PRIx32
"",
2737 switch (cfi_info->
pri_id) {
2755 LOG_ERROR(
"cfi primary command set %i unsupported", cfi_info->
pri_id);
2767 LOG_DEBUG(
"Vcc min: %x.%x, Vcc max: %x.%x, Vpp min: %u.%x, Vpp max: %u.%x",
2773 LOG_DEBUG(
"typ. word write timeout: %u us, typ. buf write timeout: %u us, "
2774 "typ. block erase timeout: %u ms, typ. chip erase timeout: %u ms",
2778 LOG_DEBUG(
"max. word write timeout: %u us, max. buf write timeout: %u us, "
2779 "max. block erase timeout: %u ms, max. chip erase timeout: %u ms",
2795 LOG_DEBUG(
"calculated word write timeout: %u ms, buf write timeout: %u ms, "
2796 "block erase timeout: %u ms, chip erase timeout: %u ms",
2801 switch (cfi_info->
pri_id) {
2812 LOG_ERROR(
"cfi primary command set %i unsupported", cfi_info->
pri_id);
2817 LOG_WARNING(
"configuration specifies 0x%" PRIx32
" size, but a 0x%" PRIx32
2818 " size flash was found",
bank->size, cfi_info->
dev_size);
2823 bank->num_sectors = 1;
2826 bank->sectors[sector].offset = 0x0;
2827 bank->sectors[sector].size =
bank->size;
2828 bank->sectors[sector].is_erased = -1;
2829 bank->sectors[sector].is_protected = -1;
2836 bank->num_sectors = num_sectors;
2842 bank->sectors[sector].size =
2844 *
bank->bus_width /
bank->chip_width;
2846 bank->sectors[sector].is_erased = -1;
2847 bank->sectors[sector].is_protected = -1;
2853 "CFI size is 0x%" PRIx32
", but total sector size is 0x%" PRIx32
"",
2886 for (
unsigned int i = 0; i <
bank->num_sectors; i++) {
2887 uint8_t block_status;
2892 if (block_status & 1)
2893 bank->sectors[i].is_protected = 1;
2895 bank->sectors[i].is_protected = 0;
2915 for (
unsigned int i = 0; i <
bank->num_sectors; i++) {
2916 uint8_t block_status;
2921 if (block_status & 1)
2922 bank->sectors[i].is_protected = 1;
2924 bank->sectors[i].is_protected = 0;
2939 if (cfi_info->
qry[0] !=
'Q')
2942 switch (cfi_info->
pri_id) {
2949 LOG_ERROR(
"cfi primary command set %i unsupported", cfi_info->
pri_id);
2960 if (cfi_info->
qry[0] == 0xff) {
2974 "0x%4.4x, alt_id: 0x%4.4x, alt_addr: 0x%4.4x\n",
2975 cfi_info->
qry[0], cfi_info->
qry[1], cfi_info->
qry[2],
2979 "Vpp min: %u.%x, Vpp max: %u.%x\n",
2986 "typ. buf write timeout: %u us, "
2987 "typ. block erase timeout: %u ms, "
2988 "typ. chip erase timeout: %u ms\n",
2995 "max. buf write timeout: %u us, max. "
2996 "block erase timeout: %u ms, max. chip erase timeout: %u ms\n",
3009 "max buffer write size: 0x%x\n",
3014 switch (cfi_info->
pri_id) {
3023 LOG_ERROR(
"cfi primary command set %i unsupported", cfi_info->
pri_id);
3040 .flash_bank_command = cfi_flash_bank_command,
static struct aice_port_param_s param
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(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 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 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)
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
uint8_t num_erase_regions
int(* read_mem)(struct flash_bank *bank, target_addr_t addr, uint32_t count, uint8_t *buffer)
unsigned buf_write_timeout
uint8_t chip_erase_timeout_max
uint16_t max_buf_write_size
uint32_t * erase_region_info
unsigned block_erase_timeout
unsigned chip_erase_timeout
uint8_t word_write_timeout_max
uint8_t word_write_timeout_typ
enum target_endianness endianness
uint8_t buf_write_timeout_typ
uint8_t chip_erase_timeout_typ
unsigned word_write_timeout
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
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_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_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)
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(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.