Browse Source

Small bugfixes

Petteri Aimonen 3 năm trước cách đây
mục cha
commit
58cfc0a153
2 tập tin đã thay đổi với 8 bổ sung0 xóa
  1. 1 0
      lib/AzulSCSI_platform_GD32F205/AzulSCSI_platform.cpp
  2. 7 0
      src/AzulSCSI.cpp

+ 1 - 0
lib/AzulSCSI_platform_GD32F205/AzulSCSI_platform.cpp

@@ -586,6 +586,7 @@ public:
         while (word_ptr < end_ptr)
         {
             uint32_t words_available = (count - DMA_CHCNT(DMA0, SD_SPI_RX_DMA_CHANNEL)) / 4;
+            words_available -= (word_ptr - (uint32_t*)buf);
             if (words_available > 0)
             {
                 if (word_ptr + words_available > end_ptr)

+ 7 - 0
src/AzulSCSI.cpp

@@ -436,6 +436,12 @@ void writeDataPhase_FromSD(uint32_t adds, uint32_t len)
   uint32_t pos = adds * g_currentimg->m_blocksize;
   g_currentimg->m_file.seek(pos);
 
+  if (len > g_currentimg->m_fileSize - pos)
+  {
+    azdbg("Limiting read length from ", (int)len, " to ", (int)(g_currentimg->m_fileSize - pos));
+    len = g_currentimg->m_fileSize - pos;
+  }
+
   SCSI_OUT(MSG,inactive);
   SCSI_OUT(CD ,inactive);
   SCSI_OUT(IO ,  active);
@@ -464,6 +470,7 @@ void writeDataPhase_FromSD(uint32_t adds, uint32_t len)
     else if (status != transfer_len)
     {
       azlog("Streaming failed halfway: ", (int)status, "/", (int)transfer_len, " bytes, data may be corrupt, aborting!");
+      azlog("SD card error: ", (int)SD.sdErrorCode(), " ", (int)SD.sdErrorData());
       g_scsi_sts |= 2;
       return;
     }