2009-11-16 23:52:10 +00:00
|
|
|
/* MSPDebug - debugging tool for the eZ430
|
2012-09-13 03:49:19 +00:00
|
|
|
* Copyright (C) 2009-2012 Daniel Beer
|
2009-11-16 23:52:10 +00:00
|
|
|
*
|
|
|
|
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2010-01-04 01:11:19 +00:00
|
|
|
*
|
2010-01-04 09:34:23 +00:00
|
|
|
* Various constants and tables come from uif430, written by Robert
|
2010-01-04 01:11:19 +00:00
|
|
|
* Kavaler (kavaler@diva.com). This is available under the same license
|
|
|
|
* as this program, from www.relavak.com.
|
2009-11-16 23:52:10 +00:00
|
|
|
*/
|
|
|
|
|
2010-04-30 04:01:03 +00:00
|
|
|
#include <stdlib.h>
|
2009-11-16 23:52:10 +00:00
|
|
|
|
2010-04-30 04:01:03 +00:00
|
|
|
#include "fet.h"
|
2012-09-13 03:49:19 +00:00
|
|
|
#include "fet_proto.h"
|
2012-09-17 23:17:55 +00:00
|
|
|
#include "fet_core.h"
|
2010-08-16 23:07:03 +00:00
|
|
|
#include "output.h"
|
2012-09-13 02:33:04 +00:00
|
|
|
#include "comport.h"
|
2012-09-13 02:53:30 +00:00
|
|
|
#include "ftdi.h"
|
2011-03-15 01:20:06 +00:00
|
|
|
#include "rf2500.h"
|
2011-09-16 02:40:40 +00:00
|
|
|
#include "ti3410.h"
|
2012-09-13 01:55:14 +00:00
|
|
|
#include "cp210x.h"
|
|
|
|
#include "cdc_acm.h"
|
2012-09-11 02:35:31 +00:00
|
|
|
#include "obl.h"
|
2011-03-15 01:20:06 +00:00
|
|
|
|
2011-03-15 01:56:07 +00:00
|
|
|
static device_t fet_open_rf2500(const struct device_args *args)
|
2011-03-15 01:20:06 +00:00
|
|
|
{
|
|
|
|
transport_t trans;
|
|
|
|
|
|
|
|
if (args->flags & DEVICE_FLAG_TTY) {
|
|
|
|
printc_err("This driver does not support TTY devices.\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-09-13 03:49:19 +00:00
|
|
|
trans = rf2500_open(args->path, args->requested_serial);
|
|
|
|
if (!trans)
|
|
|
|
return NULL;
|
2011-03-15 01:20:06 +00:00
|
|
|
|
2012-09-13 03:49:19 +00:00
|
|
|
return fet_open(args, FET_PROTO_SEPARATE_DATA, trans,
|
|
|
|
0, &device_rf2500);
|
2011-03-15 01:20:06 +00:00
|
|
|
}
|
|
|
|
|
2011-03-15 01:56:07 +00:00
|
|
|
const struct device_class device_rf2500 = {
|
|
|
|
.name = "rf2500",
|
|
|
|
.help =
|
2011-03-15 03:08:46 +00:00
|
|
|
"eZ430-RF2500 devices. Only USB connection is supported.",
|
2011-03-15 01:56:07 +00:00
|
|
|
.open = fet_open_rf2500,
|
|
|
|
.destroy = fet_destroy,
|
|
|
|
.readmem = fet_readmem,
|
|
|
|
.writemem = fet_writemem,
|
|
|
|
.erase = fet_erase,
|
|
|
|
.getregs = fet_getregs,
|
|
|
|
.setregs = fet_setregs,
|
|
|
|
.ctl = fet_ctl,
|
|
|
|
.poll = fet_poll
|
|
|
|
};
|
|
|
|
|
2012-09-13 01:55:14 +00:00
|
|
|
static device_t fet_open_olimex_iso_mk2(const struct device_args *args)
|
2011-03-15 01:20:06 +00:00
|
|
|
{
|
|
|
|
transport_t trans;
|
2012-09-11 02:35:31 +00:00
|
|
|
uint32_t version;
|
2011-03-15 01:20:06 +00:00
|
|
|
|
|
|
|
if (args->flags & DEVICE_FLAG_TTY)
|
2012-09-13 02:33:04 +00:00
|
|
|
trans = comport_open(args->path, 115200);
|
2011-03-15 01:20:06 +00:00
|
|
|
else
|
2012-09-13 01:55:14 +00:00
|
|
|
trans = cdc_acm_open(args->path, args->requested_serial,
|
|
|
|
115200, 0x15ba, 0x0100);
|
2011-03-15 01:20:06 +00:00
|
|
|
|
2012-09-11 02:35:31 +00:00
|
|
|
if (!trans)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (args->require_fwupdate) {
|
|
|
|
if (obl_update(trans, args->require_fwupdate) < 0) {
|
|
|
|
trans->ops->destroy(trans);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-10-04 02:24:44 +00:00
|
|
|
obl_reset(trans);
|
2012-09-11 02:35:31 +00:00
|
|
|
trans->ops->destroy(trans);
|
|
|
|
|
|
|
|
printc("Resetting, please wait...\n");
|
|
|
|
delay_s(15);
|
|
|
|
|
|
|
|
if (args->flags & DEVICE_FLAG_TTY)
|
2012-09-13 02:33:04 +00:00
|
|
|
trans = comport_open(args->path, 115200);
|
2012-09-11 02:35:31 +00:00
|
|
|
else
|
2012-09-13 01:55:14 +00:00
|
|
|
trans = cdc_acm_open(args->path,
|
|
|
|
args->requested_serial,
|
|
|
|
115200, 0x15ba, 0x0100);
|
2012-09-11 02:35:31 +00:00
|
|
|
|
|
|
|
if (!trans)
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!obl_get_version(trans, &version))
|
|
|
|
printc_dbg("Olimex firmware version: %x\n", version);
|
2011-03-15 01:20:06 +00:00
|
|
|
|
2012-09-13 03:49:19 +00:00
|
|
|
return fet_open(args,
|
|
|
|
FET_PROTO_NOLEAD_SEND | FET_PROTO_EXTRA_RECV,
|
|
|
|
trans,
|
|
|
|
FET_FORCE_RESET | FET_IDENTIFY_NEW,
|
|
|
|
&device_olimex_iso_mk2);
|
2012-09-13 01:55:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const struct device_class device_olimex_iso_mk2 = {
|
|
|
|
.name = "olimex-iso-mk2",
|
|
|
|
.help =
|
|
|
|
"Olimex MSP430-JTAG-ISO-MK2.",
|
|
|
|
.open = fet_open_olimex_iso_mk2,
|
|
|
|
.destroy = fet_destroy,
|
|
|
|
.readmem = fet_readmem,
|
|
|
|
.writemem = fet_writemem,
|
|
|
|
.erase = fet_erase,
|
|
|
|
.getregs = fet_getregs,
|
|
|
|
.setregs = fet_setregs,
|
|
|
|
.ctl = fet_ctl,
|
|
|
|
.poll = fet_poll
|
|
|
|
};
|
|
|
|
|
|
|
|
static device_t fet_open_olimex(const struct device_args *args)
|
|
|
|
{
|
|
|
|
transport_t trans;
|
|
|
|
|
|
|
|
if (args->flags & DEVICE_FLAG_TTY)
|
2012-09-13 02:33:04 +00:00
|
|
|
trans = comport_open(args->path, 115200);
|
2012-09-13 01:55:14 +00:00
|
|
|
else
|
|
|
|
trans = cdc_acm_open(args->path, args->requested_serial,
|
|
|
|
115200, 0x15ba, 0x0031);
|
|
|
|
|
|
|
|
if (!trans)
|
|
|
|
return NULL;
|
|
|
|
|
2012-09-13 03:49:19 +00:00
|
|
|
return fet_open(args,
|
|
|
|
FET_PROTO_NOLEAD_SEND | FET_PROTO_EXTRA_RECV,
|
|
|
|
trans,
|
|
|
|
FET_IDENTIFY_NEW | FET_FORCE_RESET,
|
|
|
|
&device_olimex);
|
2011-03-15 01:20:06 +00:00
|
|
|
}
|
|
|
|
|
2011-03-15 01:56:07 +00:00
|
|
|
const struct device_class device_olimex = {
|
|
|
|
.name = "olimex",
|
|
|
|
.help =
|
|
|
|
"Olimex MSP-JTAG-TINY.",
|
|
|
|
.open = fet_open_olimex,
|
|
|
|
.destroy = fet_destroy,
|
|
|
|
.readmem = fet_readmem,
|
|
|
|
.writemem = fet_writemem,
|
|
|
|
.erase = fet_erase,
|
|
|
|
.getregs = fet_getregs,
|
|
|
|
.setregs = fet_setregs,
|
|
|
|
.ctl = fet_ctl,
|
|
|
|
.poll = fet_poll
|
|
|
|
};
|
|
|
|
|
2011-12-25 22:22:04 +00:00
|
|
|
static device_t fet_open_olimex_v1(const struct device_args *args)
|
|
|
|
{
|
|
|
|
transport_t trans;
|
|
|
|
|
|
|
|
if (args->flags & DEVICE_FLAG_TTY)
|
2012-09-13 02:33:04 +00:00
|
|
|
trans = comport_open(args->path, 500000);
|
2011-12-25 22:22:04 +00:00
|
|
|
else
|
2012-09-13 01:55:14 +00:00
|
|
|
trans = cp210x_open(args->path, args->requested_serial,
|
|
|
|
500000, 0x15ba, 0x0002);
|
2011-12-25 22:22:04 +00:00
|
|
|
|
|
|
|
if (!trans)
|
|
|
|
return NULL;
|
|
|
|
|
2012-09-13 03:49:19 +00:00
|
|
|
return fet_open(args,
|
|
|
|
FET_PROTO_NOLEAD_SEND | FET_PROTO_EXTRA_RECV,
|
|
|
|
trans,
|
|
|
|
FET_IDENTIFY_NEW,
|
|
|
|
&device_olimex_v1);
|
2011-12-25 22:22:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const struct device_class device_olimex_v1 = {
|
|
|
|
.name = "olimex-v1",
|
|
|
|
.help =
|
|
|
|
"Olimex MSP-JTAG-TINY (V1).",
|
|
|
|
.open = fet_open_olimex_v1,
|
|
|
|
.destroy = fet_destroy,
|
|
|
|
.readmem = fet_readmem,
|
|
|
|
.writemem = fet_writemem,
|
|
|
|
.erase = fet_erase,
|
|
|
|
.getregs = fet_getregs,
|
|
|
|
.setregs = fet_setregs,
|
|
|
|
.ctl = fet_ctl,
|
|
|
|
.poll = fet_poll
|
|
|
|
};
|
|
|
|
|
2011-03-15 01:56:07 +00:00
|
|
|
static device_t fet_open_olimex_iso(const struct device_args *args)
|
2011-03-15 01:20:06 +00:00
|
|
|
{
|
|
|
|
transport_t trans;
|
|
|
|
|
2012-03-01 23:13:11 +00:00
|
|
|
if (args->flags & DEVICE_FLAG_TTY)
|
2012-09-13 02:33:04 +00:00
|
|
|
trans = comport_open(args->path, 200000);
|
2012-03-01 23:13:11 +00:00
|
|
|
else
|
2012-09-13 02:53:30 +00:00
|
|
|
trans = ftdi_open(args->path, args->requested_serial,
|
|
|
|
0x15ba, 0x0008, 200000);
|
2011-03-15 01:20:06 +00:00
|
|
|
|
2012-03-01 23:13:11 +00:00
|
|
|
if (!trans)
|
|
|
|
return NULL;
|
2011-03-15 01:20:06 +00:00
|
|
|
|
2012-09-13 03:49:19 +00:00
|
|
|
return fet_open(args,
|
|
|
|
FET_PROTO_NOLEAD_SEND | FET_PROTO_EXTRA_RECV,
|
|
|
|
trans,
|
|
|
|
FET_IDENTIFY_NEW,
|
|
|
|
&device_olimex_iso);
|
2011-03-15 01:20:06 +00:00
|
|
|
}
|
|
|
|
|
2011-03-15 01:56:07 +00:00
|
|
|
const struct device_class device_olimex_iso = {
|
|
|
|
.name = "olimex-iso",
|
|
|
|
.help =
|
|
|
|
"Olimex MSP-JTAG-ISO.",
|
|
|
|
.open = fet_open_olimex_iso,
|
|
|
|
.destroy = fet_destroy,
|
|
|
|
.readmem = fet_readmem,
|
|
|
|
.writemem = fet_writemem,
|
|
|
|
.erase = fet_erase,
|
|
|
|
.getregs = fet_getregs,
|
|
|
|
.setregs = fet_setregs,
|
|
|
|
.ctl = fet_ctl,
|
|
|
|
.poll = fet_poll
|
|
|
|
};
|
|
|
|
|
|
|
|
static device_t fet_open_uif(const struct device_args *args)
|
2011-03-15 01:20:06 +00:00
|
|
|
{
|
|
|
|
transport_t trans;
|
|
|
|
|
2011-09-16 02:40:40 +00:00
|
|
|
if (args->flags & DEVICE_FLAG_TTY)
|
2012-09-13 02:33:04 +00:00
|
|
|
trans = comport_open(args->path, 460800);
|
2011-09-16 02:40:40 +00:00
|
|
|
else
|
|
|
|
trans = ti3410_open(args->path, args->requested_serial);
|
2011-03-15 01:20:06 +00:00
|
|
|
|
|
|
|
if (!trans)
|
|
|
|
return NULL;
|
|
|
|
|
2012-09-13 03:49:19 +00:00
|
|
|
return fet_open(args, 0, trans, 0, &device_uif);
|
2011-03-15 01:20:06 +00:00
|
|
|
}
|
2011-03-15 01:56:07 +00:00
|
|
|
|
|
|
|
const struct device_class device_uif = {
|
2011-03-15 03:08:46 +00:00
|
|
|
.name = "uif",
|
2011-03-15 01:56:07 +00:00
|
|
|
.help =
|
|
|
|
"TI FET430UIF and compatible devices (e.g. eZ430).",
|
|
|
|
.open = fet_open_uif,
|
|
|
|
.destroy = fet_destroy,
|
|
|
|
.readmem = fet_readmem,
|
|
|
|
.writemem = fet_writemem,
|
|
|
|
.erase = fet_erase,
|
|
|
|
.getregs = fet_getregs,
|
|
|
|
.setregs = fet_setregs,
|
|
|
|
.ctl = fet_ctl,
|
|
|
|
.poll = fet_poll
|
|
|
|
};
|