removed timing routines from sd_card.c (since they were disappointing anyway)

modified S-record reader diagnostic output
This commit is contained in:
Markus Fröschle
2012-12-18 20:55:18 +00:00
parent 9a80c36081
commit 371adb5581
3 changed files with 33 additions and 55 deletions

View File

@@ -10,5 +10,5 @@
void basflash(void) void basflash(void)
{ {
xprintf("Hello from BASFLASH.S19!\r\n"); xprintf("\r\nHello from BASFLASH.S19!\r\n\r\n");
} }

View File

@@ -333,6 +333,7 @@ void flasher_load(char *flasher_filename)
DRESULT res; DRESULT res;
FRESULT fres; FRESULT fres;
FATFS fs; FATFS fs;
FIL file;
err_t err; err_t err;
void *start_address; void *start_address;
uint32_t length; uint32_t length;
@@ -344,28 +345,41 @@ void flasher_load(char *flasher_filename)
fres = f_mount(0, &fs); fres = f_mount(0, &fs);
if (fres == FR_OK) if (fres == FR_OK)
{ {
/* first pass: parse and check for inconsistencies */ if ((fres = f_open(&file, flasher_filename, FA_READ) != FR_OK))
xprintf("check file integrity: ");
err = read_srecords(flasher_filename, &start_address, &length, simulate);
if (err == OK)
{ {
/* next pass: copy data to destination */ xprintf("flasher file %s not present on disk\r\n", flasher_filename);
xprintf("OK.\r\ncopy/flash data: "); }
err = read_srecords(flasher_filename, &start_address, &length, memcpy); else
{
f_close(&file);
/* first pass: parse and check for inconsistencies */
xprintf("check file integrity: ");
err = read_srecords(flasher_filename, &start_address, &length, simulate);
if (err == OK) if (err == OK)
{ {
/* next pass: verify data */ /* next pass: copy data to destination */
xprintf("OK.\r\nverify data: "); xprintf("OK.\r\ncopy/flash data: ");
err = read_srecords(flasher_filename, &start_address, &length, verify); err = read_srecords(flasher_filename, &start_address, &length, memcpy);
if (err == OK) if (err == OK)
{ {
xprintf("OK.\r\n"); /* next pass: verify data */
typedef void void_func(void); xprintf("OK.\r\nverify data: ");
void_func *func; err = read_srecords(flasher_filename, &start_address, &length, verify);
xprintf("target successfully written and verified. Start address: %p\r\n", start_address); if (err == OK)
{
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 = start_address;
(*func)(); (*func)();
}
else
{
xprintf("failed\r\n");
}
} }
else else
{ {
@@ -377,20 +391,16 @@ void flasher_load(char *flasher_filename)
xprintf("failed\r\n"); xprintf("failed\r\n");
} }
} }
else
{
xprintf("failed\r\n");
}
} }
else else
{ {
xprintf("could not mount FAT FS\r\n"); // xprintf("could not mount FAT FS\r\n");
} }
f_mount(0, NULL); f_mount(0, NULL);
} }
else else
{ {
xprintf("could not initialize SD card\r\n"); // xprintf("could not initialize SD card\r\n");
} }
} }

View File

@@ -83,38 +83,6 @@ void sd_card_init(void)
} }
} }
f_close(&file); f_close(&file);
/*
* let's see if we find our boot flashing executable on disk
*/
fres = f_open(&file, FLASHCODE_NAME, FA_READ);
if (fres == FR_OK)
{
/*
* yes, load and execute it
*
* FIXME: we will need some kind of user confirmation here
* to avoid unwanted flashing or "bootsector viruses" before going productive
*/
uint32_t size; /* length of code piece read */
uint32_t total_size = 0L;
uint32_t start_time = MCF_SLT_SCNT(0);
uint32_t end_time;
uint32_t time = 0;
while ((fres = f_read(&file, (void *) FLASHCODE_ADDRESS, 1024, &size)) == FR_OK)
{
total_size += size / 1024;
//xprintf("read hunk of %d bytes, total_size = %d kBytes\r\n", size, total_size);
}
end_time = MCF_SLT_SCNT(0);
time = (end_time - start_time) / 132L;
xprintf("result of f_read: %ld, %ld kbytes read\r\n", fres, total_size);
xprintf("time to load %s: %ld s\r\n", FLASHCODE_NAME, time / 1000 / 100);
xprintf("equals to about %ld kBytes/second\r\n", total_size / (time / 1000 / 100));
}
f_close(&file);
} }
f_mount(0, 0L); /* release work area */ f_mount(0, 0L); /* release work area */
} }