flasher.ld
1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* Create a USB DFU firmware that runs from RAM.
* Flashing using ST's ROMed DFU bootloader is reliable but very slow. To make
* flashing faster, we can leverage ST's bootloader to copy a small "flasher" in
* RAM, and run it from there.
* Caution: ST's bootloader uses some RAM, so we want to stay off of that memory
* region. Per AN2606, section 47, it's using 0x20003000 - 0x2003FFFF; We'll try
* to play safe and avoid the first 32KB of RAM. */
MEMORY {
RAM_BUFFER (rw) : ORIGIN = 0x20000000 + 32K, LENGTH = 256K - 32K
}
/* The stack is quite large, and should really be equal to Epsilon's. Indeed,
* we're making the Calculator object live on the stack, and it's quite large
* (about 4K just for this single object). Using a stack too small will result
* in some memory being overwritten (for instance, vtables that live in the
* .rodata section). */
STACK_SIZE = 32K;
SECTIONS {
.isr_vector_table ORIGIN(RAM_BUFFER) : {
KEEP(*(.isr_vector_table))
} >RAM_BUFFER
.text : {
. = ALIGN(4);
*(.text)
*(.text.*)
} >RAM_BUFFER
.init_array : {
. = ALIGN(4);
_init_array_start = .;
KEEP (*(.init_array*))
_init_array_end = .;
} >RAM_BUFFER
.rodata : {
. = ALIGN(4);
*(.rodata)
*(.rodata.*)
} >RAM_BUFFER
.data : {
. = ALIGN(4);
*(.data)
*(.data.*)
} >RAM_BUFFER
.bss : {
. = ALIGN(4);
_bss_section_start_ram = .;
*(.bss)
*(.bss.*)
*(COMMON)
_bss_section_end_ram = .;
} >RAM_BUFFER
.stack : {
. = ALIGN(8);
_stack_end = .;
. += (STACK_SIZE - 8);
. = ALIGN(8);
_stack_start = .;
} >RAM_BUFFER
.phony : {
/* We won't do dynamic memory allocation */
_heap_start = .;
_heap_end = .;
/* Effectively bypass copying .data to RAM */
_data_section_start_flash = .;
_data_section_start_ram = .;
_data_section_end_ram = .;
} >RAM_BUFFER
}