Skip to content

Commit 249783f

Browse files
authored
Add newlib samples (#38)
1 parent 6f7b1ec commit 249783f

File tree

11 files changed

+1144
-0
lines changed

11 files changed

+1144
-0
lines changed

arm-software/embedded/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,12 @@ if(LLVM_TOOLCHAIN_C_LIBRARY STREQUAL newlib)
317317
DESTINATION bin
318318
COMPONENT llvm-toolchain-newlib-configs
319319
)
320+
install(
321+
DIRECTORY
322+
${CMAKE_CURRENT_SOURCE_DIR}/newlib-samples/
323+
DESTINATION samples
324+
COMPONENT llvm-toolchain-newlib-configs
325+
)
320326
endif()
321327

322328
install(
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
/* Linker script to configure memory regions.
2+
* Need modifying for a specific board.
3+
* BOOT.ORIGIN: starting address of boot flash
4+
* BOOT.LENGTH: length of boot flash
5+
* FLASH.ORIGIN: starting address of flash
6+
* FLASH.LENGTH: length of flash
7+
* RAM.ORIGIN: starting address of RAM bank 0
8+
* RAM.LENGTH: length of RAM bank 0
9+
*/
10+
11+
MEMORY
12+
{
13+
BOOT (rx) : ORIGIN = 0x00000000, LENGTH = 0x003FFF
14+
FLASH (rx) : ORIGIN = 0x21000000, LENGTH = 0x0FFFFF
15+
RAM (rwx) : ORIGIN = 0x21600000, LENGTH = 0xa00000
16+
}
17+
18+
/* Linker script to place sections and symbol values. Should be used together
19+
* with other linker script that defines memory regions FLASH and RAM.
20+
* It references following symbols, which must be defined in code:
21+
* Reset_Handler : Entry of reset handler
22+
*
23+
* It defines following symbols, which code can use without definition:
24+
* __exidx_start
25+
* __exidx_end
26+
* __copy_table_start__
27+
* __copy_table_end__
28+
* __zero_table_start__
29+
* __zero_table_end__
30+
* __etext
31+
* __data_start__
32+
* __preinit_array_start
33+
* __preinit_array_end
34+
* __init_array_start
35+
* __init_array_end
36+
* __fini_array_start
37+
* __fini_array_end
38+
* __data_end__
39+
* __bss_start__
40+
* __bss_end__
41+
* __end__
42+
* end
43+
* __HeapLimit
44+
* __StackLimit
45+
* __StackTop
46+
* __stack
47+
*/
48+
ENTRY(Reset_Handler)
49+
50+
SECTIONS
51+
{
52+
.isr_vector :
53+
{
54+
KEEP(*(.isr_vector))
55+
} > BOOT
56+
57+
.text :
58+
{
59+
*(.text*)
60+
61+
KEEP(*(.init))
62+
KEEP(*(.fini))
63+
64+
/* .ctors */
65+
*crtbegin.o(.ctors)
66+
*crtbegin?.o(.ctors)
67+
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
68+
*(SORT(.ctors.*))
69+
*(.ctors)
70+
71+
/* .dtors */
72+
*crtbegin.o(.dtors)
73+
*crtbegin?.o(.dtors)
74+
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
75+
*(SORT(.dtors.*))
76+
*(.dtors)
77+
78+
KEEP(*(.eh_frame*))
79+
} > FLASH
80+
81+
.rodata :
82+
{
83+
*(.rodata .rodata.*)
84+
} > FLASH
85+
86+
.ARM.extab :
87+
{
88+
*(.ARM.extab* .gnu.linkonce.armextab.*)
89+
} > FLASH
90+
91+
__exidx_start = .;
92+
.ARM.exidx :
93+
{
94+
*(.ARM.exidx .ARM.exidx* .gnu.linkonce.armexidx.*)
95+
} > FLASH
96+
__exidx_end = .;
97+
98+
/* To copy multiple ROM to RAM sections,
99+
* uncomment .copy.table section and,
100+
* define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */
101+
/*
102+
.copy.table :
103+
{
104+
. = ALIGN(4);
105+
__copy_table_start__ = .;
106+
LONG (__etext)
107+
LONG (__data_start__)
108+
LONG (__data_end__ - __data_start__)
109+
LONG (__etext2)
110+
LONG (__data2_start__)
111+
LONG (__data2_end__ - __data2_start__)
112+
__copy_table_end__ = .;
113+
} > FLASH
114+
*/
115+
116+
/* To clear multiple BSS sections,
117+
* uncomment .zero.table section and,
118+
* define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */
119+
/*
120+
.zero.table :
121+
{
122+
. = ALIGN(4);
123+
__zero_table_start__ = .;
124+
LONG (__bss_start__)
125+
LONG (__bss_end__ - __bss_start__)
126+
LONG (__bss2_start__)
127+
LONG (__bss2_end__ - __bss2_start__)
128+
__zero_table_end__ = .;
129+
} > FLASH
130+
*/
131+
132+
/* Location counter can end up 2byte aligned with narrow Thumb code but
133+
__etext is assumed by startup code to be the LMA of a section in RAM
134+
which must be 4byte aligned */
135+
__etext = ALIGN (4);
136+
137+
.data : AT (__etext)
138+
{
139+
__data_start__ = .;
140+
*(vtable)
141+
*(.data*)
142+
143+
. = ALIGN(4);
144+
/* preinit data */
145+
PROVIDE_HIDDEN (__preinit_array_start = .);
146+
KEEP(*(.preinit_array))
147+
PROVIDE_HIDDEN (__preinit_array_end = .);
148+
149+
. = ALIGN(4);
150+
/* init data */
151+
PROVIDE_HIDDEN (__init_array_start = .);
152+
KEEP(*(SORT(.init_array.*)))
153+
KEEP(*(.init_array))
154+
PROVIDE_HIDDEN (__init_array_end = .);
155+
156+
157+
. = ALIGN(4);
158+
/* finit data */
159+
PROVIDE_HIDDEN (__fini_array_start = .);
160+
KEEP(*(SORT(.fini_array.*)))
161+
KEEP(*(.fini_array))
162+
PROVIDE_HIDDEN (__fini_array_end = .);
163+
164+
KEEP(*(.jcr*))
165+
. = ALIGN(4);
166+
/* All data end */
167+
__data_end__ = .;
168+
169+
} > RAM
170+
171+
.bss :
172+
{
173+
. = ALIGN(4);
174+
__bss_start__ = .;
175+
*(.bss*)
176+
*(COMMON)
177+
. = ALIGN(4);
178+
__bss_end__ = .;
179+
} > RAM
180+
181+
.heap (NOLOAD):
182+
{
183+
__end__ = .;
184+
PROVIDE(end = .);
185+
*(.heap*)
186+
__HeapLimit = .;
187+
} > RAM
188+
189+
/* .stack_dummy section doesn't contains any symbols. It is only
190+
* used for linker to calculate size of stack sections, and assign
191+
* values to stack symbols later */
192+
.stack_dummy (NOLOAD):
193+
{
194+
*(.stack*)
195+
} > RAM
196+
197+
/* Set stack top to end of RAM, and stack limit move down by
198+
* size of stack_dummy section */
199+
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
200+
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
201+
PROVIDE(__stack = __StackTop);
202+
203+
/* Check if data + heap + stack exceeds RAM limit */
204+
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
205+
}

0 commit comments

Comments
 (0)