unsik Kim <donari75@gmail.com>:
[openocd.git] / src / flash / mflash.c
index 10830b25e6ee2e33fa03aa83eec94d4c46409ca7..f668db0d7c27cf258e14eaafd19133c9cb0693a8 100644 (file)
 #include "config.h"
 #endif
 
-#include <ctype.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <inttypes.h>
-
-#include "command.h"
-#include "log.h"
-#include "target.h"
+#include "mflash.h"
 #include "time_support.h"
 #include "fileio.h"
-#include "mflash.h"
+#include "log.h"
+
 
 static int s3c2440_set_gpio_to_output (mflash_gpio_num_t gpio);
 static int s3c2440_set_gpio_output_val (mflash_gpio_num_t gpio, u8 val);
@@ -201,28 +191,18 @@ static int s3c2440_set_gpio_output_val (mflash_gpio_num_t gpio, u8 val)
        return ret;
 }
 
-static int mflash_rst(u8 level)
+static int mg_hdrst(u8 level)
 {
        return mflash_bank->gpio_drv->set_gpio_output_val(mflash_bank->rst_pin, level);
 }
 
-static int mflash_init_gpio (void)
+static int mg_init_gpio (void)
 {
        mflash_gpio_drv_t *gpio_drv = mflash_bank->gpio_drv;
 
        gpio_drv->set_gpio_to_output(mflash_bank->rst_pin);
        gpio_drv->set_gpio_output_val(mflash_bank->rst_pin, 1);
 
-       if (mflash_bank->wp_pin.num != -1) {
-               gpio_drv->set_gpio_to_output(mflash_bank->wp_pin);
-               gpio_drv->set_gpio_output_val(mflash_bank->wp_pin, 1);
-       }
-
-       if (mflash_bank->dpd_pin.num != -1) {
-               gpio_drv->set_gpio_to_output(mflash_bank->dpd_pin);
-               gpio_drv->set_gpio_output_val(mflash_bank->dpd_pin, 1);
-       }
-
        return ERROR_OK;
 }
 
@@ -380,16 +360,16 @@ static int mg_mflash_probe(void)
 {
        mflash_bank->proved = 0;
 
-       mflash_init_gpio();
+       mg_init_gpio();
 
        LOG_INFO("reset mflash");
 
-       mflash_rst(0);
+       mg_hdrst(0);
 
        if (mg_dsk_wait(mg_io_wait_bsy, MG_OEM_DISK_WAIT_TIME_LONG) != ERROR_OK)
                return ERROR_FAIL;
 
-       mflash_rst(1);
+       mg_hdrst(1);
 
        if (mg_dsk_wait(mg_io_wait_not_bsy, MG_OEM_DISK_WAIT_TIME_LONG) != ERROR_OK)
                return ERROR_FAIL;
@@ -412,7 +392,7 @@ static int mg_mflash_probe(void)
        return ERROR_OK;
 }
 
