1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES
index dbb5843..8802fb5 100644
--- a/apps/plugins/SOURCES
+++ b/apps/plugins/SOURCES
@@ -244,3 +244,4 @@ test_touchscreen.c
 #endif
 test_viewports.c
 #endif
+test_disk.c
diff --git a/firmware/target/arm/as3525/sd-as3525.c b/firmware/target/arm/as3525/sd-as3525.c
index 19914ab..6f94414 100644
--- a/firmware/target/arm/as3525/sd-as3525.c
+++ b/firmware/target/arm/as3525/sd-as3525.c
@@ -397,6 +397,9 @@ static int sd_init_card(const int drive)
         mci_delay();
     }

+    if(!send_cmd(INTERNAL_AS3525, SD_DESELECT_CARD, 0, MCI_NO_FLAGS, NULL))
+        panicf("desel init failed");
+
     card_info[drive].initialized = 1;

     return 0;
@@ -701,6 +704,9 @@ static int sd_transfer_sectors(IF_MD2(int drive,) unsigned long start,

     last_disk_activity = current_tick;

+    if(!send_cmd(INTERNAL_AS3525, SD_SELECT_CARD, card_info[INTERNAL_AS3525].rca, MCI_NO_FLAGS, NULL))
+        panicf("sel failed");
+
     dma_retain();

     while(count)
@@ -821,6 +827,9 @@ static int sd_transfer_sectors(IF_MD2(int drive,) unsigned long start,

 sd_transfer_error:

+    if(!send_cmd(INTERNAL_AS3525, SD_DESELECT_CARD, 0, MCI_NO_FLAGS, NULL))
+        panicf("desel 0 failed");
+
     dma_release();

 #ifndef BOOTLOADER