Explorar el Código

projects/riscv_usb: Improve firmware size by turning on LTO

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Sylvain Munaut hace 5 años
padre
commit
3fd3e6bec1

+ 1 - 1
projects/riscv_usb/fw/Makefile

@@ -3,7 +3,7 @@ CC = $(CROSS)gcc
 OBJCOPY = $(CROSS)objcopy
 ICEPROG = iceprog
 
-CFLAGS=-Wall -Os -march=rv32i -mabi=ilp32 -ffreestanding -nostartfiles
+CFLAGS=-Wall -Os -march=rv32i -mabi=ilp32 -ffreestanding -flto -nostartfiles -fomit-frame-pointer -Wl,--gc-section
 
 HEADERS=\
 	mini-printf.h \

+ 3 - 3
projects/riscv_usb/fw/boot.S

@@ -22,9 +22,9 @@
 #define FLASH_APP_ADDR 0x00100000
 #endif
 
-	.section .text
-
-start:
+	.section .text.start
+	.global _start
+_start:
 
 #ifdef BOOT_DEBUG
 	// Set UART divisor

+ 2 - 0
projects/riscv_usb/fw/lnk-app.lds

@@ -4,10 +4,12 @@ MEMORY
     SPRAM (xrw) : ORIGIN = 0x0001c000, LENGTH = 0x4000
     BRAM  (xrw) : ORIGIN = 0x00000010, LENGTH = 0x03f0
 }
+ENTRY(_start)
 SECTIONS {
     .text :
     {
         . = ALIGN(4);
+        *(.text.start)
         *(.text)
         *(.text*)
         *(.rodata)

+ 2 - 0
projects/riscv_usb/fw/lnk-boot.lds

@@ -2,10 +2,12 @@ MEMORY
 {
     ROM (rx)    : ORIGIN = 0x00000000, LENGTH = 0x0400
 }
+ENTRY(_start)
 SECTIONS {
     .text :
     {
         . = ALIGN(4);
+        *(.text.start)
         *(.text)
         *(.text*)
     } >ROM

+ 3 - 3
projects/riscv_usb/fw/start.S

@@ -19,9 +19,9 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-	.section .text
-
-start:
+	.section .text.start
+	.global _start
+_start:
 
 	// zero-initialize register file
 	addi x1, zero, 0