Firmware: SD debugging + minor cleanups

This commit is contained in:
ikari 2011-12-16 19:16:31 +01:00
parent c97278c3d6
commit 39b78ae91c
3 changed files with 8 additions and 3 deletions

View File

@ -2198,7 +2198,6 @@ FRESULT f_read (
#if !_FS_TINY #if !_FS_TINY
#if !_FS_READONLY #if !_FS_READONLY
if (fp->flag & FA__DIRTY) { /* Write sector I/O buffer if needed */ if (fp->flag & FA__DIRTY) { /* Write sector I/O buffer if needed */
printf("DIRTY!?!\n");
if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK)
ABORT(fp->fs, FR_DISK_ERR); ABORT(fp->fs, FR_DISK_ERR);
fp->flag &= ~FA__DIRTY; fp->flag &= ~FA__DIRTY;
@ -2222,7 +2221,6 @@ printf("DIRTY!?!\n");
mem_cpy(rbuff, &fp->fs->win[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ mem_cpy(rbuff, &fp->fs->win[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */
#else #else
mem_cpy(rbuff, &fp->buf[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ mem_cpy(rbuff, &fp->buf[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */
printf("final mem_cpy, rcnt=%d, rbuff-buff=%d\n", rcnt, (void*)rbuff-buff);
} else { } else {
sd_offload_partial_start = fp->fptr % SS(fp->fs); sd_offload_partial_start = fp->fptr % SS(fp->fs);
sd_offload_partial_end = sd_offload_partial_start + rcnt; sd_offload_partial_end = sd_offload_partial_start + rcnt;
@ -2376,7 +2374,6 @@ FRESULT f_sync (
res = validate(fp->fs, fp->id); /* Check validity of the object */ res = validate(fp->fs, fp->id); /* Check validity of the object */
if (res == FR_OK) { if (res == FR_OK) {
if (fp->flag & FA__WRITTEN) { /* Has the file been written? */ if (fp->flag & FA__WRITTEN) { /* Has the file been written? */
printf("DIRTY?!?!?!\n");
#if !_FS_TINY /* Write-back dirty buffer */ #if !_FS_TINY /* Write-back dirty buffer */
if (fp->flag & FA__DIRTY) { if (fp->flag & FA__DIRTY) {
if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK) if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK)

View File

@ -133,6 +133,7 @@
#include "spi.h" #include "spi.h"
#include "fpga_spi.h" #include "fpga_spi.h"
#include "timer.h" #include "timer.h"
#include "sdnative.h"
void fpga_spi_init(void) { void fpga_spi_init(void) {
spi_init(SPI_SPEED_FAST); spi_init(SPI_SPEED_FAST);
@ -230,10 +231,12 @@ void fpga_sddma(uint8_t tgt, uint8_t partial) {
FPGA_SELECT(); FPGA_SELECT();
FPGA_TX_BYTE(0xF1); /* STATUS */ FPGA_TX_BYTE(0xF1); /* STATUS */
FPGA_TX_BYTE(0x00); /* dummy */ FPGA_TX_BYTE(0x00); /* dummy */
DBG_SD printf("FPGA DMA request sent, wait for completion...");
while((status=FPGA_RX_BYTE()) & 0x80) { while((status=FPGA_RX_BYTE()) & 0x80) {
FPGA_RX_BYTE(); /* eat the 2nd status byte */ FPGA_RX_BYTE(); /* eat the 2nd status byte */
test++; test++;
} }
DBG_SD printf("...complete\n");
FPGA_DESELECT(); FPGA_DESELECT();
if(test<5)printf("loopy: %ld %02x\n", test, status); if(test<5)printf("loopy: %ld %02x\n", test, status);
BITBAND(SD_CLKREG->FIODIR, SD_CLKPIN) = 1; BITBAND(SD_CLKREG->FIODIR, SD_CLKPIN) = 1;

View File

@ -449,9 +449,11 @@ int send_command_fast(uint8_t* cmd, uint8_t* rsp, uint8_t* buf){
j=datcnt; j=datcnt;
datshift=8; datshift=8;
DBG_SD printf("response over, waiting for data...\n"); DBG_SD printf("response over, waiting for data...\n");
/* wait for data start bit on DAT0 */
while((BITBAND(SD_DAT0REG->FIOPIN, SD_DAT0PIN)) && --timeout) { while((BITBAND(SD_DAT0REG->FIOPIN, SD_DAT0PIN)) && --timeout) {
wiggle_fast_neg1(); wiggle_fast_neg1();
} }
DBG_SD if(!timeout) printf("timed out!\n");
wiggle_fast_neg1(); /* eat the start bit */ wiggle_fast_neg1(); /* eat the start bit */
if(sd_offload) { if(sd_offload) {
if(sd_offload_partial) { if(sd_offload_partial) {
@ -588,9 +590,12 @@ int stream_datablock(uint8_t *buf) {
uint8_t datdata=0; uint8_t datdata=0;
uint32_t timeout=1000000; uint32_t timeout=1000000;
DBG_SD printf("stream_datablock: wait for ready...\n");
while((BITBAND(SD_DAT0REG->FIOPIN, SD_DAT0PIN)) && --timeout) { while((BITBAND(SD_DAT0REG->FIOPIN, SD_DAT0PIN)) && --timeout) {
wiggle_fast_neg1(); wiggle_fast_neg1();
} }
DBG_SD if(!timeout) printf("timeout!\n");
wiggle_fast_neg1(); /* eat the start bit */ wiggle_fast_neg1(); /* eat the start bit */
if(sd_offload) { if(sd_offload) {
if(sd_offload_partial) { if(sd_offload_partial) {