diff --git a/BaS_gcc/Makefile b/BaS_gcc/Makefile index 7c92cab..c21aaa9 100644 --- a/BaS_gcc/Makefile +++ b/BaS_gcc/Makefile @@ -156,12 +156,15 @@ LIBBAS=libbas.a LIBS=$(patsubst %,%/$(LIBBAS),$(TRGTDIRS)) -all: fls ram bfl lib +all: fls ram bfl lib tos fls: $(patsubst %,%/$(FLASH_EXEC),$(TRGTDIRS)) ram: $(patsubst %,%/$(RAM_EXEC),$(TRGTDIRS)) bfl: $(patsubst %,%/$(BASFLASH_EXEC),$(TRGTDIRS)) lib: $(LIBS) +.PHONY: tos +tos: + (cd tos; make) .PHONY: clean clean: diff --git a/BaS_gcc/sys/init_fpga.c b/BaS_gcc/sys/init_fpga.c index 6296316..0216ffb 100644 --- a/BaS_gcc/sys/init_fpga.c +++ b/BaS_gcc/sys/init_fpga.c @@ -79,7 +79,7 @@ void config_gpio_for_jtag_config(void) MCF_GPIO_PDDR_FEC1L_PDDR_FEC1L4; /* bit 4 = LED => output */ /* all other bits = input */ /* - * unfortunately, the GPIO module cannot trigger interrupts. That means FPGA_CONFIG needs to be polled to detect + * unfortunately, the GPIO module cannot trigger interrupts. That means CONF_DONE needs to be polled to detect * external FPGA (re)configuration and reset the system in that case. Could be done from the OS as well... */ } diff --git a/BaS_gcc/sys/sysinit.c b/BaS_gcc/sys/sysinit.c index d911f58..44bc599 100644 --- a/BaS_gcc/sys/sysinit.c +++ b/BaS_gcc/sys/sysinit.c @@ -1089,6 +1089,9 @@ void initialize_hardware(void) #endif , MAJOR_VERSION, MINOR_VERSION, __DATE__, __TIME__); + extern char *rom_header; + + xprintf("running from %p\r\n\r\n", &rom_header); /* * Determine cause(s) of Reset */ diff --git a/BaS_gcc/tos/Makefile b/BaS_gcc/tos/Makefile new file mode 100644 index 0000000..e37437b --- /dev/null +++ b/BaS_gcc/tos/Makefile @@ -0,0 +1,11 @@ +.PHONY: tos +.PHONY: jtagwait +.PHONY: mcdcook +tos: jtagwait mcdcook + +jtagwait: + (cd $@; make) + +mcdcook: + (cd $@; make) + diff --git a/BaS_gcc/tos/jtagwait/jtagwait.creator.user b/BaS_gcc/tos/jtagwait/jtagwait.creator.user index a991cc5..bd445fe 100644 --- a/BaS_gcc/tos/jtagwait/jtagwait.creator.user +++ b/BaS_gcc/tos/jtagwait/jtagwait.creator.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/BaS_gcc/tos/jtagwait/sources/jtagwait.c b/BaS_gcc/tos/jtagwait/sources/jtagwait.c index 1dc7f75..494b81c 100644 --- a/BaS_gcc/tos/jtagwait/sources/jtagwait.c +++ b/BaS_gcc/tos/jtagwait/sources/jtagwait.c @@ -15,66 +15,95 @@ extern long _FPGA_JTAG_VALID; #define FPGA_CONFIG (1 << 2) #define FPGA_CONF_DONE (1 << 5) +long bas_start = 0xe0000000; + void wait_for_jtag(void) { - int i; + int i; - /* set supervisor stack to end of SRAM1 */ - __asm__ __volatile__ ( - " move #0x2700,sr\n\t" /* disable interrupts */ - " move.l #0xff101000 + 0x1000 - 4,d0\n\t" /* 4KB on-chip core SRAM1 */ - " move.l d0,sp\n\t" /* set stack pointer */ - : - : - : "d0", "cc" /* clobber */ - ); + /* set supervisor stack to end of SRAM1 */ + __asm__ __volatile__ ( + " move #0x2700,sr\n\t" /* disable interrupts */ + " move.l #0xff101000 + 0x1000 - 4,d0\n\t" /* 4KB on-chip core SRAM1 */ + " move.l d0,sp\n\t" /* set stack pointer */ + : + : + : "d0", "cc" /* clobber */ + ); - MCF_EPORT_EPIER = 0x0; /* disable EPORT interrupts */ - MCF_INTC_IMRL = 0xffffffff; - MCF_INTC_IMRH = 0xffffffff; /* disable interrupt controller */ + MCF_EPORT_EPIER = 0x0; /* disable EPORT interrupts */ + MCF_INTC_IMRL = 0xffffffff; + MCF_INTC_IMRH = 0xffffffff; /* disable interrupt controller */ - MCF_MMU_MMUCR &= ~MCF_MMU_MMUCR_EN; /* disable MMU */ + MCF_MMU_MMUCR &= ~MCF_MMU_MMUCR_EN; /* disable MMU */ - xprintf("relocated supervisor stack, disabled interrupts and disabled MMU\r\n"); + xprintf("relocated supervisor stack, disabled interrupts and disabled MMU\r\n"); - /* - * configure FEC1L port directions to enable external JTAG configuration download to FPGA - */ - MCF_GPIO_PDDR_FEC1L = 0 | - MCF_GPIO_PDDR_FEC1L_PDDR_FEC1L4; /* bit 4 = LED => output */ - /* all other bits = input */ + /* + * configure FEC1L port directions to enable external JTAG configuration download to FPGA + */ + MCF_GPIO_PDDR_FEC1L = 0 | + MCF_GPIO_PDDR_FEC1L_PDDR_FEC1L4; /* bit 4 = LED => output */ + /* all other bits = input */ - xprintf("waiting for JTAG configuration start\r\n"); - /* - * now that this GPIO ports have been switched to input, we can poll for FPGA config - * started from the JTAG interface (CONF_DONE goes low) and finish (CONF_DONE goes high) - */ - while ((MCF_GPIO_PPDSDR_FEC1L & FPGA_CONF_DONE)); /* wait for JTAG config load started */ + xprintf("waiting for JTAG configuration start\r\n"); + /* + * now that this GPIO ports have been switched to input, we can poll for FPGA config + * started from the JTAG interface (CONF_DONE goes low) and finish (CONF_DONE goes high) + */ + while ((MCF_GPIO_PPDSDR_FEC1L & FPGA_CONF_DONE)); /* wait for JTAG config load started */ - xprintf("waiting for JTAG configuration finished\r\n"); - while (!(MCF_GPIO_PPDSDR_FEC1L & FPGA_CONF_DONE)); /* wait for JTAG config load finished */ + xprintf("waiting for JTAG configuration finished\r\n"); + while (!(MCF_GPIO_PPDSDR_FEC1L & FPGA_CONF_DONE)); /* wait for JTAG config load finished */ - xprintf("JTAG configuration finished.\r\n"); - _FPGA_JTAG_LOADED = true; /* indicate jtag loaded FPGA config to BaS */ - _FPGA_JTAG_VALID = VALID_JTAG; + xprintf("JTAG configuration finished.\r\n"); + _FPGA_JTAG_LOADED = true; /* indicate jtag loaded FPGA config to BaS */ + _FPGA_JTAG_VALID = VALID_JTAG; - /* wait */ - xprintf("wait a little to let things settle...\r\n"); - for (i = 0; i < 1000000; i++); + /* wait */ + xprintf("wait a little to let things settle...\r\n"); + for (i = 0; i < 1000000; i++); - __asm__ __volatile__( - " jmp 0xe0000000\n\t" - : : : - ); + __asm__ __volatile__( + " jmp (%[bas_start])\n\t" + : /* no output */ + : [bas_start] "a" (bas_start) + : /* clobber not needed */ + ); } int main(int argc, char *argv[]) { - printf("\033E\r\nFPGA JTAG configuration support\r\n"); - printf("You may now savely load a new FPGA configuration through the JTAG interface\r\n" - "and your Firebee will reboot once finished using that new configuration.\r\n"); - Supexec(wait_for_jtag); + printf("\033E\r\nFPGA JTAG configuration support\r\n"); + printf("You may now savely load a new FPGA configuration through the JTAG interface\r\n" + "and your Firebee will reboot once finished using that new configuration.\r\n"); + if (argc == 2) + { + /* + * we got an argument. This is supposed to be the address that we need to jump to after JTAG + * configuration has been finished. Meant to support BaS in RAM testing + */ + char *addr_str = argv[1]; + char *addr = NULL; + char *end = NULL; - return 0; /* just to make the compiler happy, we will never return */ + addr = (char *) strtol(addr_str, &end, 16); + if (addr != NULL && addr <= (char *) 0xe0000000 && addr >= (char *) 0x10000000) + { + /* + * seems to be a valid address + */ + bas_start = (long) addr; + + printf("BaS start address set to %p\r\n", addr); + } + else + { + printf("\r\nNote: BaS start address %p not valid. Stick to %p.\r\n", addr, (void *) bas_start); + } + } + Supexec(wait_for_jtag); + + return 0; /* just to make the compiler happy, we will never return */ }