added sector erase logic. Does not compile currently.

This commit is contained in:
Markus Fröschle
2013-02-01 16:11:18 +00:00
parent d759370bfc
commit 69f147e9cf
2 changed files with 33 additions and 11 deletions

View File

@@ -71,8 +71,7 @@ CSRCS= \
$(SRCDIR)/sd_card.c \ $(SRCDIR)/sd_card.c \
$(SRCDIR)/wait.c \ $(SRCDIR)/wait.c \
$(SRCDIR)/s19reader.c \ $(SRCDIR)/s19reader.c \
$(SRCDIR)/flash.c \ $(SRCDIR)/flash.c
$(SRCDIR)/basflash.c
ASRCS= \ ASRCS= \
$(SRCDIR)/startcf.S \ $(SRCDIR)/startcf.S \
@@ -114,6 +113,7 @@ endif
# the basflash (SD-card executable called from BaS) final link stage # the basflash (SD-card executable called from BaS) final link stage
$(BASFLASH_EXEC): $(OBJS) $(LDCBFL) $(BASFLASH_EXEC): $(OBJS) $(LDCBFL)
$(CC) $(CFLAGS) $(INCLUDE) -c $(SRCDIR)/basflash.c -o $(OBJDIR)/basflash.o
$(CPP) -P -DTARGET_ADDRESS=$(BF_TARGET_ADDRESS) -DFORMAT=$(FORMAT) $(LDCBSRC) -o $(LDCBFS) $(CPP) -P -DTARGET_ADDRESS=$(BF_TARGET_ADDRESS) -DFORMAT=$(FORMAT) $(LDCBSRC) -o $(LDCBFS)
$(LD) --oformat $(FORMAT) -Map $(MAPFILE) --cref -T $(LDCBFS) -L. -lbas -o $@ $(LD) --oformat $(FORMAT) -Map $(MAPFILE) --cref -T $(LDCBFS) -L. -lbas -o $@
ifeq ($(COMPILE_ELF),Y) ifeq ($(COMPILE_ELF),Y)

View File

@@ -14,19 +14,38 @@
typedef enum {OK, ERR} err_t; typedef enum {OK, ERR} err_t;
bool memcpy() uint32_t mx29lv640d_sector_groups[] =
{ {
return true; 0xe0000000, 0xe0008000, 0xe0010000, 0xe0018000, 0xe0020000, 0xe0028000, 0xe0030000, 0xe0038000,
0xe0040000, 0xe0048000, 0xe0050000, 0xe0058000, 0xe0060000, 0xe0068000, 0xe0070000, 0xe0078000,
0xe0080000, 0xe0088000, 0xe0090000, 0xe0098000, 0xe00a0000, 0xe00a8000, 0xe00b0000, 0xe00b8000,
0xe00c0000, 0xe00c8000, 0xe00d0000, 0xe00d8000, 0xe00e0000, 0xe00e8000, 0xe00f0000, 0xe00f8000,
0xe0100000, 0xe0108000, 0xe0110000, 0xe0118000, 0xe0120000, 0xe0128000, 0xe0130000, 0xe0138000,
};
extern err_t simulate();
extern err_t memcpy();
extern err_t verify();
err_t erase_flash_sector(const void *start_address)
{
return OK;
} }
bool verify() err_t erase_flash_region(void *start_address)
{ {
return true; const uint32_t flash_region_size = 0x400000; /* 4 MByte */
} const uint32_t flash_sector_size = 0x2000; /* 8 KByte */
err_t err;
bool simulate() const void *p = start_address;
{
return true; do {
err = erase_flash_sector(p);
p += flash_sector_size;
} while ((p < start_address + flash_region_size) && err == OK);
return err;
} }
void srec_flash(char *flash_filename) void srec_flash(char *flash_filename)
@@ -59,8 +78,11 @@ void srec_flash(char *flash_filename)
err = read_srecords(flash_filename, &start_address, &length, simulate); err = read_srecords(flash_filename, &start_address, &length, simulate);
if (err == OK) if (err == OK)
{ {
xprintf("OK.\r\nerase flash area (from %p): ", start_address);
err = erase(start_address);
/* next pass: copy data to destination */ /* next pass: copy data to destination */
xprintf("OK.\r\ncopy/flash data: "); xprintf("OK.\r\flash data: ");
err = read_srecords(flash_filename, &start_address, &length, memcpy); err = read_srecords(flash_filename, &start_address, &length, memcpy);
if (err == OK) if (err == OK)
{ {