Skip to content

Commit

Permalink
Merge pull request #614 from FrankBoesing/patch-1
Browse files Browse the repository at this point in the history
Reduce memory usage (wasted RAM)
  • Loading branch information
PaulStoffregen authored Sep 26, 2021
2 parents 6d0e3ae + 918343c commit 2e2dcf7
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
10 changes: 6 additions & 4 deletions teensy4/imxrt1062.ld
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ SECTIONS
} > ITCM AT> FLASH

.data : {
*(.rodata*)
*(.data*)
*(.endpoint_queue)
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.data*)))
KEEP(*(.vectorsram))
} > DTCM AT> FLASH

.bss ALIGN(4) : {
*(.bss*)
*(COMMON)
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss*)))
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(COMMON)))
. = ALIGN(32);
. = . + 32; /* MPU to trap stack overflow */
} > DTCM
Expand Down
10 changes: 6 additions & 4 deletions teensy4/imxrt1062_mm.ld
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ SECTIONS
} > ITCM AT> FLASH

.data : {
*(.rodata*)
*(.data*)
*(.endpoint_queue)
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.data*)))
KEEP(*(.vectorsram))
} > DTCM AT> FLASH

.bss ALIGN(4) : {
*(.bss*)
*(COMMON)
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss*)))
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(COMMON)))
. = ALIGN(32);
. = . + 32; /* MPU to trap stack overflow */
} > DTCM
Expand Down
12 changes: 7 additions & 5 deletions teensy4/imxrt1062_t41.ld
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ SECTIONS
} > ITCM AT> FLASH

.data : {
*(.rodata*)
*(.data*)
*(.endpoint_queue)
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.data*)))
KEEP(*(.vectorsram))
} > DTCM AT> FLASH

.bss ALIGN(4) : {
*(.bss*)
*(COMMON)
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss*)))
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(COMMON)))
. = ALIGN(32);
. = . + 32; /* MPU to trap stack overflow */
} > DTCM
Expand All @@ -71,7 +73,7 @@ SECTIONS
} > RAM

.bss.extram (NOLOAD) : {
*(.externalram)
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.externalram)))
. = ALIGN(32);
} > ERAM

Expand Down
2 changes: 1 addition & 1 deletion teensy4/startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extern unsigned long _estack;
extern unsigned long _extram_start;
extern unsigned long _extram_end;

__attribute__ ((used, aligned(1024)))
__attribute__ ((used, aligned(1024), section(".vectorsram")))
void (* volatile _VectorsRam[NVIC_NUM_INTERRUPTS+16])(void);

static void memory_copy(uint32_t *dest, const uint32_t *src, uint32_t *dest_end);
Expand Down
2 changes: 1 addition & 1 deletion teensy4/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct endpoint_struct {
uint8_t experimental_buffer[1152] __attribute__ ((section(".dmabuffers"), aligned(64)));
#endif

endpoint_t endpoint_queue_head[(NUM_ENDPOINTS+1)*2] __attribute__ ((used, aligned(4096)));
endpoint_t endpoint_queue_head[(NUM_ENDPOINTS+1)*2] __attribute__ ((used, aligned(4096), section(".endpoint_queue") ));

transfer_t endpoint0_transfer_data __attribute__ ((used, aligned(32)));
transfer_t endpoint0_transfer_ack __attribute__ ((used, aligned(32)));
Expand Down

0 comments on commit 2e2dcf7

Please sign in to comment.