]> begriffs open source - freertos/blob - portable/ARMv8M/copy_files.py
FreeRTOS MPU: Remove MPU region number check (#1261)
[freertos] / portable / ARMv8M / copy_files.py
1 #/*
2 # * FreeRTOS Kernel <DEVELOPMENT BRANCH>
3 # * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 # *
5 # * SPDX-License-Identifier: MIT
6 # *
7 # * Permission is hereby granted, free of charge, to any person obtaining a copy of
8 # * this software and associated documentation files (the "Software"), to deal in
9 # * the Software without restriction, including without limitation the rights to
10 # * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11 # * the Software, and to permit persons to whom the Software is furnished to do so,
12 # * subject to the following conditions:
13 # *
14 # * The above copyright notice and this permission notice shall be included in all
15 # * copies or substantial portions of the Software.
16 # *
17 # * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 # * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19 # * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20 # * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 # * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 # * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 # *
24 # * https://www.FreeRTOS.org
25 # * https://github.com/FreeRTOS
26 # *
27 # */
28
29 import os
30 import shutil
31
32 _THIS_FILE_DIRECTORY_ = os.path.dirname(os.path.realpath(__file__))
33 _FREERTOS_PORTABLE_DIRECTORY_ = os.path.dirname(_THIS_FILE_DIRECTORY_)
34
35 _COMPILERS_ = ['GCC', 'IAR']
36 _ARCH_NS_ = ['ARM_CM85', 'ARM_CM85_NTZ', 'ARM_CM55', 'ARM_CM55_NTZ', 'ARM_CM35P', 'ARM_CM35P_NTZ', 'ARM_CM33', 'ARM_CM33_NTZ', 'ARM_CM23', 'ARM_CM23_NTZ']
37 _ARCH_S_ = ['ARM_CM85', 'ARM_CM55', 'ARM_CM35P', 'ARM_CM33', 'ARM_CM23']
38
39 # Files to be compiled in the Secure Project
40 _SECURE_COMMON_FILE_PATHS_ = [
41     os.path.join('secure', 'context'),
42     os.path.join('secure', 'heap'),
43     os.path.join('secure', 'init'),
44     os.path.join('secure', 'macros')
45 ]
46
47 _SECURE_PORTABLE_FILE_PATHS_ = {
48     'GCC':{
49         'ARM_CM23' :[os.path.join('secure', 'context', 'portable', 'GCC', 'ARM_CM23')],
50         'ARM_CM33' :[os.path.join('secure', 'context', 'portable', 'GCC', 'ARM_CM33')],
51         'ARM_CM35P':[os.path.join('secure', 'context', 'portable', 'GCC', 'ARM_CM33')],
52         'ARM_CM55' :[os.path.join('secure', 'context', 'portable', 'GCC', 'ARM_CM33')],
53         'ARM_CM85' :[os.path.join('secure', 'context', 'portable', 'GCC', 'ARM_CM33')]
54     },
55     'IAR':{
56         'ARM_CM23' :[os.path.join('secure', 'context', 'portable', 'IAR', 'ARM_CM23')],
57         'ARM_CM33' :[os.path.join('secure', 'context', 'portable', 'IAR', 'ARM_CM33')],
58         'ARM_CM35P':[os.path.join('secure', 'context', 'portable', 'IAR', 'ARM_CM33')],
59         'ARM_CM55' :[os.path.join('secure', 'context', 'portable', 'IAR', 'ARM_CM33')],
60         'ARM_CM85' :[os.path.join('secure', 'context', 'portable', 'IAR', 'ARM_CM33')]
61     }
62 }
63
64 # Files to be compiled in the Non-Secure Project
65 _NONSECURE_COMMON_FILE_PATHS_ = [
66     'non_secure'
67 ]
68
69 _NONSECURE_PORTABLE_FILE_PATHS_ = {
70     'GCC':{
71         'ARM_CM23'      : [os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM23')],
72         'ARM_CM23_NTZ'  : [os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM23_NTZ')],
73         'ARM_CM33'      : [os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM33')],
74         'ARM_CM33_NTZ'  : [os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM33_NTZ')],
75         'ARM_CM35P'     : [os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM33', 'portasm.c'),
76                            os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM33', 'mpu_wrappers_v2_asm.c'),
77                            os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM35P', 'portmacro.h')],
78         'ARM_CM35P_NTZ' : [os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM33_NTZ', 'portasm.c'),
79                            os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM33_NTZ', 'mpu_wrappers_v2_asm.c'),
80                            os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM35P', 'portmacro.h')],
81         'ARM_CM55'      : [os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM33', 'portasm.c'),
82                            os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM33', 'mpu_wrappers_v2_asm.c'),
83                            os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM55', 'portmacro.h')],
84         'ARM_CM55_NTZ'  : [os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM33_NTZ', 'portasm.c'),
85                            os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM33_NTZ', 'mpu_wrappers_v2_asm.c'),
86                            os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM55', 'portmacro.h')],
87         'ARM_CM85'      : [os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM33', 'portasm.c'),
88                            os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM33', 'mpu_wrappers_v2_asm.c'),
89                            os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM85', 'portmacro.h')],
90         'ARM_CM85_NTZ'  : [os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM33_NTZ', 'portasm.c'),
91                            os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM33_NTZ', 'mpu_wrappers_v2_asm.c'),
92                            os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM85', 'portmacro.h')]
93     },
94     'IAR':{
95         'ARM_CM23'      : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM23')],
96         'ARM_CM23_NTZ'  : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM23_NTZ')],
97         'ARM_CM33'      : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33')],
98         'ARM_CM33_NTZ'  : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33_NTZ')],
99         'ARM_CM35P'     : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33', 'portasm.s'),
100                            os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33', 'mpu_wrappers_v2_asm.S'),
101                            os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM35P', 'portmacro.h')],
102         'ARM_CM35P_NTZ' : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33_NTZ', 'portasm.s'),
103                            os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33_NTZ', 'mpu_wrappers_v2_asm.S'),
104                            os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM35P', 'portmacro.h')],
105         'ARM_CM55'      : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33', 'portasm.s'),
106                            os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33', 'mpu_wrappers_v2_asm.S'),
107                            os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM55', 'portmacro.h')],
108         'ARM_CM55_NTZ'  : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33_NTZ', 'portasm.s'),
109                            os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33_NTZ', 'mpu_wrappers_v2_asm.S'),
110                            os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM55', 'portmacro.h')],
111         'ARM_CM85'      : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33', 'portasm.s'),
112                            os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33', 'mpu_wrappers_v2_asm.S'),
113                            os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM85', 'portmacro.h')],
114         'ARM_CM85_NTZ'  : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33_NTZ', 'portasm.s'),
115                            os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33_NTZ', 'mpu_wrappers_v2_asm.S'),
116                            os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM85', 'portmacro.h')]
117     },
118 }
119
120
121 def copy_files_in_dir(src_abs_path, dst_abs_path):
122     if os.path.isfile(src_abs_path):
123         print('Src: {}'.format(src_abs_path))
124         print('Dst: {}\n'.format(dst_abs_path))
125         shutil.copy2(src_abs_path, dst_abs_path)
126     else:
127         for src_file in os.listdir(src_abs_path):
128             src_file_abs_path = os.path.join(src_abs_path, src_file)
129             if os.path.isfile(src_file_abs_path) and src_file != 'ReadMe.txt':
130                 if not os.path.exists(dst_abs_path):
131                     os.makedirs(dst_abs_path)
132                 print('Src: {}'.format(src_file_abs_path))
133                 print('Dst: {}\n'.format(dst_abs_path))
134                 shutil.copy2(src_file_abs_path, dst_abs_path)
135
136
137 def copy_common_files_for_compiler_and_arch(compiler, arch, src_paths, dst_path):
138     for src_path in src_paths:
139
140         src_abs_path = os.path.join(_THIS_FILE_DIRECTORY_, src_path)
141         dst_abs_path = os.path.join(_FREERTOS_PORTABLE_DIRECTORY_, compiler, arch, dst_path)
142
143         copy_files_in_dir(src_abs_path, dst_abs_path)
144
145
146 def copy_portable_files_for_compiler_and_arch(compiler, arch, src_paths, dst_path):
147     for src_path in src_paths[compiler][arch]:
148
149         src_abs_path = os.path.join(_THIS_FILE_DIRECTORY_, src_path)
150         dst_abs_path = os.path.join(_FREERTOS_PORTABLE_DIRECTORY_, compiler, arch, dst_path)
151
152         copy_files_in_dir(src_abs_path, dst_abs_path)
153
154
155 def copy_files():
156     # Copy Secure Files
157     for compiler in _COMPILERS_:
158         for arch in _ARCH_S_:
159             copy_common_files_for_compiler_and_arch(compiler, arch, _SECURE_COMMON_FILE_PATHS_, 'secure')
160             copy_portable_files_for_compiler_and_arch(compiler, arch, _SECURE_PORTABLE_FILE_PATHS_, 'secure')
161
162     # Copy Non-Secure Files
163     for compiler in _COMPILERS_:
164         for arch in _ARCH_NS_:
165             copy_common_files_for_compiler_and_arch(compiler, arch, _NONSECURE_COMMON_FILE_PATHS_, 'non_secure')
166             copy_portable_files_for_compiler_and_arch(compiler, arch, _NONSECURE_PORTABLE_FILE_PATHS_, 'non_secure')
167
168
169 def main():
170     copy_files()
171
172
173 if __name__ == '__main__':
174     main()