Includes library modifications to allow access to AIN_4 (AIN_0 / 5)
mbd_os/tools/export/gccarm.py@0:eafc3fd41f75, 2016-09-20 (annotated)
- Committer:
- bryantaylor
- Date:
- Tue Sep 20 21:26:12 2016 +0000
- Revision:
- 0:eafc3fd41f75
hackathon
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bryantaylor | 0:eafc3fd41f75 | 1 | """ |
bryantaylor | 0:eafc3fd41f75 | 2 | mbed SDK |
bryantaylor | 0:eafc3fd41f75 | 3 | Copyright (c) 2011-2016 ARM Limited |
bryantaylor | 0:eafc3fd41f75 | 4 | |
bryantaylor | 0:eafc3fd41f75 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); |
bryantaylor | 0:eafc3fd41f75 | 6 | you may not use this file except in compliance with the License. |
bryantaylor | 0:eafc3fd41f75 | 7 | You may obtain a copy of the License at |
bryantaylor | 0:eafc3fd41f75 | 8 | |
bryantaylor | 0:eafc3fd41f75 | 9 | http://www.apache.org/licenses/LICENSE-2.0 |
bryantaylor | 0:eafc3fd41f75 | 10 | |
bryantaylor | 0:eafc3fd41f75 | 11 | Unless required by applicable law or agreed to in writing, software |
bryantaylor | 0:eafc3fd41f75 | 12 | distributed under the License is distributed on an "AS IS" BASIS, |
bryantaylor | 0:eafc3fd41f75 | 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
bryantaylor | 0:eafc3fd41f75 | 14 | See the License for the specific language governing permissions and |
bryantaylor | 0:eafc3fd41f75 | 15 | limitations under the License. |
bryantaylor | 0:eafc3fd41f75 | 16 | """ |
bryantaylor | 0:eafc3fd41f75 | 17 | from os.path import splitext, basename, relpath, join, abspath, dirname |
bryantaylor | 0:eafc3fd41f75 | 18 | from os import curdir, getcwd |
bryantaylor | 0:eafc3fd41f75 | 19 | from tools.export.exporters import Exporter |
bryantaylor | 0:eafc3fd41f75 | 20 | |
bryantaylor | 0:eafc3fd41f75 | 21 | |
bryantaylor | 0:eafc3fd41f75 | 22 | class GccArm(Exporter): |
bryantaylor | 0:eafc3fd41f75 | 23 | NAME = 'GccArm' |
bryantaylor | 0:eafc3fd41f75 | 24 | TOOLCHAIN = 'GCC_ARM' |
bryantaylor | 0:eafc3fd41f75 | 25 | |
bryantaylor | 0:eafc3fd41f75 | 26 | TARGETS = [ |
bryantaylor | 0:eafc3fd41f75 | 27 | 'LPC1768', |
bryantaylor | 0:eafc3fd41f75 | 28 | 'LPC1549', |
bryantaylor | 0:eafc3fd41f75 | 29 | 'KL05Z', |
bryantaylor | 0:eafc3fd41f75 | 30 | 'KL25Z', |
bryantaylor | 0:eafc3fd41f75 | 31 | 'KL43Z', |
bryantaylor | 0:eafc3fd41f75 | 32 | 'KL46Z', |
bryantaylor | 0:eafc3fd41f75 | 33 | 'K64F', |
bryantaylor | 0:eafc3fd41f75 | 34 | 'K22F', |
bryantaylor | 0:eafc3fd41f75 | 35 | 'K20D50M', |
bryantaylor | 0:eafc3fd41f75 | 36 | 'LPC4088', |
bryantaylor | 0:eafc3fd41f75 | 37 | 'LPC4088_DM', |
bryantaylor | 0:eafc3fd41f75 | 38 | 'LPC4330_M4', |
bryantaylor | 0:eafc3fd41f75 | 39 | 'LPC11U24', |
bryantaylor | 0:eafc3fd41f75 | 40 | 'LPC1114', |
bryantaylor | 0:eafc3fd41f75 | 41 | 'LPC11U35_401', |
bryantaylor | 0:eafc3fd41f75 | 42 | 'LPC11U35_501', |
bryantaylor | 0:eafc3fd41f75 | 43 | 'LPC11U37H_401', |
bryantaylor | 0:eafc3fd41f75 | 44 | 'LPC810', |
bryantaylor | 0:eafc3fd41f75 | 45 | 'LPC812', |
bryantaylor | 0:eafc3fd41f75 | 46 | 'LPC824', |
bryantaylor | 0:eafc3fd41f75 | 47 | 'SSCI824', |
bryantaylor | 0:eafc3fd41f75 | 48 | 'STM32F407', |
bryantaylor | 0:eafc3fd41f75 | 49 | 'DISCO_F100RB', |
bryantaylor | 0:eafc3fd41f75 | 50 | 'DISCO_F051R8', |
bryantaylor | 0:eafc3fd41f75 | 51 | 'DISCO_F407VG', |
bryantaylor | 0:eafc3fd41f75 | 52 | 'DISCO_F429ZI', |
bryantaylor | 0:eafc3fd41f75 | 53 | 'DISCO_F469NI', |
bryantaylor | 0:eafc3fd41f75 | 54 | 'DISCO_F303VC', |
bryantaylor | 0:eafc3fd41f75 | 55 | 'DISCO_F746NG', |
bryantaylor | 0:eafc3fd41f75 | 56 | 'DISCO_F769NI', |
bryantaylor | 0:eafc3fd41f75 | 57 | 'DISCO_L476VG', |
bryantaylor | 0:eafc3fd41f75 | 58 | 'UBLOX_C027', |
bryantaylor | 0:eafc3fd41f75 | 59 | 'ARCH_PRO', |
bryantaylor | 0:eafc3fd41f75 | 60 | 'NRF51822', |
bryantaylor | 0:eafc3fd41f75 | 61 | 'HRM1017', |
bryantaylor | 0:eafc3fd41f75 | 62 | 'TY51822R3', |
bryantaylor | 0:eafc3fd41f75 | 63 | 'RBLAB_NRF51822', |
bryantaylor | 0:eafc3fd41f75 | 64 | 'RBLAB_BLENANO', |
bryantaylor | 0:eafc3fd41f75 | 65 | 'LPC2368', |
bryantaylor | 0:eafc3fd41f75 | 66 | 'LPC2460', |
bryantaylor | 0:eafc3fd41f75 | 67 | 'LPCCAPPUCCINO', |
bryantaylor | 0:eafc3fd41f75 | 68 | 'ARCH_BLE', |
bryantaylor | 0:eafc3fd41f75 | 69 | 'MTS_GAMBIT', |
bryantaylor | 0:eafc3fd41f75 | 70 | 'ARCH_MAX', |
bryantaylor | 0:eafc3fd41f75 | 71 | 'NUCLEO_F401RE', |
bryantaylor | 0:eafc3fd41f75 | 72 | 'NUCLEO_F410RB', |
bryantaylor | 0:eafc3fd41f75 | 73 | 'NUCLEO_F411RE', |
bryantaylor | 0:eafc3fd41f75 | 74 | 'NUCLEO_F429ZI', |
bryantaylor | 0:eafc3fd41f75 | 75 | 'NUCLEO_F446RE', |
bryantaylor | 0:eafc3fd41f75 | 76 | 'NUCLEO_F446ZE', |
bryantaylor | 0:eafc3fd41f75 | 77 | 'B96B_F446VE', |
bryantaylor | 0:eafc3fd41f75 | 78 | 'ARCH_MAX', |
bryantaylor | 0:eafc3fd41f75 | 79 | 'NUCLEO_F030R8', |
bryantaylor | 0:eafc3fd41f75 | 80 | 'NUCLEO_F031K6', |
bryantaylor | 0:eafc3fd41f75 | 81 | 'NUCLEO_F042K6', |
bryantaylor | 0:eafc3fd41f75 | 82 | 'NUCLEO_F070RB', |
bryantaylor | 0:eafc3fd41f75 | 83 | 'NUCLEO_F072RB', |
bryantaylor | 0:eafc3fd41f75 | 84 | 'NUCLEO_F091RC', |
bryantaylor | 0:eafc3fd41f75 | 85 | 'NUCLEO_F103RB', |
bryantaylor | 0:eafc3fd41f75 | 86 | 'NUCLEO_F207ZG', |
bryantaylor | 0:eafc3fd41f75 | 87 | 'NUCLEO_F302R8', |
bryantaylor | 0:eafc3fd41f75 | 88 | 'NUCLEO_F303K8', |
bryantaylor | 0:eafc3fd41f75 | 89 | 'NUCLEO_F303RE', |
bryantaylor | 0:eafc3fd41f75 | 90 | 'NUCLEO_F334R8', |
bryantaylor | 0:eafc3fd41f75 | 91 | 'NUCLEO_F303ZE', |
bryantaylor | 0:eafc3fd41f75 | 92 | 'NUCLEO_F746ZG', |
bryantaylor | 0:eafc3fd41f75 | 93 | 'NUCLEO_F767ZI', |
bryantaylor | 0:eafc3fd41f75 | 94 | 'DISCO_L053C8', |
bryantaylor | 0:eafc3fd41f75 | 95 | 'NUCLEO_L011K4', |
bryantaylor | 0:eafc3fd41f75 | 96 | 'NUCLEO_L031K6', |
bryantaylor | 0:eafc3fd41f75 | 97 | 'NUCLEO_L053R8', |
bryantaylor | 0:eafc3fd41f75 | 98 | 'NUCLEO_L073RZ', |
bryantaylor | 0:eafc3fd41f75 | 99 | 'NUCLEO_L432KC', |
bryantaylor | 0:eafc3fd41f75 | 100 | 'NUCLEO_L476RG', |
bryantaylor | 0:eafc3fd41f75 | 101 | 'DISCO_F334C8', |
bryantaylor | 0:eafc3fd41f75 | 102 | 'MAX32600MBED', |
bryantaylor | 0:eafc3fd41f75 | 103 | 'MAXWSNENV', |
bryantaylor | 0:eafc3fd41f75 | 104 | 'MAX32620HSP', |
bryantaylor | 0:eafc3fd41f75 | 105 | 'MTS_MDOT_F405RG', |
bryantaylor | 0:eafc3fd41f75 | 106 | 'MTS_MDOT_F411RE', |
bryantaylor | 0:eafc3fd41f75 | 107 | 'NUCLEO_L152RE', |
bryantaylor | 0:eafc3fd41f75 | 108 | 'NRF51_DK', |
bryantaylor | 0:eafc3fd41f75 | 109 | 'NRF51_DONGLE', |
bryantaylor | 0:eafc3fd41f75 | 110 | 'NRF51_MICROBIT', |
bryantaylor | 0:eafc3fd41f75 | 111 | 'MTM_MTCONNECT04S', |
bryantaylor | 0:eafc3fd41f75 | 112 | 'SEEED_TINY_BLE', |
bryantaylor | 0:eafc3fd41f75 | 113 | 'DISCO_F401VC', |
bryantaylor | 0:eafc3fd41f75 | 114 | 'DELTA_DFCM_NNN40', |
bryantaylor | 0:eafc3fd41f75 | 115 | 'RZ_A1H', |
bryantaylor | 0:eafc3fd41f75 | 116 | 'MOTE_L152RC', |
bryantaylor | 0:eafc3fd41f75 | 117 | 'EFM32WG_STK3800', |
bryantaylor | 0:eafc3fd41f75 | 118 | 'EFM32LG_STK3600', |
bryantaylor | 0:eafc3fd41f75 | 119 | 'EFM32GG_STK3700', |
bryantaylor | 0:eafc3fd41f75 | 120 | 'EFM32ZG_STK3200', |
bryantaylor | 0:eafc3fd41f75 | 121 | 'EFM32HG_STK3400', |
bryantaylor | 0:eafc3fd41f75 | 122 | 'EFM32PG_STK3401', |
bryantaylor | 0:eafc3fd41f75 | 123 | 'NZ32_SC151', |
bryantaylor | 0:eafc3fd41f75 | 124 | 'SAMR21G18A', |
bryantaylor | 0:eafc3fd41f75 | 125 | 'TEENSY3_1', |
bryantaylor | 0:eafc3fd41f75 | 126 | 'SAMD21J18A', |
bryantaylor | 0:eafc3fd41f75 | 127 | 'SAMD21G18A', |
bryantaylor | 0:eafc3fd41f75 | 128 | 'SAML21J18A', |
bryantaylor | 0:eafc3fd41f75 | 129 | 'SAMG55J19', |
bryantaylor | 0:eafc3fd41f75 | 130 | 'ARM_BEETLE_SOC', |
bryantaylor | 0:eafc3fd41f75 | 131 | 'ELMO_F411RE', |
bryantaylor | 0:eafc3fd41f75 | 132 | 'BLUEPILL_F103C8', |
bryantaylor | 0:eafc3fd41f75 | 133 | ] |
bryantaylor | 0:eafc3fd41f75 | 134 | |
bryantaylor | 0:eafc3fd41f75 | 135 | DOT_IN_RELATIVE_PATH = True |
bryantaylor | 0:eafc3fd41f75 | 136 | |
bryantaylor | 0:eafc3fd41f75 | 137 | MBED_CONFIG_HEADER_SUPPORTED = True |
bryantaylor | 0:eafc3fd41f75 | 138 | |
bryantaylor | 0:eafc3fd41f75 | 139 | def generate(self): |
bryantaylor | 0:eafc3fd41f75 | 140 | # "make" wants Unix paths |
bryantaylor | 0:eafc3fd41f75 | 141 | self.resources.win_to_unix() |
bryantaylor | 0:eafc3fd41f75 | 142 | |
bryantaylor | 0:eafc3fd41f75 | 143 | to_be_compiled = [] |
bryantaylor | 0:eafc3fd41f75 | 144 | for r_type in ['s_sources', 'c_sources', 'cpp_sources']: |
bryantaylor | 0:eafc3fd41f75 | 145 | r = getattr(self.resources, r_type) |
bryantaylor | 0:eafc3fd41f75 | 146 | if r: |
bryantaylor | 0:eafc3fd41f75 | 147 | for source in r: |
bryantaylor | 0:eafc3fd41f75 | 148 | base, ext = splitext(source) |
bryantaylor | 0:eafc3fd41f75 | 149 | to_be_compiled.append(base + '.o') |
bryantaylor | 0:eafc3fd41f75 | 150 | |
bryantaylor | 0:eafc3fd41f75 | 151 | libraries = [] |
bryantaylor | 0:eafc3fd41f75 | 152 | for lib in self.resources.libraries: |
bryantaylor | 0:eafc3fd41f75 | 153 | l, _ = splitext(basename(lib)) |
bryantaylor | 0:eafc3fd41f75 | 154 | libraries.append(l[3:]) |
bryantaylor | 0:eafc3fd41f75 | 155 | |
bryantaylor | 0:eafc3fd41f75 | 156 | ctx = { |
bryantaylor | 0:eafc3fd41f75 | 157 | 'name': self.project_name, |
bryantaylor | 0:eafc3fd41f75 | 158 | 'to_be_compiled': to_be_compiled, |
bryantaylor | 0:eafc3fd41f75 | 159 | 'object_files': self.resources.objects, |
bryantaylor | 0:eafc3fd41f75 | 160 | 'include_paths': self.resources.inc_dirs, |
bryantaylor | 0:eafc3fd41f75 | 161 | 'library_paths': self.resources.lib_dirs, |
bryantaylor | 0:eafc3fd41f75 | 162 | 'linker_script': self.resources.linker_script, |
bryantaylor | 0:eafc3fd41f75 | 163 | 'libraries': libraries, |
bryantaylor | 0:eafc3fd41f75 | 164 | 'symbols': self.toolchain.get_symbols(), |
bryantaylor | 0:eafc3fd41f75 | 165 | 'cpu_flags': self.toolchain.cpu, |
bryantaylor | 0:eafc3fd41f75 | 166 | 'hex_files': self.resources.hex_files, |
bryantaylor | 0:eafc3fd41f75 | 167 | 'vpath': (["../../.."] |
bryantaylor | 0:eafc3fd41f75 | 168 | if basename(dirname(dirname(self.export_dir))) == "projectfiles" |
bryantaylor | 0:eafc3fd41f75 | 169 | else [".."]) |
bryantaylor | 0:eafc3fd41f75 | 170 | } |
bryantaylor | 0:eafc3fd41f75 | 171 | |
bryantaylor | 0:eafc3fd41f75 | 172 | for key in ['include_paths', 'library_paths', 'linker_script', 'hex_files']: |
bryantaylor | 0:eafc3fd41f75 | 173 | if isinstance(ctx[key], list): |
bryantaylor | 0:eafc3fd41f75 | 174 | ctx[key] = [ctx['vpath'][0] + "/" + t for t in ctx[key]] |
bryantaylor | 0:eafc3fd41f75 | 175 | else: |
bryantaylor | 0:eafc3fd41f75 | 176 | ctx[key] = ctx['vpath'][0] + "/" + ctx[key] |
bryantaylor | 0:eafc3fd41f75 | 177 | if "../." not in ctx["include_paths"]: |
bryantaylor | 0:eafc3fd41f75 | 178 | ctx["include_paths"] += ['../.'] |
bryantaylor | 0:eafc3fd41f75 | 179 | ctx.update(self.flags) |
bryantaylor | 0:eafc3fd41f75 | 180 | self.gen_file('gcc_arm_%s.tmpl' % self.target.lower(), ctx, 'Makefile') |