Use target_addr_t exclusively for comparison of sector boudaries and
address range.
Use the last addres for both address range end and sector end.
It avoids problems with a flash bank mapped at the very end of
target address space.
Change-Id: Idf97c837453d97cbc4cf8a1c76ad799f4142f19e
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4985
Tested-by: jenkins
Reviewed-by: Tim Newsome <tim@sifive.com>
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
{
struct flash_bank *c;
struct flash_sector *block_array;
{
struct flash_bank *c;
struct flash_sector *block_array;
- target_addr_t last_addr = addr + length; /* first address AFTER end */
+ target_addr_t last_addr = addr + length - 1; /* the last address of range */
int first = -1;
int last = -1;
int i;
int first = -1;
int last = -1;
int i;
}
/* check whether it all fits in this bank */
}
/* check whether it all fits in this bank */
- if (addr + length - 1 > c->base + c->size - 1) {
+ if (last_addr > c->base + c->size - 1) {
LOG_ERROR("Flash access does not fit into bank.");
return ERROR_FLASH_DST_BREAKS_ALIGNMENT;
}
LOG_ERROR("Flash access does not fit into bank.");
return ERROR_FLASH_DST_BREAKS_ALIGNMENT;
}
num_blocks = c->num_sectors;
}
num_blocks = c->num_sectors;
}
- addr -= c->base;
- last_addr -= c->base;
-
for (i = 0; i < num_blocks; i++) {
struct flash_sector *f = &block_array[i];
for (i = 0; i < num_blocks; i++) {
struct flash_sector *f = &block_array[i];
- uint32_t end = f->offset + f->size;
+ target_addr_t sector_addr = c->base + f->offset;
+ target_addr_t sector_last_addr = sector_addr + f->size - 1;
/* start only on a sector boundary */
if (first < 0) {
/* scanned past the first sector? */
/* start only on a sector boundary */
if (first < 0) {
/* scanned past the first sector? */
+ if (addr < sector_addr)
break;
/* is this the first sector? */
break;
/* is this the first sector? */
+ if (addr == sector_addr)
first = i;
/* Does this need head-padding? If so, pad and warn;
first = i;
/* Does this need head-padding? If so, pad and warn;
* ever know if that data was in use. The warning
* should help users sort out messes later.
*/
* ever know if that data was in use. The warning
* should help users sort out messes later.
*/
- else if (addr < end && pad_reason) {
+ else if (addr <= sector_last_addr && pad_reason) {
/* FIXME say how many bytes (e.g. 80 KB) */
LOG_WARNING("Adding extra %s range, "
/* FIXME say how many bytes (e.g. 80 KB) */
LOG_WARNING("Adding extra %s range, "
- "%#8.8x to " TARGET_ADDR_FMT,
+ TARGET_ADDR_FMT " .. " TARGET_ADDR_FMT,
addr - 1);
first = i;
} else
addr - 1);
first = i;
} else
}
/* is this (also?) the last sector? */
}
/* is this (also?) the last sector? */
- if (last_addr == end) {
+ if (last_addr == sector_last_addr) {
/* Does this need tail-padding? If so, pad and warn;
* or else force an error.
*/
/* Does this need tail-padding? If so, pad and warn;
* or else force an error.
*/
- if (last_addr < end && pad_reason) {
+ if (last_addr < sector_last_addr && pad_reason) {
/* FIXME say how many bytes (e.g. 80 KB) */
LOG_WARNING("Adding extra %s range, "
/* FIXME say how many bytes (e.g. 80 KB) */
LOG_WARNING("Adding extra %s range, "
+ TARGET_ADDR_FMT " .. " TARGET_ADDR_FMT,
- (unsigned) last_addr,
- (unsigned) end - 1);
+ last_addr + 1,
+ sector_last_addr);
last = i;
break;
}
/* MUST finish on a sector boundary */
last = i;
break;
}
/* MUST finish on a sector boundary */
- if (last_addr <= f->offset)
+ if (last_addr < sector_addr)
if (first == -1 || last == -1) {
LOG_ERROR("address range " TARGET_ADDR_FMT " .. " TARGET_ADDR_FMT
" is not sector-aligned",
if (first == -1 || last == -1) {
LOG_ERROR("address range " TARGET_ADDR_FMT " .. " TARGET_ADDR_FMT
" is not sector-aligned",
- c->base + addr,
- c->base + last_addr - 1);
return ERROR_FLASH_DST_BREAKS_ALIGNMENT;
}
return ERROR_FLASH_DST_BREAKS_ALIGNMENT;
}
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)