- bootloader build with LTO
- switch between debugger from rom or from app - gdb_stub: added debug output to stdout git-svn-id: http://moon:8086/svn/mips@104 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
@@ -12,8 +12,8 @@ else
|
|||||||
ENDIAN_FLAGS=-EB
|
ENDIAN_FLAGS=-EB
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS=$(ENDIAN_FLAGS) -Os -I. -I../libsys -msoft-float -march=r3000 -G0 -I../libsys/boards/$(BOARD) -D$(BOARD)
|
CFLAGS=$(ENDIAN_FLAGS) -Os -flto -I. -I../libsys -msoft-float -march=r3000 -G0 -I../libsys/boards/$(BOARD) -D$(BOARD)
|
||||||
LFLAGS=$(ENDIAN_FLAGS)
|
LFLAGS=$(ENDIAN_FLAGS) -Os -flto
|
||||||
|
|
||||||
ifeq ($(TLB),yes)
|
ifeq ($(TLB),yes)
|
||||||
CFLAGS+=-DSYS_IO_BASE=0xAC000000 -DSDRAM_BASE=0x80000000 -DFLASH_BASE_IO=0xA4000000 -DFLASH_BASE_MEM=0x88000000
|
CFLAGS+=-DSYS_IO_BASE=0xAC000000 -DSDRAM_BASE=0x80000000 -DFLASH_BASE_IO=0xA4000000 -DFLASH_BASE_MEM=0x88000000
|
||||||
|
|||||||
@@ -11,48 +11,38 @@
|
|||||||
#include "../../../libsys/uart.h"
|
#include "../../../libsys/uart.h"
|
||||||
|
|
||||||
extern uart_if_t uart_if[];
|
extern uart_if_t uart_if[];
|
||||||
|
extern void handle_exception (unsigned long *registers);
|
||||||
|
|
||||||
int gdb_stub(struct xcptcontext * xcp) __attribute__ ((section (".gdb")));
|
int gdb_stub(struct xcptcontext * xcp) __attribute__ ((section (".gdb")));
|
||||||
|
|
||||||
int gdb_stub(struct xcptcontext * xcp)
|
int gdb_stub(struct xcptcontext * xcp)
|
||||||
{
|
{
|
||||||
handle_exception((unsigned long *)xcp);
|
handle_exception((unsigned long *)xcp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void _dbg_writechar(uart_if_t const *pUart, char c)
|
void dbg_putchar(char c)
|
||||||
{
|
{
|
||||||
UART_writechar(pUart, c);
|
if (c == 0x0A)
|
||||||
|
{
|
||||||
|
UART_writechar(&uart_if[UART_DEBUGGER], 0x0D);
|
||||||
|
}
|
||||||
|
UART_writechar(&uart_if[UART_DEBUGGER], c);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline char _dbg_readchar(uart_if_t const *pUart)
|
char dbg_getchar()
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
// busy read
|
// busy read
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
c = UART_readchar(pUart);
|
c = UART_readchar(&uart_if[UART_DEBUGGER]);
|
||||||
|
|
||||||
} while(c < 0);
|
} while(c < 0);
|
||||||
|
|
||||||
return (char)c;
|
return (char)c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dbg_putchar(char c)
|
|
||||||
{
|
|
||||||
if (c == 0x0A)
|
|
||||||
{
|
|
||||||
_dbg_writechar(&uart_if[UART_DEBUGGER], 0x0D);
|
|
||||||
}
|
|
||||||
_dbg_writechar(&uart_if[UART_DEBUGGER], c);
|
|
||||||
}
|
|
||||||
|
|
||||||
char dbg_getchar()
|
|
||||||
{
|
|
||||||
return (char)_dbg_readchar(&uart_if[UART_DEBUGGER]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void board_init(void)
|
void board_init(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -13,7 +13,7 @@ else
|
|||||||
ENDIAN_FLAGS=-EB
|
ENDIAN_FLAGS=-EB
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS=$(ENDIAN_FLAGS) -g -msoft-float -O2 -march=r3000 -I. -Iboards/$(BOARD) -D$(BOARD)
|
CFLAGS=$(ENDIAN_FLAGS) -g -msoft-float -O2 -march=r3000 -I. -Iboards/$(BOARD) -D$(BOARD) -DWITH_ROM_GDBSTUB
|
||||||
|
|
||||||
ifeq ($(TLB),yes)
|
ifeq ($(TLB),yes)
|
||||||
CFLAGS+=-DSYS_IO_BASE=0xAC000000 -DSDRAM_BASE=0x80000000 -DFLASH_BASE_IO=0xA4000000 -DFLASH_BASE_MEM=0x88000000
|
CFLAGS+=-DSYS_IO_BASE=0xAC000000 -DSDRAM_BASE=0x80000000 -DFLASH_BASE_IO=0xA4000000 -DFLASH_BASE_MEM=0x88000000
|
||||||
@@ -32,7 +32,7 @@ OBJCOPY=mips-elf-objcopy
|
|||||||
FLASHGEN=flashgen
|
FLASHGEN=flashgen
|
||||||
|
|
||||||
OBJS-ml402=$(addprefix $(BUILD_DIR)/, libsys.o xcpt.o syscalls.o cop0.o irq.o mips_dbg.o mips_dis.o mips_ps2.o mips_gfx.o console.o screen.o uart.o board.o gpio.o)
|
OBJS-ml402=$(addprefix $(BUILD_DIR)/, libsys.o xcpt.o syscalls.o cop0.o irq.o mips_dbg.o mips_dis.o mips_ps2.o mips_gfx.o console.o screen.o uart.o board.o gpio.o)
|
||||||
OBJS-denano=$(addprefix $(BUILD_DIR)/, libsys.o xcpt.o syscalls.o cop0.o irq.o mips_dbg.o mips_dis.o console.o uart.o board.o)
|
OBJS-denano=$(addprefix $(BUILD_DIR)/, libsys.o xcpt.o syscalls.o cop0.o irq.o mips_dbg.o mips_dis.o console.o uart.o board.o gdb_stub.o)
|
||||||
|
|
||||||
all: $(BUILD_DIR) $(BUILD_DIR)/libsys.a
|
all: $(BUILD_DIR) $(BUILD_DIR)/libsys.a
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,19 @@
|
|||||||
#include "../../console.h"
|
#include "../../console.h"
|
||||||
#include "../../regdef.h"
|
#include "../../regdef.h"
|
||||||
|
|
||||||
const fp_xcpt_t dbg_func = (fp_xcpt_t)0xbfc01f00;
|
|
||||||
|
|
||||||
extern uart_if_t uart_if[];
|
extern uart_if_t uart_if[];
|
||||||
|
extern void handle_exception (unsigned long *registers);
|
||||||
|
|
||||||
|
int gdb_stub(struct xcptcontext * xcp)
|
||||||
|
{
|
||||||
|
handle_exception((unsigned long *)xcp);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#ifdef WITH_ROM_GDBSTUB
|
||||||
|
const fp_xcpt_t dbg_func = (fp_xcpt_t)0xbfc01f00;
|
||||||
|
#else
|
||||||
|
const fp_xcpt_t dbg_func = (fp_xcpt_t)gdb_stub;
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
|
#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
|
||||||
|
|
||||||
@@ -48,9 +58,7 @@ void dbg_uart_isr(struct xcptcontext *xcp)
|
|||||||
void dbg_uart_setup()
|
void dbg_uart_setup()
|
||||||
{
|
{
|
||||||
const int UART_INT = SYS_INT_UART1;
|
const int UART_INT = SYS_INT_UART1;
|
||||||
dbg_uart = (uart_if_t*)con_getInterfaceByName("UART-1")->pInst;
|
*uart_if[UART_DEBUGGER].pCTRL = SYS_UART_BIT_RX_INTEN;
|
||||||
|
|
||||||
*dbg_uart->pCTRL = SYS_UART_BIT_RX_INTEN;
|
|
||||||
interrupt_register(UART_INT, dbg_uart_isr);
|
interrupt_register(UART_INT, dbg_uart_isr);
|
||||||
interrupt_enable(UART_INT);
|
interrupt_enable(UART_INT);
|
||||||
}
|
}
|
||||||
@@ -88,3 +96,26 @@ void board_init(void)
|
|||||||
|
|
||||||
// Do some initializations here
|
// Do some initializations here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dbg_putchar(char c)
|
||||||
|
{
|
||||||
|
if (c == 0x0A)
|
||||||
|
{
|
||||||
|
UART_writechar(&uart_if[UART_DEBUGGER], 0x0D);
|
||||||
|
}
|
||||||
|
UART_writechar(&uart_if[UART_DEBUGGER], c);
|
||||||
|
}
|
||||||
|
|
||||||
|
char dbg_getchar()
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
|
||||||
|
// busy read
|
||||||
|
do
|
||||||
|
{
|
||||||
|
c = UART_readchar(&uart_if[UART_DEBUGGER]);
|
||||||
|
|
||||||
|
} while(c < 0);
|
||||||
|
|
||||||
|
return (char)c;
|
||||||
|
}
|
||||||
|
|||||||
@@ -11,9 +11,19 @@
|
|||||||
#include "../../console.h"
|
#include "../../console.h"
|
||||||
#include "../../regdef.h"
|
#include "../../regdef.h"
|
||||||
|
|
||||||
const fp_xcpt_t dbg_func = (fp_xcpt_t)0xbfc01f00;
|
|
||||||
|
|
||||||
extern uart_if_t uart_if[];
|
extern uart_if_t uart_if[];
|
||||||
|
extern void handle_exception (unsigned long *registers);
|
||||||
|
|
||||||
|
int gdb_stub(struct xcptcontext * xcp)
|
||||||
|
{
|
||||||
|
handle_exception((unsigned long *)xcp);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#ifdef WITH_ROM_GDBSTUB
|
||||||
|
const fp_xcpt_t dbg_func = (fp_xcpt_t)0xbfc01f00;
|
||||||
|
#else
|
||||||
|
const fp_xcpt_t dbg_func = (fp_xcpt_t)gdb_stub;
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
|
#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
|
||||||
|
|
||||||
@@ -48,9 +58,7 @@ void dbg_uart_isr(struct xcptcontext *xcp)
|
|||||||
void dbg_uart_setup()
|
void dbg_uart_setup()
|
||||||
{
|
{
|
||||||
const int UART_INT = SYS_INT_UART;
|
const int UART_INT = SYS_INT_UART;
|
||||||
dbg_uart = (uart_if_t*)con_getInterfaceByName("UART-1")->pInst;
|
*uart_if[UART_DEBUGGER].pCTRL = SYS_UART_BIT_RX_INTEN;
|
||||||
|
|
||||||
*dbg_uart->pCTRL = SYS_UART_BIT_RX_INTEN;
|
|
||||||
interrupt_register(UART_INT, dbg_uart_isr);
|
interrupt_register(UART_INT, dbg_uart_isr);
|
||||||
interrupt_enable(UART_INT);
|
interrupt_enable(UART_INT);
|
||||||
}
|
}
|
||||||
@@ -88,3 +96,26 @@ void board_init(void)
|
|||||||
|
|
||||||
// Do some initializations here
|
// Do some initializations here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dbg_putchar(char c)
|
||||||
|
{
|
||||||
|
if (c == 0x0A)
|
||||||
|
{
|
||||||
|
UART_writechar(&uart_if[UART_DEBUGGER], 0x0D);
|
||||||
|
}
|
||||||
|
UART_writechar(&uart_if[UART_DEBUGGER], c);
|
||||||
|
}
|
||||||
|
|
||||||
|
char dbg_getchar()
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
|
||||||
|
// busy read
|
||||||
|
do
|
||||||
|
{
|
||||||
|
c = UART_readchar(&uart_if[UART_DEBUGGER]);
|
||||||
|
|
||||||
|
} while(c < 0);
|
||||||
|
|
||||||
|
return (char)c;
|
||||||
|
}
|
||||||
|
|||||||
+17
-2
@@ -92,8 +92,9 @@
|
|||||||
extern void dbg_putchar(char c); /* write a single character */
|
extern void dbg_putchar(char c); /* write a single character */
|
||||||
extern char dbg_getchar(); /* read and return a single char */
|
extern char dbg_getchar(); /* read and return a single char */
|
||||||
extern void ICACHE_invalidate_all();
|
extern void ICACHE_invalidate_all();
|
||||||
|
extern int sputs(char const *pStr);
|
||||||
extern void flush_i_cache();
|
extern void print_byte(char byte);
|
||||||
|
extern void print_word(int word);
|
||||||
|
|
||||||
void putDebugChar(char c)
|
void putDebugChar(char c)
|
||||||
{
|
{
|
||||||
@@ -415,6 +416,7 @@ handle_exception (unsigned long *registers)
|
|||||||
char remcomInBuffer[BUFMAX];
|
char remcomInBuffer[BUFMAX];
|
||||||
char remcomOutBuffer[BUFMAX];
|
char remcomOutBuffer[BUFMAX];
|
||||||
|
|
||||||
|
sputs("Entry\n");
|
||||||
unsigned long tt; /* Trap type */
|
unsigned long tt; /* Trap type */
|
||||||
unsigned long sigval;
|
unsigned long sigval;
|
||||||
unsigned long addr;
|
unsigned long addr;
|
||||||
@@ -466,6 +468,7 @@ handle_exception (unsigned long *registers)
|
|||||||
switch (*ptr++)
|
switch (*ptr++)
|
||||||
{
|
{
|
||||||
case '?':
|
case '?':
|
||||||
|
sputs("?\n");
|
||||||
remcomOutBuffer[0] = 'S';
|
remcomOutBuffer[0] = 'S';
|
||||||
remcomOutBuffer[1] = hexchars[sigval >> 4];
|
remcomOutBuffer[1] = hexchars[sigval >> 4];
|
||||||
remcomOutBuffer[2] = hexchars[sigval & 0xf];
|
remcomOutBuffer[2] = hexchars[sigval & 0xf];
|
||||||
@@ -473,10 +476,12 @@ handle_exception (unsigned long *registers)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'd': /* toggle debug flag */
|
case 'd': /* toggle debug flag */
|
||||||
|
sputs("d\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'g': /* return the value of the CPU registers */
|
case 'g': /* return the value of the CPU registers */
|
||||||
{
|
{
|
||||||
|
sputs("g\n");
|
||||||
ptr = remcomOutBuffer;
|
ptr = remcomOutBuffer;
|
||||||
/* R00 .. R31 */
|
/* R00 .. R31 */
|
||||||
ptr = mem2hex((char *)®isters[R00], ptr, 4*32, 0);
|
ptr = mem2hex((char *)®isters[R00], ptr, 4*32, 0);
|
||||||
@@ -499,6 +504,7 @@ handle_exception (unsigned long *registers)
|
|||||||
|
|
||||||
case 'G': /* set the value of the CPU registers - return OK */
|
case 'G': /* set the value of the CPU registers - return OK */
|
||||||
{
|
{
|
||||||
|
sputs("G\n");
|
||||||
unsigned long *newsp, sr;
|
unsigned long *newsp, sr;
|
||||||
sr = registers[SR];
|
sr = registers[SR];
|
||||||
|
|
||||||
@@ -538,6 +544,7 @@ handle_exception (unsigned long *registers)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'm': /* mAA..AA,LLLL Read LLLL bytes at address AA..AA */
|
case 'm': /* mAA..AA,LLLL Read LLLL bytes at address AA..AA */
|
||||||
|
sputs("m\n");
|
||||||
/* Try to read %x,%x. */
|
/* Try to read %x,%x. */
|
||||||
|
|
||||||
if (hexToInt(&ptr, &addr) && *ptr++ == ',' && hexToInt(&ptr, &length))
|
if (hexToInt(&ptr, &addr) && *ptr++ == ',' && hexToInt(&ptr, &length))
|
||||||
@@ -552,6 +559,7 @@ handle_exception (unsigned long *registers)
|
|||||||
{
|
{
|
||||||
strcpy(remcomOutBuffer,"E01");
|
strcpy(remcomOutBuffer,"E01");
|
||||||
}
|
}
|
||||||
|
sputs("m:"); print_word(addr); sputs(",");print_word(length); sputs("\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'M': /* MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK */
|
case 'M': /* MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK */
|
||||||
@@ -572,14 +580,17 @@ handle_exception (unsigned long *registers)
|
|||||||
{
|
{
|
||||||
strcpy(remcomOutBuffer, "E02");
|
strcpy(remcomOutBuffer, "E02");
|
||||||
}
|
}
|
||||||
|
sputs("M:"); print_word(addr); sputs(",");print_word(length); sputs("\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c': /* cAA..AA Continue at address AA..AA(optional) */
|
case 'c': /* cAA..AA Continue at address AA..AA(optional) */
|
||||||
/* try to read optional parameter, pc unchanged if no parm */
|
/* try to read optional parameter, pc unchanged if no parm */
|
||||||
|
|
||||||
|
sputs("c: PC="); print_word(registers[PC]);sputs("\n");
|
||||||
if (hexToInt(&ptr, &addr))
|
if (hexToInt(&ptr, &addr))
|
||||||
{
|
{
|
||||||
registers[PC] = addr;
|
registers[PC] = addr;
|
||||||
|
sputs("c: addr="); print_word(addr);sputs("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Need to flush the instruction cache here, as we may have deposited a
|
/* Need to flush the instruction cache here, as we may have deposited a
|
||||||
@@ -592,6 +603,7 @@ handle_exception (unsigned long *registers)
|
|||||||
|
|
||||||
/* kill the program */
|
/* kill the program */
|
||||||
case 'k' : /* do nothing */
|
case 'k' : /* do nothing */
|
||||||
|
sputs("Kill\n");
|
||||||
break;
|
break;
|
||||||
#if 0
|
#if 0
|
||||||
case 't': /* Test feature */
|
case 't': /* Test feature */
|
||||||
@@ -599,9 +611,12 @@ handle_exception (unsigned long *registers)
|
|||||||
#endif
|
#endif
|
||||||
case 'r': /* Reset */
|
case 'r': /* Reset */
|
||||||
// Perform reset
|
// Perform reset
|
||||||
|
sputs("Reset\n");
|
||||||
break;
|
break;
|
||||||
} /* switch */
|
} /* switch */
|
||||||
/* reply to the request */
|
/* reply to the request */
|
||||||
putpacket(remcomOutBuffer);
|
putpacket(remcomOutBuffer);
|
||||||
}
|
}
|
||||||
|
sputs("Exit\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user