Browse Source

sdcard: reinitialize on system (soft) reset

When the software is reinitialized, make sure we reset the sdcard
status; otherwise it will hang after reset.
H. Peter Anvin 3 years ago
parent
commit
2e544bb970
8 changed files with 6989 additions and 6980 deletions
  1. BIN
      fpga/output_files/max80.jbc
  2. BIN
      fpga/output_files/max80.jic
  3. BIN
      fpga/output_files/max80.pof
  4. BIN
      fpga/output_files/max80.sof
  5. 6980 6980
      rv32/boot.mif
  6. 6 0
      rv32/sdcard.c
  7. 1 0
      rv32/sdcard.h
  8. 2 0
      rv32/system.c

BIN
fpga/output_files/max80.jbc


BIN
fpga/output_files/max80.jic


BIN
fpga/output_files/max80.pof


BIN
fpga/output_files/max80.sof


File diff suppressed because it is too large
+ 6980 - 6980
rv32/boot.mif


+ 6 - 0
rv32/sdcard.c

@@ -655,6 +655,12 @@ DSTATUS sdcard_present_poll(void)
 
 #define SDCARD_RETRY (TIMER_HZ*2)		/* Retry max every 2 s */
 
+void sdcard_reset(void)
+{
+    memset(&sdc, 0, sizeof sdc);
+    sdc.status = sdc.fsstatus = STA_NOINIT;
+}
+
 DSTATUS sdcard_init(void)
 {
     uint16_t  status;

+ 1 - 0
rv32/sdcard.h

@@ -35,6 +35,7 @@ typedef unsigned int sector_t;
 
 extern int sdcard_read_sectors(void *, sector_t, int);
 extern int sdcard_write_sectors(const void *, sector_t, int);
+extern void sdcard_reset(void);
 extern DSTATUS sdcard_init(void);
 extern DSTATUS sdcard_present_poll(void);
 

+ 2 - 0
rv32/system.c

@@ -1,5 +1,6 @@
 #include "fw.h"
 #include "io.h"
+#include "sdcard.h"
 #include "abcio.h"
 #include "sys.h"
 #include "console.h"
@@ -117,6 +118,7 @@ void init(void)
 
     set_leds(3);
 
+    sdcard_reset();
     disk_cache_init();
     abcdisk_init();
 

Some files were not shown because too many files changed in this diff