Skip to content

Commit 2f8d4b7

Browse files
committed
updated startup files
1 parent 4598b21 commit 2f8d4b7

4 files changed

Lines changed: 108 additions & 96 deletions

File tree

startup/STM32F4/.armcc/startup.h

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,12 @@
11
/*******************************************************************************
22
@file startup.h
33
@author Rajmund Szymanski
4-
@date 11.12.2019
4+
@date 03.01.2020
55
@brief Startup file header for armcc compiler.
66
*******************************************************************************/
77

88
#pragma once
99

10-
/*******************************************************************************
11-
Configuration of stacks and heap
12-
*******************************************************************************/
13-
14-
#define __main_stack_size (((main_stack_size)+7)&(~7))
15-
#define __proc_stack_size (((proc_stack_size)+7)&(~7))
16-
17-
#if main_stack_size > 0
18-
char __main_stack[__main_stack_size] __ALIGNED(8) __attribute__ ((used, section(".stack"), zero_init));
19-
#endif
20-
21-
#if proc_stack_size > 0
22-
char __proc_stack[__proc_stack_size] __ALIGNED(8) __attribute__ ((used, section(".heap"), zero_init));
23-
#endif
24-
25-
__attribute__ ((section(".heap")))
26-
__asm void __user_stacks_and_heap_config( void )
27-
{
28-
__heap_base EQU .
29-
__heap_limit EQU RAM_end - __proc_stack_size
30-
#if main_stack_size > 0
31-
__initial_msp EQU RAM_start + __main_stack_size
32-
#else
33-
__initial_msp EQU __heap_limit
34-
#endif
35-
#if proc_stack_size > 0
36-
__initial_sp EQU RAM_end
37-
#else
38-
__initial_sp EQU __initial_msp
39-
#endif
40-
41-
#if proc_stack_size > 0
42-
#ifndef __MICROLIB
43-
IMPORT __use_two_region_memory
44-
#endif
45-
#endif
46-
47-
EXPORT __heap_base
48-
EXPORT __heap_limit
49-
EXPORT __initial_msp
50-
EXPORT __initial_sp
51-
}
52-
5310
/*******************************************************************************
5411
Additional definitions
5512
*******************************************************************************/

startup/STM32F4/.armcc/startup.s

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
;*******************************************************************************
2+
;file startup.s
3+
;author Rajmund Szymanski
4+
;date 03.01.2020
5+
;brief Startup code for armcc compiler.
6+
;*******************************************************************************
7+
8+
#ifndef main_stack_size
9+
#define main_stack_size 0
10+
#endif
11+
#ifndef proc_stack_size
12+
#define proc_stack_size 0
13+
#endif
14+
15+
#define __main_stack_size (((main_stack_size)+7)&(~7))
16+
#define __proc_stack_size (((proc_stack_size)+7)&(~7))
17+
#define __RAM_end 0x20020000
18+
19+
AREA |.heap|, NOINIT, READWRITE, ALIGN=3
20+
__heap_base
21+
__heap_limit EQU __RAM_end - __proc_stack_size
22+
23+
#if __main_stack_size > 0
24+
AREA |.stack|, NOINIT, READWRITE, ALIGN=3
25+
__main_stack SPACE __main_stack_size
26+
__initial_msp
27+
#else
28+
__initial_msp EQU __heap_limit
29+
#endif
30+
31+
#if __proc_stack_size > 0
32+
AREA |.heap|, NOINIT, READWRITE, ALIGN=3
33+
__proc_stack SPACE __proc_stack_size
34+
__initial_sp EQU __RAM_end
35+
#else
36+
__initial_sp EQU __initial_msp
37+
#endif
38+
39+
#if __proc_stack_size > 0
40+
#ifndef __MICROLIB
41+
EXPORT __use_two_region_memory
42+
#endif
43+
#endif
44+
45+
EXPORT __heap_base
46+
EXPORT __heap_limit
47+
EXPORT __initial_msp
48+
EXPORT __initial_sp
49+
50+
END

