Hello,
i have worked on the issues, please let me know if there was something that i
have not picked up.
Regards,
Mathias
Am 16.09.2011 10:00, schrieb Øyvind Harboe:
First of all, overall I think the code looks good!
Some nit-picking below.
The OpenOCD error handling is modeled upon exception handling, report error
in place and then just propagate errors (exceptions) without changing the
return
value.
1. Switch to LOG_ERROR.
+FLASH_BANK_COMMAND_HANDLER(kinetis_flash_bank_command)
+{
+ if (CMD_ARGC 6) {
+ LOG_WARNING(incomplete flash_bank kinetis configuration %d,
+ CMD_ARGC);
+ return ERROR_FLASH_OPERATION_FAILED;
+ }
2. Just return LOG_ERROR()
+static int kinetis_protect(struct flash_bank *bank, int set, int first,
+ int last)
+{
+ struct flash_bank *master_bank = kinetis_get_master_bank(bank);
+
+ LOG_WARNING(kinetis_protect not supported yet);
+
+ if (bank-target-state != TARGET_HALTED) {
+ LOG_ERROR(Target not halted);
+ return ERROR_TARGET_NOT_HALTED;
+ }
+
+ if (master_bank == NULL) {
+ return ERROR_FLASH_OPERATION_FAILED;
+ }
+
+ return ERROR_OK;
+}
3. Modify to return error as primary return value and pointer in
secondary return
value, then just propagate the return value unchanged upon error.
+static struct flash_bank *kinetis_get_master_bank(struct flash_bank *bank)
4. This fn does not propagate failure:
+static void kinetis_update_bank_info(struct flash_bank *bank)
+{
+ struct flash_bank *master_bank = kinetis_get_master_bank(bank);
+
+ if (master_bank == NULL) {
+ return;
+ }
+
5. propagate (just return) the error code, do not change it:
+ if (kinetis_ftfl_command(bank, w0, w1, w2) != ERROR_OK) {
+ return ERROR_FLASH_OPERATION_FAILED;
+ }
+
+
From ab35e7489fb125fac84049040ea86776f34cf952 Mon Sep 17 00:00:00 2001
From: Mathias K. kes...@freenet.de
Date: Sat, 17 Sep 2011 10:09:50 +0200
Subject: [PATCH 2/2] kinetis cpu flash driver
Initial release of the freescale kinetis cpu flash driver.
---
src/flash/nor/Makefile.am |3 +-
src/flash/nor/drivers.c |2 +
src/flash/nor/kinetis.c | 562 +
3 files changed, 566 insertions(+), 1 deletions(-)
create mode 100644 src/flash/nor/kinetis.c
diff --git a/src/flash/nor/Makefile.am b/src/flash/nor/Makefile.am
index d7d66b0..a966826 100644
--- a/src/flash/nor/Makefile.am
+++ b/src/flash/nor/Makefile.am
@@ -32,7 +32,8 @@ NOR_DRIVERS = \
tms470.c \
virtual.c \
fm3.c \
- dsp5680xx_flash.c
+ dsp5680xx_flash.c \
+ kinetis.c
noinst_HEADERS = \
core.h \
diff --git a/src/flash/nor/drivers.c b/src/flash/nor/drivers.c
index 5d6e248..a437d84 100644
--- a/src/flash/nor/drivers.c
+++ b/src/flash/nor/drivers.c
@@ -45,6 +45,7 @@ extern struct flash_driver stmsmi_flash;
extern struct flash_driver em357_flash;
extern struct flash_driver dsp5680xx_flash;
extern struct flash_driver fm3_flash;
+extern struct flash_driver kinetis_flash;
/**
* The list of built-in flash drivers.
@@ -75,6 +76,7 @@ static struct flash_driver *flash_drivers[] = {
em357_flash,
fm3_flash,
dsp5680xx_flash,
+ kinetis_flash,
NULL,
};
diff --git a/src/flash/nor/kinetis.c b/src/flash/nor/kinetis.c
new file mode 100644
index 000..2613522
--- /dev/null
+++ b/src/flash/nor/kinetis.c
@@ -0,0 +1,562 @@
+/***
+ * Copyright (C) 2011 by Mathias Kuester *
+ * kes...@freenet.de *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of*
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+