Create separate memory read/write functions which facilitate access
to the CFI NOR, so that they can be replaced by controller-specific
functions if necessary. This would become necessary when implementing
support for e.g. HyperFlash controllers, which do not directly map
the HyperFlash into the address space.
Change-Id: I1bba1edfd397cb37bfedb43efe2dd03feb26a375
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Reviewed-on: http://openocd.zylin.com/5145
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
+static int cfi_target_write_memory(struct target *target, target_addr_t addr,
+ uint32_t size, uint32_t count,
+ const uint8_t *buffer)
+{
+ return target_write_memory(target, addr, size, count, buffer);
+}
+
+static int cfi_target_read_memory(struct target *target, target_addr_t addr,
+ uint32_t size, uint32_t count,
+ uint8_t *buffer)
+{
+ return target_read_memory(target, addr, size, count, buffer);
+}
+
static void cfi_command(struct flash_bank *bank, uint8_t cmd, uint8_t *cmd_buf)
{
int i;
static void cfi_command(struct flash_bank *bank, uint8_t cmd, uint8_t *cmd_buf)
{
int i;
uint8_t command[CFI_MAX_BUS_WIDTH];
cfi_command(bank, cmd, command);
uint8_t command[CFI_MAX_BUS_WIDTH];
cfi_command(bank, cmd, command);
- return target_write_memory(bank->target, address, bank->bus_width, 1, command);
+ return cfi_target_write_memory(bank->target, address, bank->bus_width, 1, command);
}
/* read unsigned 8-bit value from the bank
}
/* read unsigned 8-bit value from the bank
uint8_t data[CFI_MAX_BUS_WIDTH];
int retval;
uint8_t data[CFI_MAX_BUS_WIDTH];
int retval;
- retval = target_read_memory(target, flash_address(bank, sector, offset),
+ retval = cfi_target_read_memory(target, flash_address(bank, sector, offset),
bank->bus_width, 1, data);
if (retval != ERROR_OK)
return retval;
bank->bus_width, 1, data);
if (retval != ERROR_OK)
return retval;
- retval = target_read_memory(target, flash_address(bank, sector, offset),
+ retval = cfi_target_read_memory(target, flash_address(bank, sector, offset),
bank->bus_width, 1, data);
if (retval != ERROR_OK)
return retval;
bank->bus_width, 1, data);
if (retval != ERROR_OK)
return retval;
if (cfi_info->x16_as_x8) {
uint8_t i;
for (i = 0; i < 2; i++) {
if (cfi_info->x16_as_x8) {
uint8_t i;
for (i = 0; i < 2; i++) {
- retval = target_read_memory(target, flash_address(bank, sector, offset + i),
+ retval = cfi_target_read_memory(target, flash_address(bank, sector, offset + i),
bank->bus_width, 1, &data[i * bank->bus_width]);
if (retval != ERROR_OK)
return retval;
}
} else {
bank->bus_width, 1, &data[i * bank->bus_width]);
if (retval != ERROR_OK)
return retval;
}
} else {
- retval = target_read_memory(target, flash_address(bank, sector, offset),
+ retval = cfi_target_read_memory(target, flash_address(bank, sector, offset),
bank->bus_width, 2, data);
if (retval != ERROR_OK)
return retval;
bank->bus_width, 2, data);
if (retval != ERROR_OK)
return retval;
if (cfi_info->x16_as_x8) {
uint8_t i;
for (i = 0; i < 4; i++) {
if (cfi_info->x16_as_x8) {
uint8_t i;
for (i = 0; i < 4; i++) {
- retval = target_read_memory(target, flash_address(bank, sector, offset + i),
+ retval = cfi_target_read_memory(target, flash_address(bank, sector, offset + i),
bank->bus_width, 1, &data[i * bank->bus_width]);
if (retval != ERROR_OK)
return retval;
}
} else {
bank->bus_width, 1, &data[i * bank->bus_width]);
if (retval != ERROR_OK)
return retval;
}
} else {
- retval = target_read_memory(target, flash_address(bank, sector, offset),
+ retval = cfi_target_read_memory(target, flash_address(bank, sector, offset),
bank->bus_width, 4, data);
if (retval != ERROR_OK)
return retval;
bank->bus_width, 4, data);
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
- retval = target_write_memory(target, address, bank->bus_width, 1, word);
+ retval = cfi_target_write_memory(target, address, bank->bus_width, 1, word);
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
- retval = target_write_memory(target, address, bank->bus_width, bufferwsize, word);
+ retval = cfi_target_write_memory(target, address, bank->bus_width, bufferwsize, word);
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
- retval = target_write_memory(target, address, bank->bus_width, 1, word);
+ retval = cfi_target_write_memory(target, address, bank->bus_width, 1, word);
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
- retval = target_write_memory(target, address, bank->bus_width, bufferwsize, word);
+ retval = cfi_target_write_memory(target, address, bank->bus_width, bufferwsize, word);
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
LOG_INFO("Fixup %d unaligned read head bytes", align);
/* read a complete word from flash */
LOG_INFO("Fixup %d unaligned read head bytes", align);
/* read a complete word from flash */
- retval = target_read_memory(target, read_p, bank->bus_width, 1, current_word);
+ retval = cfi_target_read_memory(target, read_p, bank->bus_width, 1, current_word);
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
align = count / bank->bus_width;
if (align) {
align = count / bank->bus_width;
if (align) {
- retval = target_read_memory(target, read_p, bank->bus_width, align, buffer);
+ retval = cfi_target_read_memory(target, read_p, bank->bus_width, align, buffer);
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
LOG_INFO("Fixup %" PRIu32 " unaligned read tail bytes", count);
/* read a complete word from flash */
LOG_INFO("Fixup %" PRIu32 " unaligned read tail bytes", count);
/* read a complete word from flash */
- retval = target_read_memory(target, read_p, bank->bus_width, 1, current_word);
+ retval = cfi_target_read_memory(target, read_p, bank->bus_width, 1, current_word);
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
LOG_INFO("Fixup %d unaligned head bytes", align);
/* read a complete word from flash */
LOG_INFO("Fixup %d unaligned head bytes", align);
/* read a complete word from flash */
- retval = target_read_memory(target, write_p, bank->bus_width, 1, current_word);
+ retval = cfi_target_read_memory(target, write_p, bank->bus_width, 1, current_word);
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
LOG_INFO("Fixup %" PRId32 " unaligned tail bytes", count);
/* read a complete word from flash */
LOG_INFO("Fixup %" PRId32 " unaligned tail bytes", count);
/* read a complete word from flash */
- retval = target_read_memory(target, write_p, bank->bus_width, 1, current_word);
+ retval = cfi_target_read_memory(target, write_p, bank->bus_width, 1, current_word);
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
- retval = target_read_memory(target, flash_address(bank, 0, 0x00),
+ retval = cfi_target_read_memory(target, flash_address(bank, 0, 0x00),
bank->bus_width, 1, value_buf0);
if (retval != ERROR_OK)
return retval;
bank->bus_width, 1, value_buf0);
if (retval != ERROR_OK)
return retval;
- retval = target_read_memory(target, flash_address(bank, 0, 0x01),
+ retval = cfi_target_read_memory(target, flash_address(bank, 0, 0x01),
bank->bus_width, 1, value_buf1);
if (retval != ERROR_OK)
return retval;
bank->bus_width, 1, value_buf1);
if (retval != ERROR_OK)
return retval;
Linking to existing account procedure
If you already have an account and want to add another login method
you
MUST first sign in with your existing account and
then change URL to read
https://review.openocd.org/login/?link
to get to this page again but this time it'll work for linking. Thank you.
SSH host keys fingerprints
1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=.. |
|+o.. . |
|*.o . . |
|+B . . . |
|Bo. = o S |
|Oo.+ + = |
|oB=.* = . o |
| =+=.+ + E |
|. .=o . o |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)