|
| 1 | +""" |
| 2 | +mbed SDK |
| 3 | +Copyright (c) 2011-2016 ARM Limited |
| 4 | +
|
| 5 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +you may not use this file except in compliance with the License. |
| 7 | +You may obtain a copy of the License at |
| 8 | +
|
| 9 | +http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +
|
| 11 | +Unless required by applicable law or agreed to in writing, software |
| 12 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +See the License for the specific language governing permissions and |
| 15 | +limitations under the License. |
| 16 | +""" |
| 17 | +from exporters import Exporter |
| 18 | +from os.path import splitext, basename, join |
| 19 | +from random import randint |
| 20 | +from workspace_tools.utils import mkdir |
| 21 | + |
| 22 | + |
| 23 | +class Sw4STM32(Exporter): |
| 24 | + NAME = 'Sw4STM32' |
| 25 | + TOOLCHAIN = 'GCC_ARM' |
| 26 | + |
| 27 | + BOARDS = { |
| 28 | + # 'DISCO_F051R8': {'name': 'STM32F0DISCOVERY', 'mcuId': 'STM32F051R8Tx'}, |
| 29 | + # 'DISCO_F303VC': {'name': 'STM32F3DISCOVERY', 'mcuId': 'STM32F303VCTx'}, |
| 30 | + 'DISCO_F334C8': {'name': 'STM32F3348DISCOVERY', 'mcuId': 'STM32F334C8Tx'}, |
| 31 | + # 'DISCO_F401VC': {'name': 'STM32F401C-DISCO', 'mcuId': 'STM32F401VCTx'}, |
| 32 | + 'DISCO_F407VG': {'name': 'STM32F4DISCOVERY', 'mcuId': 'STM32F407VGTx'}, |
| 33 | + 'DISCO_F429ZI': {'name': 'STM32F429I-DISCO', 'mcuId': 'STM32F429ZITx'}, |
| 34 | + 'DISCO_F746NG': {'name': 'STM32F746G-DISCO', 'mcuId': 'STM32F746NGHx'}, |
| 35 | + 'DISCO_L053C8': {'name': 'STM32L0538DISCOVERY', 'mcuId': 'STM32L053C8Tx'}, |
| 36 | + 'DISCO_L476VG': {'name': 'STM32L476G-DISCO', 'mcuId': 'STM32L476VGTx'}, |
| 37 | + 'DISCO_F469NI': {'name': 'DISCO-F469NI', 'mcuId': 'STM32F469NIHx'}, |
| 38 | + 'NUCLEO_F030R8': {'name': 'NUCLEO-F030R8', 'mcuId': 'STM32F030R8Tx'}, |
| 39 | + 'NUCLEO_F070RB': {'name': 'NUCLEO-F070RB', 'mcuId': 'STM32F070RBTx'}, |
| 40 | + 'NUCLEO_F072RB': {'name': 'NUCLEO-F072RB', 'mcuId': 'STM32F072RBTx'}, |
| 41 | + 'NUCLEO_F091RC': {'name': 'NUCLEO-F091RC', 'mcuId': 'STM32F091RCTx'}, |
| 42 | + 'NUCLEO_F103RB': {'name': 'NUCLEO-F103RB', 'mcuId': 'STM32F103RBTx'}, |
| 43 | + 'NUCLEO_F302R8': {'name': 'NUCLEO-F302R8', 'mcuId': 'STM32F302R8Tx'}, |
| 44 | + 'NUCLEO_F303RE': {'name': 'NUCLEO-F303RE', 'mcuId': 'STM32F303RETx'}, |
| 45 | + 'NUCLEO_F334R8': {'name': 'NUCLEO-F334R8', 'mcuId': 'STM32F334R8Tx'}, |
| 46 | + 'NUCLEO_F401RE': {'name': 'NUCLEO-F401RE', 'mcuId': 'STM32F401RETx'}, |
| 47 | + 'NUCLEO_F411RE': {'name': 'NUCLEO-F411RE', 'mcuId': 'STM32F411RETx'}, |
| 48 | + 'NUCLEO_F446RE': {'name': 'NUCLEO-F446RE', 'mcuId': 'STM32F446RETx'}, |
| 49 | + 'NUCLEO_L053R8': {'name': 'NUCLEO-L053R8', 'mcuId': 'STM32L053R8Tx'}, |
| 50 | + 'NUCLEO_L152RE': {'name': 'NUCLEO-L152RE', 'mcuId': 'STM32L152RETx'}, |
| 51 | + 'NUCLEO_L476RG': {'name': 'NUCLEO-L476RG', 'mcuId': 'STM32L476RGTx'}, |
| 52 | + 'NUCLEO_F031K6': {'name': 'NUCLEO-F031K6', 'mcuId': 'STM32F031K6Tx'}, |
| 53 | + 'NUCLEO_F042K6': {'name': 'NUCLEO-F042K6', 'mcuId': 'STM32F042K6Tx'}, |
| 54 | + 'NUCLEO_F303K8': {'name': 'NUCLEO-F303K8', 'mcuId': 'STM32F303K8Tx'}, |
| 55 | + 'NUCLEO_F410RB': {'name': 'NUCLEO-F410RB', 'mcuId': 'STM32F410RBTx'}, |
| 56 | + } |
| 57 | + |
| 58 | + TARGETS = BOARDS.keys() |
| 59 | + |
| 60 | + def __gen_dir(self, dirname): |
| 61 | + settings = join(self.inputDir, dirname) |
| 62 | + mkdir(settings) |
| 63 | + |
| 64 | + def __generate_uid(self): |
| 65 | + return "%0.9u" % randint(0, 999999999) |
| 66 | + |
| 67 | + def generate(self): |
| 68 | + libraries = [] |
| 69 | + for lib in self.resources.libraries: |
| 70 | + l, _ = splitext(basename(lib)) |
| 71 | + libraries.append(l[3:]) |
| 72 | + |
| 73 | + ctx = { |
| 74 | + 'name': self.program_name, |
| 75 | + 'include_paths': self.resources.inc_dirs, |
| 76 | + 'linker_script': self.resources.linker_script, |
| 77 | + 'symbols': self.get_symbols(), |
| 78 | + 'board_name': self.BOARDS[self.target.upper()]['name'], |
| 79 | + 'mcu_name': self.BOARDS[self.target.upper()]['mcuId'], |
| 80 | + 'debug_config_uid': self.__generate_uid(), |
| 81 | + 'debug_tool_compiler_uid': self.__generate_uid(), |
| 82 | + 'debug_tool_compiler_input_uid': self.__generate_uid(), |
| 83 | + 'release_config_uid': self.__generate_uid(), |
| 84 | + 'release_tool_compiler_uid': self.__generate_uid(), |
| 85 | + 'release_tool_compiler_input_uid': self.__generate_uid(), |
| 86 | + 'uid': self.__generate_uid() |
| 87 | + } |
| 88 | + |
| 89 | + self.__gen_dir('.settings') |
| 90 | + self.gen_file('sw4stm32_language_settings_commom.tmpl', ctx, '.settings/language.settings.xml') |
| 91 | + self.gen_file('sw4stm32_project_common.tmpl', ctx, '.project') |
| 92 | + self.gen_file('sw4stm32_cproject_common.tmpl', ctx, '.cproject') |
0 commit comments