autoprobing can fail and this error has to be
reported up the call stack.
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
-struct flash_bank *get_flash_bank_by_name(const char *name)
+int get_flash_bank_by_name(const char *name, struct flash_bank **bank_result)
{
struct flash_bank *bank;
int retval;
{
struct flash_bank *bank;
int retval;
if (retval != ERROR_OK)
{
LOG_ERROR("auto_probe failed %d\n", retval);
if (retval != ERROR_OK)
{
LOG_ERROR("auto_probe failed %d\n", retval);
+ *bank_result = bank;
+ return ERROR_OK;
}
int get_flash_bank_by_num(int num, struct flash_bank **bank)
}
int get_flash_bank_by_num(int num, struct flash_bank **bank)
-/* lookup flash bank by address */
-struct flash_bank *get_flash_bank_by_addr(struct target *target, uint32_t addr)
+/* lookup flash bank by address, bank not found is success, but
+ * result_bank is set to NULL. */
+int get_flash_bank_by_addr(struct target *target, uint32_t addr, bool check, struct flash_bank **result_bank)
if (retval != ERROR_OK)
{
LOG_ERROR("auto_probe failed %d\n", retval);
if (retval != ERROR_OK)
{
LOG_ERROR("auto_probe failed %d\n", retval);
}
/* check whether address belongs to this flash bank */
if ((addr >= c->base) && (addr <= c->base + (c->size - 1)) && target == c->target)
}
/* check whether address belongs to this flash bank */
if ((addr >= c->base) && (addr <= c->base + (c->size - 1)) && target == c->target)
+ {
+ *result_bank = c;
+ return ERROR_OK;
+ }
- LOG_ERROR("No flash at address 0x%08" PRIx32 "\n", addr);
- return NULL;
+ *result_bank = NULL;
+ if (check)
+ {
+ LOG_ERROR("No flash at address 0x%08" PRIx32 "\n", addr);
+ return ERROR_FAIL;
+ }
+ return ERROR_OK;
}
int default_flash_mem_blank_check(struct flash_bank *bank)
}
int default_flash_mem_blank_check(struct flash_bank *bank)
- if ((c = get_flash_bank_by_addr(target, addr)) == NULL)
- return ERROR_FLASH_DST_OUT_OF_BANK; /* no corresponding bank found */
+ int retval = get_flash_bank_by_addr(target, addr, true, &c);
+ if (retval != ERROR_OK)
+ return retval;
if (c->size == 0 || c->num_sectors == 0)
{
if (c->size == 0 || c->num_sectors == 0)
{
}
/* find the corresponding flash bank */
}
/* find the corresponding flash bank */
- if ((c = get_flash_bank_by_addr(target, run_address)) == NULL)
+ int retval;
+ retval = get_flash_bank_by_addr(target, run_address, false, &c);
+ if (retval != ERROR_OK)
+ return retval;
+ if (c == NULL)
{
section++; /* and skip it */
section_offset = 0;
{
section++; /* and skip it */
section_offset = 0;
* bank number: when two str9x banks are defined, then 'str9x.1' refers
* to the second.
*/
* bank number: when two str9x banks are defined, then 'str9x.1' refers
* to the second.
*/
-struct flash_bank *get_flash_bank_by_name(const char *name);
+int get_flash_bank_by_name(const char *name, struct flash_bank **bank_result);
/**
* Returns the flash bank specified by @a name, which matches the
* driver name and a suffix (option) specify the driver-specific
/**
* Returns the flash bank specified by @a name, which matches the
* driver name and a suffix (option) specify the driver-specific
* Returns the flash bank located at a specified address.
* @param target The target, presumed to contain one or more banks.
* @param addr An address that is within the range of the bank.
* Returns the flash bank located at a specified address.
* @param target The target, presumed to contain one or more banks.
* @param addr An address that is within the range of the bank.
+ * @param check return ERROR_OK and result_bank NULL if the bank does not exist
* @returns The struct flash_bank located at @a addr, or NULL.
*/
* @returns The struct flash_bank located at @a addr, or NULL.
*/
-struct flash_bank *get_flash_bank_by_addr(struct target *target, uint32_t addr);
+int get_flash_bank_by_addr(struct target *target, uint32_t addr, bool check, struct flash_bank **result_bank);
#endif // FLASH_NOR_CORE_H
#endif // FLASH_NOR_CORE_H
struct flash_bank **bank)
{
const char *name = CMD_ARGV[name_index];
struct flash_bank **bank)
{
const char *name = CMD_ARGV[name_index];
- *bank = get_flash_bank_by_name(name);
+ int retval = get_flash_bank_by_name(name, bank);
+ if (retval != ERROR_OK)
+ return retval;
if (*bank)
return ERROR_OK;
if (*bank)
return ERROR_OK;
return ERROR_COMMAND_SYNTAX_ERROR;
}
return ERROR_COMMAND_SYNTAX_ERROR;
}
- p = get_flash_bank_by_addr(target, address);
- if (p == NULL)
- {
- return ERROR_FAIL;
- }
+ retval = get_flash_bank_by_addr(target, address, true, &p);
+ if (retval != ERROR_OK)
+ return retval;
/* We can't know if we did a resume + halt, in which case we no longer know the erased state */
flash_set_dirty();
/* We can't know if we did a resume + halt, in which case we no longer know the erased state */
flash_set_dirty();
{
struct flash_bank *bank;
{
struct flash_bank *bank;
- bank = get_flash_bank_by_addr(target, address);
- if (bank == NULL)
- {
- retval = ERROR_FAIL;
+ retval = get_flash_bank_by_addr(target, address, true, &bank );
+ if (retval != ERROR_OK)
cur_size = MIN((count * wordsize - wrote), chunksize);
err = flash_driver_write(bank, chunk, address - bank->base + wrote, cur_size);
cur_size = MIN((count * wordsize - wrote), chunksize);
err = flash_driver_write(bank, chunk, address - bank->base + wrote, cur_size);
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)