diff --git a/BaS_gcc/.cproject b/BaS_gcc/.cproject
index 7d5eb7b..de1188a 100644
--- a/BaS_gcc/.cproject
+++ b/BaS_gcc/.cproject
@@ -122,33 +122,6 @@
-
-
-
- make
-
- all
- true
- true
- true
-
-
- make
- clean
- true
- true
- true
-
-
- make
-
- ram
- true
- true
- true
-
-
-
@@ -191,4 +164,38 @@
+
+
+
+ make
+ all
+ true
+ true
+ true
+
+
+ make
+
+ clean
+ true
+ true
+ true
+
+
+ make
+ ram
+ true
+ true
+ true
+
+
+ make
+
+ basflash
+ true
+ true
+ true
+
+
+
diff --git a/BaS_gcc/Makefile b/BaS_gcc/Makefile
index 67f0fbd..63f823c 100644
--- a/BaS_gcc/Makefile
+++ b/BaS_gcc/Makefile
@@ -48,11 +48,13 @@ MAPFILE=bas.map
# Linker control file. The final $(LDCFILE) is intermediate only (preprocessed version of $(LDCSRC)
LDCFILE=bas.lk
LDCSRC=bas.lk.in
+LDCBFS=basflash.lk
# this Makefile can create the BaS to flash or an arbitrary ram address (for BDM debugging). See
# below for the definition of TARGET_ADDRESS
FLASH_EXEC=bas.$(EXE)
RAM_EXEC=ram.$(EXE)
+BASFLASH_EXEC=basflash.$(EXE)
CSRCS= \
$(SRCDIR)/sysinit.c \
@@ -65,7 +67,8 @@ CSRCS= \
$(SRCDIR)/ff.c \
$(SRCDIR)/sd_card.c \
$(SRCDIR)/wait.c \
- $(SRCDIR)/s19reader.c
+ $(SRCDIR)/s19reader.c\
+ $(SRCDIR)/basflash.c
ASRCS= \
$(SRCDIR)/startcf.S \
@@ -82,9 +85,12 @@ OBJS=$(COBJS) $(AOBJS)
all: $(FLASH_EXEC)
ram: $(RAM_EXEC)
+.PHONY basflash: $(BASFLASH_EXEC)
+
.PHONY clean:
@ rm -f $(FLASH_EXEC) $(FLASH_EXEC).elf $(FLASH_EXEC).s19\
$(RAM_EXEC) $(RAM_EXEC).elf $(RAM_EXEC).s19\
+ $(BASFLASH_EXEC) $(BASFLASH_EXEC).elf $(BASFLASH_EXEC).s19 \
$(OBJS) $(MAPFILE) $(LDCFILE) depend
$(FLASH_EXEC): TARGET_ADDRESS=0xe0000000
@@ -98,7 +104,15 @@ ifeq ($(COMPILE_ELF),Y)
else
objcopy -I srec -O elf32-big --alt-machine-code 4 $@ $@.elf
endif
-
+
+$(BASFLASH_EXEC): $(OBJS) $(LDCBFL)
+ $(LD) --oformat $(FORMAT) -Map $(MAPFILE) --cref -T $(LDCBFS) -o $@
+ifeq ($(COMPILE_ELF),Y)
+ $(OBJCOPY) -O srec $@ $@.s19
+else
+ objcopy -I srec -O elf32-big --alt-machine-code 4 $@ $@.elf
+endif
+
# compile init_fpga with -mbitfield for testing purposes
$(OBJDIR)/init_fpga.o: CFLAGS += -mbitfield
diff --git a/BaS_gcc/basflash.lk b/BaS_gcc/basflash.lk
new file mode 100644
index 0000000..3b1dbf3
--- /dev/null
+++ b/BaS_gcc/basflash.lk
@@ -0,0 +1,28 @@
+MEMORY
+{
+ flasher (WX) : ORIGIN = 0x10000000, LENGTH = 0x00100000 /* target to load basflash */
+}
+
+SECTIONS
+{
+ .text :
+ {
+ objs/basflash.o(.text)
+ objs/unicode.o(.text)
+ objs/mmc.o(.text)
+ objs/ff.o(.text)
+ objs/sd_card.o(.text)
+ objs/s19reader.o(.text)
+ objs/bas_printf.o(.text)
+ objs/printf_helper.o(.text)
+ objs/cache.o(.text)
+ *(.data)
+ *(.bss)
+ *(.rodata)
+ *(.rodata.*)
+ } > flasher
+
+ /* Memory mapped registers */
+ __MBAR = 0xFF000000;
+
+}
diff --git a/BaS_gcc/sources/basflash.c b/BaS_gcc/sources/basflash.c
new file mode 100644
index 0000000..7e9f6e6
--- /dev/null
+++ b/BaS_gcc/sources/basflash.c
@@ -0,0 +1,14 @@
+/*
+ * basflash.c
+ *
+ * Created on: 18.12.2012
+ * Author: mfro
+ */
+
+#include
+#include
+
+void basflash(void)
+{
+ xprintf("Hello from BASFLASH.S19!\r\n");
+}
diff --git a/BaS_gcc/sources/s19reader.c b/BaS_gcc/sources/s19reader.c
index 62db3a0..666fa60 100644
--- a/BaS_gcc/sources/s19reader.c
+++ b/BaS_gcc/sources/s19reader.c
@@ -195,7 +195,7 @@ typedef err_t (*memcpy_callback_t)(uint8_t *dst, uint8_t *src, uint32_t length);
* returns
* OK or an err_t error code if anything failed
*/
-err_t read_srecords(char *filename, uint8_t **start_address, uint32_t *actual_length, memcpy_callback_t callback)
+err_t read_srecords(char *filename, void **start_address, uint32_t *actual_length, memcpy_callback_t callback)
{
FRESULT fres;
FIL file;
@@ -210,8 +210,6 @@ err_t read_srecords(char *filename, uint8_t **start_address, uint32_t *actual_le
bool found_block_end = FALSE;
bool found_block_data = FALSE;
- xprintf("succesfully opened file \"%s\"\r\n", filename);
-
while (ret == OK && (uint8_t *) f_gets((char *) line, sizeof(line), &file) != NULL)
{
lineno++;
@@ -230,7 +228,6 @@ err_t read_srecords(char *filename, uint8_t **start_address, uint32_t *actual_le
switch (vector[0])
{
case 0: /* block header */
- xprintf("S0 record (block header) found\r\n");
found_block_header = TRUE;
if (found_block_data || found_block_end)
{
@@ -257,7 +254,8 @@ err_t read_srecords(char *filename, uint8_t **start_address, uint32_t *actual_le
}
else
{
- xprintf("S7 record (end) found after %d valid data blocks\r\n", data_records);
+ // xprintf("S7 record (end) found after %d valid data blocks\r\n", data_records);
+ *start_address = (void *) SREC_ADDR32(vector);
}
break;
@@ -336,11 +334,9 @@ void flasher_load(char *flasher_filename)
FRESULT fres;
FATFS fs;
err_t err;
- uint8_t *start_address;
+ void *start_address;
uint32_t length;
- xprintf("S-record reader\r\n");
-
disk_initialize(0);
res = disk_status(0);
if (res == RES_OK)
@@ -349,32 +345,41 @@ void flasher_load(char *flasher_filename)
if (fres == FR_OK)
{
/* first pass: parse and check for inconsistencies */
+ xprintf("check file integrity: ");
err = read_srecords(flasher_filename, &start_address, &length, simulate);
if (err == OK)
{
/* next pass: copy data to destination */
+ xprintf("OK.\r\ncopy/flash data: ");
err = read_srecords(flasher_filename, &start_address, &length, memcpy);
if (err == OK)
{
/* next pass: verify data */
+ xprintf("OK.\r\nverify data: ");
err = read_srecords(flasher_filename, &start_address, &length, verify);
if (err == OK)
{
- xprintf("target successfully written and verified\r\n");
+ xprintf("OK.\r\n");
+ typedef void void_func(void);
+ void_func *func;
+ xprintf("target successfully written and verified. Start address: %p\r\n", start_address);
+
+ func = start_address;
+ (*func)();
}
else
{
- xprintf("verification failed\r\n");
+ xprintf("failed\r\n");
}
}
else
{
- xprintf("copy memory pass failed\r\n");
+ xprintf("failed\r\n");
}
}
else
{
- xprintf("check file pass failed\r\n");
+ xprintf("failed\r\n");
}
}
else