2 # * FreeRTOS Kernel <DEVELOPMENT BRANCH>
3 # * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5 # * SPDX-License-Identifier: MIT
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:
14 # * The above copyright notice and this permission notice shall be included in all
15 # * copies or substantial portions of the Software.
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.
24 # * https://www.FreeRTOS.org
25 # * https://github.com/FreeRTOS
32 _THIS_FILE_DIRECTORY_ = os.path.dirname(os.path.realpath(__file__))
33 _FREERTOS_PORTABLE_DIRECTORY_ = os.path.dirname(_THIS_FILE_DIRECTORY_)
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']
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')
47 _SECURE_PORTABLE_FILE_PATHS_ = {
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')]
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')]
64 # Files to be compiled in the Non-Secure Project
65 _NONSECURE_COMMON_FILE_PATHS_ = [
69 _NONSECURE_PORTABLE_FILE_PATHS_ = {
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_CM35P', 'portmacro.h')],
77 'ARM_CM35P_NTZ' : [os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM33_NTZ', 'portasm.c'),
78 os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM35P', 'portmacro.h')],
79 'ARM_CM55' : [os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM33', 'portasm.c'),
80 os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM55', 'portmacro.h')],
81 'ARM_CM55_NTZ' : [os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM33_NTZ', 'portasm.c'),
82 os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM55', 'portmacro.h')],
83 'ARM_CM85' : [os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM33', 'portasm.c'),
84 os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM85', 'portmacro.h')],
85 'ARM_CM85_NTZ' : [os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM33_NTZ', 'portasm.c'),
86 os.path.join('non_secure', 'portable', 'GCC', 'ARM_CM85', 'portmacro.h')]
89 'ARM_CM23' : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM23')],
90 'ARM_CM23_NTZ' : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM23_NTZ')],
91 'ARM_CM33' : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33')],
92 'ARM_CM33_NTZ' : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33_NTZ')],
93 'ARM_CM35P' : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33', 'portasm.s'),
94 os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM35P', 'portmacro.h')],
95 'ARM_CM35P_NTZ' : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33_NTZ', 'portasm.s'),
96 os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM35P', 'portmacro.h')],
97 'ARM_CM55' : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33', 'portasm.s'),
98 os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM55', 'portmacro.h')],
99 'ARM_CM55_NTZ' : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33_NTZ', 'portasm.s'),
100 os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM55', 'portmacro.h')],
101 'ARM_CM85' : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33', 'portasm.s'),
102 os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM85', 'portmacro.h')],
103 'ARM_CM85_NTZ' : [os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM33_NTZ', 'portasm.s'),
104 os.path.join('non_secure', 'portable', 'IAR', 'ARM_CM85', 'portmacro.h')]
109 def copy_files_in_dir(src_abs_path, dst_abs_path):
110 if os.path.isfile(src_abs_path):
111 print('Src: {}'.format(src_abs_path))
112 print('Dst: {}\n'.format(dst_abs_path))
113 shutil.copy2(src_abs_path, dst_abs_path)
115 for src_file in os.listdir(src_abs_path):
116 src_file_abs_path = os.path.join(src_abs_path, src_file)
117 if os.path.isfile(src_file_abs_path) and src_file != 'ReadMe.txt':
118 if not os.path.exists(dst_abs_path):
119 os.makedirs(dst_abs_path)
120 print('Src: {}'.format(src_file_abs_path))
121 print('Dst: {}\n'.format(dst_abs_path))
122 shutil.copy2(src_file_abs_path, dst_abs_path)
125 def copy_common_files_for_compiler_and_arch(compiler, arch, src_paths, dst_path):
126 for src_path in src_paths:
128 src_abs_path = os.path.join(_THIS_FILE_DIRECTORY_, src_path)
129 dst_abs_path = os.path.join(_FREERTOS_PORTABLE_DIRECTORY_, compiler, arch, dst_path)
131 copy_files_in_dir(src_abs_path, dst_abs_path)
134 def copy_portable_files_for_compiler_and_arch(compiler, arch, src_paths, dst_path):
135 for src_path in src_paths[compiler][arch]:
137 src_abs_path = os.path.join(_THIS_FILE_DIRECTORY_, src_path)
138 dst_abs_path = os.path.join(_FREERTOS_PORTABLE_DIRECTORY_, compiler, arch, dst_path)
140 copy_files_in_dir(src_abs_path, dst_abs_path)
145 for compiler in _COMPILERS_:
146 for arch in _ARCH_S_:
147 copy_common_files_for_compiler_and_arch(compiler, arch, _SECURE_COMMON_FILE_PATHS_, 'secure')
148 copy_portable_files_for_compiler_and_arch(compiler, arch, _SECURE_PORTABLE_FILE_PATHS_, 'secure')
150 # Copy Non-Secure Files
151 for compiler in _COMPILERS_:
152 for arch in _ARCH_NS_:
153 copy_common_files_for_compiler_and_arch(compiler, arch, _NONSECURE_COMMON_FILE_PATHS_, 'non_secure')
154 copy_portable_files_for_compiler_and_arch(compiler, arch, _NONSECURE_PORTABLE_FILE_PATHS_, 'non_secure')
161 if __name__ == '__main__':