Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce device_name is valid in targets.json #3695

Merged
merged 3 commits into from
Feb 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ script:
- make -C events/equeue test clean
- PYTHONPATH=. python tools/test/config_test/config_test.py
- PYTHONPATH=. python tools/test/build_api/build_api_test.py
- PYTHONPATH=. python tools/test/targets/target_test.py
- python tools/test/pylint.py
- py.test tools/test/toolchains/api.py
- python tools/test/memap/memap_test.py
Expand Down
24 changes: 9 additions & 15 deletions targets/targets.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
"device_has": ["ANALOGIN", "ANALOGOUT", "CAN", "I2C", "INTERRUPTIN", "PWMOUT", "RTC", "SERIAL", "SERIAL_FC", "SPI", "SPISLAVE"],
"default_lib": "small",
"release_versions": ["2"],
"device_name": "lpc1549"
"device_name": "LPC1549JBD64"
},
"LPC1768": {
"inherits": ["LPCTarget"],
Expand Down Expand Up @@ -632,7 +632,7 @@
"detect_code": ["0217"],
"device_has": ["ANALOGIN", "ANALOGOUT", "ERROR_RED", "I2C", "I2CSLAVE", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SLEEP", "SPI", "SPISLAVE", "STDIO_MESSAGES"],
"release_versions": ["2", "5"],
"device_name" : "MK66FN256xxx15"
"device_name" : "MK82FN256xxx15"
},
"NUCLEO_F030R8": {
"supported_form_factors": ["ARDUINO", "MORPHO"],
Expand Down Expand Up @@ -1073,7 +1073,7 @@
"macros": ["TRANSACTION_QUEUE_SIZE_SPI=2","USBHOST_OTHER"],
"device_has": ["ANALOGIN", "ANALOGOUT", "CAN", "I2C", "I2CSLAVE", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SERIAL_FC", "SLEEP", "SPI", "SPISLAVE", "SPI_ASYNCH", "STDIO_MESSAGES", "TRNG"],
"release_versions": ["2", "5"],
"device_name": "stm32l476rg"
"device_name": "STM32L476RG"
},
"NUCLEO_L486RG": {
"supported_form_factors": ["ARDUINO", "MORPHO"],
Expand All @@ -1085,7 +1085,7 @@
"detect_code": ["0827"],
"device_has": ["ANALOGIN", "ANALOGOUT", "CAN", "I2C", "I2CSLAVE", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SERIAL_FC", "SLEEP", "SPI", "SPISLAVE", "STDIO_MESSAGES"],
"release_versions": ["2", "5"],
"device_name": "stm32l486rg"
"device_name": "STM32L486RG"
},
"STM32F3XX": {
"inherits": ["Target"],
Expand Down Expand Up @@ -1239,7 +1239,7 @@
"macros": ["TRANSACTION_QUEUE_SIZE_SPI=2", "USBHOST_OTHER"],
"device_has": ["ANALOGIN", "ANALOGOUT", "CAN", "I2C", "I2CSLAVE", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_FC", "SLEEP", "SPI", "SPISLAVE", "SPI_ASYNCH", "STDIO_MESSAGES", "TRNG"],
"release_versions": ["2", "5"],
"device_name": "stm32l476vg"
"device_name": "STM32L476VG"
},
"MTS_MDOT_F405RG": {
"inherits": ["Target"],
Expand Down Expand Up @@ -1827,8 +1827,7 @@
"macros": ["CMSDK_BEETLE", "WSF_MS_PER_TICK=20", "WSF_TOKEN_ENABLED=FALSE", "WSF_TRACE_ENABLED=TRUE", "WSF_ASSERT_ENABLED=FALSE", "WSF_PRINTF_MAX_LEN=128", "ASIC", "CONFIG_HOST_REV=0x20", "CONFIG_ALLOW_DEEP_SLEEP=FALSE", "HCI_VS_TARGET", "CONFIG_ALLOW_SETTING_WRITE=TRUE", "WSF_MAX_HANDLERS=20", "NO_LEDS"],
"device_has": ["ANALOGIN", "CLCD", "I2C", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "SERIAL", "SLEEP", "SPI"],
"features": ["BLE"],
"release_versions": ["2", "5"],
"device_name": "beetle"
"release_versions": ["2", "5"]
},
"RZ_A1H": {
"supported_form_factors": ["ARDUINO"],
Expand All @@ -1839,8 +1838,7 @@
"inherits": ["Target"],
"device_has": ["ANALOGIN", "CAN", "ERROR_PATTERN", "ETHERNET", "I2C", "I2CSLAVE", "I2C_ASYNCH", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SERIAL_FC", "SPI", "SPISLAVE", "SPI_ASYNCH", "STDIO_MESSAGES"],
"features": ["LWIP"],
"release_versions": ["2", "5"],
"device_name": "r7s721001"
"release_versions": ["2", "5"]
},
"VK_RZ_A1H": {
"inherits": ["Target"],
Expand All @@ -1852,8 +1850,7 @@
"device_has": ["ANALOGIN", "CAN", "ERROR_PATTERN", "ETHERNET", "I2C", "I2CSLAVE", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_FC", "SPI", "SPISLAVE", "STDIO_MESSAGES"],
"features": ["LWIP"],
"default_lib": "std",
"release_versions": ["2", "5"],
"device_name": "r7s721000"
"release_versions": ["2", "5"]
},
"MAXWSNENV": {
"inherits": ["Target"],
Expand All @@ -1872,8 +1869,7 @@
"extra_labels": ["Maxim", "MAX32600"],
"supported_toolchains": ["GCC_ARM", "IAR", "ARM"],
"device_has": ["ANALOGIN", "ANALOGOUT", "ERROR_PATTERN", "I2C", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_FC", "SLEEP", "SPI", "STDIO_MESSAGES"],
"release_versions": ["2", "5"],
"device_name": "max326000x85"
"release_versions": ["2", "5"]
},
"MAX32620HSP": {
"inherits": ["Target"],
Expand Down Expand Up @@ -2252,7 +2248,6 @@
"macros": ["EFR32MG1P233F256GM48", "TRANSACTION_QUEUE_SIZE_SPI=4"],
"supported_toolchains": ["GCC_ARM", "ARM", "uARM", "IAR"],
"release_versions": ["2", "5"],
"device_name": "EFR32MG1P233F256GM48",
"public": false
},
"EFR32MG1_BRD4150": {
Expand Down Expand Up @@ -2600,7 +2595,6 @@
"macros": ["CM3", "CPU_NCS36510", "TARGET_NCS36510", "LOAD_ADDRESS=0x3000"],
"supported_toolchains": ["GCC_ARM", "ARM", "IAR"],
"device_has": ["ANALOGIN", "SERIAL", "I2C", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_FC", "SLEEP", "SPI", "LOWPOWERTIMER", "TRNG"],
"device_name": "NCS36510",
"release_versions": ["2", "5"]
},
"NUMAKER_PFM_M453": {
Expand Down
22 changes: 16 additions & 6 deletions tools/export/iar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,19 @@ class IAR(Exporter):
with open(def_loc, 'r') as f:
IAR_DEFS = json.load(f)

#supported targets have a device name and corresponding definition in
#iar_definitions.json
TARGETS = [target for target, obj in TARGET_MAP.iteritems()
if hasattr(obj, 'device_name') and
obj.device_name in IAR_DEFS.keys() and "IAR" in obj.supported_toolchains]
def _iar_support(tgt, iar_targets):
if "IAR" not in tgt.supported_toolchains:
return False
if hasattr(tgt, 'device_name') and tgt.device_name in iar_targets:
return True
if tgt.name in iar_targets:
return True
return False

#supported targets have a name or device_name which maps to a definition
#in iar_definitions.json
TARGETS = [target for target, obj in TARGET_MAP.iteritems() if
_iar_support(obj, IAR_DEFS.keys())]

def iar_groups(self, grouped_src):
"""Return a namedtuple of group info
Expand All @@ -56,7 +64,9 @@ def iar_groups(self, grouped_src):

def iar_device(self):
"""Retrieve info from iar_definitions.json"""
device_name = TARGET_MAP[self.target].device_name
tgt = TARGET_MAP[self.target]
device_name = (tgt.device_name if hasattr(tgt, "device_name") else
tgt.name)
device_info = self.IAR_DEFS[device_name]
iar_defaults ={
"OGChipSelectEditMenu": "",
Expand Down
6 changes: 3 additions & 3 deletions tools/export/iar/iar_definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,14 @@
"STM32F091RC": {
"OGChipSelectEditMenu": "STM32F091RC\tST STM32F091RC"
},
"r7s721001": {
"RZ_A1H": {
"OGChipSelectEditMenu": "R7S721001\tRenesas R7S721001",
"CoreVariant": 37,
"GFPUCoreSlave": 37,
"GBECoreSlave": 37,
"NEON":1
},
"r7s721000": {
"VK_RZ_A1H": {
"OGChipSelectEditMenu": "R7S721000\tRenesas R7S721000",
"CoreVariant": 37,
"GFPUCoreSlave": 37,
Expand All @@ -153,7 +153,7 @@
"STM32F031K6": {
"OGChipSelectEditMenu": "STM32F031x6\tST STM32F031x6"
},
"max326000x85": {
"MAX32600MBED": {
"OGChipSelectEditMenu": "MAX32600x85\tMaxim MAX32600x85"
},
"STM32F407VG": {
Expand Down
43 changes: 43 additions & 0 deletions tools/test/targets/target_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python
"""
mbed
Copyright (c) 2017-2017 ARM Limited

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

import sys
from os.path import join, abspath, dirname
import unittest

# Be sure that the tools directory is in the search path
ROOT = abspath(join(dirname(__file__), "..", "..", ".."))
sys.path.insert(0, ROOT)

from tools.targets import TARGETS
from tools.arm_pack_manager import Cache

class TestTargets(unittest.TestCase):

def test_device_name(self):
"""Assert device name is in a pack"""
cache = Cache(True, True)
named_targets = (target for target in TARGETS if
hasattr(target, "device_name"))
for target in named_targets:
self.assertTrue(target.device_name in cache.index,
"Target %s contains invalid device_name %s" %
(target.name, target.device_name))

if __name__ == '__main__':
unittest.main()