S-record load to RAM tested successfully. basflash.s19 is a short test program (just a single line of code) that can be loaded from SD card and executed. Control is given back to BaS() on return.
This commit is contained in:
@@ -122,33 +122,6 @@
|
|||||||
<path value=""/>
|
<path value=""/>
|
||||||
</doc-comment-owner>
|
</doc-comment-owner>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
|
|
||||||
<buildTargets>
|
|
||||||
<target name="all" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
|
||||||
<buildCommand>make</buildCommand>
|
|
||||||
<buildArguments/>
|
|
||||||
<buildTarget>all</buildTarget>
|
|
||||||
<stopOnError>true</stopOnError>
|
|
||||||
<useDefaultCommand>true</useDefaultCommand>
|
|
||||||
<runAllBuilders>true</runAllBuilders>
|
|
||||||
</target>
|
|
||||||
<target name="clean" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
|
||||||
<buildCommand>make</buildCommand>
|
|
||||||
<buildTarget>clean</buildTarget>
|
|
||||||
<stopOnError>true</stopOnError>
|
|
||||||
<useDefaultCommand>true</useDefaultCommand>
|
|
||||||
<runAllBuilders>true</runAllBuilders>
|
|
||||||
</target>
|
|
||||||
<target name="ram" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
|
||||||
<buildCommand>make</buildCommand>
|
|
||||||
<buildArguments/>
|
|
||||||
<buildTarget>ram</buildTarget>
|
|
||||||
<stopOnError>true</stopOnError>
|
|
||||||
<useDefaultCommand>true</useDefaultCommand>
|
|
||||||
<runAllBuilders>true</runAllBuilders>
|
|
||||||
</target>
|
|
||||||
</buildTargets>
|
|
||||||
</storageModule>
|
|
||||||
<storageModule moduleId="scannerConfiguration">
|
<storageModule moduleId="scannerConfiguration">
|
||||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.500844171.756690686;cdt.managedbuild.toolchain.gnu.cross.base.500844171.756690686.;cdt.managedbuild.tool.gnu.cross.c.compiler.1024005096;cdt.managedbuild.tool.gnu.c.compiler.input.1427165564">
|
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.500844171.756690686;cdt.managedbuild.toolchain.gnu.cross.base.500844171.756690686.;cdt.managedbuild.tool.gnu.cross.c.compiler.1024005096;cdt.managedbuild.tool.gnu.c.compiler.input.1427165564">
|
||||||
@@ -191,4 +164,38 @@
|
|||||||
</scannerConfigBuildInfo>
|
</scannerConfigBuildInfo>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||||
|
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
|
||||||
|
<buildTargets>
|
||||||
|
<target name="all" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
|
<buildCommand>make</buildCommand>
|
||||||
|
<buildTarget>all</buildTarget>
|
||||||
|
<stopOnError>true</stopOnError>
|
||||||
|
<useDefaultCommand>true</useDefaultCommand>
|
||||||
|
<runAllBuilders>true</runAllBuilders>
|
||||||
|
</target>
|
||||||
|
<target name="clean" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
|
<buildCommand>make</buildCommand>
|
||||||
|
<buildArguments/>
|
||||||
|
<buildTarget>clean</buildTarget>
|
||||||
|
<stopOnError>true</stopOnError>
|
||||||
|
<useDefaultCommand>true</useDefaultCommand>
|
||||||
|
<runAllBuilders>true</runAllBuilders>
|
||||||
|
</target>
|
||||||
|
<target name="ram" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
|
<buildCommand>make</buildCommand>
|
||||||
|
<buildTarget>ram</buildTarget>
|
||||||
|
<stopOnError>true</stopOnError>
|
||||||
|
<useDefaultCommand>true</useDefaultCommand>
|
||||||
|
<runAllBuilders>true</runAllBuilders>
|
||||||
|
</target>
|
||||||
|
<target name="basflash" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
|
<buildCommand>make</buildCommand>
|
||||||
|
<buildArguments/>
|
||||||
|
<buildTarget>basflash</buildTarget>
|
||||||
|
<stopOnError>true</stopOnError>
|
||||||
|
<useDefaultCommand>true</useDefaultCommand>
|
||||||
|
<runAllBuilders>true</runAllBuilders>
|
||||||
|
</target>
|
||||||
|
</buildTargets>
|
||||||
|
</storageModule>
|
||||||
</cproject>
|
</cproject>
|
||||||
|
|||||||
@@ -48,11 +48,13 @@ MAPFILE=bas.map
|
|||||||
# Linker control file. The final $(LDCFILE) is intermediate only (preprocessed version of $(LDCSRC)
|
# Linker control file. The final $(LDCFILE) is intermediate only (preprocessed version of $(LDCSRC)
|
||||||
LDCFILE=bas.lk
|
LDCFILE=bas.lk
|
||||||
LDCSRC=bas.lk.in
|
LDCSRC=bas.lk.in
|
||||||
|
LDCBFS=basflash.lk
|
||||||
|
|
||||||
# this Makefile can create the BaS to flash or an arbitrary ram address (for BDM debugging). See
|
# this Makefile can create the BaS to flash or an arbitrary ram address (for BDM debugging). See
|
||||||
# below for the definition of TARGET_ADDRESS
|
# below for the definition of TARGET_ADDRESS
|
||||||
FLASH_EXEC=bas.$(EXE)
|
FLASH_EXEC=bas.$(EXE)
|
||||||
RAM_EXEC=ram.$(EXE)
|
RAM_EXEC=ram.$(EXE)
|
||||||
|
BASFLASH_EXEC=basflash.$(EXE)
|
||||||
|
|
||||||
CSRCS= \
|
CSRCS= \
|
||||||
$(SRCDIR)/sysinit.c \
|
$(SRCDIR)/sysinit.c \
|
||||||
@@ -65,7 +67,8 @@ CSRCS= \
|
|||||||
$(SRCDIR)/ff.c \
|
$(SRCDIR)/ff.c \
|
||||||
$(SRCDIR)/sd_card.c \
|
$(SRCDIR)/sd_card.c \
|
||||||
$(SRCDIR)/wait.c \
|
$(SRCDIR)/wait.c \
|
||||||
$(SRCDIR)/s19reader.c
|
$(SRCDIR)/s19reader.c\
|
||||||
|
$(SRCDIR)/basflash.c
|
||||||
|
|
||||||
ASRCS= \
|
ASRCS= \
|
||||||
$(SRCDIR)/startcf.S \
|
$(SRCDIR)/startcf.S \
|
||||||
@@ -82,9 +85,12 @@ OBJS=$(COBJS) $(AOBJS)
|
|||||||
|
|
||||||
all: $(FLASH_EXEC)
|
all: $(FLASH_EXEC)
|
||||||
ram: $(RAM_EXEC)
|
ram: $(RAM_EXEC)
|
||||||
|
.PHONY basflash: $(BASFLASH_EXEC)
|
||||||
|
|
||||||
.PHONY clean:
|
.PHONY clean:
|
||||||
@ rm -f $(FLASH_EXEC) $(FLASH_EXEC).elf $(FLASH_EXEC).s19\
|
@ rm -f $(FLASH_EXEC) $(FLASH_EXEC).elf $(FLASH_EXEC).s19\
|
||||||
$(RAM_EXEC) $(RAM_EXEC).elf $(RAM_EXEC).s19\
|
$(RAM_EXEC) $(RAM_EXEC).elf $(RAM_EXEC).s19\
|
||||||
|
$(BASFLASH_EXEC) $(BASFLASH_EXEC).elf $(BASFLASH_EXEC).s19 \
|
||||||
$(OBJS) $(MAPFILE) $(LDCFILE) depend
|
$(OBJS) $(MAPFILE) $(LDCFILE) depend
|
||||||
|
|
||||||
$(FLASH_EXEC): TARGET_ADDRESS=0xe0000000
|
$(FLASH_EXEC): TARGET_ADDRESS=0xe0000000
|
||||||
@@ -99,6 +105,14 @@ else
|
|||||||
objcopy -I srec -O elf32-big --alt-machine-code 4 $@ $@.elf
|
objcopy -I srec -O elf32-big --alt-machine-code 4 $@ $@.elf
|
||||||
endif
|
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
|
# compile init_fpga with -mbitfield for testing purposes
|
||||||
$(OBJDIR)/init_fpga.o: CFLAGS += -mbitfield
|
$(OBJDIR)/init_fpga.o: CFLAGS += -mbitfield
|
||||||
|
|
||||||
|
|||||||
28
BaS_gcc/basflash.lk
Normal file
28
BaS_gcc/basflash.lk
Normal file
@@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
14
BaS_gcc/sources/basflash.c
Normal file
14
BaS_gcc/sources/basflash.c
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
* basflash.c
|
||||||
|
*
|
||||||
|
* Created on: 18.12.2012
|
||||||
|
* Author: mfro
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <bas_printf.h>
|
||||||
|
|
||||||
|
void basflash(void)
|
||||||
|
{
|
||||||
|
xprintf("Hello from BASFLASH.S19!\r\n");
|
||||||
|
}
|
||||||
@@ -195,7 +195,7 @@ typedef err_t (*memcpy_callback_t)(uint8_t *dst, uint8_t *src, uint32_t length);
|
|||||||
* returns
|
* returns
|
||||||
* OK or an err_t error code if anything failed
|
* 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;
|
FRESULT fres;
|
||||||
FIL file;
|
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_end = FALSE;
|
||||||
bool found_block_data = 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)
|
while (ret == OK && (uint8_t *) f_gets((char *) line, sizeof(line), &file) != NULL)
|
||||||
{
|
{
|
||||||
lineno++;
|
lineno++;
|
||||||
@@ -230,7 +228,6 @@ err_t read_srecords(char *filename, uint8_t **start_address, uint32_t *actual_le
|
|||||||
switch (vector[0])
|
switch (vector[0])
|
||||||
{
|
{
|
||||||
case 0: /* block header */
|
case 0: /* block header */
|
||||||
xprintf("S0 record (block header) found\r\n");
|
|
||||||
found_block_header = TRUE;
|
found_block_header = TRUE;
|
||||||
if (found_block_data || found_block_end)
|
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
|
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;
|
break;
|
||||||
|
|
||||||
@@ -336,11 +334,9 @@ void flasher_load(char *flasher_filename)
|
|||||||
FRESULT fres;
|
FRESULT fres;
|
||||||
FATFS fs;
|
FATFS fs;
|
||||||
err_t err;
|
err_t err;
|
||||||
uint8_t *start_address;
|
void *start_address;
|
||||||
uint32_t length;
|
uint32_t length;
|
||||||
|
|
||||||
xprintf("S-record reader\r\n");
|
|
||||||
|
|
||||||
disk_initialize(0);
|
disk_initialize(0);
|
||||||
res = disk_status(0);
|
res = disk_status(0);
|
||||||
if (res == RES_OK)
|
if (res == RES_OK)
|
||||||
@@ -349,32 +345,41 @@ void flasher_load(char *flasher_filename)
|
|||||||
if (fres == FR_OK)
|
if (fres == FR_OK)
|
||||||
{
|
{
|
||||||
/* first pass: parse and check for inconsistencies */
|
/* first pass: parse and check for inconsistencies */
|
||||||
|
xprintf("check file integrity: ");
|
||||||
err = read_srecords(flasher_filename, &start_address, &length, simulate);
|
err = read_srecords(flasher_filename, &start_address, &length, simulate);
|
||||||
if (err == OK)
|
if (err == OK)
|
||||||
{
|
{
|
||||||
/* next pass: copy data to destination */
|
/* next pass: copy data to destination */
|
||||||
|
xprintf("OK.\r\ncopy/flash data: ");
|
||||||
err = read_srecords(flasher_filename, &start_address, &length, memcpy);
|
err = read_srecords(flasher_filename, &start_address, &length, memcpy);
|
||||||
if (err == OK)
|
if (err == OK)
|
||||||
{
|
{
|
||||||
/* next pass: verify data */
|
/* next pass: verify data */
|
||||||
|
xprintf("OK.\r\nverify data: ");
|
||||||
err = read_srecords(flasher_filename, &start_address, &length, verify);
|
err = read_srecords(flasher_filename, &start_address, &length, verify);
|
||||||
if (err == OK)
|
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
|
else
|
||||||
{
|
{
|
||||||
xprintf("verification failed\r\n");
|
xprintf("failed\r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xprintf("copy memory pass failed\r\n");
|
xprintf("failed\r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xprintf("check file pass failed\r\n");
|
xprintf("failed\r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user