Clone of official tools

Committer:
The Other Jimmy
Date:
Wed Jan 04 11:58:24 2017 -0600
Revision:
31:8ea194f6145b
Parent:
24:25bff2709c20
Update tools to follow mbed-os tools release 5.3.1

Who changed what in which revision?

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