Przeglądaj źródła

GD32F205: Avoid including USB in bootloader

usb_log_poll() was bringing in unnecessary code,
causing bootloader to be larger than needed and
exceed 32 kB.
Petteri Aimonen 11 miesięcy temu
rodzic
commit
f68e827c40

+ 7 - 2
lib/ZuluSCSI_platform_GD32F205/ZuluSCSI_platform.cpp

@@ -46,6 +46,10 @@ bool g_moved_select_in = false;
 // hw_config.cpp c functions
 #include "platform_hw_config.h"
 
+// usb_log_poll() is called through function pointer to
+// avoid including USB in SD card bootloader.
+static void (*g_usb_log_poll_func)(void);
+static void usb_log_poll();
 
 
 /*************************/
@@ -394,6 +398,7 @@ void platform_late_init()
 {
     // Initialize usb for CDC serial output
     usb_serial_init();
+    g_usb_log_poll_func = &usb_log_poll;
 
     logmsg("Platform: ", g_platform_name);
     logmsg("FW Version: ", g_log_firmwareversion);
@@ -615,7 +620,7 @@ void show_hardfault(uint32_t *sp)
 
     while (1)
     {
-        usb_log_poll();
+        if (g_usb_log_poll_func) g_usb_log_poll_func();
         // Flash the crash address on the LED
         // Short pulse means 0, long pulse means 1
         int base_delay = 1000;
@@ -688,7 +693,7 @@ void __assert_func(const char *file, int line, const char *func, const char *exp
 
     while(1)
     {
-        usb_log_poll();
+        if (g_usb_log_poll_func) g_usb_log_poll_func();
         LED_OFF();
         for (int j = 0; j < 1000; j++) delay_ns(100000);
         LED_ON();