]> git.sur5r.net Git - openocd/commitdiff
- renamed x7926 driver to aduc702x to match other flash drivers
authorntfreak <ntfreak@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Wed, 24 Sep 2008 22:15:22 +0000 (22:15 +0000)
committerntfreak <ntfreak@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Wed, 24 Sep 2008 22:15:22 +0000 (22:15 +0000)
- removed c99 types (mingw issues) from aduc driver and cleanup
- updated docs for aduc702x flash driver

git-svn-id: svn://svn.berlios.de/openocd/trunk@995 b42882b7-edfa-0310-969c-e2dbd0fdcd60

doc/openocd.texi
src/flash/Makefile.am
src/flash/aduc702x.c [new file with mode: 0644]
src/flash/flash.c
src/flash/x7026.c [deleted file]
src/openocd.c
src/target/target/aduc702x.cfg

index b899891c19bb5f68c2d3cbd426042558186bcbf9..13825fb89ded5611a12ce08050c4668c47d1c1ad 100644 (file)
@@ -703,6 +703,13 @@ stellaris flash plugin only require the @var{target#}.
 @b{flash bank stm32x} <@var{base}> <@var{size}> 0 0 <@var{target#}>
 stm32x flash plugin only require the @var{target#}. 
 
+@subsection aduc702x options
+@cindex aduc702x options
+
+@b{flash bank aduc702x} <@var{base}> <@var{size}> 0 0 <@var{target#}>
+aduc702x flash plugin require the flash @var{base}, @var{size} and @var{target#}.
+currently only the aduc7206 is supported.
+
 @node Target library
 @chapter Target library
 @cindex Target library
index 77e870f1d6a0ec5d27dd5ae7d0898ad95c5e8139..5bce55f9e2d5ec5ed2f1910f3b73d8835891349e 100644 (file)
@@ -2,7 +2,7 @@ INCLUDES = -I$(top_srcdir)/src/helper -I$(top_srcdir)/src/jtag -I$(top_srcdir)/s
 AM_CPPFLAGS = -DPKGLIBDIR=\"$(pkglibdir)\" @CPPFLAGS@
 METASOURCES = AUTO
 noinst_LIBRARIES = libflash.a
-libflash_a_SOURCES = flash.c lpc2000.c cfi.c non_cfi.c at91sam7.c str7x.c str9x.c x7026.c nand.c lpc3180_nand_controller.c \
+libflash_a_SOURCES = flash.c lpc2000.c cfi.c non_cfi.c at91sam7.c str7x.c str9x.c aduc702x.c nand.c lpc3180_nand_controller.c \
                                         stellaris.c str9xpec.c stm32x.c tms470.c ecos.c  \
                     s3c24xx_nand.c s3c2410_nand.c s3c2412_nand.c s3c2440_nand.c s3c2443_nand.c lpc288x.c ocl.c
 noinst_HEADERS = flash.h lpc2000.h cfi.h non_cfi.h at91sam7.h str7x.h str9x.h nand.h lpc3180_nand_controller.h \
diff --git a/src/flash/aduc702x.c b/src/flash/aduc702x.c
new file mode 100644 (file)
index 0000000..0df5747
--- /dev/null
@@ -0,0 +1,209 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Kevin McGuire                                   *
+ *   Copyright (C) 2008 by Marcel Wijlaars                                 *
+ *                                                                         *
+ *   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.             *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "replacements.h"
+
+#include "flash.h"
+#include "target.h"
+#include "log.h"
+#include "armv4_5.h"
+#include "algorithm.h"
+#include "binarybuffer.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+int aduc702x_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank);
+int aduc702x_register_commands(struct command_context_s *cmd_ctx);
+int aduc702x_erase(struct flash_bank_s *bank, int first, int last);
+int aduc702x_protect(struct flash_bank_s *bank, int set, int first, int last);
+int aduc702x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count);
+int aduc702x_probe(struct flash_bank_s *bank);
+int aduc702x_info(struct flash_bank_s *bank, char *buf, int buf_size);
+int aduc702x_protect_check(struct flash_bank_s *bank);
+
+#define ADUC702x_FLASH                         0xfffff800
+#define ADUC702x_FLASH_FEESTA          (0*4)
+#define ADUC702x_FLASH_FEEMOD          (1*4)
+#define ADUC702x_FLASH_FEECON          (2*4)
+#define ADUC702x_FLASH_FEEDAT          (3*4)
+#define ADUC702x_FLASH_FEEADR          (4*4)
+#define ADUC702x_FLASH_FEESIGN         (5*4)
+#define ADUC702x_FLASH_FEEPRO          (6*4)
+#define ADUC702x_FLASH_FEEHIDE         (7*4)
+
+typedef struct {
+       u32 feesta;
+       u32 feemod;
+       u32 feecon;
+       u32 feedat;
+       u32 feeadr;
+       u32 feesign;
+       u32 feepro;
+       u32 feehide;
+} ADUC702x_FLASH_MMIO;
+
+typedef struct
+{
+       unsigned char tmp;
+} aduc702x_bank;
+
+flash_driver_t aduc702x_flash =
+{
+       .name = "aduc702x",
+       .register_commands = aduc702x_register_commands,
+       .flash_bank_command = aduc702x_flash_bank_command,
+       .erase = aduc702x_erase,
+       .protect = aduc702x_protect,
+       .write = aduc702x_write,
+       .probe = aduc702x_probe,
+       .auto_probe = aduc702x_probe,
+       .erase_check = default_flash_blank_check,
+       .protect_check = aduc702x_protect_check,
+       .info = aduc702x_info
+};
+
+int aduc702x_register_commands(struct command_context_s *cmd_ctx)
+{
+       return ERROR_OK;
+}
+
+/* flash bank aduc702x <base> <size> 0 0 <target#>  */
+int aduc702x_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank)
+{
+       aduc702x_bank *nbank;
+
+       if (argc < 6)
+       {
+               LOG_WARNING("incomplete flash_bank aduc702x configuration");
+               return ERROR_FLASH_BANK_INVALID;
+       }
+
+       nbank = malloc(sizeof(aduc702x_bank));
+       /* just warn that we are used to normally using 0x80000 */
+       if (bank->base != 0x80000)
+       {
+               LOG_WARNING("Default base address is 0x80000 on the ADuC7026!");
+       }
+       
+       nbank->tmp = 1;
+       bank->driver_priv = nbank;
+       return ERROR_OK;
+}
+
+int aduc702x_protect_check(struct flash_bank_s *bank)
+{
+       printf("aduc702x_protect_check not implemented yet.\n");
+       return ERROR_OK;
+}
+
+int aduc702x_erase(struct flash_bank_s *bank, int first, int last)
+{
+       int x;
+       int count;
+       u32 v;
+       target_t *target = bank->target;
+
+       /* mass erase */
+       if ((first | last) == 0)
+       {
+               LOG_DEBUG("performing mass erase.\n");
+               target_write_u32(target, ADUC702x_FLASH + ADUC702x_FLASH_FEEDAT, 0x3cff);
+               target_write_u32(target, ADUC702x_FLASH + ADUC702x_FLASH_FEEADR, 0xffc3);
+               target_read_u32(target, ADUC702x_FLASH + ADUC702x_FLASH_FEEMOD, &v);
+               target_write_u32(target, ADUC702x_FLASH + ADUC702x_FLASH_FEEMOD, v | 0x8);
+               target_write_u32(target, ADUC702x_FLASH + ADUC702x_FLASH_FEECON, 0x06);
+               for (v = 0x4; v & 0x4;
+                       target_read_u32(target, ADUC702x_FLASH + ADUC702x_FLASH_FEESTA, &v));
+
+               if (!(v & 0x1))
+               {
+                       LOG_ERROR("mass erase failed.\n");
+                       return ERROR_FLASH_SECTOR_NOT_ERASED;
+               }
+               LOG_DEBUG("mass erase successful.\n");
+               return ERROR_OK;
+       }
+
+       count = last - first;
+       for (x = 0; x < count; ++x)
+       {
+               target_write_u32(target, ADUC702x_FLASH + ADUC702x_FLASH_FEEADR, bank->base + first * 512 + x * 512);
+               target_write_u32(target, ADUC702x_FLASH + ADUC702x_FLASH_FEECON, 0x05);
+               for (v = 0x4; v & 0x4; target_read_u32(target, ADUC702x_FLASH + ADUC702x_FLASH_FEESTA, &v));
+               if (!(v & 0x1))
+               {
+                       LOG_ERROR("erase failed for page address %x\n", bank->base + first * 512 + x * 512);
+                       return ERROR_FLASH_SECTOR_NOT_ERASED;
+               }
+               LOG_DEBUG("erased page address %x\n", bank->base + first * 512 + x * 512);
+       }
+       return ERROR_OK;
+}
+
+int aduc702x_protect(struct flash_bank_s *bank, int set, int first, int last)
+{
+       printf("aduc702x_protect not implemented yet.\n");
+       return ERROR_FLASH_OPERATION_FAILED;
+}
+
+int aduc702x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
+{
+       int x;
+       u32     v;
+       target_t *target = bank->target;
+       
+       for (x = 0; x < count; x += 2)
+       {
+               target_write_u32(target, ADUC702x_FLASH + ADUC702x_FLASH_FEEADR, offset + x);
+               /* if we able to encounter a single byte instead of a word */
+               if ((x + 1) == count) {
+                       target_write_u32(target, ADUC702x_FLASH + ADUC702x_FLASH_FEEDAT, buffer[x]);
+               }
+               else {
+                       target_write_u32(target, ADUC702x_FLASH + ADUC702x_FLASH_FEEDAT, buffer[x] | (buffer[x+1] << 8));
+               }
+               target_write_u32(target, ADUC702x_FLASH + ADUC702x_FLASH_FEECON, 0x02);
+               for (v = 0x4; v & 0x4; target_read_u32(target, ADUC702x_FLASH + ADUC702x_FLASH_FEESTA, &v));
+               if (!(v & 0x1))
+               {
+                       LOG_ERROR("single write failed for address %x.\n", offset + x);
+                       return ERROR_FLASH_OPERATION_FAILED;
+               }
+               LOG_DEBUG("single write for address %x.\n", offset + x);
+       }
+       return ERROR_OK;
+}
+
+int aduc702x_probe(struct flash_bank_s *bank)
+{
+       return ERROR_OK;
+}
+
+int aduc702x_info(struct flash_bank_s *bank, char *buf, int buf_size)
+{
+       snprintf(buf, buf_size, "aduc702x flash driver info" );
+       return ERROR_OK;
+}
index a1b64ade898fed1af0cf8c2df98720faa9038e86..3d450ac8dc0306dbd472cbc1959cbdfcec72b370 100644 (file)
@@ -69,7 +69,7 @@ extern flash_driver_t cfi_flash;
 extern flash_driver_t at91sam7_flash;
 extern flash_driver_t str7x_flash;
 extern flash_driver_t str9x_flash;
-extern flash_driver_t x7026_flash;
+extern flash_driver_t aduc702x_flash;
 extern flash_driver_t stellaris_flash;
 extern flash_driver_t str9xpec_flash;
 extern flash_driver_t stm32x_flash;
@@ -85,7 +85,7 @@ flash_driver_t *flash_drivers[] =
        &at91sam7_flash,
        &str7x_flash,
        &str9x_flash,
-       &x7026_flash,
+       &aduc702x_flash,
        &stellaris_flash,
        &str9xpec_flash,
        &stm32x_flash,
diff --git a/src/flash/x7026.c b/src/flash/x7026.c
deleted file mode 100644 (file)
index e700a8b..0000000
+++ /dev/null
@@ -1,217 +0,0 @@
-/***************************************************************************\r
- *   Copyright (C) 2008 by Kevin McGuire                                   *\r
- *   Copyright (C) 2008 by Marcel Wijlaars                                 *\r
- *\r
- *   This program is free software; you can redistribute it and/or modify  *\r
- *   it under the terms of the GNU General Public License as published by  *\r
- *   the Free Software Foundation; either version 2 of the License, or     *\r
- *   (at your option) any later version.                                   *\r
- *                                                                         *\r
- *   This program is distributed in the hope that it will be useful,       *\r
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *\r
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *\r
- *   GNU General Public License for more details.                          *\r
- *                                                                         *\r
- *   You should have received a copy of the GNU General Public License     *\r
- *   along with this program; if not, write to the                         *\r
- *   Free Software Foundation, Inc.,                                       *\r
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *\r
- ***************************************************************************/\r
-\r
-\r
-#ifdef HAVE_CONFIG_H\r
-#include "config.h"\r
-#endif\r
-\r
-#include "replacements.h"\r
-\r
-#include "flash.h"\r
-#include "target.h"\r
-#include "log.h"\r
-#include "armv4_5.h"\r
-#include "algorithm.h"\r
-#include "binarybuffer.h"\r
-\r
-#include <stdlib.h>\r
-#include <string.h>\r
-#include <unistd.h>\r
-\r
-int x7026_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank);\r
-int x7026_register_commands(struct command_context_s *cmd_ctx);\r
-int x7026_erase(struct flash_bank_s *bank, int first, int last);\r
-int x7026_protect(struct flash_bank_s *bank, int set, int first, int last);\r
-int x7026_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count);\r
-int x7026_probe(struct flash_bank_s *bank);\r
-int x7026_info(struct flash_bank_s *bank, char *buf, int buf_size);\r
-int x7026_protect_check(struct flash_bank_s *bank);\r
-int x7026_erase_check(struct flash_bank_s *bank);\r
-\r
-#define ADUC7026_FLASH                         0xfffff800\r
-#define ADUC7026_FLASH_FEESTA                  (0*4)\r
-#define ADUC7026_FLASH_FEEMOD                  (1*4)\r
-#define ADUC7026_FLASH_FEECON                  (2*4)\r
-#define ADUC7026_FLASH_FEEDAT                  (3*4)\r
-#define ADUC7026_FLASH_FEEADR                  (4*4)\r
-#define ADUC7026_FLASH_FEESIGN         (5*4)\r
-#define ADUC7026_FLASH_FEEPRO                  (6*4)\r
-#define ADUC7026_FLASH_FEEHIDE         (7*4)\r
-\r
-typedef struct{\r
-       uint32_t        feesta;\r
-       uint32_t        feemod;\r
-       uint32_t        feecon;\r
-       uint32_t        feedat;\r
-       uint32_t        feeadr;\r
-       uint32_t        feesign;\r
-       uint32_t        feepro;\r
-       uint32_t        feehide;\r
-} ADUC7026_FLASH_MMIO;\r
-\r
-typedef struct\r
-{\r
-       unsigned char tmp;\r
-} X7026_BANK;\r
-\r
-flash_driver_t x7026_flash =\r
-{\r
-       .name = "x7026",\r
-       .register_commands = x7026_register_commands,\r
-       .flash_bank_command = x7026_flash_bank_command,\r
-       .erase = x7026_erase,\r
-       .protect = x7026_protect,\r
-       .write = x7026_write,\r
-       .probe = x7026_probe,\r
-       .auto_probe = x7026_probe,\r
-       .erase_check = x7026_erase_check,\r
-       .protect_check = x7026_protect_check,\r
-       .info = x7026_info\r
-};\r
-\r
-int x7026_register_commands(struct command_context_s *cmd_ctx)\r
-{\r
-       printf("x7026_register_commands not implemented yet.\n");\r
-       return ERROR_OK;\r
-}\r
-\r
-/* flash bank str7x <base> <size> 0 0 <target#>  */\r
-int x7026_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank)\r
-{\r
-       X7026_BANK      *nbank;\r
-\r
-       if (argc < 6)\r
-       {\r
-               LOG_WARNING("incomplete flash_bank x7026 configuration");\r
-               return ERROR_FLASH_BANK_INVALID;\r
-       }\r
-\r
-       nbank = malloc(sizeof(X7026_BANK));\r
-       /* just warn that we are used to normally using 0x80000 */\r
-       if(bank->base != 0x80000)\r
-       {\r
-               LOG_WARNING("Default base address is 0x80000 on the ADuC7026!");\r
-       }\r
-       nbank->tmp = 1;\r
-       bank->driver_priv = nbank;\r
-       return ERROR_OK;\r
-}\r
-\r
-int x7026_protect_check(struct flash_bank_s *bank)\r
-{\r
-       printf("x7026_protect_check not implemented yet.\n");\r
-       return ERROR_OK;\r
-}\r
-\r
-int x7026_erase(struct flash_bank_s *bank, int first, int last)\r
-{\r
-       unsigned int    x;\r
-       int                     count;\r
-       u32                     v;\r
-       target_t *target = bank->target;\r
-\r
-       /* mass erase */\r
-       if((first | last) == 0)\r
-       {\r
-               printf("performing mass erase.\n");\r
-               target_write_u32(target, ADUC7026_FLASH + ADUC7026_FLASH_FEEDAT, 0x3cff);\r
-               target_write_u32(target, ADUC7026_FLASH + ADUC7026_FLASH_FEEADR, 0xffc3);\r
-               target_read_u32(target, ADUC7026_FLASH + ADUC7026_FLASH_FEEMOD, &v);\r
-               target_write_u32(target, ADUC7026_FLASH + ADUC7026_FLASH_FEEMOD, v | 0x8);\r
-               target_write_u32(target, ADUC7026_FLASH + ADUC7026_FLASH_FEECON, 0x06);\r
-               for(v = 0x4; v & 0x4;\r
-                       target_read_u32(target, ADUC7026_FLASH + ADUC7026_FLASH_FEESTA, &v));\r
-\r
-               if(!(v & 0x1))\r
-               {\r
-                       printf("mass erase failed.\n");\r
-                       return -1;\r
-               }\r
-               printf("mass erase successful.\n");\r
-               return ERROR_OK;\r
-       }\r
-\r
-       count = last - first;\r
-       for(x = 0; x < (unsigned int)count; ++x)\r
-       {\r
-               target_write_u32(target, ADUC7026_FLASH + ADUC7026_FLASH_FEEADR, bank->base + first * 512 + x * 512);\r
-               target_write_u32(target, ADUC7026_FLASH + ADUC7026_FLASH_FEECON, 0x05);\r
-               for(v = 0x4; v & 0x4; target_read_u32(target, ADUC7026_FLASH + ADUC7026_FLASH_FEESTA, &v));\r
-               if(!(v & 0x1))\r
-               {\r
-                       printf("erase failed for page address %x\n", bank->base + first * 512 + x * 512);\r
-                       return -1;\r
-               }\r
-               printf("erased page address %x\n", bank->base + first * 512 + x * 512);\r
-       }\r
-       return ERROR_OK;\r
-}\r
-\r
-int x7026_protect(struct flash_bank_s *bank, int set, int first, int last)\r
-{\r
-       printf("x7026_protect not implemented yet.\n");\r
-       return -1;\r
-}\r
-\r
-int x7026_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)\r
-{\r
-       unsigned int    x;\r
-       u32                     v;\r
-       target_t                *target = bank->target;\r
-       for(x = 0; x < count; x += 2)\r
-       {\r
-               target_write_u32(target, ADUC7026_FLASH + ADUC7026_FLASH_FEEADR, offset + x);\r
-               /* if we able to encounter a single byte instead of a word */\r
-               if((x + 1) == count)\r
-               {\r
-                       target_write_u32(target, ADUC7026_FLASH + ADUC7026_FLASH_FEEDAT, buffer[x]);\r
-               }else{\r
-                       target_write_u32(target, ADUC7026_FLASH + ADUC7026_FLASH_FEEDAT, buffer[x] | (buffer[x+1] << 8));\r
-               }\r
-               target_write_u32(target, ADUC7026_FLASH + ADUC7026_FLASH_FEECON, 0x02);\r
-               for(v = 0x4; v & 0x4; target_read_u32(target, ADUC7026_FLASH + ADUC7026_FLASH_FEESTA, &v));\r
-               if(!(v & 0x1))\r
-               {\r
-                       printf("single write failed for address %x.\n", offset + x);\r
-                       return -1;\r
-               }\r
-               printf("single write for address %x.\n", offset + x);\r
-       }\r
-       return ERROR_OK;\r
-}\r
-\r
-int x7026_probe(struct flash_bank_s *bank)\r
-{\r
-       printf("x7026_probe not implemented yet.\n");\r
-       return ERROR_OK;\r
-}\r
-\r
-int x7026_info(struct flash_bank_s *bank, char *buf, int buf_size)\r
-{\r
-       snprintf(buf, buf_size, "x7026 flash driver info" );\r
-       return -1;\r
-}\r
-\r
-int x7026_erase_check(struct flash_bank_s *bank)\r
-{\r
-       printf("x7026_erase_check not implemented yet.\n");\r
-       return -1;\r
-}\r
index d0bd9de1babf618d1dc467f6639f2c00eaa1dd2b..ccace082f39587a5d7322add926f9a8215cb0587 100644 (file)
@@ -60,7 +60,6 @@
 
 #include "replacements.h"
 
