BSL now shows descriptive errors returned by FET.

This commit is contained in:
Daniel Beer 2010-05-15 13:44:46 +12:00
parent c96ce58a8f
commit fab96c725d
5 changed files with 129 additions and 72 deletions

View File

@ -43,7 +43,7 @@ install: mspdebug mspdebug.man
mspdebug: main.o fet.o rf2500.o dis.o uif.o ihex.o elf32.o stab.o util.o \
bsl.o sim.o symmap.o gdb.o btree.o device.o rtools.o sym.o devcmd.o \
cproc.o vector.o cproc_util.o expr.o
cproc.o vector.o cproc_util.o expr.o fet_error.o
$(CC) $(LDFLAGS) -o $@ $^ -lusb $(READLINE_LIBS)
.c.o:

5
bsl.c
View File

@ -28,6 +28,7 @@
#include "bsl.h"
#include "util.h"
#include "fet_error.h"
struct bsl_device {
struct device base;
@ -299,8 +300,8 @@ static int enter_via_fet(struct bsl_device *dev)
/* Check that it's what we expect */
if (memcmp(buf, "\x06\x00\x24\x00\x00\x00\x61\x01", 8)) {
fprintf(stderr, "bsl: bootloader start returned error %d\n",
buf[5]);
fprintf(stderr, "bsl: bootloader start returned error "
"%d (%s)\n", buf[5], fet_error(buf[5]));
return -1;
}

72
fet.c
View File

@ -29,6 +29,7 @@
#include "util.h"
#include "fet.h"
#include "fet_error.h"
#define MAX_PARAMS 16
@ -217,70 +218,6 @@ static int send_rf2500_data(struct fet_device *dev,
#define PTYPE_NAK 5
#define PTYPE_FLASH_ACK 6
/* This table is taken from uif430 */
static const char *error_strings[] =
{
"No error", // 0
"Could not initialize device interface", // 1
"Could not close device interface", // 2
"Invalid parameter(s)", // 3
"Could not find device (or device not supported)", // 4
"Unknown device", // 5
"Could not read device memory", // 6
"Could not write device memory", // 7
"Could not read device configuration fuses", // 8
"Incorrectly configured device; device derivative not supported",// 9
"Could not set device Vcc", // 10
"Could not reset device", // 11
"Could not preserve/restore device memory", // 12
"Could not set device operating frequency", // 13
"Could not erase device memory", // 14
"Could not set device breakpoint", // 15
"Could not single step device", // 16
"Could not run device (to breakpoint)", // 17
"Could not determine device state", // 18
"Could not open Enhanced Emulation Module", // 19
"Could not read Enhanced Emulation Module register", // 20
"Could not write Enhanced Emulation Module register", // 21
"Could not close Enhanced Emulation Module", // 22
"File open error", // 23
"Could not determine file type", // 24
"Unexpected end of file encountered", // 25
"File input/output error", // 26
"File data error", // 27
"Verification error", // 28
"Could not blow device security fuse", // 29
"Could not access device - security fuse is blown", // 30
"Error within Intel Hex file", // 31
"Could not write device Register", // 32
"Could not read device Register", // 33
"Not supported by selected Interface", // 34
"Could not communicate with FET", // 35
"No external power supply detected", // 36
"External power too low", // 37
"External power detected", // 38
"External power too high", // 39
"Hardware Self Test Error", // 40
"Fast Flash Routine experienced a timeout", // 41
"Could not create thread for polling", // 42
"Could not initialize Enhanced Emulation Module", // 43
"Insufficient resources", // 44
"No clock control emulation on connected device", // 45
"No state storage buffer implemented on connected device", // 46
"Could not read trace buffer", // 47
"Enable the variable watch function", // 48
"No trigger sequencer implemented on connected device", // 49
"Could not read sequencer state - Sequencer is disabled", // 50
"Could not remove trigger - Used in sequencer", // 51
"Could not set combination - Trigger is used in sequencer", // 52
"Invalid error number", // 53
};
static int parse_packet(struct fet_device *dev, int plen)
{
uint16_t c = calc_checksum(dev->fet_buf + 2, plen - 2);
@ -304,11 +241,8 @@ static int parse_packet(struct fet_device *dev, int plen)
error = dev->fet_buf[i++];
if (error) {
fprintf(stderr, "fet: FET returned error code %d\n",
error);
if (error > 0 && error < ARRAY_LEN(error_strings)) {
fprintf(stderr, " (%s)\n", error_strings[error]);
}
fprintf(stderr, "fet: FET returned error code %d (%s)\n",
error, fet_error(error));
return -1;
}

95
fet_error.c Normal file
View File

@ -0,0 +1,95 @@
/* MSPDebug - debugging tool for the eZ430
* Copyright (C) 2009, 2010 Daniel Beer
*
* 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
*
* Various constants and tables come from uif430, written by Robert
* Kavaler (kavaler@diva.com). This is available under the same license
* as this program, from www.relavak.com.
*/
#include "util.h"
/* This table is taken from uif430 */
static const char *error_strings[] =
{
"No error", // 0
"Could not initialize device interface", // 1
"Could not close device interface", // 2
"Invalid parameter(s)", // 3
"Could not find device (or device not supported)", // 4
"Unknown device", // 5
"Could not read device memory", // 6
"Could not write device memory", // 7
"Could not read device configuration fuses", // 8
"Incorrectly configured device; device derivative not supported",// 9
"Could not set device Vcc", // 10
"Could not reset device", // 11
"Could not preserve/restore device memory", // 12
"Could not set device operating frequency", // 13
"Could not erase device memory", // 14
"Could not set device breakpoint", // 15
"Could not single step device", // 16
"Could not run device (to breakpoint)", // 17
"Could not determine device state", // 18
"Could not open Enhanced Emulation Module", // 19
"Could not read Enhanced Emulation Module register", // 20
"Could not write Enhanced Emulation Module register", // 21
"Could not close Enhanced Emulation Module", // 22
"File open error", // 23
"Could not determine file type", // 24
"Unexpected end of file encountered", // 25
"File input/output error", // 26
"File data error", // 27
"Verification error", // 28
"Could not blow device security fuse", // 29
"Could not access device - security fuse is blown", // 30
"Error within Intel Hex file", // 31
"Could not write device Register", // 32
"Could not read device Register", // 33
"Not supported by selected Interface", // 34
"Could not communicate with FET", // 35
"No external power supply detected", // 36
"External power too low", // 37
"External power detected", // 38
"External power too high", // 39
"Hardware Self Test Error", // 40
"Fast Flash Routine experienced a timeout", // 41
"Could not create thread for polling", // 42
"Could not initialize Enhanced Emulation Module", // 43
"Insufficient resources", // 44
"No clock control emulation on connected device", // 45
"No state storage buffer implemented on connected device", // 46
"Could not read trace buffer", // 47
"Enable the variable watch function", // 48
"No trigger sequencer implemented on connected device", // 49
"Could not read sequencer state - Sequencer is disabled", // 50
"Could not remove trigger - Used in sequencer", // 51
"Could not set combination - Trigger is used in sequencer", // 52
"Invalid error number", // 53
};
const char *fet_error(int code)
{
if (code < 0 || code >= ARRAY_LEN(error_strings))
return "Unknown error";
return error_strings[code];
}

27
fet_error.h Normal file
View File

@ -0,0 +1,27 @@
/* MSPDebug - debugging tool for MSP430 MCUs
* Copyright (C) 2009, 2010 Daniel Beer
*
* 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
*/
#ifndef FET_ERROR_H_
#define FET_ERROR_H_
/* Translate an error code received from a FET into a string that can
* be displayed to the user.
*/
const char *fet_error(int code);
#endif