changeset 408:431023033c86

Intel flash: flash status command implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Tue, 17 Jun 2014 01:52:46 +0000
parents f2cc551e597f
children 23ab8fe81764
files loadtools/flashops.c loadtools/flmain.c loadtools/flmisc.c
diffstat 3 files changed, 39 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/loadtools/flashops.c	Tue Jun 17 01:39:59 2014 +0000
+++ b/loadtools/flashops.c	Tue Jun 17 01:52:46 2014 +0000
@@ -107,6 +107,27 @@
 	return(0);
 }
 
+intel_status_cmd(bi)
+	struct flash_bank_info *bi;
+{
+	int stat;
+	uint16_t sr;
+
+	/* issue Read SR command */
+	stat = do_w16(bi->base_addr, 0x70);
+	if (stat) {
+		fprintf(stderr,
+			"unexpected response to w16 for Read SR command\n");
+		return(-1);
+	}
+	stat = do_r16(bi->base_addr, &sr);
+	if (stat)
+		return(stat);	/* error msg already printed */
+	sr &= 0xFF;
+	printf("Status Register: %02X\n", sr);
+	return(0);
+}
+
 intel_sector_unlock(bi, sp)
 	struct flash_bank_info *bi;
 	struct sector_info *sp;
@@ -174,7 +195,7 @@
 struct flash_cmdset flash_cmdset_intel = {
 	.cmdset_name		= "Intel",
 	.reset_cmd		= intel_reset_cmd,
-	.status_cmd		= invalid,
+	.status_cmd		= intel_status_cmd,
 	.unlock_sector		= intel_sector_unlock,
 	.erase_sector		= intel_sector_erase,
 	.loadagent_setbase_cmd	= "INFB",
--- a/loadtools/flmain.c	Tue Jun 17 01:39:59 2014 +0000
+++ b/loadtools/flmain.c	Tue Jun 17 01:52:46 2014 +0000
@@ -202,6 +202,7 @@
 extern int flashcmd_quickprog();
 extern int flashcmd_reset();
 extern int flashcmd_sectors();
+extern int flashcmd_status();
 
 static struct cmdtab {
 	char *cmd;
@@ -219,6 +220,7 @@
 	{"quickprog", flashcmd_quickprog},
 	{"reset", flashcmd_reset},
 	{"sectors", flashcmd_sectors},
+	{"status", flashcmd_status},
 	{0, 0}
 };
 
--- a/loadtools/flmisc.c	Tue Jun 17 01:39:59 2014 +0000
+++ b/loadtools/flmisc.c	Tue Jun 17 01:52:46 2014 +0000
@@ -233,3 +233,18 @@
 	bi = flash_bank_info + bank;
 	return bi->ops->reset_cmd(bi);
 }
+
+flashcmd_status(argc, argv, bank)
+	char **argv;
+{
+	struct flash_bank_info *bi;
+
+	if (argc > 2) {
+		fprintf(stderr, "error: too many arguments\n");
+		return(-1);
+	}
+	if (flash_get_cfi(bank) < 0)
+		return(-1);
+	bi = flash_bank_info + bank;
+	return bi->ops->status_cmd(bi);
+}