Bladeren bron

make inclusion of sources optional

Thomas Buck 1 jaar geleden
bovenliggende
commit
c6da7c81a2
3 gewijzigde bestanden met toevoegingen van 35 en 13 verwijderingen
  1. 10
    0
      include/config.h
  2. 0
    3
      include/fat_disk.h
  3. 25
    10
      src/debug_disk.c

+ 10
- 0
include/config.h Bestand weergeven

@@ -22,4 +22,14 @@
22 22
 //#define DISABLE_CDC_DTR_CHECK
23 23
 #define DEBOUNCE_DELAY_MS 5
24 24
 
25
+#define DEBUG_DISK_WRITE_SOURCES
26
+
27
+#define DISK_BLOCK_SIZE 512
28
+
29
+#ifdef DEBUG_DISK_WRITE_SOURCES
30
+#define DISK_BLOCK_COUNT (256 + 128)
31
+#else // DEBUG_DISK_WRITE_SOURCES
32
+#define DISK_BLOCK_COUNT 128 // 128 is minimum size for fatfs lib
33
+#endif // DEBUG_DISK_WRITE_SOURCES
34
+
25 35
 #endif // __CONFIG_H__

+ 0
- 3
include/fat_disk.h Bestand weergeven

@@ -16,9 +16,6 @@
16 16
  * See <http://www.gnu.org/licenses/>.
17 17
  */
18 18
 
19
-#define DISK_BLOCK_COUNT 300
20
-#define DISK_BLOCK_SIZE 512
21
-
22 19
 void fat_disk_init(void);
23 20
 
24 21
 uint8_t *fat_disk_get_sector(uint32_t sector);

+ 25
- 10
src/debug_disk.c Bestand weergeven

@@ -26,20 +26,14 @@
26 26
 #include "log.h"
27 27
 #include "debug_disk.h"
28 28
 
29
+#ifdef DEBUG_DISK_WRITE_SOURCES
29 30
 #include "pack_data.h"
31
+#endif // DEBUG_DISK_WRITE_SOURCES
30 32
 
31 33
 static FATFS fs;
32 34
 static bool mounted = false;
33 35
 
34
-void debug_disk_init(void) {
35
-    if (debug_disk_mount() != 0) {
36
-        debug("error mounting disk");
37
-        return;
38
-    }
39
-
40
-    // maximum length: 11 bytes
41
-    f_setlabel("DEBUG DISK");
42
-
36
+static void write_readme(void) {
43 37
     FIL file;
44 38
     FRESULT res = f_open(&file, "README.md", FA_CREATE_ALWAYS | FA_WRITE);
45 39
     if (res != FR_OK) {
@@ -66,8 +60,12 @@ void debug_disk_init(void) {
66 60
             debug("error: f_close returned %d", res);
67 61
         }
68 62
     }
63
+}
69 64
 
70
-    res = f_open(&file, "src.tar.xz", FA_CREATE_ALWAYS | FA_WRITE);
65
+#ifdef DEBUG_DISK_WRITE_SOURCES
66
+static void write_sources(void) {
67
+    FIL file;
68
+    FRESULT res = f_open(&file, "src.tar.xz", FA_CREATE_ALWAYS | FA_WRITE);
71 69
     if (res != FR_OK) {
72 70
         debug("error: f_open returned %d", res);
73 71
     } else {
@@ -92,6 +90,23 @@ void debug_disk_init(void) {
92 90
             debug("error: f_close returned %d", res);
93 91
         }
94 92
     }
93
+}
94
+#endif // DEBUG_DISK_WRITE_SOURCES
95
+
96
+void debug_disk_init(void) {
97
+    if (debug_disk_mount() != 0) {
98
+        debug("error mounting disk");
99
+        return;
100
+    }
101
+
102
+    // maximum length: 11 bytes
103
+    f_setlabel("DEBUG DISK");
104
+
105
+    write_readme();
106
+
107
+#ifdef DEBUG_DISK_WRITE_SOURCES
108
+    write_sources();
109
+#endif // DEBUG_DISK_WRITE_SOURCES
95 110
 
96 111
     if (debug_disk_unmount() != 0) {
97 112
         debug("error unmounting disk");

Laden…
Annuleren
Opslaan