Support for Olimex MSP430-JTAG-ISO.

This commit is contained in:
Daniel Beer 2010-11-09 09:16:31 +13:00
parent 2e89e0b45d
commit 1570f3cbdd
5 changed files with 85 additions and 7 deletions

View File

@ -41,3 +41,7 @@ Andrew Armenia <andrew@asquaredlabs.com>:
James Laird <james.laird@nicta.com.au>: James Laird <james.laird@nicta.com.au>:
* Support for CC430F5133. * Support for CC430F5133.
Stefan Mahr <Stefan.Mahr@phairon.com>:
* Initial support, testing and analysis for Olimex
MSP430-JTAG-ISO.

25
main.c
View File

@ -174,7 +174,7 @@ static device_t driver_open_olimex(const struct cmdline_args *args)
transport_t trans; transport_t trans;
if (args->serial_device) if (args->serial_device)
trans = uif_open(args->serial_device, 1); trans = uif_open(args->serial_device, UIF_TYPE_OLIMEX);
else else
trans = olimex_open(args->usb_device); trans = olimex_open(args->usb_device);
@ -184,6 +184,23 @@ static device_t driver_open_olimex(const struct cmdline_args *args)
return driver_open_fet(args, FET_PROTO_OLIMEX, trans); return driver_open_fet(args, FET_PROTO_OLIMEX, trans);
} }
static device_t driver_open_olimex_iso(const struct cmdline_args *args)
{
transport_t trans;
if (!args->serial_device) {
printc_err("This driver does not support USB access. "
"Specify a tty device using -d.\n");
return NULL;
}
trans = uif_open(args->serial_device, UIF_TYPE_OLIMEX_ISO);
if (!trans)
return NULL;
return driver_open_fet(args, FET_PROTO_OLIMEX, trans);
}
static device_t driver_open_sim(const struct cmdline_args *args) static device_t driver_open_sim(const struct cmdline_args *args)
{ {
return sim_open(fetch_io, store_io, NULL); return sim_open(fetch_io, store_io, NULL);
@ -199,7 +216,7 @@ static device_t driver_open_uif(const struct cmdline_args *args)
return NULL; return NULL;
} }
trans = uif_open(args->serial_device, 0); trans = uif_open(args->serial_device, UIF_TYPE_FET);
if (!trans) if (!trans)
return NULL; return NULL;
@ -239,6 +256,10 @@ static const struct driver driver_table[] = {
.help = "Olimex MSP-JTAG-TINY.", .help = "Olimex MSP-JTAG-TINY.",
.func = driver_open_olimex .func = driver_open_olimex
}, },
{ .name = "olimex-iso",
.help = "Olimex MSP-JTAG-ISO.",
.func = driver_open_olimex_iso
},
{ {
.name = "sim", .name = "sim",
.help = "Simulation mode.", .help = "Simulation mode.",

View File

@ -71,6 +71,8 @@ Connect to an eZ430-RF2500 device. Only USB connection is supported.
.IP "\fBolimex\fR" .IP "\fBolimex\fR"
Connect to an Olimex MSP-JTAG-TINY device. Both USB and tty access are Connect to an Olimex MSP-JTAG-TINY device. Both USB and tty access are
supported. supported.
.IP "\fBolimex-iso\fR"
Connect to an Olimex MSP-JTAG-ISO device. Only tty access is supported.
.IP "\fBsim\fR" .IP "\fBsim\fR"
Do not connect to any hardware device, but instead start in simulation Do not connect to any hardware device, but instead start in simulation
mode. A 64k buffer is allocated to simulate the device memory. The CPU mode. A 64k buffer is allocated to simulate the device memory. The CPU

53
uif.c
View File

@ -25,6 +25,10 @@
#include <unistd.h> #include <unistd.h>
#include <termios.h> #include <termios.h>
#include <linux/serial.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include "uif.h" #include "uif.h"
#include "util.h" #include "util.h"
#include "output.h" #include "output.h"
@ -81,7 +85,35 @@ static void serial_destroy(transport_t tr_base)
free(tr); free(tr);
} }
transport_t uif_open(const char *device, int is_olimex) static int open_olimex_iso(const char *device)
{
int fd = open(device, O_RDWR | O_NOCTTY);
struct termios attr;
struct serial_struct serial_info;
if (fd < 0)
return -1;
tcgetattr(fd, &attr);
cfmakeraw(&attr);
cfsetispeed(&attr, B38400);
cfsetospeed(&attr, B38400);
serial_info.flags = ASYNC_SPD_CUST;
serial_info.custom_divisor = 120;
if (ioctl(fd, TIOCSSERIAL, &serial_info) < 0) {
printc_err("open_olimex_iso: can't do ioctl TIOCSSERIAL: %s\n",
strerror(errno));
return -1;
}
if (tcsetattr(fd, TCSAFLUSH, &attr) < 0)
return -1;
return fd;
}
transport_t uif_open(const char *device, uif_type_t type)
{ {
struct uif_transport *tr = malloc(sizeof(*tr)); struct uif_transport *tr = malloc(sizeof(*tr));
@ -94,10 +126,23 @@ transport_t uif_open(const char *device, int is_olimex)
tr->base.recv = serial_recv; tr->base.recv = serial_recv;
tr->base.destroy = serial_destroy; tr->base.destroy = serial_destroy;
printc("Trying to open %s on %s...\n", switch (type) {
is_olimex ? "Olimex" : "UIF", device); case UIF_TYPE_FET:
printc("Trying to open UIF on %s...\n", device);
tr->serial_fd = open_serial(device, B460800);
break;
case UIF_TYPE_OLIMEX:
printc("Trying to open Olimex on %s...\n", device);
tr->serial_fd = open_serial(device, B500000);
break;
case UIF_TYPE_OLIMEX_ISO:
printc("Trying to open Olimex (ISO) on %s...\n", device);
tr->serial_fd = open_olimex_iso(device);
break;
}
tr->serial_fd = open_serial(device, is_olimex ? B500000 : B460800);
if (tr->serial_fd < 0) { if (tr->serial_fd < 0) {
printc_err("uif: can't open serial device: %s: %s\n", printc_err("uif: can't open serial device: %s: %s\n",
device, strerror(errno)); device, strerror(errno));

8
uif.h
View File

@ -21,10 +21,16 @@
#include "transport.h" #include "transport.h"
typedef enum {
UIF_TYPE_FET,
UIF_TYPE_OLIMEX,
UIF_TYPE_OLIMEX_ISO
} uif_type_t;
/* This function is for opening an eZ430-F2013 or FET430UIF device via /* This function is for opening an eZ430-F2013 or FET430UIF device via
* a kernel-supported serial interface. The argument given should be the * a kernel-supported serial interface. The argument given should be the
* filename of the relevant tty device. * filename of the relevant tty device.
*/ */
transport_t uif_open(const char *device, int is_olimex); transport_t uif_open(const char *device, uif_type_t type);
#endif #endif