From ec3dfed06668f277dc6199c3df31af470987ae92 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 31 Aug 2021 00:28:29 +0700 Subject: [PATCH 1/4] update tinyusb to commit https://github.com/hathach/tinyusb/commit/38f5aee9c31299874dcda1758cb98e4404c6ad9d --- lib/tinyusb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tinyusb b/lib/tinyusb index 3a248951e2744..38f5aee9c3129 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit 3a248951e2744ba89f5fb96eda85a971001115f0 +Subproject commit 38f5aee9c31299874dcda1758cb98e4404c6ad9d From cd5acae4f429dbad649f0c10b72fd483c2294feb Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 31 Aug 2021 18:04:01 -0700 Subject: [PATCH 2/4] Sort .text section to reduce fill --- ports/atmel-samd/boards/common.template.ld | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ports/atmel-samd/boards/common.template.ld b/ports/atmel-samd/boards/common.template.ld index 53c4cf5eece88..b5faf7f458c91 100644 --- a/ports/atmel-samd/boards/common.template.ld +++ b/ports/atmel-samd/boards/common.template.ld @@ -27,8 +27,12 @@ SECTIONS . = ALIGN(4); _sfixed = .; KEEP(*(.vectors)) /* isr vector table */ - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ + + /* Sort text sections so that they have fewer *fill* bytes needed. */ + *SORT_BY_ALIGNMENT(SORT_BY_NAME(.text)) /* .text sections (code) */ + *SORT_BY_ALIGNMENT(SORT_BY_NAME(.text*)) /* .text* sections (code) */ + + /* Don't sort rodata because it impacts codegen size. */ *(.rodata) /* .rodata sections (constants, strings, etc.) */ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ @@ -62,8 +66,8 @@ SECTIONS _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialize the .data section in RAM */ *(.ramfunc) *(.ramfunc*) - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ + *SORT_BY_ALIGNMENT(SORT_BY_NAME(.data)) /* .data sections */ + *SORT_BY_ALIGNMENT(SORT_BY_NAME(.data*)) /* .data* sections */ . = ALIGN(4); _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialize the .data section in RAM */ @@ -76,7 +80,7 @@ SECTIONS _sbss = .; _szero = .; /* define a global symbol at bss start; used by startup code */ *(.bss) - *(.bss*) + *SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss*)) *(COMMON) . = ALIGN(4); From 0cffa6be81636565750f31714efbf7727768db86 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 31 Aug 2021 19:33:44 -0700 Subject: [PATCH 3/4] Sort .text section to reduce fill on nRF --- ports/nrf/boards/common.template.ld | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ports/nrf/boards/common.template.ld b/ports/nrf/boards/common.template.ld index 855d8522fcb85..3591f23976689 100644 --- a/ports/nrf/boards/common.template.ld +++ b/ports/nrf/boards/common.template.ld @@ -62,8 +62,8 @@ SECTIONS .text : { . = ALIGN(4); - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ + *SORT_BY_ALIGNMENT(SORT_BY_NAME(.text)) /* .text sections (code) */ + *SORT_BY_ALIGNMENT(SORT_BY_NAME(.text*)) /* .text* sections (code) */ *(.rodata) /* .rodata sections (constants, strings, etc.) */ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ /* *(.glue_7) */ /* glue arm to thumb code */ @@ -85,8 +85,8 @@ SECTIONS . = ALIGN(4); _sdata = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */ _ram_start = .; /* create a global symbol at ram start for garbage collector */ - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ + *SORT_BY_ALIGNMENT(SORT_BY_NAME(.data)) /* .data sections */ + *SORT_BY_ALIGNMENT(SORT_BY_NAME(.data*)) /* .data* sections */ . = ALIGN(4); _edata = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */ @@ -97,8 +97,8 @@ SECTIONS { . = ALIGN(4); _sbss = .; /* define a global symbol at bss start; used by startup code */ - *(.bss) - *(.bss*) + *SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss)) + *SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss*)) *(COMMON) . = ALIGN(4); From 9c4c3e1780ac23d6f3d520459c7f7bb01f1578df Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 1 Sep 2021 08:57:18 -0700 Subject: [PATCH 4/4] Only sort .text for nrf --- ports/nrf/boards/common.template.ld | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ports/nrf/boards/common.template.ld b/ports/nrf/boards/common.template.ld index 3591f23976689..306145e00cf3c 100644 --- a/ports/nrf/boards/common.template.ld +++ b/ports/nrf/boards/common.template.ld @@ -73,32 +73,32 @@ SECTIONS _etext = .; /* define a global symbol at end of code */ } >FLASH_FIRMWARE - /* used by the startup to initialize data */ - _sidata = .; - /* This is the initialized data section The program executes knowing that the data is in the RAM but the loader puts the initial values in the FLASH (inidata). It is one task of the startup to copy the initial values from FLASH to RAM. */ - .data : AT (_sidata) + .data : { . = ALIGN(4); _sdata = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */ _ram_start = .; /* create a global symbol at ram start for garbage collector */ - *SORT_BY_ALIGNMENT(SORT_BY_NAME(.data)) /* .data sections */ - *SORT_BY_ALIGNMENT(SORT_BY_NAME(.data*)) /* .data* sections */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ . = ALIGN(4); _edata = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */ - } >APP_RAM + } >APP_RAM AT > FLASH_FIRMWARE + + /* used by the startup to initialize data */ + _sidata = LOADADDR(.data); /* Zero-initialized data section */ .bss : { . = ALIGN(4); _sbss = .; /* define a global symbol at bss start; used by startup code */ - *SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss)) - *SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss*)) + *(.bss) + *(.bss*) *(COMMON) . = ALIGN(4);