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