Clone of official tools

Committer:
The Other Jimmy
Date:
Wed Feb 15 13:53:18 2017 -0600
Revision:
35:da9c89f8be7d
Child:
36:96847d42f010
Update tools to mbed-os 5.3.5

Who changed what in which revision?

UserRevisionLine numberNew contents of line
The Other Jimmy 35:da9c89f8be7d 1 """
The Other Jimmy 35:da9c89f8be7d 2 mbed SDK
The Other Jimmy 35:da9c89f8be7d 3 Copyright (c) 2011-2016 ARM Limited
The Other Jimmy 35:da9c89f8be7d 4
The Other Jimmy 35:da9c89f8be7d 5 Licensed under the Apache License, Version 2.0 (the "License");
The Other Jimmy 35:da9c89f8be7d 6 you may not use this file except in compliance with the License.
The Other Jimmy 35:da9c89f8be7d 7 You may obtain a copy of the License at
The Other Jimmy 35:da9c89f8be7d 8
The Other Jimmy 35:da9c89f8be7d 9 http://www.apache.org/licenses/LICENSE-2.0
The Other Jimmy 35:da9c89f8be7d 10
The Other Jimmy 35:da9c89f8be7d 11 Unless required by applicable law or agreed to in writing, software
The Other Jimmy 35:da9c89f8be7d 12 distributed under the License is distributed on an "AS IS" BASIS,
The Other Jimmy 35:da9c89f8be7d 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
The Other Jimmy 35:da9c89f8be7d 14 See the License for the specific language governing permissions and
The Other Jimmy 35:da9c89f8be7d 15 limitations under the License.
The Other Jimmy 35:da9c89f8be7d 16 """
The Other Jimmy 35:da9c89f8be7d 17 from os.path import splitext, basename, join
The Other Jimmy 35:da9c89f8be7d 18 from random import randint
The Other Jimmy 35:da9c89f8be7d 19 from tools.utils import mkdir
The Other Jimmy 35:da9c89f8be7d 20 from tools.export.exporters import Exporter
The Other Jimmy 35:da9c89f8be7d 21
The Other Jimmy 35:da9c89f8be7d 22
The Other Jimmy 35:da9c89f8be7d 23 class Sw4STM32(Exporter):
The Other Jimmy 35:da9c89f8be7d 24 NAME = 'Sw4STM32'
The Other Jimmy 35:da9c89f8be7d 25 TOOLCHAIN = 'GCC_ARM'
The Other Jimmy 35:da9c89f8be7d 26
The Other Jimmy 35:da9c89f8be7d 27 BOARDS = {
The Other Jimmy 35:da9c89f8be7d 28 'B96B_F446VE': {'name': 'B96B-F446VE', 'mcuId': 'STM32F446VETx'},
The Other Jimmy 35:da9c89f8be7d 29 'DISCO_F051R8': {'name': 'STM32F0DISCOVERY', 'mcuId': 'STM32F051R8Tx'},
The Other Jimmy 35:da9c89f8be7d 30 'DISCO_F303VC': {'name': 'STM32F3DISCOVERY', 'mcuId': 'STM32F303VCTx'},
The Other Jimmy 35:da9c89f8be7d 31 'DISCO_F334C8': {'name': 'STM32F3348DISCOVERY', 'mcuId': 'STM32F334C8Tx'},
The Other Jimmy 35:da9c89f8be7d 32 'DISCO_F401VC': {'name': 'STM32F401C-DISCO', 'mcuId': 'STM32F401VCTx'},
The Other Jimmy 35:da9c89f8be7d 33 'DISCO_F407VG': {'name': 'STM32F4DISCOVERY', 'mcuId': 'STM32F407VGTx'},
The Other Jimmy 35:da9c89f8be7d 34 'DISCO_F429ZI': {'name': 'STM32F429I-DISCO', 'mcuId': 'STM32F429ZITx'},
The Other Jimmy 35:da9c89f8be7d 35 'DISCO_F469NI': {'name': 'DISCO-F469NI', 'mcuId': 'STM32F469NIHx'},
The Other Jimmy 35:da9c89f8be7d 36 'DISCO_F746NG': {'name': 'STM32F746G-DISCO', 'mcuId': 'STM32F746NGHx'},
The Other Jimmy 35:da9c89f8be7d 37 'DISCO_F769NI': {'name': 'DISCO-F769NI', 'mcuId': 'STM32F769NIHx'},
The Other Jimmy 35:da9c89f8be7d 38 'DISCO_L053C8': {'name': 'STM32L0538DISCOVERY', 'mcuId': 'STM32L053C8Tx'},
The Other Jimmy 35:da9c89f8be7d 39 'DISCO_L476VG': {'name': 'STM32L476G-DISCO', 'mcuId': 'STM32L476VGTx'},
The Other Jimmy 35:da9c89f8be7d 40 'NUCLEO_F030R8': {'name': 'NUCLEO-F030R8', 'mcuId': 'STM32F030R8Tx'},
The Other Jimmy 35:da9c89f8be7d 41 'NUCLEO_F031K6': {'name': 'NUCLEO-F031K6', 'mcuId': 'STM32F031K6Tx'},
The Other Jimmy 35:da9c89f8be7d 42 'NUCLEO_F042K6': {'name': 'NUCLEO-F042K6', 'mcuId': 'STM32F042K6Tx'},
The Other Jimmy 35:da9c89f8be7d 43 'NUCLEO_F070RB': {'name': 'NUCLEO-F070RB', 'mcuId': 'STM32F070RBTx'},
The Other Jimmy 35:da9c89f8be7d 44 'NUCLEO_F072RB': {'name': 'NUCLEO-F072RB', 'mcuId': 'STM32F072RBTx'},
The Other Jimmy 35:da9c89f8be7d 45 'NUCLEO_F091RC': {'name': 'NUCLEO-F091RC', 'mcuId': 'STM32F091RCTx'},
The Other Jimmy 35:da9c89f8be7d 46 'NUCLEO_F103RB': {'name': 'NUCLEO-F103RB', 'mcuId': 'STM32F103RBTx'},
The Other Jimmy 35:da9c89f8be7d 47 'NUCLEO_F207ZG': {'name': 'NUCLEO-F207ZG', 'mcuId': 'STM32F207ZGTx'},
The Other Jimmy 35:da9c89f8be7d 48 'NUCLEO_F302R8': {'name': 'NUCLEO-F302R8', 'mcuId': 'STM32F302R8Tx'},
The Other Jimmy 35:da9c89f8be7d 49 'NUCLEO_F303K8': {'name': 'NUCLEO-F303K8', 'mcuId': 'STM32F303K8Tx'},
The Other Jimmy 35:da9c89f8be7d 50 'NUCLEO_F303RE': {'name': 'NUCLEO-F303RE', 'mcuId': 'STM32F303RETx'},
The Other Jimmy 35:da9c89f8be7d 51 'NUCLEO_F303ZE': {'name': 'NUCLEO-F303ZE', 'mcuId': 'STM32F303ZETx'},
The Other Jimmy 35:da9c89f8be7d 52 'NUCLEO_F334R8': {'name': 'NUCLEO-F334R8', 'mcuId': 'STM32F334R8Tx'},
The Other Jimmy 35:da9c89f8be7d 53 'NUCLEO_F401RE': {'name': 'NUCLEO-F401RE', 'mcuId': 'STM32F401RETx'},
The Other Jimmy 35:da9c89f8be7d 54 'NUCLEO_F410RB': {'name': 'NUCLEO-F410RB', 'mcuId': 'STM32F410RBTx'},
The Other Jimmy 35:da9c89f8be7d 55 'NUCLEO_F411RE': {'name': 'NUCLEO-F411RE', 'mcuId': 'STM32F411RETx'},
The Other Jimmy 35:da9c89f8be7d 56 'NUCLEO_F429ZI': {'name': 'NUCLEO-F429ZI', 'mcuId': 'STM32F429ZITx'},
The Other Jimmy 35:da9c89f8be7d 57 'NUCLEO_F446RE': {'name': 'NUCLEO-F446RE', 'mcuId': 'STM32F446RETx'},
The Other Jimmy 35:da9c89f8be7d 58 'NUCLEO_F446ZE': {'name': 'NUCLEO-F446ZE', 'mcuId': 'STM32F446ZETx'},
The Other Jimmy 35:da9c89f8be7d 59 'NUCLEO_F746ZG': {'name': 'NUCLEO-F746ZG', 'mcuId': 'STM32F746ZGTx'},
The Other Jimmy 35:da9c89f8be7d 60 'NUCLEO_F767ZI': {'name': 'NUCLEO-F767ZI', 'mcuId': 'STM32F767ZITx'},
The Other Jimmy 35:da9c89f8be7d 61 'NUCLEO_L011K4': {'name': 'NUCLEO-L011K4', 'mcuId': 'STM32L011K4Tx'},
The Other Jimmy 35:da9c89f8be7d 62 'NUCLEO_L031K6': {'name': 'NUCLEO-L031K6', 'mcuId': 'STM32L031K6Tx'},
The Other Jimmy 35:da9c89f8be7d 63 'NUCLEO_L053R8': {'name': 'NUCLEO-L053R8', 'mcuId': 'STM32L053R8Tx'},
The Other Jimmy 35:da9c89f8be7d 64 'NUCLEO_L073RZ': {'name': 'NUCLEO-L073RZ', 'mcuId': 'STM32L073RZTx'},
The Other Jimmy 35:da9c89f8be7d 65 'NUCLEO_L152RE': {'name': 'NUCLEO-L152RE', 'mcuId': 'STM32L152RETx'},
The Other Jimmy 35:da9c89f8be7d 66 'NUCLEO_L432KC': {'name': 'NUCLEO-L432KC', 'mcuId': 'STM32L432KCUx'},
The Other Jimmy 35:da9c89f8be7d 67 'NUCLEO_L476RG': {'name': 'NUCLEO-L476RG', 'mcuId': 'STM32L476RGTx'},
The Other Jimmy 35:da9c89f8be7d 68 }
The Other Jimmy 35:da9c89f8be7d 69
The Other Jimmy 35:da9c89f8be7d 70 TARGETS = BOARDS.keys()
The Other Jimmy 35:da9c89f8be7d 71
The Other Jimmy 35:da9c89f8be7d 72 def __gen_dir(self, dirname):
The Other Jimmy 35:da9c89f8be7d 73 settings = join(self.export_dir, dirname)
The Other Jimmy 35:da9c89f8be7d 74 mkdir(settings)
The Other Jimmy 35:da9c89f8be7d 75
The Other Jimmy 35:da9c89f8be7d 76 def __generate_uid(self):
The Other Jimmy 35:da9c89f8be7d 77 return "%0.9u" % randint(0, 999999999)
The Other Jimmy 35:da9c89f8be7d 78
The Other Jimmy 35:da9c89f8be7d 79 def generate(self):
The Other Jimmy 35:da9c89f8be7d 80 fp_hardware = "no"
The Other Jimmy 35:da9c89f8be7d 81 fp_abi = "soft"
The Other Jimmy 35:da9c89f8be7d 82 core = self.toolchain.target.core
The Other Jimmy 35:da9c89f8be7d 83 if core == "Cortex-M4F" or core == "Cortex-M7F":
The Other Jimmy 35:da9c89f8be7d 84 fp_hardware = "fpv4-sp-d16"
The Other Jimmy 35:da9c89f8be7d 85 fp_abi = "soft-fp"
The Other Jimmy 35:da9c89f8be7d 86 elif core == "Cortex-M7FD":
The Other Jimmy 35:da9c89f8be7d 87 fp_hardware = "fpv5-d16"
The Other Jimmy 35:da9c89f8be7d 88 fp_abi = "soft-fp"
The Other Jimmy 35:da9c89f8be7d 89
The Other Jimmy 35:da9c89f8be7d 90 libraries = []
The Other Jimmy 35:da9c89f8be7d 91 for lib in self.resources.libraries:
The Other Jimmy 35:da9c89f8be7d 92 l, _ = splitext(basename(lib))
The Other Jimmy 35:da9c89f8be7d 93 libraries.append(l[3:])
The Other Jimmy 35:da9c89f8be7d 94
The Other Jimmy 35:da9c89f8be7d 95 ctx = {
The Other Jimmy 35:da9c89f8be7d 96 'name': self.project_name,
The Other Jimmy 35:da9c89f8be7d 97 'include_paths': self.resources.inc_dirs,
The Other Jimmy 35:da9c89f8be7d 98 'linker_script': self.resources.linker_script,
The Other Jimmy 35:da9c89f8be7d 99 'library_paths': self.resources.lib_dirs,
The Other Jimmy 35:da9c89f8be7d 100 'object_files': self.resources.objects,
The Other Jimmy 35:da9c89f8be7d 101 'libraries': libraries,
The Other Jimmy 35:da9c89f8be7d 102 'symbols': self.toolchain.get_symbols(),
The Other Jimmy 35:da9c89f8be7d 103 'board_name': self.BOARDS[self.target.upper()]['name'],
The Other Jimmy 35:da9c89f8be7d 104 'mcu_name': self.BOARDS[self.target.upper()]['mcuId'],
The Other Jimmy 35:da9c89f8be7d 105 'debug_config_uid': self.__generate_uid(),
The Other Jimmy 35:da9c89f8be7d 106 'debug_tool_compiler_uid': self.__generate_uid(),
The Other Jimmy 35:da9c89f8be7d 107 'debug_tool_compiler_input_uid': self.__generate_uid(),
The Other Jimmy 35:da9c89f8be7d 108 'release_config_uid': self.__generate_uid(),
The Other Jimmy 35:da9c89f8be7d 109 'release_tool_compiler_uid': self.__generate_uid(),
The Other Jimmy 35:da9c89f8be7d 110 'release_tool_compiler_input_uid': self.__generate_uid(),
The Other Jimmy 35:da9c89f8be7d 111 'uid': self.__generate_uid(),
The Other Jimmy 35:da9c89f8be7d 112 'floating_point_hardware': fp_hardware,
The Other Jimmy 35:da9c89f8be7d 113 'floating_point_abi': fp_abi
The Other Jimmy 35:da9c89f8be7d 114 }
The Other Jimmy 35:da9c89f8be7d 115
The Other Jimmy 35:da9c89f8be7d 116 self.__gen_dir('.settings')
The Other Jimmy 35:da9c89f8be7d 117 self.gen_file('sw4stm32/language_settings_commom.tmpl', ctx, '.settings/language.settings.xml')
The Other Jimmy 35:da9c89f8be7d 118 self.gen_file('sw4stm32/project_common.tmpl', ctx, '.project')
The Other Jimmy 35:da9c89f8be7d 119 self.gen_file('sw4stm32/cproject_common.tmpl', ctx, '.cproject')