Skip to content

Commit decb0c0

Browse files
committed
Merge pull request #1513 from DanKupiniak/add_sw4stm32_export
Added SW4STM32 project exporter for stm32 targets
2 parents bad9c12 + edc14ea commit decb0c0

File tree

6 files changed

+355
-5
lines changed

6 files changed

+355
-5
lines changed

workspace_tools/export/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from shutil import copytree, rmtree, copy
2020

2121
from workspace_tools.utils import mkdir
22-
from workspace_tools.export import uvision4, codesourcery, codered, gccarm, ds5_5, iar, emblocks, coide, kds, zip, simplicityv3, atmelstudio
22+
from workspace_tools.export import uvision4, codesourcery, codered, gccarm, ds5_5, iar, emblocks, coide, kds, zip, simplicityv3, atmelstudio, sw4stm32
2323
from workspace_tools.export.exporters import zip_working_directory_and_clean_up, OldLibrariesException
2424
from workspace_tools.targets import TARGET_NAMES, EXPORT_MAP, TARGET_MAP
2525

@@ -37,6 +37,7 @@
3737
'kds' : kds.KDS,
3838
'simplicityv3' : simplicityv3.SimplicityV3,
3939
'atmelstudio' : atmelstudio.AtmelStudio,
40+
'sw4stm32' : sw4stm32.Sw4STM32,
4041
}
4142

4243
ERROR_MESSAGE_UNSUPPORTED_TOOLCHAIN = """
@@ -172,9 +173,9 @@ def mcu_ide_matrix(verbose_html=False, platform_filter=None):
172173
for ide in supported_ides:
173174
text = "-"
174175
if target in EXPORTERS[ide].TARGETS:
175-
if verbose_html:
176-
text = "✓"
177-
else:
176+
if verbose_html:
177+
text = "✓"
178+
else:
178179
text = "x"
179180
perm_counter += 1
180181
row.append(text)

workspace_tools/export/sw4stm32.py

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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

Comments
 (0)