Clone of official tools

Committer:
The Other Jimmy
Date:
Thu Jul 13 15:26:26 2017 -0500
Revision:
38:399953da035d
Parent:
36:96847d42f010
Child:
40:7d3fa6b99b2b
Update to tools release 5.5.2

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 36:96847d42f010 28 'B96B_F446VE': {'name': 'B96B-F446VE', 'mcuId': 'STM32F446VETx'},
The Other Jimmy 36:96847d42f010 29 'DISCO_F051R8': {'name': 'STM32F0DISCOVERY', 'mcuId': 'STM32F051R8Tx'},
The Other Jimmy 36:96847d42f010 30 'DISCO_F303VC': {'name': 'STM32F3DISCOVERY', 'mcuId': 'STM32F303VCTx'},
The Other Jimmy 36:96847d42f010 31 'DISCO_F334C8': {'name': 'STM32F3348DISCOVERY', 'mcuId': 'STM32F334C8Tx'},
The Other Jimmy 36:96847d42f010 32 'DISCO_F401VC': {'name': 'STM32F401C-DISCO', 'mcuId': 'STM32F401VCTx'},
The Other Jimmy 36:96847d42f010 33 'DISCO_F407VG': {'name': 'STM32F4DISCOVERY', 'mcuId': 'STM32F407VGTx'},
The Other Jimmy 38:399953da035d 34 'DISCO_F413ZH': {'name': 'DISCO_F413', 'mcuId': 'STM32F413ZHTx'},
The Other Jimmy 36:96847d42f010 35 'DISCO_F429ZI': {'name': 'STM32F429I-DISCO', 'mcuId': 'STM32F429ZITx'},
The Other Jimmy 36:96847d42f010 36 'DISCO_F469NI': {'name': 'DISCO-F469NI', 'mcuId': 'STM32F469NIHx'},
The Other Jimmy 36:96847d42f010 37 'DISCO_F746NG': {'name': 'STM32F746G-DISCO', 'mcuId': 'STM32F746NGHx'},
The Other Jimmy 36:96847d42f010 38 'DISCO_F769NI': {'name': 'DISCO-F769NI', 'mcuId': 'STM32F769NIHx'},
The Other Jimmy 36:96847d42f010 39 'DISCO_L053C8': {'name': 'STM32L0538DISCOVERY', 'mcuId': 'STM32L053C8Tx'},
The Other Jimmy 36:96847d42f010 40 'DISCO_L072CZ_LRWAN1': {'name': 'DISCO-L072CZ-LRWAN1', 'mcuId': 'STM32L072CZTx'},
The Other Jimmy 36:96847d42f010 41 'DISCO_L475VG_IOT01A': {'name': 'STM32L475G-DISCO', 'mcuId': 'STM32L475VGTx'},
The Other Jimmy 36:96847d42f010 42 'DISCO_L476VG': {'name': 'STM32L476G-DISCO', 'mcuId': 'STM32L476VGTx'},
The Other Jimmy 36:96847d42f010 43 'NUCLEO_F030R8': {'name': 'NUCLEO-F030R8', 'mcuId': 'STM32F030R8Tx'},
The Other Jimmy 36:96847d42f010 44 'NUCLEO_F031K6': {'name': 'NUCLEO-F031K6', 'mcuId': 'STM32F031K6Tx'},
The Other Jimmy 36:96847d42f010 45 'NUCLEO_F042K6': {'name': 'NUCLEO-F042K6', 'mcuId': 'STM32F042K6Tx'},
The Other Jimmy 36:96847d42f010 46 'NUCLEO_F070RB': {'name': 'NUCLEO-F070RB', 'mcuId': 'STM32F070RBTx'},
The Other Jimmy 36:96847d42f010 47 'NUCLEO_F072RB': {'name': 'NUCLEO-F072RB', 'mcuId': 'STM32F072RBTx'},
The Other Jimmy 36:96847d42f010 48 'NUCLEO_F091RC': {'name': 'NUCLEO-F091RC', 'mcuId': 'STM32F091RCTx'},
The Other Jimmy 36:96847d42f010 49 'NUCLEO_F103RB': {'name': 'NUCLEO-F103RB', 'mcuId': 'STM32F103RBTx'},
The Other Jimmy 36:96847d42f010 50 'NUCLEO_F207ZG': {'name': 'NUCLEO-F207ZG', 'mcuId': 'STM32F207ZGTx'},
The Other Jimmy 36:96847d42f010 51 'NUCLEO_F302R8': {'name': 'NUCLEO-F302R8', 'mcuId': 'STM32F302R8Tx'},
The Other Jimmy 36:96847d42f010 52 'NUCLEO_F303K8': {'name': 'NUCLEO-F303K8', 'mcuId': 'STM32F303K8Tx'},
The Other Jimmy 36:96847d42f010 53 'NUCLEO_F303RE': {'name': 'NUCLEO-F303RE', 'mcuId': 'STM32F303RETx'},
The Other Jimmy 36:96847d42f010 54 'NUCLEO_F303ZE': {'name': 'NUCLEO-F303ZE', 'mcuId': 'STM32F303ZETx'},
The Other Jimmy 36:96847d42f010 55 'NUCLEO_F334R8': {'name': 'NUCLEO-F334R8', 'mcuId': 'STM32F334R8Tx'},
The Other Jimmy 36:96847d42f010 56 'NUCLEO_F401RE': {'name': 'NUCLEO-F401RE', 'mcuId': 'STM32F401RETx'},
The Other Jimmy 36:96847d42f010 57 'NUCLEO_F410RB': {'name': 'NUCLEO-F410RB', 'mcuId': 'STM32F410RBTx'},
The Other Jimmy 36:96847d42f010 58 'NUCLEO_F411RE': {'name': 'NUCLEO-F411RE', 'mcuId': 'STM32F411RETx'},
The Other Jimmy 36:96847d42f010 59 'NUCLEO_F429ZI': {'name': 'NUCLEO-F429ZI', 'mcuId': 'STM32F429ZITx'},
The Other Jimmy 36:96847d42f010 60 'NUCLEO_F446RE': {'name': 'NUCLEO-F446RE', 'mcuId': 'STM32F446RETx'},
The Other Jimmy 36:96847d42f010 61 'NUCLEO_F446ZE': {'name': 'NUCLEO-F446ZE', 'mcuId': 'STM32F446ZETx'},
The Other Jimmy 36:96847d42f010 62 'NUCLEO_F746ZG': {'name': 'NUCLEO-F746ZG', 'mcuId': 'STM32F746ZGTx'},
The Other Jimmy 36:96847d42f010 63 'NUCLEO_F767ZI': {'name': 'NUCLEO-F767ZI', 'mcuId': 'STM32F767ZITx'},
The Other Jimmy 36:96847d42f010 64 'NUCLEO_L011K4': {'name': 'NUCLEO-L011K4', 'mcuId': 'STM32L011K4Tx'},
The Other Jimmy 36:96847d42f010 65 'NUCLEO_L031K6': {'name': 'NUCLEO-L031K6', 'mcuId': 'STM32L031K6Tx'},
The Other Jimmy 36:96847d42f010 66 'NUCLEO_L053R8': {'name': 'NUCLEO-L053R8', 'mcuId': 'STM32L053R8Tx'},
The Other Jimmy 36:96847d42f010 67 'NUCLEO_L073RZ': {'name': 'NUCLEO-L073RZ', 'mcuId': 'STM32L073RZTx'},
The Other Jimmy 36:96847d42f010 68 'NUCLEO_L152RE': {'name': 'NUCLEO-L152RE', 'mcuId': 'STM32L152RETx'},
The Other Jimmy 36:96847d42f010 69 'NUCLEO_L432KC': {'name': 'NUCLEO-L432KC', 'mcuId': 'STM32L432KCUx'},
The Other Jimmy 36:96847d42f010 70 'NUCLEO_L476RG': {'name': 'NUCLEO-L476RG', 'mcuId': 'STM32L476RGTx'},
The Other Jimmy 35:da9c89f8be7d 71 }
The Other Jimmy 35:da9c89f8be7d 72
The Other Jimmy 35:da9c89f8be7d 73 TARGETS = BOARDS.keys()
The Other Jimmy 35:da9c89f8be7d 74
The Other Jimmy 35:da9c89f8be7d 75 def __gen_dir(self, dirname):
The Other Jimmy 35:da9c89f8be7d 76 settings = join(self.export_dir, dirname)
The Other Jimmy 35:da9c89f8be7d 77 mkdir(settings)
The Other Jimmy 35:da9c89f8be7d 78
The Other Jimmy 35:da9c89f8be7d 79 def __generate_uid(self):
The Other Jimmy 35:da9c89f8be7d 80 return "%0.9u" % randint(0, 999999999)
The Other Jimmy 35:da9c89f8be7d 81
The Other Jimmy 35:da9c89f8be7d 82 def generate(self):
The Other Jimmy 35:da9c89f8be7d 83 fp_hardware = "no"
The Other Jimmy 35:da9c89f8be7d 84 fp_abi = "soft"
The Other Jimmy 35:da9c89f8be7d 85 core = self.toolchain.target.core
The Other Jimmy 35:da9c89f8be7d 86 if core == "Cortex-M4F" or core == "Cortex-M7F":
The Other Jimmy 35:da9c89f8be7d 87 fp_hardware = "fpv4-sp-d16"
The Other Jimmy 35:da9c89f8be7d 88 fp_abi = "soft-fp"
The Other Jimmy 35:da9c89f8be7d 89 elif core == "Cortex-M7FD":
The Other Jimmy 35:da9c89f8be7d 90 fp_hardware = "fpv5-d16"
The Other Jimmy 35:da9c89f8be7d 91 fp_abi = "soft-fp"
The Other Jimmy 35:da9c89f8be7d 92
The Other Jimmy 35:da9c89f8be7d 93 libraries = []
The Other Jimmy 35:da9c89f8be7d 94 for lib in self.resources.libraries:
The Other Jimmy 35:da9c89f8be7d 95 l, _ = splitext(basename(lib))
The Other Jimmy 35:da9c89f8be7d 96 libraries.append(l[3:])
The Other Jimmy 35:da9c89f8be7d 97
The Other Jimmy 35:da9c89f8be7d 98 ctx = {
The Other Jimmy 35:da9c89f8be7d 99 'name': self.project_name,
The Other Jimmy 35:da9c89f8be7d 100 'include_paths': self.resources.inc_dirs,
The Other Jimmy 35:da9c89f8be7d 101 'linker_script': self.resources.linker_script,
The Other Jimmy 35:da9c89f8be7d 102 'library_paths': self.resources.lib_dirs,
The Other Jimmy 35:da9c89f8be7d 103 'object_files': self.resources.objects,
The Other Jimmy 35:da9c89f8be7d 104 'libraries': libraries,
The Other Jimmy 35:da9c89f8be7d 105 'symbols': self.toolchain.get_symbols(),
The Other Jimmy 35:da9c89f8be7d 106 'board_name': self.BOARDS[self.target.upper()]['name'],
The Other Jimmy 35:da9c89f8be7d 107 'mcu_name': self.BOARDS[self.target.upper()]['mcuId'],
The Other Jimmy 35:da9c89f8be7d 108 'debug_config_uid': self.__generate_uid(),
The Other Jimmy 35:da9c89f8be7d 109 'debug_tool_compiler_uid': self.__generate_uid(),
The Other Jimmy 35:da9c89f8be7d 110 'debug_tool_compiler_input_uid': self.__generate_uid(),
The Other Jimmy 35:da9c89f8be7d 111 'release_config_uid': self.__generate_uid(),
The Other Jimmy 35:da9c89f8be7d 112 'release_tool_compiler_uid': self.__generate_uid(),
The Other Jimmy 35:da9c89f8be7d 113 'release_tool_compiler_input_uid': self.__generate_uid(),
The Other Jimmy 35:da9c89f8be7d 114 'uid': self.__generate_uid(),
The Other Jimmy 35:da9c89f8be7d 115 'floating_point_hardware': fp_hardware,
The Other Jimmy 35:da9c89f8be7d 116 'floating_point_abi': fp_abi
The Other Jimmy 35:da9c89f8be7d 117 }
The Other Jimmy 35:da9c89f8be7d 118
The Other Jimmy 35:da9c89f8be7d 119 self.__gen_dir('.settings')
The Other Jimmy 35:da9c89f8be7d 120 self.gen_file('sw4stm32/language_settings_commom.tmpl', ctx, '.settings/language.settings.xml')
The Other Jimmy 35:da9c89f8be7d 121 self.gen_file('sw4stm32/project_common.tmpl', ctx, '.project')
The Other Jimmy 35:da9c89f8be7d 122 self.gen_file('sw4stm32/cproject_common.tmpl', ctx, '.cproject')