-static int mflash_probe_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+static int mg_probe_cmd(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
 {
        int ret;
 
@@ -473,14 +453,16 @@ static int mg_mflash_read_sects(void *buff, u32 sect_num, u32 sect_cnt)
        residue = sect_cnt % 256;
 
        for (i = 0; i < quotient; i++) {
-               LOG_DEBUG("sect num : %u buff : 0x%8.8x", sect_num, (u32)buff_ptr);
+               LOG_DEBUG("sect num : %u buff : 0x%0lx", sect_num, 
+                       (unsigned long)buff_ptr);
                mg_mflash_do_read_sects(buff_ptr, sect_num, 256);
                sect_num += 256;
                buff_ptr += 256 * MG_MFLASH_SECTOR_SIZE;
        }
 
        if (residue) {
-               LOG_DEBUG("sect num : %u buff : %8.8x", sect_num, (u32)buff_ptr);
+               LOG_DEBUG("sect num : %u buff : %0lx", sect_num, 
+                       (unsigned long)buff_ptr);
                mg_mflash_do_read_sects(buff_ptr, sect_num, residue);
        }
 
@@ -542,14 +524,16 @@ static int mg_mflash_write_sects(void *buff, u32 sect_num, u32 sect_cnt)
        residue = sect_cnt % 256;
 
        for (i = 0; i < quotient; i++) {
-               LOG_DEBUG("sect num : %u buff : %8.8x", sect_num, (u32)buff_ptr);
+               LOG_DEBUG("sect num : %u buff : %0lx", sect_num, 
+                       (unsigned long)buff_ptr);
                mg_mflash_do_write_sects(buff_ptr, sect_num, 256);
                sect_num += 256;
                buff_ptr += 256 * MG_MFLASH_SECTOR_SIZE;
        }
 
        if (residue) {
-               LOG_DEBUG("sect num : %u buff : %8.8x", sect_num, (u32)buff_ptr);
+               LOG_DEBUG("sect num : %u buff : %0lx", sect_num, 
+                       (unsigned long)buff_ptr);
                mg_mflash_do_write_sects(buff_ptr, sect_num, residue);
        }
 
@@ -678,7 +662,7 @@ static int mg_mflash_write(u32 addr, u8 *buff, u32 len)
        return ERROR_OK;
 }
 
-static int mflash_write_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+static int mg_write_cmd(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
 {
        u32 address, buf_cnt;
        u8 *buffer;
@@ -730,7 +714,7 @@ static int mflash_write_command(struct command_context_s *cmd_ctx, char *cmd, ch
        return ERROR_OK;
 }
 
-static int mflash_dump_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+static int mg_dump_cmd(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
 {
        u32 address, size_written, size;
        u8 *buffer;
@@ -780,46 +764,38 @@ static int mflash_dump_command(struct command_context_s *cmd_ctx, char *cmd, cha
 int mflash_init_drivers(struct command_context_s *cmd_ctx)
 {
        if (mflash_bank) {
-               register_command(cmd_ctx, mflash_cmd, "probe", mflash_probe_command, COMMAND_EXEC, NULL);
-               register_command(cmd_ctx, mflash_cmd, "write", mflash_write_command, COMMAND_EXEC,
+               register_command(cmd_ctx, mflash_cmd, "probe", mg_probe_cmd, COMMAND_EXEC, NULL);
+               register_command(cmd_ctx, mflash_cmd, "write", mg_write_cmd, COMMAND_EXEC,
                                "mflash write <num> <file> <address>");
-               register_command(cmd_ctx, mflash_cmd, "dump", mflash_dump_command, COMMAND_EXEC,
+               register_command(cmd_ctx, mflash_cmd, "dump", mg_dump_cmd, COMMAND_EXEC,
                                                "mflash dump <num> <file> <address> <size>");
        }
 
        return ERROR_OK;
 }
 
-static int mflash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+static int mg_bank_cmd(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
 {
        target_t *target;
        char *str;
        int i;
 
-       if (argc < 8)
+       if (argc < 4)
        {
                return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
-       if ((target = get_target_by_num(strtoul(args[7], NULL, 0))) == NULL)
+       if ((target = get_target(args[3])) == NULL)
        {
-               LOG_ERROR("target %lu not defined", strtoul(args[7], NULL, 0));
+               LOG_ERROR("target '%s' not defined", args[3]);
                return ERROR_FAIL;
        }
 
        mflash_bank = calloc(sizeof(mflash_bank_t), 1);
        mflash_bank->base = strtoul(args[1], NULL, 0);
-       mflash_bank->chip_width = strtoul(args[2], NULL, 0);
-       mflash_bank->bus_width = strtoul(args[3], NULL, 0);
-       mflash_bank->rst_pin.num = strtoul(args[4], &str, 0);
+       mflash_bank->rst_pin.num = strtoul(args[2], &str, 0);
        if (*str)
                mflash_bank->rst_pin.port[0] = (u16)tolower(str[0]);
-       mflash_bank->wp_pin.num = strtol(args[5], &str, 0);
-       if (*str)
-               mflash_bank->wp_pin.port[0] = (u16)tolower(str[0]);
-       mflash_bank->dpd_pin.num = strtol(args[6], &str, 0);
-       if (*str)
-               mflash_bank->dpd_pin.port[0] = (u16)tolower(str[0]);
 
        mflash_bank->target = target;
 
@@ -840,7 +816,7 @@ static int mflash_bank_command(struct command_context_s *cmd_ctx, char *cmd, cha
 int mflash_register_commands(struct command_context_s *cmd_ctx)
 {
        mflash_cmd = register_command(cmd_ctx, NULL, "mflash", NULL, COMMAND_ANY, NULL);
-       register_command(cmd_ctx, mflash_cmd, "bank", mflash_bank_command, COMMAND_CONFIG,
-                       "mflash bank <soc> <base> <chip_width> <bus_width> <RST pin> <WP pin> <DPD pin> <target #>");
+       register_command(cmd_ctx, mflash_cmd, "bank", mg_bank_cmd, COMMAND_CONFIG,
+                       "mflash bank <soc> <base> <RST pin> <target #>");
        return ERROR_OK;
 }

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)