-
 /* Give TELNET a way to find out what version this is */
 int handle_version_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
 {
@@ -69,7 +68,6 @@ int handle_version_command(struct command_context_s *cmd_ctx, char *cmd, char **
        return ERROR_OK;
 }
 
-
 void exit_handler(void)
 {
        /* close JTAG interface */
@@ -91,8 +89,6 @@ static int log_target_callback_event_handler(struct target_s *target, enum targe
        return ERROR_OK;
 }
 
-
-
 /* OpenOCD can't really handle failure of this command. Patches welcome! :-) */
 int handle_init_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
 {
@@ -148,8 +144,6 @@ int handle_init_command(struct command_context_s *cmd_ctx, char *cmd, char **arg
        tcl_init(); /* allows tcl to just connect without going thru telnet */
 
        target_register_event_callback(log_target_callback_event_handler, cmd_ctx);
-
-       
        
        return ERROR_OK;
 }
index e3e886202b75f7f3b99cf54fdaa4ccb76b545831..5c297fbe028b65192e36e76e10c11402c2f16d1b 100644 (file)
@@ -24,7 +24,7 @@ target arm7tdmi little 0
 #working_area 0 0x11C00 0x400 backup
 
 ## flash configuration
-flash bank x7026 0x80000 0x10000 2 2 0
+flash bank aduc702x 0x80000 0x10000 2 2 0
 
 ## If you use the watchdog, the following code makes sure that the board
 ## doesn't reboot when halted via JTAG.  Yes, on the older generation