From a1d9651ab6bdf28faad79178029fe7809260da95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Fr=C3=B6schle?= Date: Sun, 17 Feb 2013 22:47:24 +0000 Subject: [PATCH] modified to enable remote debugging of basflash.s19. basflash.s19 does not work in this version (hang)! --- BaS_gcc/.gdbinit | 8 +++----- BaS_gcc/Makefile | 6 +++--- BaS_gcc/bas.lk.in | 2 +- BaS_gcc/mcf5474.gdb | 2 ++ BaS_gcc/sources/BaS.c | 6 +++--- BaS_gcc/sources/basflash.c | 5 +++-- BaS_gcc/sources/basflash_start.c | 14 +++++++++++++- BaS_gcc/sources/s19reader.c | 2 ++ BaS_gcc/sources/startcf.S | 1 + 9 files changed, 31 insertions(+), 15 deletions(-) diff --git a/BaS_gcc/.gdbinit b/BaS_gcc/.gdbinit index 0770898..02dc87c 100644 --- a/BaS_gcc/.gdbinit +++ b/BaS_gcc/.gdbinit @@ -1,12 +1,10 @@ #set disassemble-next-line on -define tr +define pdtr target remote | m68k-bdm-gdbserver pipe /dev/bdmcf3 + monitor bdm-reset end -define tbtr +define tr target remote | m68k-bdm-gdbserver pipe /dev/tblcf3 end - -tr - source mcf5474.gdb diff --git a/BaS_gcc/Makefile b/BaS_gcc/Makefile index 36fc825..15188ba 100644 --- a/BaS_gcc/Makefile +++ b/BaS_gcc/Makefile @@ -35,8 +35,8 @@ CFLAGS=-mcpu=5474\ -g\ -Wno-multichar\ -Winline\ - -Os\ - -fomit-frame-pointer\ + -O \ + -fno-omit-frame-pointer\ -fno-strict-aliasing\ -ffreestanding\ -fleading-underscore\ @@ -107,7 +107,7 @@ $(RAM_EXEC): TARGET_ADDRESS=0x10000000 $(RAM_EXEC): LDCFILE=ram.lk $(RAM_EXEC): MAPFILE=ram.map -$(BASFLASH_EXEC): TARGET_ADDRESS=0x00040000 +$(BASFLASH_EXEC): TARGET_ADDRESS=0x00100000 $(BASFLASH_EXEC): LDCFILE=basflash.lk $(BASFLASH_EXEC): MAPFILE=basflash.map diff --git a/BaS_gcc/bas.lk.in b/BaS_gcc/bas.lk.in index 8230976..b23f738 100644 --- a/BaS_gcc/bas.lk.in +++ b/BaS_gcc/bas.lk.in @@ -1,6 +1,6 @@ MEMORY { - bas_rom (RX) : ORIGIN = TARGET_ADDRESS, LENGTH = 0x00200000 + bas_rom (RX) : ORIGIN = TARGET_ADDRESS, LENGTH = 0x00100000 bas_ram (WX) : ORIGIN = 0x1FE00000, LENGTH = 0x00100000 /* target to copy BaS to */ } diff --git a/BaS_gcc/mcf5474.gdb b/BaS_gcc/mcf5474.gdb index 0edf899..7978299 100644 --- a/BaS_gcc/mcf5474.gdb +++ b/BaS_gcc/mcf5474.gdb @@ -61,4 +61,6 @@ define ib setup-dram end +tr ib +load diff --git a/BaS_gcc/sources/BaS.c b/BaS_gcc/sources/BaS.c index 7a79c4e..2f579f9 100644 --- a/BaS_gcc/sources/BaS.c +++ b/BaS_gcc/sources/BaS.c @@ -205,8 +205,6 @@ void BaS(void) vec_init(); xprintf("finished\r\n"); - enable_coldfire_interrupts(); - MCF_MMU_MMUCR = MCF_MMU_MMUCR_EN; /* MMU on */ xprintf("IDE reset: "); @@ -241,7 +239,6 @@ void BaS(void) xprintf("finished\r\n"); sd_card_init(); - srec_execute("BASFLASH.S19"); /* * memory setup @@ -295,6 +292,8 @@ void BaS(void) __asm__ __volatile__("move.w #0x0700,sr \n\t" : : : "memory"); } + srec_execute("BASFLASH.S19"); + /* Jump into the OS */ typedef void void_func(void); typedef struct { @@ -303,6 +302,7 @@ void BaS(void) } ROM_HEADER; xprintf("Call OS. BaS initialization finished...\r\n"); + enable_coldfire_interrupts(); ROM_HEADER* os_header = (ROM_HEADER*)TOS; os_header->initial_pc(); diff --git a/BaS_gcc/sources/basflash.c b/BaS_gcc/sources/basflash.c index 6f620b2..bbce2b8 100644 --- a/BaS_gcc/sources/basflash.c +++ b/BaS_gcc/sources/basflash.c @@ -308,8 +308,8 @@ err_t srec_load(char *flash_filename) void basflash(void) { - const char *basflash_str = "\\BASFLASH\\"; - const char *bastest_str = "\\BASTEST\\"; + const char *basflash_str = "\\BASFLASH"; + const char *bastest_str = "\\BASTEST"; DRESULT res; FRESULT fres; FATFS fs; @@ -351,6 +351,7 @@ void basflash(void) strcpy(path, bastest_str); strncat(path, fileinfo.fname, 13); + xprintf("loading file %s\n", path); /* * load file */ diff --git a/BaS_gcc/sources/basflash_start.c b/BaS_gcc/sources/basflash_start.c index 1398e98..019ad40 100644 --- a/BaS_gcc/sources/basflash_start.c +++ b/BaS_gcc/sources/basflash_start.c @@ -5,10 +5,22 @@ * Author: mfro */ +#include +static uint32_t ownstack[4096]; +static uint32_t *stackptr = &ownstack[4095]; + +/* + * setup our own stack in SDRAM to prevent clashing BaS's in SRAM (size limited). + */ void startup(void) { - void basflash(void); + static uint32_t oldstack; + void basflash(void); + __asm__ __volatile__("move.l sp,%0\n\t" : "=g"(oldstack) : :); + __asm__ __volatile__("move.l %0,sp\n\t" : : "g"(stackptr) : ); basflash(); + __asm__ __volatile__("move.l %0,sp\n\t" : : "g"(oldstack) :); + (void) stackptr; /* make compiler happy about unused variables */ } diff --git a/BaS_gcc/sources/s19reader.c b/BaS_gcc/sources/s19reader.c index 2710979..0489b36 100644 --- a/BaS_gcc/sources/s19reader.c +++ b/BaS_gcc/sources/s19reader.c @@ -32,6 +32,7 @@ #include "diskio.h" #include "ff.h" #include "s19reader.h" +#include "cache.h" /* * Yes, I know. The following doesn't really look like code should look like... @@ -390,6 +391,7 @@ void srec_execute(char *flasher_filename) xprintf("target successfully written and verified. Start address: %p\r\n", start_address); func = start_address; + flush_and_invalidate_caches(); (*func)(); } else diff --git a/BaS_gcc/sources/startcf.S b/BaS_gcc/sources/startcf.S index 6188337..56ef762 100644 --- a/BaS_gcc/sources/startcf.S +++ b/BaS_gcc/sources/startcf.S @@ -46,6 +46,7 @@ _rom_entry: /* set stack pointer to end of SRAM1 */ lea __SUP_SP,a7 + move.l #0,(sp) /* Initialize the processor caches. * The instruction cache is fully enabled.