Browse Source

Align the sds struct on 32bit boundaries

The sds struct need to be aligned on a 32 bit boundary because it
is filled via the DMA. If not, depending on how the memory map
gets compiled it can cause the board to freeze.
Morio 1 year ago
parent
commit
50070e19b0

+ 3 - 2
lib/ZuluSCSI_platform_RP2040/sd_card_sdio.cpp

@@ -1,5 +1,6 @@
 /** 
- * ZuluSCSI™ - Copyright (c) 2022 Rabbit Hole Computing™
+ * ZuluSCSI™ - Copyright (c) 2022-2024 Rabbit Hole Computing™
+ * Copyright (c) 2024 Tech by Androda, LLC
  * 
  * ZuluSCSI™ firmware is licensed under the GPL version 3 or any later version. 
  * 
@@ -35,7 +36,7 @@ static uint32_t g_sdio_ocr; // Operating condition register from card
 static uint32_t g_sdio_rca; // Relative card address
 static cid_t g_sdio_cid;
 static csd_t g_sdio_csd;
-static sds_t g_sdio_sds;
+static sds_t __attribute__((aligned(4))) g_sdio_sds;
 static int g_sdio_error_line;
 static sdio_status_t g_sdio_error;
 static uint32_t g_sdio_dma_buf[128];

+ 2 - 1
lib/ZuluSCSI_platform_RP2040/sdio.cpp

@@ -1,5 +1,6 @@
 /** 
- * ZuluSCSI™ - Copyright (c) 2022 Rabbit Hole Computing™
+ * ZuluSCSI™ - Copyright (c) 2022-2024 Rabbit Hole Computing™
+ * Copyright (c) 2024 Tech by Androda, LLC
  * 
  * ZuluSCSI™ firmware is licensed under the GPL version 3 or any later version. 
  * 

+ 11 - 0
src/ZuluSCSI.cpp

@@ -66,6 +66,10 @@ bool g_rawdrive_active;
 static bool g_romdrive_active;
 static bool g_sdcard_present;
 
+#ifndef SD_SPEED_CLASS_WARN_BELOW
+#define SD_SPEED_CLASS_WARN_BELOW 10
+#endif
+
 /************************************/
 /* Status reporting by blinking led */
 /************************************/
@@ -174,6 +178,13 @@ void print_sd_info()
     logmsg("SD Date: ", (int)sd_cid.mdtMonth(), "/", sd_cid.mdtYear());
     logmsg("SD Serial: ", sd_cid.psn());
   }
+
+  sds_t sds = {0};
+  if (SD.card()->readSDS(&sds) && sds.speedClass() < SD_SPEED_CLASS_WARN_BELOW)
+  {
+    logmsg("-- WARNING: Your SD Card Speed Class is ", (int)sds.speedClass(), ". Class ", (int) SD_SPEED_CLASS_WARN_BELOW," or better is recommended for best performance.");
+  }
+
 }
 
 /*********************************/

+ 0 - 12
src/ZuluSCSI_disk.cpp

@@ -44,10 +44,6 @@
 #include <assert.h>
 #include <SdFat.h>
 
-#ifndef SD_SPEED_CLASS_WARN_BELOW
-#define SD_SPEED_CLASS_WARN_BELOW 10
-#endif
-
 extern "C" {
 #include <scsi2sd_time.h>
 #include <sd.h>
@@ -1054,14 +1050,6 @@ void s2s_configInit(S2S_BoardCfg* config)
     ini_gets("SCSI", "System", "", tmp, sizeof(tmp), CONFIGFILE);
     scsi_system_settings_t *sysCfg = g_scsi_settings.initSystem(tmp);
 
-    sds_t sds = {0};
-    SD.card()->readSDS(&sds);
-    if ( sds.speedClass() < SD_SPEED_CLASS_WARN_BELOW)
-    {
-		logmsg("WARNING: Your SD Card Speed Class is ", (int)sds.speedClass(), ". Class ", (int) SD_SPEED_CLASS_WARN_BELOW," or better is recommended for best performance.");
-    }
-
-
     if (g_scsi_settings.getSystemPreset() != SYS_PRESET_NONE)
     {
         logmsg("Active configuration (using system preset \"", g_scsi_settings.getSystemPresetName(), "\"):");