From e182be2204cdc95b84dde6fb86e2e603d01579b3 Mon Sep 17 00:00:00 2001 From: Daniel Beer Date: Mon, 21 Feb 2011 11:30:32 +1300 Subject: [PATCH] Added fet_block_size option. This option controls the buffer size used for transfers to and from the FET. Increasing it will improve transfer times, but may cause problems with some chips. Also, the default request size used for several commands has been increased to take advantage of this. --- devcmd.c | 4 ++-- fet.c | 25 ++++++++++++++++++++----- mspdebug.man | 4 ++++ opdb.c | 11 +++++++++++ prog.h | 2 +- 5 files changed, 38 insertions(+), 8 deletions(-) diff --git a/devcmd.c b/devcmd.c index 586ba62..3b5df61 100644 --- a/devcmd.c +++ b/devcmd.c @@ -82,7 +82,7 @@ int cmd_md(char **arg) reader_set_repeat("md 0x%x 0x%x", offset + length, length); while (length) { - uint8_t buf[128]; + uint8_t buf[4096]; int blen = length > sizeof(buf) ? sizeof(buf) : length; if (device_default->readmem(device_default, @@ -450,7 +450,7 @@ int cmd_hexout(char **arg) return -1; while (length) { - uint8_t buf[128]; + uint8_t buf[4096]; int count = length; if (count > sizeof(buf)) diff --git a/fet.c b/fet.c index bd1d76c..d299c2b 100644 --- a/fet.c +++ b/fet.c @@ -32,9 +32,10 @@ #include "fet_error.h" #include "fet_db.h" #include "output.h" +#include "opdb.h" #define MAX_PARAMS 16 -#define BLOCK_SIZE 64 +#define MAX_BLOCK_SIZE 4096 struct fet_device { struct device base; @@ -357,10 +358,10 @@ static int send_command(struct fet_device *dev, int command_code, const uint32_t *params, int nparams, const uint8_t *extra, int exlen) { - uint8_t datapkt[256]; + uint8_t datapkt[MAX_BLOCK_SIZE * 2]; int len = 0; - uint8_t buf[512]; + uint8_t buf[MAX_BLOCK_SIZE * 3]; uint16_t cksum; int i = 0; int j; @@ -758,10 +759,23 @@ static int write_byte(struct fet_device *dev, address_t addr, uint8_t value) return 0; } +static int get_adjusted_block_size(void) +{ + int block_size = opdb_get_numeric("fet_block_size") & ~1; + + if (block_size < 2) + block_size = 2; + if (block_size > MAX_BLOCK_SIZE) + block_size = MAX_BLOCK_SIZE; + + return block_size; +} + int fet_readmem(device_t dev_base, address_t addr, uint8_t *buffer, address_t count) { struct fet_device *dev = (struct fet_device *)dev_base; + int block_size = get_adjusted_block_size(); if (addr & 1) { if (read_byte(dev, addr, buffer) < 0) @@ -772,7 +786,7 @@ int fet_readmem(device_t dev_base, address_t addr, uint8_t *buffer, } while (count > 1) { - int plen = count > BLOCK_SIZE ? BLOCK_SIZE : count; + int plen = count > block_size ? block_size : count; plen &= ~0x1; @@ -804,6 +818,7 @@ int fet_writemem(device_t dev_base, address_t addr, const uint8_t *buffer, address_t count) { struct fet_device *dev = (struct fet_device *)dev_base; + int block_size = get_adjusted_block_size(); if (addr & 1) { if (write_byte(dev, addr, *buffer) < 0) @@ -814,7 +829,7 @@ int fet_writemem(device_t dev_base, address_t addr, } while (count > 1) { - int plen = count > BLOCK_SIZE ? BLOCK_SIZE : count; + int plen = count > block_size ? block_size : count; int ret; plen &= ~0x1; diff --git a/mspdebug.man b/mspdebug.man index 6fd4801..7881af2 100644 --- a/mspdebug.man +++ b/mspdebug.man @@ -430,6 +430,10 @@ The following are all valid examples of address expressions: MSPDebug's behaviour can be configured via the following variables: .IP "\fBcolor\fR (boolean)" If true, MSPDebug will colorize debugging output. +.IP "\fBfet_block_size\fR (numeric)" +Change the size of the buffer used to transfer memory to and from the +FET. Increasing the value from the default of 64 will improve transfer +speed, but may cause problems with some chips. .IP "\fBgdb_loop\fR (boolean)" Automatically restart the GDB server after disconnection. If this option is set, then the GDB server keeps running until an error occurs, diff --git a/opdb.c b/opdb.c index 6a0c77a..1f28ee4 100644 --- a/opdb.c +++ b/opdb.c @@ -55,6 +55,17 @@ const static struct opdb_key keys[] = { .defval = { .numeric = 10 } + }, + { + .name = "fet_block_size", + .type = OPDB_TYPE_NUMERIC, + .help = +"Size of buffer used for memory transfers to and from the FET device.\n" +"Increasing this value will result in faster transfers, but may cause\n" +"problems with some chips.\n", + .defval = { + .numeric = 64 + } } }; diff --git a/prog.h b/prog.h index 0b3d82a..a531f66 100644 --- a/prog.h +++ b/prog.h @@ -19,7 +19,7 @@ #ifndef PROG_H_ #define PROG_H_ -#define PROG_BUFSIZE 128 +#define PROG_BUFSIZE 4096 struct prog_data { uint8_t buf[PROG_BUFSIZE];