startup/STM32F4/.clang/startup.S

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*******************************************************************************
2+
@file startup.S
3+
@author Rajmund Szymanski
4+
@date 03.01.2020
5+
@brief Startup code for armclang compiler.
6+
*******************************************************************************/
7+
8+
#ifndef main_stack_size
9+
#define main_stack_size 0
10+
#endif
11+
#ifndef proc_stack_size
12+
#define proc_stack_size 0
13+
#endif
14+
15+
#define __main_stack_size (((main_stack_size)+7)&(~7))
16+
#define __proc_stack_size (((proc_stack_size)+7)&(~7))
17+
#define __RAM_end 0x20020000
18+
19+
.syntax unified
20+
.arch armv7e-m
21+
22+
.section .heap, "w","nobits"
23+
.align 3
24+
__heap_base = .
25+
__heap_limit = __RAM_end - __proc_stack_size
26+
27+
#if __main_stack_size > 0
28+
.section .stack, "w","nobits"
29+
.align 3
30+
.space __main_stack_size
31+
__initial_msp = .
32+
#else
33+
__initial_msp = __heap_limit
34+
#endif
35+
36+
#if __proc_stack_size > 0
37+
.section .heap, "w","nobits"
38+
.align 3
39+
.space __proc_stack_size
40+
__initial_sp = __RAM_end
41+
#else
42+
__initial_sp = __initial_msp
43+
#endif
44+
45+
#if __proc_stack_size > 0
46+
#ifndef __MICROLIB
47+
.global __use_two_region_memory
48+
#endif
49+
#endif
50+
51+
.global __heap_base
52+
.global __heap_limit
53+
.global __initial_msp
54+
.global __initial_sp
55+
56+
.end

startup/STM32F4/.clang/startup.h

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,12 @@
11
/*******************************************************************************
22
@file startup.h
33
@author Rajmund Szymanski
4-
@date 11.12.2019
4+
@date 03.01.2020
55
@brief Startup file header for armclang compiler.
66
*******************************************************************************/
77

88
#pragma once
99

10-
#define NUM(n) #n"\n"
11-
#define STR(n) NUM(n)
12-
13-
/*******************************************************************************
14-
Configuration of stacks and heap
15-
*******************************************************************************/
16-
17-
#define __main_stack_size (((main_stack_size)+7)&(~7))
18-
#define __proc_stack_size (((proc_stack_size)+7)&(~7))
19-
20-
__attribute__ ((naked))
21-
void __user_stacks_and_heap_config( void )
22-
{
23-
__asm volatile
24-
(
25-
" .pushsection .heap, \"w\",\"nobits\"\n"
26-
"__heap_base = . \n"
27-
"__heap_limit = "STR(RAM_end - __proc_stack_size)
28-
" .popsection \n"
29-
#if __main_stack_size > 0
30-
" .pushsection .stack,\"w\",\"nobits\"\n"
31-
" .align 3 \n"
32-
" .space "STR(__main_stack_size)
33-
"__initial_msp = . \n"
34-
" .popsection \n"
35-
#else
36-
"__initial_msp = __heap_limit \n"
37-
#endif
38-
#if __proc_stack_size > 0
39-
" .pushsection .heap, \"w\",\"nobits\"\n"
40-
" .align 3 \n"
41-
" .space "STR(__proc_stack_size)
42-
" .popsection \n"
43-
"__initial_sp = "STR(RAM_end)
44-
#else
45-
"__initial_sp = __initial_msp \n"
46-
#endif
47-
48-
#if __proc_stack_size > 0
49-
#ifndef __MICROLIB
50-
" .global __use_two_region_memory\n"
51-
#endif
52-
#endif
53-
54-
" .global __heap_base \n"
55-
" .global __heap_limit \n"
56-
" .global __initial_msp \n"
57-
" .global __initial_sp \n"
58-
);
59-
}
60-
6110
/*******************************************************************************
6211
Additional definitions
6312
*******************************************************************************/

0 commit comments

Comments
 (0)