-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharm.py
executable file
·227 lines (200 loc) · 5.63 KB
/
arm.py
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#!/bin/env python3
from cross_definitions import CrossDefinitions
# Some examples of use
# NB : for "virtual" definitions like openocd or arm_none_eabi, writing to file
# is **not** necessary!
###############################################################################
# Architectures
def ARM(cpu):
return CrossDefinitions(
'arm/arm-base-' + cpu,
'',
host_machine={
'cpu_family': 'arm',
'endian': 'little',
'system': 'none',
'cpu': cpu,
},
)
# Possible extensions: m a f d q c
def RISCV(base='rv32i', extensions=''):
return CrossDefinitions(
'riscv/riscv-base-' + base + '-[' + extensions + ']',
'',
host_machine={
'cpu_family': 'riscv',
'endian': 'little',
'system': 'none',
'cpu': base,
}
)
###############################################################################
# Toolchains
arm_linux_gnueabi_gcc = CrossDefinitions(
'arm/arm-linux-gnueabihf-gcc-base',
'Base of arm-linux-gnueabihf defs',
binaries={
'c': 'arm-linux-gnueabihf-gcc',
'cpp': 'arm-linux-gnueabihf-g++',
'rust': ['rustc', '--target', 'arm-unknown-linux-gnueabihf'],
# '-C', 'linker=/usr/bin/arm-linux-gnueabihf-gcc-7'
'ld': 'arm-linux-gnueabihf-ld',
'ar': 'arm-linux-gnueabihf-ar',
'as': 'arm-linux-gnueabihf-as',
'size': 'arm-linux-gnueabihf-size',
'objdump': 'arm-linux-gnueabihf-objdump',
'objcopy': 'arm-linux-gnueabihf-objcopy',
'strip': 'arm-linux-gnueabihf-strip',
'gdb': 'arm-linux-gnueabihf-gdb',
'pkgconfig':'arm-linux-gnueabihf-pkg-config',
},
properties={
'root': '/usr/arm-linux-gnueabihf',
'c_args': [
],
'has_function_printf': True,
'has_function_hfkerhisadf': False,
},
host_machine={
'system': 'linux',
'cpu_family': 'arm',
}
)
arm_none_eabi_gcc = CrossDefinitions(
'arm/arm-none-eabi-gcc-base',
'Base of arm-none-eabi defs',
binaries={
'c': 'arm-none-eabi-gcc',
'cpp': 'arm-none-eabi-g++',
'ld': 'arm-none-eabi-ld',
'ar': 'arm-none-eabi-ar',
'as': 'arm-none-eabi-as',
'size': 'arm-none-eabi-size',
'objdump': 'arm-none-eabi-objdump',
'objcopy': 'arm-none-eabi-objcopy',
'strip': 'arm-none-eabi-strip',
'gdb': 'arm-none-eabi-gdb',
},
properties={
'c_args': [
],
},
)
arm_none_eabi_clang = CrossDefinitions(
'arm/arm-none-eabi-clang-base',
'Base of arm-none-eabi defs',
binaries={
'c': 'clang',
'cpp': 'clang++',
'ld': 'llvm-link',
'ar': 'llvm-ar',
'as': 'llvm-as',
'size': 'llvm-size',
'objdump': 'llvm-objdump',
'objcopy': 'arm-none-eabi-objcopy',
'strip': 'arm-none-eabi-strip',
'gdb': 'arm-none-eabi-gdb',
},
properties={
'c_args': [
'--target=arm-none-eabi',
'-mthumb'
],
'c_link_args': [
'--target=arm-none-eabi',
'-nostdlib',
],
},
)
# arm_none_eabi.write_to_file()
openocd = CrossDefinitions('openocd', '', {'openocd': 'openocd', })
###############################################################################
# Stm32
def stm32(cortex):
stm32 = CrossDefinitions(
'arm/stm32base',
'Common definitions for STM32',
properties={
'c_args': [
# # Code-optimization / deletion:
'-fdata-sections', # each variable to a seperate section
'-ffunction-sections', # each function to a seperate section
'-fno-common', # Really wanted ?
'-mthumb',
'-mcpu=' + cortex,
'--static',
],
'c_link_args': [
'-Wl,--gc-sections',
'-nostartfiles',
],
},
based_on=[
ARM(cortex),
arm_none_eabi_gcc,
openocd,
],
)
return stm32
# STM32 Families
stm32f0 = CrossDefinitions(
'arm/stm32/stm32f0', '',
properties={
'c_args': ['-mfloat-abi=soft'],
},
based_on=stm32('cortex-m0'),
)
# stm32f1 = CrossDefinitions(
# 'arm/stm32/stm32f1', '',
# based_on=stm32('cortex-m3'),
# )
# stm32f2 = CrossDefinitions(
# 'arm/stm32/stm32f2', '',
# based_on=stm32('cortex-m3'),
# )
stm32f3 = CrossDefinitions(
'arm/stm32/stm32f3', '',
properties={
'c_args': ['-mfloat-abi=hard', '-mfpu=fpv4-sp-d16'],
},
based_on=stm32('cortex-m4f'),
)
stm32f4 = CrossDefinitions(
'arm/stm32/stm32f4', '',
properties={
'c_args': ['-mfloat-abi=hard', '-mfpu=fpv4-sp-d16'],
},
based_on=stm32('cortex-m4f'),
)
# stm32f7 = CrossDefinitions(
# 'arm/stm32/stm32f7', '',
# based_on=stm32('cortex-m7f'),
# )
# stm32l0 = CrossDefinitions(
# 'arm/stm32/stm32l0', '',
# based_on=stm32('cortex-m0+'),
# )
# stm32l1 = CrossDefinitions(
# 'arm/stm32/stm32l1', '',
# based_on=stm32('cortex-m3'),
# )
stm32l4 = CrossDefinitions(
'arm/stm32/stm32l4', '',
properties={
'c_args': ['-mfloat-abi=hard', '-mfpu=fpv4-sp-d16'],
},
based_on=stm32('cortex-m3'),
)
for i in [
stm32f0,
# stm32f1,
# stm32f2,
stm32f3,
stm32f4,
# stm32f7,
# stm32l0,
# stm32l1,
stm32l4,
]:
i.write_to_file()
# STM32 specific mcus