Quellcode durchsuchen

Decrease bootloader flash usage

Added more to the discard section in the bootloader linker files for
RP2040 and RP3250 based boards. Added the linker .map file generation to
the build_bootloader.py script.
J. Morio Sakaguchi vor 2 Monaten
Ursprung
Commit
eb25f57935

+ 31 - 0
lib/BlueSCSI_platform_RP2MCU/rp2040_btldr.ld

@@ -44,7 +44,38 @@ SECTIONS
         __flash_binary_start = .;
     } > FLASH
 
+    /* Discard code that is not used in bootloader mode to
+    * reduce the flash usage.
+    */
+    /DISCARD/ : {
+
+        *scanf*(*)
+        *strtod*(*)
+        *libipv4.a:*(*)
+        *liblwip*.a:*(*)
+        *libBlueSCSI_audio_RP2MCU.a:*(*)
+        *libAdafruit*.a:*(*)
+        *libWire.a:*(*)
+        *libSPI.a:*(*)
+        *libBlueSCSI_platform_RP2MCU.a:BlueSCSI_platform_network.cpp.o*(*)
+        *libFrameworkArduino.a:cyw43_wrappers.cpp.o*(*)
+
+        /* gt */
+        *BlueSCSI_tape.cpp.o*(*)
+        *BlueSCSI_mode.cpp.o*(*)
+        *BlueSCSI_blink.cpp.o*(*)
+        *BlueSCSI_buffer_control.cpp.o*(*)
+        *uiDiskUtils.cpp.o*(*)
+        *SDNavigator.cpp.o*(*)
+    }
+
     .text : {
+        cyw43_digitalWrite = 0;
+        cyw43_digitalRead = 0;
+        cyw43_pinMode = 0;
+        init_cyw43_wifi = bootloader_main;
+        platform_poll = 0;
+
         __logical_binary_start = .;
         KEEP (*(.btldr_vectors))
         KEEP (*(.binary_info_header))

+ 34 - 0
lib/BlueSCSI_platform_RP2MCU/rp23xx_btldr.ld

@@ -45,7 +45,41 @@ SECTIONS
         __flash_binary_start = .;
     } > FLASH
 
+    /* Discard code that is not used in bootloader mode to
+    * reduce the flash usage.
+    */
+    /DISCARD/ : {
+
+        *scanf*(*)
+        *strtod*(*)
+        *libipv4.a:*(*)
+        *liblwip*.a:*(*)
+        *libBlueSCSI_audio_RP2MCU.a:*(*)
+        *libAdafruit*.a:*(*)
+        *libWire.a:*(*)
+        *libSPI.a:*(*)
+        *libBlueSCSI_UI_RP2MCU.a:*(*)
+        *libBlueSCSI_platform_RP2MCU.a:BlueSCSI_platform_network.cpp.o*(*)
+        *libFrameworkArduino.a:cyw43_wrappers.cpp.o*(*)
+
+        /* gt */
+        *BlueSCSI_tape.cpp.o*(*)
+        *BlueSCSI_mode.cpp.o*(*)
+        *BlueSCSI_blink.cpp.o*(*)
+        *BlueSCSI_buffer_control.cpp.o*(*)
+        *uiDiskUtils.cpp.o*(*)
+        *SDNavigator.cpp.o*(*)
+    }
+
     .text : {
+        cyw43_digitalWrite = 0;
+        cyw43_digitalRead = 0;
+        cyw43_pinMode = 0;
+        init_cyw43_wifi = bootloader_main;
+        setPendingImageLoad = 0;
+        platform_poll = 0;
+
+
         __logical_binary_start = .;
         KEEP (*(.btldr_vectors))
         KEEP (*(.binary_info_header))

+ 1 - 1
src/build_bootloader.py

@@ -58,7 +58,7 @@ if env2.GetProjectOption("ldscript_bootloader"):
     env2.Replace(LDSCRIPT_PATH = env2.GetProjectOption("ldscript_bootloader"))
     env2['LINKFLAGS'] = [a for a in env2['LINKFLAGS'] if not a.startswith('-T') and not a.endswith('.ld')]
     env2.Append(LINKFLAGS="-T" + env2.GetProjectOption("ldscript_bootloader"))
-
+    env2.Append(LINKFLAGS="-Wl,-Map=\"" + os.path.join("$BUILD_DIR", "bootloader.map") + "\"")
 # Build bootloader.elf
 bootloader_elf = env2.Program(
     os.path.join("$BUILD_DIR", "bootloader.elf"),