Strip down linker script
This commit is contained in:
+10
-37
@@ -5,10 +5,14 @@ PROVIDE( _stack_size = __stack_size );
|
||||
|
||||
MEMORY
|
||||
{
|
||||
/* CH32V20x_D6 -> 10 KB SRAM */
|
||||
/* allow full flash (incl. non-zero-wait) */
|
||||
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 224K
|
||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 10K
|
||||
/* Try to squeeze down to this target size */
|
||||
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 2K
|
||||
/* We have a total of 512 bytes here.
|
||||
- Need 256 bytes to buffer a flash page across USB packets
|
||||
- Need space for USB buffers
|
||||
- Tiny tiny amount of free space
|
||||
*/
|
||||
USBRAM (rw) : ORIGIN = 0x400060c0, LENGTH = 64
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
@@ -29,29 +33,6 @@ SECTIONS
|
||||
. = ALIGN(4);
|
||||
} >FLASH
|
||||
|
||||
.preinit_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
} >FLASH
|
||||
|
||||
.init_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
|
||||
KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
} >FLASH
|
||||
|
||||
.fini_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
|
||||
KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
} >FLASH
|
||||
|
||||
PROVIDE(_data_lma = .);
|
||||
|
||||
.data :
|
||||
@@ -73,7 +54,7 @@ SECTIONS
|
||||
*(.srodata .srodata.*)
|
||||
. = ALIGN(4);
|
||||
PROVIDE( _edata = .);
|
||||
} >RAM AT>FLASH
|
||||
} >USBRAM AT>FLASH
|
||||
|
||||
.bss :
|
||||
{
|
||||
@@ -85,15 +66,7 @@ SECTIONS
|
||||
*(COMMON*)
|
||||
. = ALIGN(4);
|
||||
PROVIDE( _ebss = .);
|
||||
} >RAM
|
||||
} >USBRAM
|
||||
|
||||
PROVIDE( _end = _ebss);
|
||||
|
||||
.stack ORIGIN(RAM) + LENGTH(RAM) - __stack_size :
|
||||
{
|
||||
PROVIDE( _heap_end = . );
|
||||
PROVIDE( _susrstack = . );
|
||||
. = . + __stack_size;
|
||||
PROVIDE( _eusrstack = .);
|
||||
} >RAM
|
||||
}
|
||||
|
||||
@@ -32,46 +32,7 @@ _start:
|
||||
bltu a0, a1, 1b
|
||||
2:
|
||||
|
||||
// Call preinit array functions
|
||||
la s0, __preinit_array_start
|
||||
la s1, __preinit_array_end
|
||||
bgeu s0, s1, 2f
|
||||
1:
|
||||
lw t0, (s0)
|
||||
jalr t0
|
||||
addi s0, s0, 4
|
||||
bltu s0, s1, 1b
|
||||
2:
|
||||
|
||||
// Call init array functions
|
||||
la s0, __init_array_start
|
||||
la s1, __init_array_end
|
||||
bgeu s0, s1, 2f
|
||||
1:
|
||||
lw t0, (s0)
|
||||
jalr t0
|
||||
addi s0, s0, 4
|
||||
bltu s0, s1, 1b
|
||||
2:
|
||||
|
||||
// Invoke main with a possible mode switch
|
||||
la ra, 1f
|
||||
// Invoke main
|
||||
la t0, main
|
||||
csrw mepc, t0
|
||||
mret
|
||||
|
||||
1:
|
||||
// Return from main, call fini array functions
|
||||
la s0, __fini_array_start
|
||||
la s1, __fini_array_end
|
||||
bgeu s0, s1, 2f
|
||||
1:
|
||||
lw t0, (s0)
|
||||
jalr t0
|
||||
addi s0, s0, 4
|
||||
bltu s0, s1, 1b
|
||||
2:
|
||||
|
||||
// Finally, loop infinitely
|
||||
wfi
|
||||
j 2b
|
||||
|
||||
Reference in New Issue
Block a user