Browse Source

make inclusion of sources optional

Thomas Buck 1 year ago
parent
commit
c6da7c81a2
3 changed files with 35 additions and 13 deletions
  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 View File

22
 //#define DISABLE_CDC_DTR_CHECK
22
 //#define DISABLE_CDC_DTR_CHECK
23
 #define DEBOUNCE_DELAY_MS 5
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
 #endif // __CONFIG_H__
35
 #endif // __CONFIG_H__

+ 0
- 3
include/fat_disk.h View File

16
  * See <http://www.gnu.org/licenses/>.
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
 void fat_disk_init(void);
19
 void fat_disk_init(void);
23
 
20
 
24
 uint8_t *fat_disk_get_sector(uint32_t sector);
21
 uint8_t *fat_disk_get_sector(uint32_t sector);

+ 25
- 10
src/debug_disk.c View File

26
 #include "log.h"
26
 #include "log.h"
27
 #include "debug_disk.h"
27
 #include "debug_disk.h"
28
 
28
 
29
+#ifdef DEBUG_DISK_WRITE_SOURCES
29
 #include "pack_data.h"
30
 #include "pack_data.h"
31
+#endif // DEBUG_DISK_WRITE_SOURCES
30
 
32
 
31
 static FATFS fs;
33
 static FATFS fs;
32
 static bool mounted = false;
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
     FIL file;
37
     FIL file;
44
     FRESULT res = f_open(&file, "README.md", FA_CREATE_ALWAYS | FA_WRITE);
38
     FRESULT res = f_open(&file, "README.md", FA_CREATE_ALWAYS | FA_WRITE);
45
     if (res != FR_OK) {
39
     if (res != FR_OK) {
66
             debug("error: f_close returned %d", res);
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
     if (res != FR_OK) {
69
     if (res != FR_OK) {
72
         debug("error: f_open returned %d", res);
70
         debug("error: f_open returned %d", res);
73
     } else {
71
     } else {
92
             debug("error: f_close returned %d", res);
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
     if (debug_disk_unmount() != 0) {
111
     if (debug_disk_unmount() != 0) {
97
         debug("error unmounting disk");
112
         debug("error unmounting disk");

Loading…
Cancel
Save