- 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:
2017-01-19 18:03:53 +00:00
parent cfef553c9c
commit f3e297c9e6
6 changed files with 102 additions and 35 deletions
+2 -2
View File
@@ -13,7 +13,7 @@ else
ENDIAN_FLAGS=-EB
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)
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
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
+36 -5
View File
@@ -11,9 +11,19 @@
#include "../../console.h"
#include "../../regdef.h"
const fp_xcpt_t dbg_func = (fp_xcpt_t)0xbfc01f00;
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]))
@@ -48,9 +58,7 @@ void dbg_uart_isr(struct xcptcontext *xcp)
void dbg_uart_setup()
{
const int UART_INT = SYS_INT_UART1;
dbg_uart = (uart_if_t*)con_getInterfaceByName("UART-1")->pInst;
*dbg_uart->pCTRL = SYS_UART_BIT_RX_INTEN;
*uart_if[UART_DEBUGGER].pCTRL = SYS_UART_BIT_RX_INTEN;
interrupt_register(UART_INT, dbg_uart_isr);
interrupt_enable(UART_INT);
}
@@ -88,3 +96,26 @@ void board_init(void)
// 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;
}
+36 -5
View File
@@ -11,9 +11,19 @@
#include "../../console.h"
#include "../../regdef.h"
const fp_xcpt_t dbg_func = (fp_xcpt_t)0xbfc01f00;
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]))
@@ -48,9 +58,7 @@ void dbg_uart_isr(struct xcptcontext *xcp)
void dbg_uart_setup()
{
const int UART_INT = SYS_INT_UART;
dbg_uart = (uart_if_t*)con_getInterfaceByName("UART-1")->pInst;
*dbg_uart->pCTRL = SYS_UART_BIT_RX_INTEN;
*uart_if[UART_DEBUGGER].pCTRL = SYS_UART_BIT_RX_INTEN;
interrupt_register(UART_INT, dbg_uart_isr);
interrupt_enable(UART_INT);
}
@@ -88,3 +96,26 @@ void board_init(void)
// 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
View File
@@ -92,8 +92,9 @@
extern void dbg_putchar(char c); /* write a single character */
extern char dbg_getchar(); /* read and return a single char */
extern void ICACHE_invalidate_all();
extern void flush_i_cache();
extern int sputs(char const *pStr);
extern void print_byte(char byte);
extern void print_word(int word);
void putDebugChar(char c)
{
@@ -415,6 +416,7 @@ handle_exception (unsigned long *registers)
char remcomInBuffer[BUFMAX];
char remcomOutBuffer[BUFMAX];
sputs("Entry\n");
unsigned long tt; /* Trap type */
unsigned long sigval;
unsigned long addr;
@@ -466,6 +468,7 @@ handle_exception (unsigned long *registers)
switch (*ptr++)
{
case '?':
sputs("?\n");
remcomOutBuffer[0] = 'S';
remcomOutBuffer[1] = hexchars[sigval >> 4];
remcomOutBuffer[2] = hexchars[sigval & 0xf];
@@ -473,10 +476,12 @@ handle_exception (unsigned long *registers)
break;
case 'd': /* toggle debug flag */
sputs("d\n");
break;
case 'g': /* return the value of the CPU registers */
{
sputs("g\n");
ptr = remcomOutBuffer;
/* R00 .. R31 */
ptr = mem2hex((char *)&registers[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 */
{
sputs("G\n");
unsigned long *newsp, sr;
sr = registers[SR];
@@ -538,6 +544,7 @@ handle_exception (unsigned long *registers)
break;
case 'm': /* mAA..AA,LLLL Read LLLL bytes at address AA..AA */
sputs("m\n");
/* Try to read %x,%x. */
if (hexToInt(&ptr, &addr) && *ptr++ == ',' && hexToInt(&ptr, &length))
@@ -552,6 +559,7 @@ handle_exception (unsigned long *registers)
{
strcpy(remcomOutBuffer,"E01");
}
sputs("m:"); print_word(addr); sputs(",");print_word(length); sputs("\n");
break;
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");
}
sputs("M:"); print_word(addr); sputs(",");print_word(length); sputs("\n");
break;
case 'c': /* cAA..AA Continue at address AA..AA(optional) */
/* try to read optional parameter, pc unchanged if no parm */
sputs("c: PC="); print_word(registers[PC]);sputs("\n");
if (hexToInt(&ptr, &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
@@ -592,6 +603,7 @@ handle_exception (unsigned long *registers)
/* kill the program */
case 'k' : /* do nothing */
sputs("Kill\n");
break;
#if 0
case 't': /* Test feature */
@@ -599,9 +611,12 @@ handle_exception (unsigned long *registers)
#endif
case 'r': /* Reset */
// Perform reset
sputs("Reset\n");
break;
} /* switch */
/* reply to the request */
putpacket(remcomOutBuffer);
}
sputs("Exit\n");
}