You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/12/13 09:52:18 UTC
[GitHub] mkiiskila closed pull request #1562: flash_loader;
add support for reading flash contents to a file.
mkiiskila closed pull request #1562: flash_loader; add support for reading flash contents to a file.
URL: https://github.com/apache/mynewt-core/pull/1562
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/apps/flash_loader/include/flash_loader/flash_loader.h b/apps/flash_loader/include/flash_loader/flash_loader.h
index f0e4798969..605e66207d 100644
--- a/apps/flash_loader/include/flash_loader/flash_loader.h
+++ b/apps/flash_loader/include/flash_loader/flash_loader.h
@@ -34,6 +34,7 @@
#define FL_CMD_ERASE 3
#define FL_CMD_VERIFY 4
#define FL_CMD_LOAD_VERIFY 5
+#define FL_CMD_DUMP 6
/*
* Return codes
diff --git a/apps/flash_loader/src/fl.c b/apps/flash_loader/src/fl.c
index acc8acd792..f714024e92 100644
--- a/apps/flash_loader/src/fl.c
+++ b/apps/flash_loader/src/fl.c
@@ -129,6 +129,19 @@ fl_verify_cmd(void)
return FL_RC_OK;
}
+static int
+fl_dump_cmd(void)
+{
+ int rc;
+
+ rc = hal_flash_read(fl_cmd_flash_id, fl_cmd_flash_addr, (void *)fl_cmd_data,
+ fl_cmd_amount);
+ if (rc) {
+ return FL_RC_FLASH_ERR;
+ }
+ return FL_RC_OK;
+}
+
/*
* Blinks led if running (and LED is defined).
*/
@@ -197,6 +210,10 @@ main(int argc, char **argv)
rc = fl_verify_cmd();
}
break;
+ case FL_CMD_DUMP:
+ fl_cmd = 0;
+ rc = fl_dump_cmd();
+ break;
default:
fl_cmd = 0;
rc = FL_RC_UNKNOWN_CMD_ERR;
diff --git a/compiler/gdbmacros/flash_loader.gdb b/compiler/gdbmacros/flash_loader.gdb
index 7469f5acfb..d59323bd7a 100644
--- a/compiler/gdbmacros/flash_loader.gdb
+++ b/compiler/gdbmacros/flash_loader.gdb
@@ -94,7 +94,7 @@ end
define fl_program
fl_ping
if fl_cmd_rc == 1
- fl_file_sz $arg0
+ fl_file_sz $arg0
set $buf_sz = fl_cmd_data_sz
set $fl_off = $arg2
@@ -132,7 +132,7 @@ define fl_program
if fl_cmd_rc == 1
printf "Done\n"
else
- printf "Error during flash load %d\n", fl_cmd_rc
+ printf "Error during flash program %d\n", fl_cmd_rc
end
end
end
@@ -159,3 +159,55 @@ Asks flash_loader to erase flash area, and then load the file there.
id - flash identifier as specified for this BSP
offset - offset to this flash
end
+
+define fl_dump
+ fl_ping
+ if fl_cmd_rc == 1
+ set $file_sz = $arg3
+ set $buf_sz = fl_cmd_data_sz
+ set $fl_off = $arg2
+ set $off = 0
+
+ set fl_cmd_flash_id = $arg1
+
+ shell rm $arg0
+ while fl_cmd_rc == 1 && $off < $file_sz
+ if $off + $buf_sz > $file_sz
+ set $buf_sz = $file_sz - $off
+ end
+
+ printf " 0x%x %d\n", $fl_off + $off, $buf_sz
+
+ set fl_cmd_flash_addr = $fl_off + $off
+ set fl_cmd_amount = $buf_sz
+
+ # dump command
+ set fl_cmd = 6
+
+ # wait for flash dump to complete
+ while fl_cmd != 0
+
+ end
+ if fl_cmd_rc == 1
+ dump binary memory /tmp/foo.gdb fl_cmd_data fl_cmd_data + $buf_sz
+ shell cat /tmp/foo.gdb >> $arg0
+ shell rm /tmp/foo.gdb
+ end
+ set $off = $off + $buf_sz
+ end
+ if fl_cmd_rc == 1
+ printf "Done\n"
+ else
+ printf "Error during flash dump %d\n", fl_cmd_rc
+ end
+ end
+end
+
+document fl_dump
+usage: fl_dump <file> <id> <offset> <amount>
+Asks flash_loader to dump contents of flash to a file.
+ file - name of the file to compare
+ id - flash identifier as specified for this BSP
+ offset - offset to this flash
+ amount - number of bytes to dump
+end
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services