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.
This commit is contained in:
Daniel Beer 2011-02-21 11:30:32 +13:00
parent 429edda47d
commit e182be2204
5 changed files with 38 additions and 8 deletions

View File

@ -82,7 +82,7 @@ int cmd_md(char **arg)
reader_set_repeat("md 0x%x 0x%x", offset + length, length); reader_set_repeat("md 0x%x 0x%x", offset + length, length);
while (length) { while (length) {
uint8_t buf[128]; uint8_t buf[4096];
int blen = length > sizeof(buf) ? sizeof(buf) : length; int blen = length > sizeof(buf) ? sizeof(buf) : length;
if (device_default->readmem(device_default, if (device_default->readmem(device_default,
@ -450,7 +450,7 @@ int cmd_hexout(char **arg)
return -1; return -1;
while (length) { while (length) {
uint8_t buf[128]; uint8_t buf[4096];
int count = length; int count = length;
if (count > sizeof(buf)) if (count > sizeof(buf))

25
fet.c
View File

@ -32,9 +32,10 @@
#include "fet_error.h" #include "fet_error.h"
#include "fet_db.h" #include "fet_db.h"
#include "output.h" #include "output.h"
#include "opdb.h"
#define MAX_PARAMS 16 #define MAX_PARAMS 16
#define BLOCK_SIZE 64 #define MAX_BLOCK_SIZE 4096
struct fet_device { struct fet_device {
struct device base; 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 uint32_t *params, int nparams,
const uint8_t *extra, int exlen) const uint8_t *extra, int exlen)
{ {
uint8_t datapkt[256]; uint8_t datapkt[MAX_BLOCK_SIZE * 2];
int len = 0; int len = 0;
uint8_t buf[512]; uint8_t buf[MAX_BLOCK_SIZE * 3];
uint16_t cksum; uint16_t cksum;
int i = 0; int i = 0;
int j; int j;
@ -758,10 +759,23 @@ static int write_byte(struct fet_device *dev, address_t addr, uint8_t value)
return 0; 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, int fet_readmem(device_t dev_base, address_t addr, uint8_t *buffer,
address_t count) address_t count)
{ {
struct fet_device *dev = (struct fet_device *)dev_base; struct fet_device *dev = (struct fet_device *)dev_base;
int block_size = get_adjusted_block_size();
if (addr & 1) { if (addr & 1) {
if (read_byte(dev, addr, buffer) < 0) 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) { while (count > 1) {
int plen = count > BLOCK_SIZE ? BLOCK_SIZE : count; int plen = count > block_size ? block_size : count;
plen &= ~0x1; plen &= ~0x1;
@ -804,6 +818,7 @@ int fet_writemem(device_t dev_base, address_t addr,
const uint8_t *buffer, address_t count) const uint8_t *buffer, address_t count)
{ {
struct fet_device *dev = (struct fet_device *)dev_base; struct fet_device *dev = (struct fet_device *)dev_base;
int block_size = get_adjusted_block_size();
if (addr & 1) { if (addr & 1) {
if (write_byte(dev, addr, *buffer) < 0) if (write_byte(dev, addr, *buffer) < 0)
@ -814,7 +829,7 @@ int fet_writemem(device_t dev_base, address_t addr,
} }
while (count > 1) { while (count > 1) {
int plen = count > BLOCK_SIZE ? BLOCK_SIZE : count; int plen = count > block_size ? block_size : count;
int ret; int ret;
plen &= ~0x1; plen &= ~0x1;

View File

@ -430,6 +430,10 @@ The following are all valid examples of address expressions:
MSPDebug's behaviour can be configured via the following variables: MSPDebug's behaviour can be configured via the following variables:
.IP "\fBcolor\fR (boolean)" .IP "\fBcolor\fR (boolean)"
If true, MSPDebug will colorize debugging output. 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)" .IP "\fBgdb_loop\fR (boolean)"
Automatically restart the GDB server after disconnection. If this Automatically restart the GDB server after disconnection. If this
option is set, then the GDB server keeps running until an error occurs, option is set, then the GDB server keeps running until an error occurs,

11
opdb.c
View File

@ -55,6 +55,17 @@ const static struct opdb_key keys[] = {
.defval = { .defval = {
.numeric = 10 .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
}
} }
}; };

2
prog.h
View File

@ -19,7 +19,7 @@
#ifndef PROG_H_ #ifndef PROG_H_
#define PROG_H_ #define PROG_H_
#define PROG_BUFSIZE 128 #define PROG_BUFSIZE 4096
struct prog_data { struct prog_data {
uint8_t buf[PROG_BUFSIZE]; uint8_t buf[PROG_BUFSIZE];