shell: flash display offsets

tags/0.1.0
S.J.R. van Schaik 8 years ago
parent d1a82f333a
commit 463cf04f8d
  1. 14
      source/shell/flash.c

@ -54,17 +54,19 @@ static void parse_hex(FILE *fp, char *buf, size_t len)
}
}
static void print_hex_ascii(const char *buf, size_t len)
static void print_hex_ascii(uint32_t offset, const char *buf, size_t len)
{
size_t n, i;
uint8_t c;
for (; len; buf += n, len -= n) {
n = min(len, 16);
printf("%04" PRIx32 ": ", offset);
for (i = 0; i < 16; ++i) {
c = (i < n) ? buf[i] : 0;
printf("%02x ", c);
printf("%02x", c);
}
printf(" ");
@ -75,6 +77,8 @@ static void print_hex_ascii(const char *buf, size_t len)
}
printf("\n");
offset += n;
}
}
@ -155,7 +159,7 @@ static void do_flash_read(const char *s)
while (len) {
nbytes = min(len, 256);
flash_read(flash, addr, buf, nbytes);
print_hex_ascii(buf, nbytes);
print_hex_ascii(addr, buf, nbytes);
addr += nbytes;
len -= nbytes;
@ -199,7 +203,7 @@ static void do_flash_write(const char *s)
nbytes = min(len, 256);
parse_hex(stdin, buf, nbytes);
printf("\n");
print_hex_ascii(buf, nbytes);
print_hex_ascii(addr, buf, nbytes);
flash_write(flash, addr, buf, nbytes);
addr += nbytes;

Loading…
Cancel
Save