ON Semiconductor / mbed-os

Dependents:   mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers sw4stm32.py Source File

sw4stm32.py

00001 """
00002 mbed SDK
00003 Copyright (c) 2011-2016 ARM Limited
00004 
00005 Licensed under the Apache License, Version 2.0 (the "License");
00006 you may not use this file except in compliance with the License.
00007 You may obtain a copy of the License at
00008 
00009 http://www.apache.org/licenses/LICENSE-2.0
00010 
00011 Unless required by applicable law or agreed to in writing, software
00012 distributed under the License is distributed on an "AS IS" BASIS,
00013 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014 See the License for the specific language governing permissions and
00015 limitations under the License.
00016 """
00017 from exporters import Exporter
00018 from os.path import splitext, basename, join
00019 from random import randint
00020 from tools.utils import mkdir
00021 
00022 
00023 class Sw4STM32(Exporter):
00024     NAME = 'Sw4STM32'
00025     TOOLCHAIN = 'GCC_ARM'
00026 
00027     BOARDS = {
00028         'B96B_F446VE':      {'name': 'B96B-F446VE',           'mcuId': 'STM32F446VETx'},
00029         'DISCO_F051R8':     {'name': 'STM32F0DISCOVERY',      'mcuId': 'STM32F051R8Tx'},
00030         'DISCO_F303VC':     {'name': 'STM32F3DISCOVERY',      'mcuId': 'STM32F303VCTx'},
00031         'DISCO_F334C8':     {'name': 'STM32F3348DISCOVERY',   'mcuId': 'STM32F334C8Tx'},
00032         'DISCO_F401VC':     {'name': 'STM32F401C-DISCO',      'mcuId': 'STM32F401VCTx'},
00033         'DISCO_F407VG':     {'name': 'STM32F4DISCOVERY',      'mcuId': 'STM32F407VGTx'},
00034         'DISCO_F429ZI':     {'name': 'STM32F429I-DISCO',      'mcuId': 'STM32F429ZITx'},
00035         'DISCO_F469NI':     {'name': 'DISCO-F469NI',          'mcuId': 'STM32F469NIHx'},
00036         'DISCO_F746NG':     {'name': 'STM32F746G-DISCO',      'mcuId': 'STM32F746NGHx'},
00037         'DISCO_F769NI':     {'name': 'DISCO-F769NI',          'mcuId': 'STM32F769NIHx'},
00038         'DISCO_L053C8':     {'name': 'STM32L0538DISCOVERY',   'mcuId': 'STM32L053C8Tx'},
00039         'DISCO_L476VG':     {'name': 'STM32L476G-DISCO',      'mcuId': 'STM32L476VGTx'},
00040         'NUCLEO_F030R8':    {'name': 'NUCLEO-F030R8',         'mcuId': 'STM32F030R8Tx'},
00041         'NUCLEO_F031K6':    {'name': 'NUCLEO-F031K6',         'mcuId': 'STM32F031K6Tx'},
00042         'NUCLEO_F042K6':    {'name': 'NUCLEO-F042K6',         'mcuId': 'STM32F042K6Tx'},
00043         'NUCLEO_F070RB':    {'name': 'NUCLEO-F070RB',         'mcuId': 'STM32F070RBTx'},
00044         'NUCLEO_F072RB':    {'name': 'NUCLEO-F072RB',         'mcuId': 'STM32F072RBTx'},
00045         'NUCLEO_F091RC':    {'name': 'NUCLEO-F091RC',         'mcuId': 'STM32F091RCTx'},
00046         'NUCLEO_F103RB':    {'name': 'NUCLEO-F103RB',         'mcuId': 'STM32F103RBTx'},
00047         'NUCLEO_F207ZG':    {'name': 'NUCLEO-F207ZG',         'mcuId': 'STM32F207ZGTx'},
00048         'NUCLEO_F302R8':    {'name': 'NUCLEO-F302R8',         'mcuId': 'STM32F302R8Tx'},
00049         'NUCLEO_F303K8':    {'name': 'NUCLEO-F303K8',         'mcuId': 'STM32F303K8Tx'},
00050         'NUCLEO_F303RE':    {'name': 'NUCLEO-F303RE',         'mcuId': 'STM32F303RETx'},
00051         'NUCLEO_F303ZE':    {'name': 'NUCLEO-F303ZE',         'mcuId': 'STM32F303ZETx'},
00052         'NUCLEO_F334R8':    {'name': 'NUCLEO-F334R8',         'mcuId': 'STM32F334R8Tx'},
00053         'NUCLEO_F401RE':    {'name': 'NUCLEO-F401RE',         'mcuId': 'STM32F401RETx'},
00054         'NUCLEO_F410RB':    {'name': 'NUCLEO-F410RB',         'mcuId': 'STM32F410RBTx'},
00055         'NUCLEO_F411RE':    {'name': 'NUCLEO-F411RE',         'mcuId': 'STM32F411RETx'},
00056         'NUCLEO_F429ZI':    {'name': 'NUCLEO-F429ZI',         'mcuId': 'STM32F429ZITx'},
00057         'NUCLEO_F446RE':    {'name': 'NUCLEO-F446RE',         'mcuId': 'STM32F446RETx'},
00058         'NUCLEO_F446ZE':    {'name': 'NUCLEO-F446ZE',         'mcuId': 'STM32F446ZETx'},
00059         'NUCLEO_F746ZG':    {'name': 'NUCLEO-F746ZG',         'mcuId': 'STM32F746ZGTx'},
00060         'NUCLEO_F767ZI':    {'name': 'NUCLEO-F767ZI',         'mcuId': 'STM32F767ZITx'},
00061         'NUCLEO_L011K4':    {'name': 'NUCLEO-L011K4',         'mcuId': 'STM32L011K4Tx'},
00062         'NUCLEO_L031K6':    {'name': 'NUCLEO-L031K6',         'mcuId': 'STM32L031K6Tx'},
00063         'NUCLEO_L053R8':    {'name': 'NUCLEO-L053R8',         'mcuId': 'STM32L053R8Tx'},
00064         'NUCLEO_L073RZ':    {'name': 'NUCLEO-L073RZ',         'mcuId': 'STM32L073RZTx'},
00065         'NUCLEO_L152RE':    {'name': 'NUCLEO-L152RE',         'mcuId': 'STM32L152RETx'},
00066         'NUCLEO_L432KC':    {'name': 'NUCLEO-L432KC',         'mcuId': 'STM32L432KCUx'},
00067         'NUCLEO_L476RG':    {'name': 'NUCLEO-L476RG',         'mcuId': 'STM32L476RGTx'},
00068     }
00069 
00070     TARGETS = BOARDS.keys()
00071 
00072     def __gen_dir(self, dirname):
00073         settings = join(self.export_dir, dirname)
00074         mkdir(settings)
00075 
00076     def __generate_uid(self):
00077         return "%0.9u" % randint(0, 999999999)
00078 
00079     def generate(self):
00080         fp_hardware = "no"
00081         fp_abi = "soft"
00082         core = self.toolchain.target.core
00083         if core == "Cortex-M4F" or core == "Cortex-M7F":
00084             fp_hardware = "fpv4-sp-d16"
00085             fp_abi = "soft-fp"
00086         elif core == "Cortex-M7FD":
00087             fp_hardware = "fpv5-d16"
00088             fp_abi = "soft-fp"
00089             
00090         libraries = []
00091         for lib in self.resources.libraries:
00092             l, _ = splitext(basename(lib))
00093             libraries.append(l[3:])
00094 
00095         ctx = {
00096             'name': self.project_name,
00097             'include_paths': self.resources.inc_dirs,
00098             'linker_script': self.resources.linker_script,
00099             'library_paths': self.resources.lib_dirs,
00100             'object_files': self.resources.objects,
00101             'libraries': libraries,
00102             'symbols': self.toolchain.get_symbols(),
00103             'board_name': self.BOARDS[self.target.upper()]['name'],
00104             'mcu_name': self.BOARDS[self.target.upper()]['mcuId'],
00105             'debug_config_uid': self.__generate_uid(),
00106             'debug_tool_compiler_uid': self.__generate_uid(),
00107             'debug_tool_compiler_input_uid': self.__generate_uid(),
00108             'release_config_uid': self.__generate_uid(),
00109             'release_tool_compiler_uid': self.__generate_uid(),
00110             'release_tool_compiler_input_uid': self.__generate_uid(),
00111             'uid': self.__generate_uid(),
00112             'floating_point_hardware': fp_hardware,
00113             'floating_point_abi': fp_abi
00114         }
00115 
00116         self.__gen_dir('.settings')
00117         self.gen_file('sw4stm32_language_settings_commom.tmpl', ctx, '.settings/language.settings.xml')
00118         self.gen_file('sw4stm32_project_common.tmpl', ctx, '.project')
00119         self.gen_file('sw4stm32_cproject_common.tmpl', ctx, '.cproject')