diff --git a/BaS_gcc/.cproject b/BaS_gcc/.cproject
index 43198e5..5588012 100644
--- a/BaS_gcc/.cproject
+++ b/BaS_gcc/.cproject
@@ -62,7 +62,7 @@
-
+
@@ -90,8 +90,8 @@
-
+
diff --git a/BaS_gcc/.project b/BaS_gcc/.project
index f516738..a81375b 100644
--- a/BaS_gcc/.project
+++ b/BaS_gcc/.project
@@ -7,6 +7,7 @@
org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
?name?
diff --git a/BaS_gcc/Makefile b/BaS_gcc/Makefile
index a073d8d..8a972e2 100644
--- a/BaS_gcc/Makefile
+++ b/BaS_gcc/Makefile
@@ -96,7 +96,7 @@ lib: $(LIBBAS)
@ 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
+ $(OBJS) $(OBJDIR)/basflash.o $(MAPFILE) $(LDCFILE) $(LIBBAS) $(LDCBFS) depend
$(FLASH_EXEC): TARGET_ADDRESS=0xe0000000
$(RAM_EXEC): TARGET_ADDRESS=0x10000000
@@ -112,8 +112,7 @@ else
endif
# the basflash (SD-card executable called from BaS) final link stage
-$(BASFLASH_EXEC): $(OBJS) $(LDCBFL)
- $(CC) $(CFLAGS) $(INCLUDE) -c $(SRCDIR)/basflash.c -o $(OBJDIR)/basflash.o
+$(BASFLASH_EXEC): $(OBJDIR)/basflash.o $(LIBBAS) $(LDCBFL)
$(CPP) -P -DTARGET_ADDRESS=$(BF_TARGET_ADDRESS) -DFORMAT=$(FORMAT) $(LDCBSRC) -o $(LDCBFS)
$(LD) --oformat $(FORMAT) -Map $(MAPFILE) --cref -T $(LDCBFS) -L. -lbas -o $@
ifeq ($(COMPILE_ELF),Y)
diff --git a/BaS_gcc/include/s19reader.h b/BaS_gcc/include/s19reader.h
index 5039e1a..8061a57 100644
--- a/BaS_gcc/include/s19reader.h
+++ b/BaS_gcc/include/s19reader.h
@@ -26,6 +26,21 @@
#ifndef _S19READER_H_
#define _S19READER_H_
+typedef enum
+{
+ OK, /* no error */
+ FAIL, /* general error aka "I don't know what went wrong" */
+ FILE_OPEN, /* file open failed */
+ FILE_READ, /* file read failed */
+ SREC_CORRUPT, /* file doesn't seem to contain valid S-records */
+ MEMCPY_FAILED, /* could not copy buffer to destination */
+ CODE_OVERLAPS, /* copying would overwrite ourself */
+ VERIFY_FAILED /* destination does not read as we've written to */
+} err_t;
+
+typedef err_t (*memcpy_callback_t)(uint8_t *dst, uint8_t *src, uint32_t length);
+
extern void srec_execute(char *filename);
+extern err_t read_srecords(char *filename, void **start_address, uint32_t *actual_length, memcpy_callback_t callback);
#endif /* _S19READER_H_ */
diff --git a/BaS_gcc/sources/basflash.c b/BaS_gcc/sources/basflash.c
index 97a63f6..cacfac6 100644
--- a/BaS_gcc/sources/basflash.c
+++ b/BaS_gcc/sources/basflash.c
@@ -12,8 +12,6 @@
#include
#include
-typedef enum {OK, ERR} err_t;
-
uint32_t mx29lv640d_sector_groups[] =
{
0xe0000000, 0xe0008000, 0xe0010000, 0xe0018000, 0xe0020000, 0xe0028000, 0xe0030000, 0xe0038000,
@@ -79,7 +77,7 @@ void srec_flash(char *flash_filename)
if (err == OK)
{
xprintf("OK.\r\nerase flash area (from %p): ", start_address);
- err = erase(start_address);
+ err = erase_flash_region(start_address);
/* next pass: copy data to destination */
xprintf("OK.\r\flash data: ");
diff --git a/BaS_gcc/sources/s19reader.c b/BaS_gcc/sources/s19reader.c
index e0aed3c..8d1e2bd 100644
--- a/BaS_gcc/sources/s19reader.c
+++ b/BaS_gcc/sources/s19reader.c
@@ -24,26 +24,14 @@
*/
#include
-#include
-#include
-#include
-#include
-#include
+#include
+#include
-typedef enum { FALSE, TRUE } bool;
-typedef enum
-{
- OK, /* no error */
- FAIL, /* general error aka "I don't know what went wrong" */
- FILE_OPEN, /* file open failed */
- FILE_READ, /* file read failed */
- SREC_CORRUPT, /* file doesn't seem to contain valid S-records */
- MEMCPY_FAILED, /* could not copy buffer to destination */
- CODE_OVERLAPS, /* copying would overwrite ourself */
- VERIFY_FAILED /* destination does not read as we've written to */
-} err_t;
-
-#define NULL (void *) 0L
+#include "bas_printf.h"
+#include "sd_card.h"
+#include "diskio.h"
+#include "ff.h"
+#include "s19reader.h"
/*
* Yes, I know. The following doesn't really look like code should look like...
@@ -155,7 +143,7 @@ void print_record(uint8_t *arr)
/*
* convert an S-record line into its corresponding byte vector (ASCII->binary)
*/
-void line_to_vector(uint8_t *line, uint8_t *vector)
+static void line_to_vector(uint8_t *line, uint8_t *vector)
{
int i;
int length;
@@ -174,8 +162,6 @@ void line_to_vector(uint8_t *line, uint8_t *vector)
}
}
-typedef err_t (*memcpy_callback_t)(uint8_t *dst, uint8_t *src, uint32_t length);
-
/*
* read and parse a Motorola S-record file and copy contents to dst. The theory of operation is to read and parse the S-record file
* and to use the supplied callback routine to copy the buffer to the destination once the S-record line is converted.
@@ -206,9 +192,9 @@ err_t read_srecords(char *filename, void **start_address, uint32_t *actual_lengt
uint8_t line[80];
int lineno = 0;
int data_records = 0;
- bool found_block_header = FALSE;
- bool found_block_end = FALSE;
- bool found_block_data = FALSE;
+ bool found_block_header = false;
+ bool found_block_end = false;
+ bool found_block_data = false;
while (ret == OK && (uint8_t *) f_gets((char *) line, sizeof(line), &file) != NULL)
{
@@ -229,7 +215,7 @@ err_t read_srecords(char *filename, void **start_address, uint32_t *actual_lengt
switch (vector[0])
{
case 0: /* block header */
- found_block_header = TRUE;
+ found_block_header = true;
if (found_block_data || found_block_end)
{
xprintf("S7 or S3 record found before S0: S-records corrupt?\r\n");