diff --git a/docs/mbed_targets.md b/docs/mbed_targets.md new file mode 100644 index 00000000000..53c4decd946 --- /dev/null +++ b/docs/mbed_targets.md @@ -0,0 +1,169 @@ +# Adding and configuring mbed targets + +mbed uses JSON as a description language for its build targets. The JSON description of mbed targets can be found in `tools/targets.json`. To better understand how a target is defined, we'll use this example (taken from `targets.json`): + +``` + "TEENSY3_1": { + "inherits": ["Target"], + "core": "Cortex-M4", + "extra_labels": ["Freescale", "K20XX", "K20DX256"], + "OUTPUT_EXT": "hex", + "is_disk_virtual": true, + "supported_toolchains": ["GCC_ARM", "ARM"], + "post_binary_hook": { + "function": "TEENSY3_1Code.binary_hook", + "toolchains": ["ARM_STD", "ARM_MICRO", "GCC_ARM"] + }, + "progen": {"target": "teensy-31"}, + "detect_code": ["0230"] +``` + +The definition of the target called **TEENSY3_1** is a JSON object. The properties in the object are either "standard" (understood by the mbed build system) or specific to the target. + +# Standard properties + +This section lists all the properties that are known to the mbed build system. Unless specified otherwise, all properties are optional. + +## inherits + +The description of a mbed target can "inherit" from one of more descriptions of other targets. When a target **A** inherits from another target **B** (**A** is the _child_ of **B** and **B** is the _parent_ of **A**), it automatically "borrows" all the definitions of properties from **B** and can modify them as needed (if you're familiar with Python, this is very similar with how class inheritance works in Python). In our example above, `TEENSY3_1` inherits from `Target` (most mbed targets inherit from `Target`). This is how `Target` is defined: + +``` +"Target": { + "core": null, + "default_toolchain": "ARM", + "supported_toolchains": null, + "extra_labels": [], + "is_disk_virtual": false, + "macros": [], + "detect_code": [], + "public": false +} +``` + +Since `TEENSY3_1` inherits from `Target`: + +- `core` is a property defined both in `TEENSY3_1` and `Target`. Since `TEENSY3_1` redefines it, the value of `core` for `TEENSY3_1` will be `Cortex-M4`. +- `default_toolchain` is not defined in `TEENSY3_1`, but since it is defined in `Target`, `TEENSY3_1` borrows it, so the value of `default_toolchain` for `TEENSY3_1` will be `ARM`. + +A target can add properties that don't exist in its parent(s). For example, `OUTPUT_EXT` is defined in `TEENSY3_1`, but doesn't exist in `Target`. + +It's possible to inherit from more than one target. For example: + +``` +"ImaginaryTarget": { + "inherits": ["Target", "TEENSY3_1"] +} +``` + +In this case, `ImaginaryTarget` inherits the properties of both `Target` and `TEENSY3_1`, so: + +- the value of `ImaginaryTarget.default_toolchain` will be `ARM` (from `Target`) +- the value of `ImaginaryTarget.OUTPUT_EXT` will be `hex` (from `TEENSY3_1`). +- the value of `ImaginaryTarget.core` will be `null` (from `Target`, since that's the first parent of `ImaginaryTarget` that defines `core`). + +Avoid using multiple inheritance for your targets if possible, since it can get pretty tricky to figure out how a property is inherited if multiple inheritance is used. If you have to use multiple inheritance, keep in mind that the mbed target description mechanism uses the old (pre 2.3) Python mechanism for finding the method resolution order: + +- look for the property in the current target. +- if not found, look for the property in the first target's parent, then in the parent of the parent and so on. +- if not found, look for the property in the rest of the target's parents, relative to the current inheritance level. + +For more details about the Python method resolution order, check for example [this link](http://makina-corpus.com/blog/metier/2014/python-tutorial-understanding-python-mro-class-search-path). + +## core + +The name of the ARM core used by the target. + +Possible values: `"Cortex-M0"`, `"Cortex-M0+"`, `"Cortex-M1"`, `"Cortex-M3"`, `"Cortex-M4"`, `"Cortex-M4F"`, `"Cortex-M7"`, `"Cortex-M7F"`, `"Cortex-A9"` + +## public + +Some mbed targets might be defined solely for the purpose of serving as an inheritance base for other targets (as opposed to being used to build mbed code). When such a target is defined, its description must have the `public` property set to `false` to prevent the mbed build system from considering it as a build target. An example is the `Target` target shown in a previous paragraph. + +If `public` is not defined for a target, it defaults to `true`. + +Note that unlike other target properties, **the value of `public` is not inherited from a parent to its children**. + +## macros, macros_add, macros_remove + +The macros in this list will be defined when compiling mbed code. The macros can be defined with or without a value. For example, the declaration `"macros": ["NO_VALUE", "VALUE=10"]` will add these definitions to the compiler's command line: `-DNO_VALUE -DVALUE=10`. + +When target inheritance is used, it's possible to alter the values of `macros` in inherited targets without re-defining `macros` completely: + +- an inherited target can use `macros_add` to add its own macros. +- an inherited target can use `macros_remove` to remove macros defined by its parents. + +For example, in this configuration: + +``` + "TargetA": { + "macros": ["PARENT_MACRO1", "PARENT_MACRO2"] + }, + "TargetB": { + "inherits": ["TargetA"], + "macros_add": ["CHILD_MACRO1"], + "macros_remove": ["PARENT_MACRO2"] + } +``` + +the value of `TargetB.macros` will be `["PARENT_MACRO1", "CHILD_MACRO1"]`. + +## extra_labels, extra_labels_add, extra_labels_remove + +The list of **labels** defines how the build system looks for sources, libraries, include directories and any other additional files that are needed at compile time. `extra_labels` can be used to make the build system aware of additional directories that must be scanned for such files. + +If target inheritance is used, it's possible to alter the values of `extra_labels` using `extra_labels_add` and `extra_labels_remove`. This is similar to the `macros_add` and `macros_remove` mechanism described in the previous paragraph. + +## supported_toolchains + +This is the list of toolchains that can be used to compile code for the target. The known toolchains are `ARM`, `uARM`, `GCC_ARM`, `GCC_CR`, `IAR`. + +## default_toolchain + +The name of the toolchain that will be used by default to compile this target (if another toolchain is not specified). Possible values are `ARM` or `uARM`. + +## post_binary_hook + +Some mbed targets require specific actions for generating a binary image that can be flashed to the target. If that's the case, these specific actions can be specified using the `post_binary_hook` property and custom Python code. For the `TEENSY3_1` target above, the definition of `post_binary_hook` looks like this: + +``` +"post_binary_hook": { + "function": "TEENSY3_1Code.binary_hook", + "toolchains": ["ARM_STD", "ARM_MICRO", "GCC_ARM"] +} +``` + +Following this definition, the build system will call the function `binary_hook` in the `TEENSY3_1Code` class after the initial binary image for the target is generated. The definition of the `TEENSY3_1Code` class **must** exist in the *targets.py* file. Since `toolchains` is also specified, `binary_hook` will only be called if the toolchain used for compiling the code is either `ARM_STD`, `ARM_MICRO` or `GCC_ARM`. Note that specifying `toolchains` is optional: if it's not specified, the hook will be called no matter what toolchain is used. + +As for the `binary_hook` code, this is how it looks in *targets.py*: + +``` +class TEENSY3_1Code: + @staticmethod + def binary_hook(t_self, resources, elf, binf): + from intelhex import IntelHex + binh = IntelHex() + binh.loadbin(binf, offset = 0) + + with open(binf.replace(".bin", ".hex"), "w") as f: + binh.tofile(f, format='hex') +``` + +In this case, it converts the output file (`binf`) from binary format to Intel HEX format. + +The hook code can look quite different between different targets. Take a look at the other classes in *targets.py* for more examples of hook code. + +## progen + +This property is used to pass additional data to the project generator (used to export the mbed code to various 3rd party tools and IDEs). A definition for `progen` looks like this: + +``` +"progen": { + "target": "lpc11u35_401", + "uvision": { + "template": ["uvision_microlib.uvproj.tmpl"] + } +``` + +The `target` property of `progen` specifies the target name that must be used for the exporter (if different than the mbed target name). +For each exporter, a template for exporting can also be specified. In this example, the template used for generating a uVision project file is in a file called `uvision_microlib.uvproj.tmpl`. It is assumed that all the templates are located in `tools/export`. diff --git a/tools/targets.json b/tools/targets.json new file mode 100644 index 00000000000..e672ed698cf --- /dev/null +++ b/tools/targets.json @@ -0,0 +1,1493 @@ +{ + "Target": { + "core": null, + "default_toolchain": "ARM", + "supported_toolchains": null, + "extra_labels": [], + "is_disk_virtual": false, + "macros": [], + "detect_code": [], + "public": false + }, + "CM4_UARM": { + "inherits": ["Target"], + "core": "Cortex-M4", + "default_toolchain": "uARM", + "public": false, + "supported_toolchains": ["uARM"] + }, + "CM4_ARM": { + "inherits": ["Target"], + "core": "Cortex-M4", + "public": false, + "supported_toolchains": ["ARM"] + }, + "CM4F_UARM": { + "inherits": ["Target"], + "core": "Cortex-M4F", + "default_toolchain": "uARM", + "public": false, + "supported_toolchains": ["uARM"] + }, + "CM4F_ARM": { + "inherits": ["Target"], + "core": "Cortex-M4F", + "public": false, + "supported_toolchains": ["ARM"] + }, + "LPCTarget": { + "inherits": ["Target"], + "post_binary_hook": { + "function": "LPCTargetCode.lpc_patch" + }, + "public": false + }, + "LPC11C24": { + "inherits": ["LPCTarget"], + "core": "Cortex-M0", + "progen": {"target": "lpc11c24_301"}, + "extra_labels": ["NXP", "LPC11XX_11CXX", "LPC11CXX"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "IAR"] + }, + "LPC1114": { + "inherits": ["LPCTarget"], + "core": "Cortex-M0", + "default_toolchain": "uARM", + "extra_labels": ["NXP", "LPC11XX_11CXX", "LPC11XX"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"], + "progen": { + "target": "lpc1114_102", + "uvision": { + "template": ["uvision_microlib.uvproj.tmpl"] + } + } + }, + "LPC11U24": { + "inherits": ["LPCTarget"], + "core": "Cortex-M0", + "default_toolchain": "uARM", + "extra_labels": ["NXP", "LPC11UXX", "LPC11U24_401"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "IAR"], + "progen": { + "target": "lpc11u24_201", + "uvision": { + "template": ["uvision_microlib.uvproj.tmpl"] + } + }, + "detect_code": ["1040"] + }, + "OC_MBUINO": { + "inherits": ["LPC11U24"], + "macros": ["TARGET_LPC11U24"], + "progen": { + "target": "lpc11u24_201", + "uvision": { + "template": ["uvision_microlib.uvproj.tmpl"] + } + }, + "extra_labels": ["NXP", "LPC11UXX"] + }, + "LPC11U24_301": { + "inherits": ["LPCTarget"], + "core": "Cortex-M0", + "extra_labels": ["NXP", "LPC11UXX"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "IAR"] + }, + "LPC11U34_421": { + "inherits": ["LPCTarget"], + "core": "Cortex-M0", + "default_toolchain": "uARM", + "extra_labels": ["NXP", "LPC11UXX"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM"] + }, + "MICRONFCBOARD": { + "inherits": ["LPC11U34_421"], + "macros": ["LPC11U34_421", "APPNEARME_MICRONFCBOARD"], + "extra_labels_add": ["APPNEARME_MICRONFCBOARD"] + }, + "LPC11U35_401": { + "inherits": ["LPCTarget"], + "core": "Cortex-M0", + "default_toolchain": "uARM", + "extra_labels": ["NXP", "LPC11UXX"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"], + "progen": { + "target": "lpc11u35_401", + "uvision": { + "template": ["uvision_microlib.uvproj.tmpl"] + } + } + }, + "LPC11U35_501": { + "inherits": ["LPCTarget"], + "core": "Cortex-M0", + "default_toolchain": "uARM", + "extra_labels": ["NXP", "LPC11UXX", "MCU_LPC11U35_501"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"], + "progen": { + "target": "lpc11u35_501", + "uvision": { + "template": ["uvision_microlib.uvproj.tmpl"] + } + } + }, + "LPC11U35_501_IBDAP": { + "inherits": ["LPCTarget"], + "core": "Cortex-M0", + "default_toolchain": "uARM", + "extra_labels": ["NXP", "LPC11UXX", "MCU_LPC11U35_501"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"], + "progen": { + "target": "lpc11u35_501", + "uvision": { + "template": ["uvision_microlib.uvproj.tmpl"] + } + } + }, + "XADOW_M0": { + "inherits": ["LPCTarget"], + "core": "Cortex-M0", + "default_toolchain": "uARM", + "extra_labels": ["NXP", "LPC11UXX", "MCU_LPC11U35_501"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"], + "progen": { + "target": "lpc11u35_501", + "uvision": { + "template": ["uvision_microlib.uvproj.tmpl"] + } + } + }, + "LPC11U35_Y5_MBUG": { + "inherits": ["LPCTarget"], + "core": "Cortex-M0", + "default_toolchain": "uARM", + "extra_labels": ["NXP", "LPC11UXX", "MCU_LPC11U35_501"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"], + "progen": { + "target": "lpc11u35_501", + "uvision": { + "template": ["uvision_microlib.uvproj.tmpl"] + } + } + }, + "LPC11U37_501": { + "inherits": ["LPCTarget"], + "core": "Cortex-M0", + "default_toolchain": "uARM", + "extra_labels": ["NXP", "LPC11UXX"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"], + "progen": { + "target": "lpc11u37_501", + "uvision": { + "template": ["uvision_microlib.uvproj.tmpl"] + } + } + }, + "LPCCAPPUCCINO": { + "inherits": ["LPC11U37_501"], + "progen": { + "target": "lpc11u37_501", + "uvision": { + "template": ["uvision_microlib.uvproj.tmpl"] + } + } + }, + "ARCH_GPRS": { + "supported_form_factors": ["ARDUINO"], + "core": "Cortex-M0", + "default_toolchain": "uARM", + "extra_labels": ["NXP", "LPC11UXX", "LPC11U37_501"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"], + "inherits": ["LPCTarget"], + "progen": { + "target": "lpc11u37_501", + "uvision": { + "template": ["uvision_microlib.uvproj.tmpl"] + } + } + }, + "LPC11U68": { + "supported_form_factors": ["ARDUINO"], + "core": "Cortex-M0+", + "default_toolchain": "uARM", + "extra_labels": ["NXP", "LPC11U6X"], + "supported_toolchains": ["ARM", "uARM", "GCC_CR", "GCC_ARM", "IAR"], + "inherits": ["LPCTarget"], + "progen": { + "target": "lpc11u68", + "uvision": { + "template": ["uvision_microlib.uvproj.tmpl"] + } + }, + "detect_code": ["1168"] + }, + "LPC1347": { + "inherits": ["LPCTarget"], + "core": "Cortex-M3", + "progen": {"target": "lpc1347"}, + "extra_labels": ["NXP", "LPC13XX"], + "supported_toolchains": ["ARM", "GCC_ARM", "IAR"] + }, + "LPC1549": { + "supported_form_factors": ["ARDUINO"], + "core": "Cortex-M3", + "default_toolchain": "uARM", + "extra_labels": ["NXP", "LPC15XX"], + "supported_toolchains": ["uARM", "GCC_CR", "GCC_ARM", "IAR"], + "inherits": ["LPCTarget"], + "progen": { + "target": "lpc1549", + "uvision": { + "template": ["uvision_microlib.uvproj.tmpl"] + } + }, + "detect_code": ["1549"] + }, + "LPC1768": { + "inherits": ["LPCTarget"], + "core": "Cortex-M3", + "extra_labels": ["NXP", "LPC176X", "MBED_LPC1768"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"], + "progen": {"target": "mbed-lpc1768"}, + "detect_code": ["1010"] + }, + "ARCH_PRO": { + "supported_form_factors": ["ARDUINO"], + "core": "Cortex-M3", + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"], + "extra_labels": ["NXP", "LPC176X"], + "macros": ["TARGET_LPC1768"], + "inherits": ["LPCTarget"], + "progen": {"target": "arch-pro"} + }, + "UBLOX_C027": { + "supported_form_factors": ["ARDUINO"], + "core": "Cortex-M3", + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"], + "extra_labels": ["NXP", "LPC176X"], + "macros": ["TARGET_LPC1768"], + "inherits": ["LPCTarget"], + "progen": {"target": "ublox-c027"} + }, + "XBED_LPC1768": { + "inherits": ["LPCTarget"], + "core": "Cortex-M3", + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"], + "extra_labels": ["NXP", "LPC176X", "XBED_LPC1768"], + "macros": ["TARGET_LPC1768"], + "progen": {"target": "lpc1768"}, + "detect_code": ["1010"] + }, + "LPC2368": { + "inherits": ["LPCTarget"], + "core": "ARM7TDMI-S", + "progen": {"target": "lpc2368"}, + "extra_labels": ["NXP", "LPC23XX"], + "supported_toolchains": ["ARM", "GCC_ARM", "GCC_CR"] + }, + "LPC2460": { + "inherits": ["LPCTarget"], + "core": "ARM7TDMI-S", + "progen": {"target": "lpc2460"}, + "extra_labels": ["NXP", "LPC2460"], + "supported_toolchains": ["GCC_ARM"] + }, + "LPC810": { + "inherits": ["LPCTarget"], + "core": "Cortex-M0+", + "default_toolchain": "uARM", + "extra_labels": ["NXP", "LPC81X"], + "is_disk_virtual": true, + "supported_toolchains": ["uARM", "IAR", "GCC_ARM"], + "progen": { + "target": "lpc810", + "uvision": { + "template": ["uvision_microlib.uvproj.tmpl"] + } + } + }, + "LPC812": { + "supported_form_factors": ["ARDUINO"], + "core": "Cortex-M0+", + "default_toolchain": "uARM", + "extra_labels": ["NXP", "LPC81X"], + "is_disk_virtual": true, + "supported_toolchains": ["uARM", "IAR", "GCC_ARM"], + "inherits": ["LPCTarget"], + "progen": { + "target": "lpc812m101", + "uvision": { + "template": ["uvision_microlib.uvproj.tmpl"] + } + }, + "detect_code": ["1050"] + }, + "LPC824": { + "supported_form_factors": ["ARDUINO"], + "core": "Cortex-M0+", + "default_toolchain": "uARM", + "extra_labels": ["NXP", "LPC82X"], + "is_disk_virtual": true, + "supported_toolchains": ["uARM", "GCC_ARM", "GCC_CR", "IAR"], + "inherits": ["LPCTarget"], + "progen": { + "target": "lpc824m201", + "uvision": { + "template": ["uvision_microlib.uvproj.tmpl"] + } + } + }, + "SSCI824": { + "inherits": ["LPCTarget"], + "core": "Cortex-M0+", + "default_toolchain": "uARM", + "extra_labels": ["NXP", "LPC82X"], + "is_disk_virtual": true, + "supported_toolchains": ["uARM", "GCC_ARM"], + "progen": { + "target": "ssci824", + "uvision": { + "template": ["uvision_microlib.uvproj.tmpl"] + } + } + }, + "LPC4088": { + "inherits": ["LPCTarget"], + "core": "Cortex-M4F", + "extra_labels": ["NXP", "LPC408X"], + "is_disk_virtual": true, + "supported_toolchains": ["ARM", "GCC_CR", "GCC_ARM", "IAR"], + "post_binary_hook": { + "function": "LPC4088Code.binary_hook", + "toolchains": ["ARM_STD", "ARM_MICRO"] + }, + "progen": {"target": "lpc4088"} + }, + "LPC4088_DM": { + "inherits": ["LPC4088"] + }, + "LPC4330_M4": { + "inherits": ["LPCTarget"], + "core": "Cortex-M4F", + "progen": {"target": "lpc4330"}, + "extra_labels": ["NXP", "LPC43XX", "LPC4330"], + "supported_toolchains": ["ARM", "GCC_CR", "IAR", "GCC_ARM"] + }, + "LPC4330_M0": { + "inherits": ["LPCTarget"], + "core": "Cortex-M0", + "extra_labels": ["NXP", "LPC43XX", "LPC4330"], + "supported_toolchains": ["ARM", "GCC_CR", "IAR"] + }, + "LPC4337": { + "inherits": ["LPCTarget"], + "core": "Cortex-M4F", + "progen": {"target": "lpc4337"}, + "extra_labels": ["NXP", "LPC43XX", "LPC4337"], + "supported_toolchains": ["ARM"] + }, + "LPC1800": { + "inherits": ["LPCTarget"], + "core": "Cortex-M3", + "extra_labels": ["NXP", "LPC43XX"], + "public": false, + "supported_toolchains": ["ARM", "GCC_CR", "IAR"] + }, + "LPC11U37H_401": { + "supported_form_factors": ["ARDUINO"], + "core": "Cortex-M0", + "default_toolchain": "uARM", + "extra_labels": ["NXP", "LPC11UXX"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "GCC_CR"], + "inherits": ["LPCTarget"], + "progen": { + "target": "lpc11u37_401", + "uvision": { + "template": ["uvision_microlib.uvproj.tmpl"] + } + } + }, + "KL05Z": { + "supported_form_factors": ["ARDUINO"], + "core": "Cortex-M0+", + "default_toolchain": "uARM", + "extra_labels": ["Freescale", "KLXX"], + "is_disk_virtual": true, + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "IAR"], + "inherits": ["Target"], + "progen": { + "target": "frdm-kl05z", + "uvision": { + "template": ["uvision_microlib.uvproj.tmpl"] + } + } + }, + "KL25Z": { + "supported_form_factors": ["ARDUINO"], + "core": "Cortex-M0+", + "extra_labels": ["Freescale", "KLXX"], + "is_disk_virtual": true, + "supported_toolchains": ["ARM", "GCC_ARM", "IAR"], + "inherits": ["Target"], + "progen": {"target": "frdm-kl25z"}, + "detect_code": ["0200"] + }, + "KL26Z": { + "supported_form_factors": ["ARDUINO"], + "core": "Cortex-M0+", + "extra_labels": ["Freescale", "KLXX"], + "is_disk_virtual": true, + "supported_toolchains": ["ARM", "GCC_ARM", "IAR"], + "inherits": ["Target"], + "progen": {"target": "kl26z"} + }, + "KL43Z": { + "supported_form_factors": ["ARDUINO"], + "core": "Cortex-M0+", + "extra_labels": ["Freescale", "KLXX"], + "is_disk_virtual": true, + "supported_toolchains": ["GCC_ARM", "ARM"], + "inherits": ["Target"], + "progen": {"target": "frdm-kl43z"} + }, + "KL46Z": { + "supported_form_factors": ["ARDUINO"], + "core": "Cortex-M0+", + "extra_labels": ["Freescale", "KLXX"], + "is_disk_virtual": true, + "supported_toolchains": ["GCC_ARM", "ARM", "IAR"], + "inherits": ["Target"], + "progen": {"target": "frdm-kl46z"}, + "detect_code": ["0220"] + }, + "K20D50M": { + "inherits": ["Target"], + "core": "Cortex-M4", + "extra_labels": ["Freescale", "K20XX"], + "is_disk_virtual": true, + "supported_toolchains": ["GCC_ARM", "ARM", "IAR"], + "progen": {"target": "frdm-k20d50m"}, + "detect_code": ["0230"] + }, + "TEENSY3_1": { + "inherits": ["Target"], + "core": "Cortex-M4", + "extra_labels": ["Freescale", "K20XX", "K20DX256"], + "OUTPUT_EXT": "hex", + "is_disk_virtual": true, + "supported_toolchains": ["GCC_ARM", "ARM"], + "post_binary_hook": { + "function": "TEENSY3_1Code.binary_hook", + "toolchains": ["ARM_STD", "ARM_MICRO", "GCC_ARM"] + }, + "progen": {"target": "teensy-31"}, + "detect_code": ["0230"] + }, + "K22F": { + "supported_form_factors": ["ARDUINO"], + "core": "Cortex-M4F", + "supported_toolchains": ["ARM", "GCC_ARM", "IAR"], + "extra_labels": ["Freescale", "KPSDK_MCUS", "KPSDK_CODE"], + "is_disk_virtual": true, + "macros": ["CPU_MK22FN512VLH12", "FSL_RTOS_MBED"], + "inherits": ["Target"], + "progen": {"target": "frdm-k22f"}, + "detect_code": ["0201"] + }, + "K64F": { + "supported_form_factors": ["ARDUINO"], + "core": "Cortex-M4F", + "supported_toolchains": ["ARM", "GCC_ARM", "IAR"], + "extra_labels": ["Freescale", "KPSDK_MCUS", "KPSDK_CODE", "MCU_K64F", "FRDM"], + "is_disk_virtual": true, + "macros": ["CPU_MK64FN1M0VMD12", "FSL_RTOS_MBED"], + "inherits": ["Target"], + "progen": {"target": "frdm-k64f"}, + "detect_code": ["0240"] + }, + "K64F_UV": { + "inherits": ["K64F"], + "core": "Cortex-M4", + "extra_labels_add": ["K64F"], + "macros_add": ["TARGET_K64F"] + }, + "MTS_GAMBIT": { + "inherits": ["Target"], + "core": "Cortex-M4F", + "supported_toolchains": ["ARM", "GCC_ARM"], + "extra_labels": ["Freescale", "KPSDK_MCUS", "KPSDK_CODE", "MCU_K64F"], + "is_disk_virtual": true, + "macros": ["CPU_MK64FN1M0VMD12", "FSL_RTOS_MBED", "TARGET_K64F"], + "progen": {"target": "mts-gambit"} + }, + "NUCLEO_F030R8": { + "supported_form_factors": ["ARDUINO", "MORPHO"], + "core": "Cortex-M0", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32F0", "STM32F030R8"], + "supported_toolchains": ["ARM", "uARM", "IAR", "GCC_ARM"], + "inherits": ["Target"], + "progen": {"target": "nucleo-f030r8"}, + "detect_code": ["0725"] + }, + "NUCLEO_F031K6": { + "supported_form_factors": ["ARDUINO"], + "core": "Cortex-M0", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32F0", "STM32F031K6"], + "supported_toolchains": ["ARM", "uARM", "IAR", "GCC_ARM"], + "inherits": ["Target"], + "progen": {"target": "nucleo-f031k6"}, + "detect_code": ["0791"] + }, + "NUCLEO_F042K6": { + "supported_form_factors": ["ARDUINO"], + "core": "Cortex-M0", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32F0", "STM32F042K6"], + "supported_toolchains": ["ARM", "uARM", "IAR", "GCC_ARM"], + "inherits": ["Target"], + "progen": {"target": "nucleo-f042k6"}, + "detect_code": ["0785"] + }, + "NUCLEO_F070RB": { + "supported_form_factors": ["ARDUINO", "MORPHO"], + "core": "Cortex-M0", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32F0", "STM32F070RB"], + "supported_toolchains": ["ARM", "uARM", "IAR", "GCC_ARM"], + "inherits": ["Target"], + "progen": {"target": "nucleo-f070rb"}, + "detect_code": ["0755"] + }, + "NUCLEO_F072RB": { + "supported_form_factors": ["ARDUINO", "MORPHO"], + "core": "Cortex-M0", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32F0", "STM32F072RB"], + "supported_toolchains": ["ARM", "uARM", "IAR", "GCC_ARM"], + "inherits": ["Target"], + "progen": {"target": "nucleo-f072rb"}, + "detect_code": ["0730"] + }, + "NUCLEO_F091RC": { + "supported_form_factors": ["ARDUINO", "MORPHO"], + "core": "Cortex-M0", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32F0", "STM32F091RC"], + "supported_toolchains": ["ARM", "uARM", "IAR", "GCC_ARM"], + "inherits": ["Target"], + "progen": {"target": "nucleo-f091rc"}, + "detect_code": ["0750"] + }, + "NUCLEO_F103RB": { + "supported_form_factors": ["ARDUINO", "MORPHO"], + "core": "Cortex-M3", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32F1", "STM32F103RB"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "IAR"], + "inherits": ["Target"], + "progen": {"target": "nucleo-f103rb"}, + "detect_code": ["0700"] + }, + "NUCLEO_F302R8": { + "supported_form_factors": ["ARDUINO", "MORPHO"], + "core": "Cortex-M4F", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32F3", "STM32F302R8"], + "supported_toolchains": ["ARM", "uARM", "IAR", "GCC_ARM"], + "inherits": ["Target"], + "progen": {"target": "nucleo-f302r8"}, + "detect_code": ["0705"] + }, + "NUCLEO_F303K8": { + "supported_form_factors": ["ARDUINO"], + "core": "Cortex-M4F", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32F3", "STM32F303K8"], + "supported_toolchains": ["ARM", "uARM", "IAR", "GCC_ARM"], + "inherits": ["Target"], + "progen": {"target": "nucleo-f303k8"}, + "detect_code": ["0775"] + }, + "NUCLEO_F303RE": { + "supported_form_factors": ["ARDUINO", "MORPHO"], + "core": "Cortex-M4F", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32F3", "STM32F303RE"], + "supported_toolchains": ["ARM", "uARM", "IAR", "GCC_ARM"], + "inherits": ["Target"], + "progen": {"target": "nucleo-f303re"}, + "detect_code": ["0745"] + }, + "NUCLEO_F334R8": { + "supported_form_factors": ["ARDUINO", "MORPHO"], + "core": "Cortex-M4F", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32F3", "STM32F334R8"], + "supported_toolchains": ["ARM", "uARM", "IAR", "GCC_ARM"], + "inherits": ["Target"], + "progen": {"target": "nucleo-f334r8"}, + "detect_code": ["0735"] + }, + "NUCLEO_F401RE": { + "supported_form_factors": ["ARDUINO", "MORPHO"], + "core": "Cortex-M4F", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32F4", "STM32F401RE"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "IAR"], + "inherits": ["Target"], + "progen": {"target": "nucleo-f401re"}, + "detect_code": ["0720"] + }, + "NUCLEO_F410RB": { + "supported_form_factors": ["ARDUINO", "MORPHO"], + "core": "Cortex-M4F", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32F4", "STM32F410RB"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "IAR"], + "inherits": ["Target"], + "progen": {"target": "nucleo-f410rb"}, + "detect_code": ["0740"] + }, + "NUCLEO_F411RE": { + "supported_form_factors": ["ARDUINO", "MORPHO"], + "core": "Cortex-M4F", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32F4", "STM32F411RE"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "IAR"], + "inherits": ["Target"], + "progen": {"target": "nucleo-f411re"}, + "detect_code": ["0740"] + }, + "ELMO_F411RE": { + "supported_form_factors": ["ARDUINO"], + "core": "Cortex-M4F", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32F4", "STM32F411RE"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM"], + "inherits": ["Target"], + "detect_code": ["----"] + }, + "NUCLEO_F446RE": { + "supported_form_factors": ["ARDUINO", "MORPHO"], + "core": "Cortex-M4F", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32F4", "STM32F446RE"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "IAR"], + "inherits": ["Target"], + "progen": {"target": "nucleo-f446re"}, + "detect_code": ["0777"] + }, + "B96B_F446VE": { + "supported_form_factors": ["ARDUINO", "MORPHO"], + "core": "Cortex-M4F", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32F4", "STM32F446VE"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "IAR"], + "inherits": ["Target"], + "detect_code": ["0840"] + }, + "NUCLEO_F746ZG": { + "inherits": ["Target"], + "core": "Cortex-M7F", + "extra_labels": ["STM", "STM32F7", "STM32F746", "STM32F746ZG"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "IAR"], + "progen": { + "target": "nucleo-f746zg", + "iar": { + "template": ["iar_nucleo_f746zg.ewp.tmpl"] + } + }, + "detect_code": ["0816"] + }, + "NUCLEO_L053R8": { + "supported_form_factors": ["ARDUINO", "MORPHO"], + "core": "Cortex-M0+", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32L0", "STM32L053R8"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "IAR"], + "inherits": ["Target"], + "progen": {"target": "nucleo-l053r8"}, + "detect_code": ["0715"] + }, + "NUCLEO_L073RZ": { + "supported_form_factors": ["ARDUINO", "MORPHO"], + "core": "Cortex-M0+", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32L0", "STM32L073RZ"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "IAR"], + "inherits": ["Target"], + "progen": {"target": "nucleo-l073rz"}, + "detect_code": ["0760"] + }, + "NUCLEO_L152RE": { + "supported_form_factors": ["ARDUINO", "MORPHO"], + "core": "Cortex-M3", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32L1", "STM32L152RE"], + "supported_toolchains": ["ARM", "uARM", "IAR", "GCC_ARM"], + "inherits": ["Target"], + "progen": {"target": "nucleo-l152re"}, + "detect_code": ["0710"] + }, + "NUCLEO_L476RG": { + "supported_form_factors": ["ARDUINO", "MORPHO"], + "core": "Cortex-M4F", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32L4", "STM32L476RG"], + "supported_toolchains": ["ARM", "uARM", "IAR", "GCC_ARM"], + "inherits": ["Target"], + "progen": {"target": "nucleo-l476rg"}, + "detect_code": ["0765"] + }, + "STM32F3XX": { + "inherits": ["Target"], + "core": "Cortex-M4", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32F3XX"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM"] + }, + "STM32F407": { + "inherits": ["Target"], + "core": "Cortex-M4F", + "extra_labels": ["STM", "STM32F4", "STM32F4XX"], + "supported_toolchains": ["ARM", "GCC_ARM", "IAR"] + }, + "ARCH_MAX": { + "supported_form_factors": ["ARDUINO"], + "core": "Cortex-M4F", + "supported_toolchains": ["ARM", "uARM", "GCC_ARM"], + "program_cycle_s": 2, + "extra_labels": ["STM", "STM32F4", "STM32F407", "STM32F407VG"], + "macros": ["LSI_VALUE=32000"], + "inherits": ["Target"], + "progen": {"target": "lpc1768"} + }, + "DISCO_F051R8": { + "inherits": ["Target"], + "core": "Cortex-M0", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32F0", "STM32F051", "STM32F051R8"], + "supported_toolchains": ["GCC_ARM"] + }, + "DISCO_F100RB": { + "inherits": ["Target"], + "core": "Cortex-M3", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32F1", "STM32F100RB"], + "supported_toolchains": ["GCC_ARM"] + }, + "DISCO_F303VC": { + "inherits": ["Target"], + "core": "Cortex-M4F", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32F3", "STM32F303", "STM32F303VC"], + "supported_toolchains": ["GCC_ARM"] + }, + "DISCO_F334C8": { + "inherits": ["Target"], + "core": "Cortex-M4F", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32F3", "STM32F334C8"], + "supported_toolchains": ["ARM", "uARM", "IAR", "GCC_ARM"], + "progen": {"target": "disco-f334c8"}, + "detect_code": ["0810"] + }, + "DISCO_F407VG": { + "inherits": ["Target"], + "core": "Cortex-M4F", + "progen": {"target": "disco-f407vg"}, + "extra_labels": ["STM", "STM32F4", "STM32F407", "STM32F407VG"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM"] + }, + "DISCO_F429ZI": { + "inherits": ["Target"], + "core": "Cortex-M4F", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32F4", "STM32F429", "STM32F429ZI"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "IAR"], + "progen": { + "target": "" + } + }, + "DISCO_F469NI": { + "supported_form_factors": ["ARDUINO"], + "core": "Cortex-M4F", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32F4", "STM32F469", "STM32F469NI"], + "supported_toolchains": ["ARM", "uARM", "IAR", "GCC_ARM"], + "inherits": ["Target"], + "progen": {"target": "disco-f469ni"}, + "detect_code": ["0788"] + }, + "DISCO_L053C8": { + "inherits": ["Target"], + "core": "Cortex-M0+", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32L0", "STM32L053C8"], + "supported_toolchains": ["ARM", "uARM", "IAR", "GCC_ARM"], + "progen": {"target": "disco-l053c8"} + }, + "DISCO_F746NG": { + "inherits": ["Target"], + "core": "Cortex-M7F", + "extra_labels": ["STM", "STM32F7", "STM32F746", "STM32F746NG"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "IAR"], + "progen": {"target": "disco-f746ng"}, + "detect_code": ["0815"] + }, + "DISCO_L476VG": { + "inherits": ["Target"], + "core": "Cortex-M4F", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32L4", "STM32L476VG"], + "supported_toolchains": ["ARM", "uARM", "IAR", "GCC_ARM"], + "progen": {"target": "disco-l476vg"}, + "detect_code": ["0820"] + }, + "MTS_MDOT_F405RG": { + "inherits": ["Target"], + "core": "Cortex-M4F", + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "IAR"], + "extra_labels": ["STM", "STM32F4", "STM32F405RG"], + "is_disk_virtual": true, + "macros": ["HSE_VALUE=26000000", "OS_CLOCK=48000000"], + "progen": {"target": "mts-mdot-f405rg"} + }, + "MTS_MDOT_F411RE": { + "inherits": ["Target"], + "core": "Cortex-M4F", + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "IAR"], + "extra_labels": ["STM", "STM32F4", "STM32F411RE"], + "macros": ["HSE_VALUE=26000000", "OS_CLOCK=96000000", "USE_PLL_HSE_EXTC=0", "VECT_TAB_OFFSET=0x00010000"], + "post_binary_hook": { + "function": "MTSCode.combine_bins_mts_dot", + "toolchains": ["GCC_ARM", "ARM_STD", "ARM_MICRO"] + }, + "progen": {"target": "mts-mdot-f411re"} + }, + "MTS_DRAGONFLY_F411RE": { + "inherits": ["Target"], + "core": "Cortex-M4F", + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "IAR"], + "extra_labels": ["STM", "STM32F4", "STM32F411RE"], + "macros": ["HSE_VALUE=26000000", "VECT_TAB_OFFSET=0x08010000"], + "post_binary_hook": { + "function": "MTSCode.combine_bins_mts_dragonfly", + "toolchains": ["GCC_ARM", "ARM_STD", "ARM_MICRO"] + }, + "progen": {"target": "mts-dragonfly-f411re"} + }, + "MOTE_L152RC": { + "inherits": ["Target"], + "core": "Cortex-M3", + "default_toolchain": "uARM", + "extra_labels": ["STM", "STM32L1", "STM32L152RC"], + "supported_toolchains": ["ARM", "uARM", "IAR", "GCC_ARM"], + "progen": {"target": "stm32l151rc"}, + "detect_code": ["4100"] + }, + "DISCO_F401VC": { + "inherits": ["Target"], + "core": "Cortex-M4F", + "default_toolchain": "GCC_ARM", + "extra_labels": ["STM", "STM32F4", "STM32F401", "STM32F401VC"], + "supported_toolchains": ["GCC_ARM"] + }, + "UBLOX_C029": { + "supported_form_factors": ["ARDUINO"], + "core": "Cortex-M4F", + "default_toolchain": "uARM", + "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "IAR"], + "extra_labels": ["STM", "STM32F4", "STM32F439", "STM32F439ZI"], + "macros": ["HSE_VALUE=24000000", "HSE_STARTUP_TIMEOUT=5000"], + "inherits": ["Target"] + }, + "NZ32_SC151": { + "inherits": ["Target"], + "core": "Cortex-M3", + "default_toolchain": "uARM", + "program_cycle_s": 1.5, + "extra_labels": ["STM", "STM32L1", "STM32L151RC"], + "supported_toolchains": ["ARM", "uARM", "GCC_ARM"], + "progen": {"target": "stm32l151rc"} + }, + "MCU_NRF51": { + "inherits": ["Target"], + "core": "Cortex-M0", + "OVERRIDE_BOOTLOADER_FILENAME": "nrf51822_bootloader.hex", + "macros": ["NRF51", "TARGET_NRF51822"], + "MERGE_BOOTLOADER": false, + "extra_labels": ["NORDIC", "MCU_NRF51", "MCU_NRF51822"], + "OUTPUT_EXT": "hex", + "is_disk_virtual": true, + "supported_toolchains": ["ARM", "GCC_ARM"], + "public": false, + "MERGE_SOFT_DEVICE": true, + "EXPECTED_SOFTDEVICES_WITH_OFFSETS": [ + { + "boot": "s130_nrf51_1.0.0_bootloader.hex", + "name": "s130_nrf51_1.0.0_softdevice.hex", + "offset": 114688 + }, + { + "boot": "s110_nrf51822_8.0.0_bootloader.hex", + "name": "s110_nrf51822_8.0.0_softdevice.hex", + "offset": 98304 + }, + { + "boot": "s110_nrf51822_7.1.0_bootloader.hex", + "name": "s110_nrf51822_7.1.0_softdevice.hex", + "offset": 90112 + }, + { + "boot": "s110_nrf51822_7.0.0_bootloader.hex", + "name": "s110_nrf51822_7.0.0_softdevice.hex", + "offset": 90112 + }, + { + "boot": "s110_nrf51822_6.0.0_bootloader.hex", + "name": "s110_nrf51822_6.0.0_softdevice.hex", + "offset": 81920 + } + ], + "detect_code": ["1070"], + "post_binary_hook": { + "function": "MCU_NRF51Code.binary_hook", + "toolchains": ["ARM_STD", "GCC_ARM"] + }, + "program_cycle_s": 6 + }, + "MCU_NRF51_16K_BASE": { + "inherits": ["MCU_NRF51"], + "extra_labels_add": ["MCU_NORDIC_16K", "MCU_NRF51_16K"], + "macros_add": ["TARGET_MCU_NORDIC_16K", "TARGET_MCU_NRF51_16K"], + "public": false + }, + "MCU_NRF51_16K_BOOT_BASE": { + "inherits": ["MCU_NRF51_16K_BASE"], + "MERGE_BOOTLOADER": true, + "extra_labels_add": ["MCU_NRF51_16K_BOOT"], + "macros_add": ["TARGET_MCU_NRF51_16K_BOOT", "TARGET_OTA_ENABLED"], + "public": false + }, + "MCU_NRF51_16K_OTA_BASE": { + "inherits": ["MCU_NRF51_16K_BASE"], + "public": false, + "extra_labels_add": ["MCU_NRF51_16K_OTA"], + "macros_add": ["TARGET_MCU_NRF51_16K_OTA", "TARGET_OTA_ENABLED"], + "MERGE_SOFT_DEVICE": false + }, + "MCU_NRF51_16K": { + "inherits": ["MCU_NRF51_16K_BASE"], + "extra_labels_add": ["MCU_NRF51_16K_S130"], + "macros_add": ["TARGET_MCU_NRF51_16K_S130"], + "public": false + }, + "MCU_NRF51_S110": { + "extra_labels_add": ["MCU_NRF51_16K_S110"], + "macros_add": ["TARGET_MCU_NRF51_16K_S110"], + "EXPECTED_SOFTDEVICES_WITH_OFFSETS": [ + { + "name" : "s110_nrf51822_8.0.0_softdevice.hex", + "boot" : "s110_nrf51822_8.0.0_bootloader.hex", + "offset" : 98304 + }, + { + "name" : "s110_nrf51822_7.1.0_softdevice.hex", + "boot" : "s110_nrf51822_7.1.0_bootloader.hex", + "offset" : 90112 + } + ], + "public": false + }, + "MCU_NRF51_16K_S110": { + "inherits": ["MCU_NRF51_S110", "MCU_NRF51_16K_BASE"], + "public": false + }, + "MCU_NRF51_16K_BOOT": { + "inherits": ["MCU_NRF51_16K_BOOT_BASE"], + "extra_labels_add": ["MCU_NRF51_16K_S130"], + "macros_add": ["TARGET_MCU_NRF51_16K_S130"], + "public": false + }, + "MCU_NRF51_16K_BOOT_S110": { + "inherits": ["MCU_NRF51_S110", "MCU_NRF51_16K_BOOT_BASE"], + "public": false + }, + "MCU_NRF51_16K_OTA": { + "inherits": ["MCU_NRF51_16K_OTA_BASE"], + "extra_labels_add": ["MCU_NRF51_16K_S130"], + "macros_add": ["TARGET_MCU_NRF51_16K_S130"], + "public": false + }, + "MCU_NRF51_16K_OTA_S110": { + "inherits": ["MCU_NRF51_S110", "MCU_NRF51_16K_OTA_BASE"], + "public": false + }, + "MCU_NRF51_32K": { + "inherits": ["MCU_NRF51"], + "extra_labels_add": ["MCU_NORDIC_32K", "MCU_NRF51_32K"], + "macros_add": ["TARGET_MCU_NORDIC_32K", "TARGET_MCU_NRF51_32K"], + "public": false + }, + "MCU_NRF51_32K_BOOT": { + "inherits": ["MCU_NRF51_32K"], + "MERGE_BOOTLOADER": true, + "extra_labels_add": ["MCU_NRF51_32K_BOOT"], + "macros_add": ["TARGET_MCU_NRF51_32K_BOOT", "TARGET_OTA_ENABLED"], + "public": false + }, + "MCU_NRF51_32K_OTA": { + "inherits": ["MCU_NRF51_32K"], + "public": false, + "extra_labels_add": ["MCU_NRF51_32K_OTA"], + "macros_add": ["TARGET_MCU_NRF51_32K_OTA", "TARGET_OTA_ENABLED"], + "MERGE_SOFT_DEVICE": false + }, + "NRF51822": { + "inherits": ["MCU_NRF51_16K"], + "progen": {"target": "mkit"}, + "extra_labels_add": ["NRF51822", "NRF51822_MKIT"], + "macros_add": ["TARGET_NRF51822_MKIT"] + }, + "NRF51822_BOOT": { + "inherits": ["MCU_NRF51_16K_BOOT"], + "extra_labels_add": ["NRF51822", "NRF51822_MKIT"], + "macros_add": ["TARGET_NRF51822_MKIT"] + }, + "NRF51822_OTA": { + "inherits": ["MCU_NRF51_16K_OTA"], + "extra_labels_add": ["NRF51822", "NRF51822_MKIT"], + "macros_add": ["TARGET_NRF51822_MKIT"] + }, + "ARCH_BLE": { + "supported_form_factors": ["ARDUINO"], + "inherits": ["MCU_NRF51_16K"], + "progen": {"target": "arch-ble"} + }, + "ARCH_BLE_BOOT": { + "supported_form_factors": ["ARDUINO"], + "inherits": ["MCU_NRF51_16K_BOOT"], + "extra_labels_add": ["ARCH_BLE"], + "macros_add": ["TARGET_ARCH_BLE"] + }, + "ARCH_BLE_OTA": { + "supported_form_factors": ["ARDUINO"], + "inherits": ["MCU_NRF51_16K_OTA"], + "extra_labels_add": ["ARCH_BLE"], + "macros_add": ["TARGET_ARCH_BLE"] + }, + "ARCH_LINK": { + "supported_form_factors": ["ARDUINO"], + "inherits": ["MCU_NRF51_16K"], + "extra_labels_add": ["ARCH_BLE"], + "macros_add": ["TARGET_ARCH_BLE"] + }, + "ARCH_LINK_BOOT": { + "supported_form_factors": ["ARDUINO"], + "inherits": ["MCU_NRF51_16K_BOOT"], + "extra_labels_add": ["ARCH_BLE", "ARCH_LINK"], + "macros_add": ["TARGET_ARCH_BLE", "TARGET_ARCH_LINK"] + }, + "ARCH_LINK_OTA": { + "supported_form_factors": ["ARDUINO"], + "inherits": ["MCU_NRF51_16K_OTA"], + "extra_labels_add": ["ARCH_BLE", "ARCH_LINK"], + "macros_add": ["TARGET_ARCH_BLE", "TARGET_ARCH_LINK"] + }, + "SEEED_TINY_BLE": { + "inherits": ["MCU_NRF51_16K"], + "progen": {"target": "seed-tinyble"} + }, + "SEEED_TINY_BLE_BOOT": { + "inherits": ["MCU_NRF51_16K_BOOT"], + "extra_labels_add": ["SEEED_TINY_BLE"], + "macros_add": ["TARGET_SEEED_TINY_BLE"] + }, + "SEEED_TINY_BLE_OTA": { + "inherits": ["MCU_NRF51_16K_OTA"], + "extra_labels_add": ["SEEED_TINY_BLE"], + "macros_add": ["TARGET_SEEED_TINY_BLE"] + }, + "HRM1017": { + "inherits": ["MCU_NRF51_16K"], + "progen": {"target": "hrm1017"}, + "macros_add": ["TARGET_NRF_LFCLK_RC"] + }, + "HRM1017_BOOT": { + "inherits": ["MCU_NRF51_16K_BOOT"], + "extra_labels_add": ["HRM1017"], + "macros_add": ["TARGET_HRM1017", "TARGET_NRF_LFCLK_RC"] + }, + "HRM1017_OTA": { + "inherits": ["MCU_NRF51_16K_OTA"], + "extra_labels_add": ["HRM1017"], + "macros_add": ["TARGET_HRM1017", "TARGET_NRF_LFCLK_RC"] + }, + "RBLAB_NRF51822": { + "supported_form_factors": ["ARDUINO"], + "inherits": ["MCU_NRF51_16K"], + "progen": {"target": "rblab-nrf51822"} + }, + "RBLAB_NRF51822_BOOT": { + "supported_form_factors": ["ARDUINO"], + "inherits": ["MCU_NRF51_16K_BOOT"], + "extra_labels_add": ["RBLAB_NRF51822"], + "macros_add": ["TARGET_RBLAB_NRF51822"] + }, + "RBLAB_NRF51822_OTA": { + "supported_form_factors": ["ARDUINO"], + "inherits": ["MCU_NRF51_16K_OTA"], + "extra_labels_add": ["RBLAB_NRF51822"], + "macros_add": ["TARGET_RBLAB_NRF51822"] + }, + "RBLAB_BLENANO": { + "inherits": ["MCU_NRF51_16K"] + }, + "RBLAB_BLENANO_BOOT": { + "inherits": ["MCU_NRF51_16K_BOOT"], + "extra_labels_add": ["RBLAB_BLENANO"], + "macros_add": ["TARGET_RBLAB_BLENANO"] + }, + "RBLAB_BLENANO_OTA": { + "inherits": ["MCU_NRF51_16K_OTA"], + "extra_labels_add": ["RBLAB_BLENANO"], + "macros_add": ["TARGET_RBLAB_BLENANO"] + }, + "NRF51822_Y5_MBUG": { + "inherits": ["MCU_NRF51_16K"] + }, + "WALLBOT_BLE": { + "inherits": ["MCU_NRF51_16K"] + }, + "WALLBOT_BLE_BOOT": { + "inherits": ["MCU_NRF51_16K_BOOT"], + "extra_labels_add": ["WALLBOT_BLE"], + "macros_add": ["TARGET_WALLBOT_BLE"] + }, + "WALLBOT_BLE_OTA": { + "inherits": ["MCU_NRF51_16K_OTA"], + "extra_labels_add": ["WALLBOT_BLE"], + "macros_add": ["TARGET_WALLBOT_BLE"] + }, + "DELTA_DFCM_NNN40": { + "inherits": ["MCU_NRF51_32K"], + "program_cycle_s": 10, + "progen": {"target": "dfcm-nnn40"}, + "macros_add": ["TARGET_NRF_LFCLK_RC"] + }, + "DELTA_DFCM_NNN40_BOOT": { + "inherits": ["MCU_NRF51_32K_BOOT"], + "program_cycle_s": 10, + "extra_labels_add": ["DELTA_DFCM_NNN40"], + "macros_add": ["TARGET_DELTA_DFCM_NNN40", "TARGET_NRF_LFCLK_RC"] + }, + "DELTA_DFCM_NNN40_OTA": { + "inherits": ["MCU_NRF51_32K_OTA"], + "program_cycle_s": 10, + "extra_labels_add": ["DELTA_DFCM_NNN40"], + "macros_add": ["TARGET_DELTA_DFCM_NNN40", "TARGET_NRF_LFCLK_RC"] + }, + "NRF51_DK": { + "supported_form_factors": ["ARDUINO"], + "inherits": ["MCU_NRF51_32K"], + "progen": {"target": "nrf51-dk"} + }, + "NRF51_DK_BOOT": { + "supported_form_factors": ["ARDUINO"], + "inherits": ["MCU_NRF51_32K_BOOT"], + "extra_labels_add": ["NRF51_DK"], + "macros_add": ["TARGET_NRF51_DK"] + }, + "NRF51_DK_OTA": { + "supported_form_factors": ["ARDUINO"], + "inherits": ["MCU_NRF51_32K_OTA"], + "extra_labels_add": ["NRF51_DK"], + "macros_add": ["TARGET_NRF51_DK"] + }, + "NRF51_DONGLE": { + "inherits": ["MCU_NRF51_32K"], + "progen": {"target": "nrf51-dongle"} + }, + "NRF51_DONGLE_BOOT": { + "inherits": ["MCU_NRF51_32K_BOOT"], + "extra_labels_add": ["NRF51_DONGLE"], + "macros_add": ["TARGET_NRF51_DONGLE"] + }, + "NRF51_DONGLE_OTA": { + "inherits": ["MCU_NRF51_32K_OTA"], + "extra_labels_add": ["NRF51_DONGLE"], + "macros_add": ["TARGET_NRF51_DONGLE"] + }, + "NRF51_MICROBIT": { + "inherits": ["MCU_NRF51_16K_S110"], + "macros_add": ["TARGET_NRF_LFCLK_RC"] + }, + "NRF51_MICROBIT_BOOT": { + "inherits": ["MCU_NRF51_16K_BOOT_S110"], + "extra_labels_add": ["NRF51_MICROBIT"], + "macros_add": ["TARGET_NRF51_MICROBIT", "TARGET_NRF_LFCLK_RC"] + }, + "NRF51_MICROBIT_OTA": { + "inherits": ["MCU_NRF51_16K_OTA_S110"], + "extra_labels_add": ["NRF51_MICROBIT"], + "macros_add": ["TARGET_NRF51_MICROBIT", "TARGET_NRF_LFCLK_RC"] + }, + "NRF51_MICROBIT_B": { + "inherits": ["MCU_NRF51_16K"], + "extra_labels_add": ["NRF51_MICROBIT"], + "macros_add": ["TARGET_NRF51_MICROBIT", "TARGET_NRF_LFCLK_RC"] + }, + "NRF51_MICROBIT_B_BOOT": { + "inherits": ["MCU_NRF51_16K_BOOT"], + "extra_labels_add": ["NRF51_MICROBIT"], + "macros_add": ["TARGET_NRF51_MICROBIT", "TARGET_NRF_LFCLK_RC"] + }, + "NRF51_MICROBIT_B_OTA": { + "inherits": ["MCU_NRF51_16K_OTA"], + "extra_labels_add": ["NRF51_MICROBIT"], + "macros_add": ["TARGET_NRF51_MICROBIT", "TARGET_NRF_LFCLK_RC"] + }, + "TY51822R3": { + "inherits": ["MCU_NRF51_32K"], + "macros_add": ["TARGET_NRF_32MHZ_XTAL"] + }, + "TY51822R3_BOOT": { + "inherits": ["MCU_NRF51_32K_BOOT"], + "extra_labels_add": ["TY51822R3"], + "macros_add": ["TARGET_TY51822R3", "TARGET_NRF_32MHZ_XTAL"] + }, + "TY51822R3_OTA": { + "inherits": ["MCU_NRF51_32K_OTA"], + "extra_labels_add": ["NRF51_DK"], + "macros_add": ["TARGET_TY51822R3", "TARGET_NRF_32MHZ_XTAL"] + }, + "ARM_MPS2_Target": { + "inherits": ["Target"], + "public": false + }, + "ARM_MPS2_M0": { + "inherits": ["ARM_MPS2_Target"], + "core": "Cortex-M0", + "supported_toolchains": ["ARM"], + "extra_labels": ["ARM_SSG", "MPS2", "MPS2_M0"], + "macros": ["CMSDK_CM0"] + }, + "ARM_MPS2_M0P": { + "inherits": ["ARM_MPS2_Target"], + "core": "Cortex-M0+", + "supported_toolchains": ["ARM"], + "extra_labels": ["ARM_SSG", "MPS2", "MPS2_M0P"], + "macros": ["CMSDK_CM0plus"] + }, + "ARM_MPS2_M1": { + "inherits": ["ARM_MPS2_Target"], + "core": "Cortex-M1", + "supported_toolchains": ["ARM"], + "extra_labels": ["ARM_SSG", "MPS2", "MPS2_M1"], + "macros": ["CMSDK_CM1"] + }, + "ARM_MPS2_M3": { + "inherits": ["ARM_MPS2_Target"], + "core": "Cortex-M3", + "supported_toolchains": ["ARM"], + "extra_labels": ["ARM_SSG", "MPS2", "MPS2_M3"], + "macros": ["CMSDK_CM3"] + }, + "ARM_MPS2_M4": { + "inherits": ["ARM_MPS2_Target"], + "core": "Cortex-M4F", + "supported_toolchains": ["ARM"], + "extra_labels": ["ARM_SSG", "MPS2", "MPS2_M4"], + "macros": ["CMSDK_CM4"] + }, + "ARM_MPS2_M7": { + "inherits": ["ARM_MPS2_Target"], + "core": "Cortex-M7", + "supported_toolchains": ["ARM"], + "extra_labels": ["ARM_SSG", "MPS2", "MPS2_M7"], + "macros": ["CMSDK_CM7"] + }, + "ARM_IOTSS_Target": { + "inherits": ["Target"], + "public": false + }, + "ARM_IOTSS_BEID": { + "inherits": ["ARM_IOTSS_Target"], + "core": "Cortex-M3", + "supported_toolchains": ["ARM"], + "extra_labels": ["ARM_SSG", "IOTSS", "IOTSS_BEID"], + "macros": ["CMSDK_BEID"] + }, + "RZ_A1H": { + "supported_form_factors": ["ARDUINO"], + "core": "Cortex-A9", + "program_cycle_s": 2, + "extra_labels": ["RENESAS", "MBRZA1H"], + "supported_toolchains": ["ARM", "GCC_ARM", "IAR"], + "inherits": ["Target"], + "progen": { + "target": "gr-peach", + "iar": { + "template": ["iar_rz_a1h.ewp.tmpl"] + } + } + }, + "MAXWSNENV": { + "inherits": ["Target"], + "core": "Cortex-M3", + "macros": ["__SYSTEM_HFX=24000000"], + "extra_labels": ["Maxim", "MAX32610"], + "supported_toolchains": ["GCC_ARM", "IAR", "ARM"], + "progen": {"target": "maxwsnenv"} + }, + "MAX32600MBED": { + "inherits": ["Target"], + "core": "Cortex-M3", + "macros": ["__SYSTEM_HFX=24000000"], + "extra_labels": ["Maxim", "MAX32600"], + "supported_toolchains": ["GCC_ARM", "IAR", "ARM"], + "progen": {"target": "max32600mbed"} + }, + "EFM32GG_STK3700": { + "inherits": ["Target"], + "core": "Cortex-M3", + "macros": ["EFM32GG990F1024"], + "extra_labels": ["Silicon_Labs", "EFM32"], + "supported_toolchains": ["GCC_ARM", "ARM", "uARM"], + "progen": {"target": "efm32gg_stk3700"} + }, + "EFM32LG_STK3600": { + "inherits": ["Target"], + "core": "Cortex-M3", + "macros": ["EFM32LG990F256"], + "extra_labels": ["Silicon_Labs", "EFM32"], + "supported_toolchains": ["GCC_ARM", "ARM", "uARM"], + "progen": {"target": "efm32lg_stk3600"} + }, + "EFM32WG_STK3800": { + "inherits": ["Target"], + "core": "Cortex-M4F", + "macros": ["EFM32WG990F256"], + "extra_labels": ["Silicon_Labs", "EFM32"], + "supported_toolchains": ["GCC_ARM", "ARM", "uARM"], + "progen": {"target": "efm32wg_stk3800"} + }, + "EFM32ZG_STK3200": { + "inherits": ["Target"], + "core": "Cortex-M0+", + "default_toolchain": "uARM", + "supported_toolchains": ["GCC_ARM", "uARM"], + "extra_labels": ["Silicon_Labs", "EFM32"], + "macros": ["EFM32ZG222F32"], + "progen": { + "target": "efm32zg_stk3200", + "uvision": { + "template": ["uvision_microlib.uvproj.tmpl"] + } + } + }, + "EFM32HG_STK3400": { + "inherits": ["Target"], + "core": "Cortex-M0+", + "default_toolchain": "uARM", + "supported_toolchains": ["GCC_ARM", "uARM"], + "extra_labels": ["Silicon_Labs", "EFM32"], + "macros": ["EFM32HG322F64"], + "progen": { + "target": "efm32hg_stk3400", + "uvision": { + "template": ["uvision_microlib.uvproj.tmpl"] + } + } + }, + "EFM32PG_STK3401": { + "inherits": ["Target"], + "core": "Cortex-M4F", + "macros": ["EFM32PG1B200F256GM48"], + "extra_labels": ["Silicon_Labs", "EFM32"], + "supported_toolchains": ["GCC_ARM", "ARM", "uARM", "IAR"], + "progen": {"target": "efm32pg_stk3401"} + }, + "WIZWIKI_W7500": { + "supported_form_factors": ["ARDUINO"], + "core": "Cortex-M0", + "extra_labels": ["WIZNET", "W7500x", "WIZwiki_W7500"], + "supported_toolchains": ["uARM", "ARM"], + "inherits": ["Target"], + "progen": {"target": "wizwiki_w7500"} + }, + "WIZWIKI_W7500P": { + "supported_form_factors": ["ARDUINO"], + "core": "Cortex-M0", + "extra_labels": ["WIZNET", "W7500x", "WIZwiki_W7500P"], + "supported_toolchains": ["uARM", "ARM"], + "inherits": ["Target"], + "progen": {"target": "wizwiki_w7500p"} + }, + "WIZWIKI_W7500ECO": { + "inherits": ["Target"], + "core": "Cortex-M0", + "progen": {"target": "wizwiki_w7500eco"}, + "extra_labels": ["WIZNET", "W7500x", "WIZwiki_W7500ECO"], + "supported_toolchains": ["uARM", "ARM"] + }, + "SAMR21G18A": { + "inherits": ["Target"], + "core": "Cortex-M0+", + "macros": [ + "__SAMR21G18A__", + "I2C_MASTER_CALLBACK_MODE=true", + "EXTINT_CALLBACK_MODE=true", + "USART_CALLBACK_MODE=true", + "TC_ASYNC=true" + ], + "extra_labels": ["Atmel", "SAM_CortexM0P", "SAMR21"], + "supported_toolchains": ["GCC_ARM", "ARM", "uARM"], + "progen": {"target": "samr21g18a"} + }, + "SAMD21J18A": { + "inherits": ["Target"], + "core": "Cortex-M0+", + "macros": [ + "__SAMD21J18A__", + "I2C_MASTER_CALLBACK_MODE=true", + "EXTINT_CALLBACK_MODE=true", + "USART_CALLBACK_MODE=true", + "TC_ASYNC=true" + ], + "extra_labels": ["Atmel", "SAM_CortexM0P", "SAMD21"], + "supported_toolchains": ["GCC_ARM", "ARM", "uARM"], + "progen": {"target": "samd21j18a"} + }, + "SAMD21G18A": { + "inherits": ["Target"], + "core": "Cortex-M0+", + "macros": [ + "__SAMD21G18A__", + "I2C_MASTER_CALLBACK_MODE=true", + "EXTINT_CALLBACK_MODE=true", + "USART_CALLBACK_MODE=true", + "TC_ASYNC=true" + ], + "extra_labels": ["Atmel", "SAM_CortexM0P", "SAMD21"], + "supported_toolchains": ["GCC_ARM", "ARM", "uARM"], + "progen": {"target": "samd21g18a"} + }, + "SAML21J18A": { + "inherits": ["Target"], + "core": "Cortex-M0+", + "macros": [ + "__SAML21J18A__", + "I2C_MASTER_CALLBACK_MODE=true", + "EXTINT_CALLBACK_MODE=true", + "USART_CALLBACK_MODE=true", + "TC_ASYNC=true" + ], + "extra_labels": ["Atmel", "SAM_CortexM0P", "SAML21"], + "supported_toolchains": ["GCC_ARM", "ARM", "uARM"], + "progen": {"target": "samr21j18a"} + } +} diff --git a/tools/targets.py b/tools/targets.py index ae0680a2657..11cc4221b29 100755 --- a/tools/targets.py +++ b/tools/targets.py @@ -34,462 +34,213 @@ import shutil from tools.patch import patch from paths import TOOLS_BOOTLOADERS +import json +import inspect +import sys -class Target: - def __init__(self): - # ARM Core - self.core = None - # Is the disk provided by the interface chip of this board virtual? - self.is_disk_virtual = False +######################################################################################################################## +# Generic Target class that reads and interprets the data in targets.json - # list of toolchains that are supported by the mbed SDK for this target - self.supported_toolchains = None +# A simple class that represents all the exceptions associated with hooking +class HookError(Exception): + pass - # list of extra specific labels - self.extra_labels = [] +# A simple decorator used for automatically caching data returned by a function +caches = {} +def cached(func): + def wrapper(*args, **kwargs): + if not caches.has_key(func): + caches[func] = func(*args, **kwargs) + return caches[func] + return wrapper - # list of macros (-D) - self.macros = [] +class Target: + # Cumulative attributes can have values appended to them, so they + # need to be computed differently than regular attributes + __cumulative_attributes = ['extra_labels', 'macros'] + + # Utility function: traverse a dictionary and change all the strings in the dictionary to + # ASCII from Unicode. Needed because the original mbed target definitions were written in + # Python and used only ASCII strings, but the Python JSON decoder always returns Unicode + # Based on http://stackoverflow.com/a/13105359 + @staticmethod + def to_ascii(input): + if isinstance(input, dict): + return dict([(Target.to_ascii(key), Target.to_ascii(value)) for key, value in input.iteritems()]) + elif isinstance(input, list): + return [Target.to_ascii(element) for element in input] + elif isinstance(input, unicode): + return input.encode('ascii') + else: + return input + + # Load the description of JSON target data + @staticmethod + @cached + def get_json_target_data(): + with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "targets.json"), "rt") as f: + return Target.to_ascii(json.load(f)) - # Default online compiler: - self.default_toolchain = "ARM" + # Get the members of this module using Python's "inspect" module + @staticmethod + @cached + def get_module_data(): + return dict([(m[0], m[1]) for m in inspect.getmembers(sys.modules[__name__])]) + + # Return the order in which target descriptions are searched for attributes + # This mimics the Python 2.2 method resolution order, which is what the old targets.py module used + # For more details, check http://makina-corpus.com/blog/metier/2014/python-tutorial-understanding-python-mro-class-search-path + # The resolution order contains (name, level) tuples, where "name" is the name of the class and "level" + # is the level in the inheritance hierarchy (the target itself is at level 0, its first parent at level 1, + # its parent's parent at level 1 and so on) + def __get_resolution_order(self, target_name, order, level = 0): + if not target_name in [l[0] for l in order]: # the resolution order can't contain duplicate target names + order.append((target_name, level)) + parents = self.get_json_target_data()[target_name].get("inherits", []) + for p in parents: + order = self.__get_resolution_order(p, order, level + 1) + return order + + # Modify the exporter specification ("progen") by changing all "template" keys to full paths + @staticmethod + def __add_paths_to_progen(data): + out = {} + for key, value in data.items(): + if isinstance(value, dict): + out[key] = Target.__add_paths_to_progen(value) + elif key == "template": + out[key] = [os.path.join(os.path.dirname(__file__), 'export', v) for v in value] + else: + out[key] = value + return out + + # Comute the value of a given target attribute + def __getattr_helper(self, attrname): + tdata = self.get_json_target_data() + if attrname in self.__cumulative_attributes: + # For a cumulative attribute, figure out when it was defined the last time (in attribute + # resolution order) then follow the "_add" and "_remove" data fields + for idx, t in enumerate(self.resolution_order): + if attrname in tdata[t[0]]: # the attribute was defined at this level in the resolution order + def_idx = idx + break + else: + raise AttributeError("Attribute '%s' not found in target '%s'" % (attrname, self.name)) + # Get the starting value of the attribute + v = (tdata[self.resolution_order[def_idx][0]][attrname] or [])[:] + # Traverse the resolution list in high inheritance to low inheritance level, left to right order + # to figure out all the other classes that change the definition by adding or removing elements + for idx in xrange(self.resolution_order[def_idx][1] - 1, -1, -1): + same_level_targets = [t[0] for t in self.resolution_order if t[1] == idx] + for t in same_level_targets: + data = tdata[t] + # Do we have anything to add ? + if data.has_key(attrname + "_add"): + v.extend(data[attrname + "_add"]) + # Do we have anything to remove ? + if data.has_key(attrname + "_remove"): + # Macros can be defined either without a value (MACRO) or with a value (MACRO=10). + # When removing, we specify only the name of the macro, without the value. So we need + # to create a mapping between the macro name and its value. This will work for + # extra_labels and other type of arrays as well, since they fall into the "macros + # without a value" category (simple definitions without a value). + name_def_map = {} + for crtv in v: + if crtv.find('=') != -1: + temp = crtv.split('=') + if len(temp) != 2: + raise ValueError("Invalid macro definition '%s'" % crtv) + name_def_map[temp[0]] = crtv + else: + name_def_map[crtv] = crtv + for e in data[attrname + "_remove"]: + if not e in name_def_map: + raise ValueError("Unable to remove '%s' in '%s.%s' since it doesn't exist" % (e, self.name, attrname)) + v.remove(name_def_map[e]) + return v + # Look for the attribute in the class and its parents, as defined by the resolution order + v = None + for t in self.resolution_order: + data = tdata[t[0]] + if data.has_key(attrname): + v = data[attrname] + break + else: # Attribute not found + raise AttributeError("Attribute '%s' not found in target '%s'" % (attrname, self.name)) + # 'progen' needs the full path to the template (the path in JSON is relative to tools/export) + return v if attrname != "progen" else self.__add_paths_to_progen(v) - self.name = self.__class__.__name__ + # Return the value of an attribute + # This function only looks for the attribute's value in the cache, the real work of computing the + # attribute's value is done in the function above (__getattr_helper) + def __getattr__(self, attrname): + if not self.attr_cache.has_key(attrname): + self.attr_cache[attrname] = self.__getattr_helper(attrname) + return self.attr_cache[attrname] - # Code used to determine devices' platform - # This code is prefix in URL link provided in mbed.htm (in mbed disk) - self.detect_code = [] + def __init__(self, name): + self.name = name + + # Compute resolution order once (it will be used later in __getattr__) + self.resolution_order = self.__get_resolution_order(self.name, []) + + # Attribute cache: once an attribute's value is computed, don't compute it again + self.attr_cache = {} def program_cycle_s(self): - return 4 if self.is_disk_virtual else 1.5 + try: + return self.__getattr__("program_cycle_s") + except AttributeError: + return 4 if self.is_disk_virtual else 1.5 def get_labels(self): return [self.name] + CORE_LABELS[self.core] + self.extra_labels + # For now, this function only allows "post binary" hooks (hooks that are executed after + # the binary image is extracted from the executable file) def init_hooks(self, hook, toolchain_name): - pass - - -### MCU Support ### - -class CM4_UARM(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4" - self.supported_toolchains = ["uARM"] - self.default_toolchain = "uARM" - -class CM4_ARM(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4" - self.supported_toolchains = ["ARM"] - self.default_toolchain = "ARM" - -class CM4F_UARM(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4F" - self.supported_toolchains = ["uARM"] - self.default_toolchain = "uARM" - -class CM4F_ARM(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4F" - self.supported_toolchains = ["ARM"] - self.default_toolchain = "ARM" - - -### NXP ### + # If there's no hook, simply return + try: + hook_data = self.post_binary_hook + except AttributeError: + return + # A hook was found. The hook's name is in the format "classname.functionname" + temp = hook_data["function"].split(".") + if len(temp) != 2: + raise HookError("Invalid format for hook '%s' in target '%s' (must be 'class_name.function_name')" % (hook_data["function"], self.name)) + class_name, function_name = temp[0], temp[1] + # "class_name" must refer to a class in this file, so check if the class exists + mdata = self.get_module_data() + if not mdata.has_key(class_name) or not inspect.isclass(mdata[class_name]): + raise HookError("Class '%s' required by '%s' in target '%s' not found in targets.py" % (class_name, hook_data["function"], self.name)) + # "function_name" must refer to a static function inside class "class_name" + cls = mdata[class_name] + if (not hasattr(cls, function_name)) or (not inspect.isfunction(getattr(cls, function_name))): + raise HookError("Static function '%s' required by '%s' in target '%s' not found in class '%s'" % (function_name, hook_data["function"], self.name, class_name)) + # Check if the hook specification also has target restrictions + toolchain_restrictions = hook_data.get("toolchains", []) + if toolchain_restrictions and (toolchain_name not in toolchain_restrictions): + return + # Finally, hook the requested function + hook.hook_add_binary("post", getattr(cls, function_name)) -# This class implements the post-link patching step needed by LPC targets -class LPCTarget(Target): - def __init__(self): - Target.__init__(self) - - def init_hooks(self, hook, toolchain_name): - hook.hook_add_binary("post", self.lpc_patch) +######################################################################################################################## +# Target specific code goes in this section +# This code can be invoked from the target description using the "post_binary_hook" key +class LPCTargetCode: @staticmethod def lpc_patch(t_self, resources, elf, binf): t_self.debug("LPC Patch: %s" % os.path.split(binf)[1]) patch(binf) -class LPC11C24(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "Cortex-M0" - self.extra_labels = ['NXP', 'LPC11XX_11CXX', 'LPC11CXX'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"] - - self.progen = { - "target":"lpc11c24_301", - } - -class LPC1114(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "Cortex-M0" - self.extra_labels = ['NXP', 'LPC11XX_11CXX', 'LPC11XX'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"] - self.default_toolchain = "uARM" - self.progen = { - "target":"lpc1114_102", - "uvision": { - "template": [os.path.join(os.path.dirname(__file__), 'export', 'uvision_microlib.uvproj.tmpl')], - } - } - -class LPC11U24(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "Cortex-M0" - self.extra_labels = ['NXP', 'LPC11UXX', 'LPC11U24_401'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"] - self.default_toolchain = "uARM" - self.detect_code = ["1040"] - self.progen = { - "target":"lpc11u24_201", - "uvision": { - "template": [os.path.join(os.path.dirname(__file__), 'export', 'uvision_microlib.uvproj.tmpl')], - } - } - -class OC_MBUINO(LPC11U24): - def __init__(self): - LPC11U24.__init__(self) - self.core = "Cortex-M0" - self.extra_labels = ['NXP', 'LPC11UXX'] - self.macros = ['TARGET_LPC11U24'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"] - self.default_toolchain = "uARM" - self.progen = { - "target":"lpc11u24_201", - "uvision": { - "template": [os.path.join(os.path.dirname(__file__), 'export', 'uvision_microlib.uvproj.tmpl')], - } - } - -class LPC11U24_301(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "Cortex-M0" - self.extra_labels = ['NXP', 'LPC11UXX'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"] - -class LPC11U34_421(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "Cortex-M0" - self.extra_labels = ['NXP', 'LPC11UXX'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"] - self.default_toolchain = "uARM" - -class MICRONFCBOARD(LPC11U34_421): - def __init__(self): - LPC11U34_421.__init__(self) - self.macros = ['LPC11U34_421', 'APPNEARME_MICRONFCBOARD'] - self.extra_labels = ['NXP', 'LPC11UXX', 'APPNEARME_MICRONFCBOARD'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"] - self.default_toolchain = "uARM" - -class LPC11U35_401(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "Cortex-M0" - self.extra_labels = ['NXP', 'LPC11UXX'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"] - self.default_toolchain = "uARM" - self.progen = { - "target":"lpc11u35_401", - "uvision": { - "template": [os.path.join(os.path.dirname(__file__), 'export', 'uvision_microlib.uvproj.tmpl')], - } - } - -class LPC11U35_501(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "Cortex-M0" - self.extra_labels = ['NXP', 'LPC11UXX', 'MCU_LPC11U35_501'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "GCC_CR" , "IAR"] - self.default_toolchain = "uARM" - self.progen = { - "target":"lpc11u35_501", - "uvision": { - "template": [os.path.join(os.path.dirname(__file__), 'export', 'uvision_microlib.uvproj.tmpl')], - } - } - -class LPC11U35_501_IBDAP(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "Cortex-M0" - self.extra_labels = ['NXP', 'LPC11UXX', 'MCU_LPC11U35_501'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "GCC_CR" , "IAR"] - self.default_toolchain = "uARM" - self.progen = { - "target":"lpc11u35_501", - "uvision": { - "template": [os.path.join(os.path.dirname(__file__), 'export', 'uvision_microlib.uvproj.tmpl')], - } - } - -class XADOW_M0(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "Cortex-M0" - self.extra_labels = ['NXP', 'LPC11UXX', 'MCU_LPC11U35_501'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"] - self.default_toolchain = "uARM" - self.progen = { - "target":"lpc11u35_501", - "uvision": { - "template": [os.path.join(os.path.dirname(__file__), 'export', 'uvision_microlib.uvproj.tmpl')], - } - } - -class LPC11U35_Y5_MBUG(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "Cortex-M0" - self.extra_labels = ['NXP', 'LPC11UXX', 'MCU_LPC11U35_501'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "GCC_CR" , "IAR"] - self.default_toolchain = "uARM" - self.progen = { - "target":"lpc11u35_501", - "uvision": { - "template": [os.path.join(os.path.dirname(__file__), 'export', 'uvision_microlib.uvproj.tmpl')], - } - } - -class LPC11U37_501(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "Cortex-M0" - self.extra_labels = ['NXP', 'LPC11UXX'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"] - self.default_toolchain = "uARM" - self.progen = { - "target":"lpc11u37_501", - "uvision": { - "template": [os.path.join(os.path.dirname(__file__), 'export', 'uvision_microlib.uvproj.tmpl')], - } - } - -class LPCCAPPUCCINO(LPC11U37_501): - def __init__(self): - LPC11U37_501.__init__(self) - -class ARCH_GPRS(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "Cortex-M0" - self.extra_labels = ['NXP', 'LPC11UXX', 'LPC11U37_501'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO"] - self.progen = { - "target":"lpc11u37_501", - "uvision": { - "template": [os.path.join(os.path.dirname(__file__), 'export', 'uvision_microlib.uvproj.tmpl')], - } - } - -class LPC11U68(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "Cortex-M0+" - self.extra_labels = ['NXP', 'LPC11U6X'] - self.supported_toolchains = ["ARM", "uARM", "GCC_CR", "GCC_ARM", "IAR"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO"] - self.detect_code = ["1168"] - self.progen = { - "target":"lpc11u68", - "uvision": { - "template": [os.path.join(os.path.dirname(__file__), 'export', 'uvision_microlib.uvproj.tmpl')], - } - } - -class LPC1347(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "Cortex-M3" - self.extra_labels = ['NXP', 'LPC13XX'] - self.supported_toolchains = ["ARM", "GCC_ARM","IAR"] - self.progen = { - "target":"lpc1347", - } - -class LPC1549(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "Cortex-M3" - self.extra_labels = ['NXP', 'LPC15XX'] - self.supported_toolchains = ["uARM", "GCC_CR", "GCC_ARM", "IAR"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO"] - self.detect_code = ["1549"] - self.progen = { - "target":"lpc1549", - "uvision": { - "template": [os.path.join(os.path.dirname(__file__), 'export', 'uvision_microlib.uvproj.tmpl')], - } - } - -class LPC1768(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "Cortex-M3" - self.extra_labels = ['NXP', 'LPC176X', 'MBED_LPC1768'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"] - self.detect_code = ["1010"] - self.progen = { - "target":"mbed-lpc1768", - } - -class ARCH_PRO(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "Cortex-M3" - self.extra_labels = ['NXP', 'LPC176X'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"] - self.macros = ['TARGET_LPC1768'] - self.supported_form_factors = ["ARDUINO"] - self.progen = { - "target":"arch-pro", - } - -class UBLOX_C027(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "Cortex-M3" - self.extra_labels = ['NXP', 'LPC176X'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"] - self.macros = ['TARGET_LPC1768'] - self.supported_form_factors = ["ARDUINO"] - self.progen = { - "target":"ublox-c027", - } - -class XBED_LPC1768(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "Cortex-M3" - self.extra_labels = ['NXP', 'LPC176X', 'XBED_LPC1768'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"] - self.macros = ['TARGET_LPC1768'] - self.detect_code = ["1010"] - self.progen = { - "target":"lpc1768", - } - -class LPC2368(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "ARM7TDMI-S" - self.extra_labels = ['NXP', 'LPC23XX'] - self.supported_toolchains = ["ARM", "GCC_ARM", "GCC_CR"] - self.progen = { - "target":"lpc2368", - } - -class LPC2460(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "ARM7TDMI-S" - self.extra_labels = ['NXP', 'LPC2460'] - self.supported_toolchains = ["GCC_ARM"] - self.progen = { - "target":"lpc2460", - } - -class LPC810(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "Cortex-M0+" - self.extra_labels = ['NXP', 'LPC81X'] - self.supported_toolchains = ["uARM", "IAR", "GCC_ARM"] - self.default_toolchain = "uARM" - self.is_disk_virtual = True - self.progen = { - "target":"lpc810", - "uvision": { - "template": [os.path.join(os.path.dirname(__file__), 'export', 'uvision_microlib.uvproj.tmpl')], - } - } - -class LPC812(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "Cortex-M0+" - self.extra_labels = ['NXP', 'LPC81X'] - self.supported_toolchains = ["uARM", "IAR", "GCC_ARM"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO"] - self.is_disk_virtual = True - self.detect_code = ["1050"] - self.progen = { - "target":"lpc812m101", - "uvision": { - "template": [os.path.join(os.path.dirname(__file__), 'export', 'uvision_microlib.uvproj.tmpl')], - } - } - -class LPC824(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "Cortex-M0+" - self.extra_labels = ['NXP', 'LPC82X'] - self.supported_toolchains = ["uARM", "GCC_ARM","GCC_CR", "IAR"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO"] - self.is_disk_virtual = True - self.progen = { - "target":"lpc824m201", - "uvision": { - "template": [os.path.join(os.path.dirname(__file__), 'export', 'uvision_microlib.uvproj.tmpl')], - } - } - -class SSCI824(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "Cortex-M0+" - self.extra_labels = ['NXP', 'LPC82X'] - self.supported_toolchains = ["uARM", "GCC_ARM"] - self.default_toolchain = "uARM" - self.is_disk_virtual = True - self.progen = { - "target":"ssci824", - "uvision": { - "template": [os.path.join(os.path.dirname(__file__), 'export', 'uvision_microlib.uvproj.tmpl')], - } - } - -class LPC4088(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "Cortex-M4F" - self.extra_labels = ['NXP', 'LPC408X'] - self.supported_toolchains = ["ARM", "GCC_CR", "GCC_ARM", "IAR"] - self.is_disk_virtual = True - self.progen = { - "target":"lpc4088", - } - - def init_hooks(self, hook, toolchain_name): - if toolchain_name in ['ARM_STD', 'ARM_MICRO']: - hook.hook_add_binary("post", self.binary_hook) - +class LPC4088Code: @staticmethod def binary_hook(t_self, resources, elf, binf): if not os.path.isdir(binf): # Regular binary file, nothing to do - LPCTarget.lpc_patch(t_self, resources, elf, binf) + LPCTargetCode.lpc_patch(t_self, resources, elf, binf) return outbin = open(binf + ".temp", "wb") partf = open(os.path.join(binf, "ER_IROM1"), "rb") @@ -513,157 +264,9 @@ def binary_hook(t_self, resources, elf, binf): shutil.rmtree(binf, True) os.rename(binf + '.temp', binf) t_self.debug("Generated custom binary file (internal flash + SPIFI)") - LPCTarget.lpc_patch(t_self, resources, elf, binf) - -class LPC4088_DM(LPC4088): - pass - -class LPC4330_M4(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "Cortex-M4F" - self.extra_labels = ['NXP', 'LPC43XX', 'LPC4330'] - self.supported_toolchains = ["ARM", "GCC_CR", "IAR", "GCC_ARM"] - self.progen = { - "target":"lpc4330", - } - -class LPC4330_M0(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "Cortex-M0" - self.extra_labels = ['NXP', 'LPC43XX', 'LPC4330'] - self.supported_toolchains = ["ARM", "GCC_CR", "IAR"] - -class LPC4337(LPCTarget): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4F" - self.extra_labels = ['NXP', 'LPC43XX', 'LPC4337'] - self.supported_toolchains = ["ARM"] - self.progen = { - "target":"lpc4337", - } - -class LPC1800(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "Cortex-M3" - self.extra_labels = ['NXP', 'LPC43XX'] - self.supported_toolchains = ["ARM", "GCC_CR", "IAR"] - -class LPC11U37H_401(LPCTarget): - def __init__(self): - LPCTarget.__init__(self) - self.core = "Cortex-M0" - self.extra_labels = ['NXP', 'LPC11UXX'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "GCC_CR"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO"] - self.progen = { - "target":"lpc11u37_401", - "uvision": { - "template": [os.path.join(os.path.dirname(__file__), 'export', 'uvision_microlib.uvproj.tmpl')], - } - } -### Freescale ### - -class KL05Z(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M0+" - self.extra_labels = ['Freescale', 'KLXX'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO"] - self.is_disk_virtual = True - self.progen = { - "target":"frdm-kl05z", - "uvision": { - "template": [os.path.join(os.path.dirname(__file__), 'export', 'uvision_microlib.uvproj.tmpl')], - } - } - -class KL25Z(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M0+" - self.extra_labels = ['Freescale', 'KLXX'] - self.supported_toolchains = ["ARM", "GCC_ARM", "IAR"] - self.supported_form_factors = ["ARDUINO"] - self.is_disk_virtual = True - self.detect_code = ["0200"] - self.progen = { - "target":"frdm-kl25z", - } - -class KL26Z(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M0+" - self.extra_labels = ['Freescale', 'KLXX'] - self.supported_toolchains = ["ARM","GCC_ARM","IAR"] - self.supported_form_factors = ["ARDUINO"] - self.is_disk_virtual = True - self.progen = { - "target":"kl26z", - } - -class KL43Z(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M0+" - self.extra_labels = ['Freescale', 'KLXX'] - self.supported_toolchains = ["GCC_ARM", "ARM"] - self.supported_form_factors = ["ARDUINO"] - self.is_disk_virtual = True - self.progen = { - "target":"frdm-kl43z", - } - -class KL46Z(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M0+" - self.extra_labels = ['Freescale', 'KLXX'] - self.supported_toolchains = ["GCC_ARM", "ARM", "IAR"] - self.supported_form_factors = ["ARDUINO"] - self.is_disk_virtual = True - self.detect_code = ["0220"] - self.progen = { - "target":"frdm-kl46z", - } - -class K20D50M(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4" - self.extra_labels = ['Freescale', 'K20XX'] - self.supported_toolchains = ["GCC_ARM", "ARM", "IAR"] - self.is_disk_virtual = True - self.detect_code = ["0230"] - self.progen = { - "target":"frdm-k20d50m", - } - -class TEENSY3_1(Target): - OUTPUT_EXT = 'hex' - - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4" - self.extra_labels = ['Freescale', 'K20XX', 'K20DX256'] - self.supported_toolchains = ["GCC_ARM", "ARM"] - self.is_disk_virtual = True - self.detect_code = ["0230"] - self.progen = { - "target":"teensy-31", - } - - def init_hooks(self, hook, toolchain_name): - if toolchain_name in ['ARM_STD', 'ARM_MICRO', 'GCC_ARM']: - hook.hook_add_binary("post", self.binary_hook) + LPCTargetCode.lpc_patch(t_self, resources, elf, binf) +class TEENSY3_1Code: @staticmethod def binary_hook(t_self, resources, elf, binf): from intelhex import IntelHex @@ -673,506 +276,10 @@ def binary_hook(t_self, resources, elf, binf): with open(binf.replace(".bin", ".hex"), "w") as f: binh.tofile(f, format='hex') -class K22F(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4F" - self.extra_labels = ['Freescale', 'KPSDK_MCUS', 'KPSDK_CODE'] - self.macros = ["CPU_MK22FN512VLH12", "FSL_RTOS_MBED"] - self.supported_toolchains = ["ARM", "GCC_ARM", "IAR"] - self.supported_form_factors = ["ARDUINO"] - self.is_disk_virtual = True - self.detect_code = ["0201"] - self.progen = { - "target":"frdm-k22f", - } - -class K64F(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4F" - self.extra_labels = ['Freescale', 'KPSDK_MCUS', 'KPSDK_CODE', 'MCU_K64F', 'FRDM'] - self.macros = ["CPU_MK64FN1M0VMD12", "FSL_RTOS_MBED"] - self.supported_toolchains = ["ARM", "GCC_ARM", "IAR"] - self.supported_form_factors = ["ARDUINO"] - self.is_disk_virtual = True - self.default_toolchain = "ARM" - self.detect_code = ["0240"] - self.progen = { - "target":"frdm-k64f", - } - -class K64F_UV(K64F): - def __init__(self): - K64F.__init__(self) - self.core = "Cortex-M4" - self.extra_labels += ['K64F'] - self.macros += ['TARGET_K64F'] - -class MTS_GAMBIT(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4F" - self.extra_labels = ['Freescale', 'KPSDK_MCUS', 'KPSDK_CODE', 'MCU_K64F'] - self.supported_toolchains = ["ARM", "GCC_ARM"] - self.macros = ["CPU_MK64FN1M0VMD12", "FSL_RTOS_MBED", "TARGET_K64F"] - self.is_disk_virtual = True - self.default_toolchain = "ARM" - self.progen = { - "target":"mts-gambit", - } - -### STMicro ### - -class NUCLEO_F030R8(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M0" - self.extra_labels = ['STM', 'STM32F0', 'STM32F030R8'] - self.supported_toolchains = ["ARM", "uARM", "IAR", "GCC_ARM"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO", "MORPHO"] - self.detect_code = ["0725"] - self.progen = { - "target":"nucleo-f030r8", - } - -class NUCLEO_F031K6(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M0" - self.extra_labels = ['STM', 'STM32F0', 'STM32F031K6'] - self.supported_toolchains = ["ARM", "uARM", "IAR", "GCC_ARM"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO"] - self.detect_code = ["0791"] - self.progen = { - "target":"nucleo-f031k6", - } - -class NUCLEO_F042K6(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M0" - self.extra_labels = ['STM', 'STM32F0', 'STM32F042K6'] - self.supported_toolchains = ["ARM", "uARM", "IAR", "GCC_ARM"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO"] - self.detect_code = ["0785"] - self.progen = { - "target":"nucleo-f042k6", - } - -class NUCLEO_F070RB(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M0" - self.extra_labels = ['STM', 'STM32F0', 'STM32F070RB'] - self.supported_toolchains = ["ARM", "uARM", "IAR", "GCC_ARM"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO", "MORPHO"] - self.detect_code = ["0755"] - self.progen = { - "target":"nucleo-f070rb", - } - -class NUCLEO_F072RB(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M0" - self.extra_labels = ['STM', 'STM32F0', 'STM32F072RB'] - self.supported_toolchains = ["ARM", "uARM", "IAR", "GCC_ARM"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO", "MORPHO"] - self.detect_code = ["0730"] - self.progen = { - "target":"nucleo-f072rb", - } - -class NUCLEO_F091RC(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M0" - self.extra_labels = ['STM', 'STM32F0', 'STM32F091RC'] - self.supported_toolchains = ["ARM", "uARM", "IAR", "GCC_ARM"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO", "MORPHO"] - self.detect_code = ["0750"] - self.progen = { - "target":"nucleo-f091rc", - } - -class NUCLEO_F103RB(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M3" - self.extra_labels = ['STM', 'STM32F1', 'STM32F103RB'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO", "MORPHO"] - self.detect_code = ["0700"] - self.progen = { - "target":"nucleo-f103rb", - } - -class NUCLEO_F302R8(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4F" - self.extra_labels = ['STM', 'STM32F3', 'STM32F302R8'] - self.supported_toolchains = ["ARM", "uARM", "IAR", "GCC_ARM"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO", "MORPHO"] - self.detect_code = ["0705"] - self.progen = { - "target":"nucleo-f302r8", - } - -class NUCLEO_F303K8(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4F" - self.extra_labels = ['STM', 'STM32F3', 'STM32F303K8'] - self.supported_toolchains = ["ARM", "uARM", "IAR", "GCC_ARM"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO"] - self.detect_code = ["0775"] - self.progen = { - "target":"nucleo-f303k8", - } - -class NUCLEO_F303RE(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4F" - self.extra_labels = ['STM', 'STM32F3', 'STM32F303RE'] - self.supported_toolchains = ["ARM", "uARM", "IAR", "GCC_ARM"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO", "MORPHO"] - self.detect_code = ["0745"] - self.progen = { - "target":"nucleo-f303re", - } - -class NUCLEO_F334R8(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4F" - self.extra_labels = ['STM', 'STM32F3', 'STM32F334R8'] - self.supported_toolchains = ["ARM", "uARM", "IAR", "GCC_ARM"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO", "MORPHO"] - self.detect_code = ["0735"] - self.progen = { - "target":"nucleo-f334r8", - } - -class NUCLEO_F401RE(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4F" - self.extra_labels = ['STM', 'STM32F4', 'STM32F401RE'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO", "MORPHO"] - self.detect_code = ["0720"] - self.progen = { - "target":"nucleo-f401re", - } - -class NUCLEO_F410RB(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4F" - self.extra_labels = ['STM', 'STM32F4', 'STM32F410RB'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO", "MORPHO"] - self.detect_code = ["0740"] - self.progen = { - "target":"nucleo-f410rb", - } - -class NUCLEO_F411RE(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4F" - self.extra_labels = ['STM', 'STM32F4', 'STM32F411RE'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO", "MORPHO"] - self.detect_code = ["0740"] - self.progen = { - "target":"nucleo-f411re", - } - -class ELMO_F411RE(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4F" - self.extra_labels = ['STM', 'STM32F4', 'STM32F411RE'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO"] - self.detect_code = ["----"] - -class NUCLEO_F446RE(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4F" - self.extra_labels = ['STM', 'STM32F4', 'STM32F446RE'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO", "MORPHO"] - self.detect_code = ["0777"] - self.progen = { - "target":"nucleo-f446re", - } - -class B96B_F446VE(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4F" - self.extra_labels = ['STM', 'STM32F4', 'STM32F446VE'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO", "MORPHO"] - self.detect_code = ["0840"] - -class NUCLEO_F746ZG(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M7F" - self.extra_labels = ['STM', 'STM32F7', 'STM32F746', 'STM32F746ZG'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"] - self.detect_code = ["0816"] - self.progen = { - "target":"nucleo-f746zg", - "iar": { - "template": [os.path.join(os.path.dirname(__file__), 'export', 'iar_nucleo_f746zg.ewp.tmpl')], - } - } - -class NUCLEO_L053R8(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M0+" - self.extra_labels = ['STM', 'STM32L0', 'STM32L053R8'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO", "MORPHO"] - self.detect_code = ["0715"] - self.progen = { - "target":"nucleo-l053r8", - } - -class NUCLEO_L073RZ(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M0+" - self.extra_labels = ['STM', 'STM32L0', 'STM32L073RZ'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO", "MORPHO"] - self.detect_code = ["0760"] - self.progen = { - "target":"nucleo-l073rz", - } - -class NUCLEO_L152RE(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M3" - self.extra_labels = ['STM', 'STM32L1', 'STM32L152RE'] - self.supported_toolchains = ["ARM", "uARM", "IAR", "GCC_ARM"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO", "MORPHO"] - self.detect_code = ["0710"] - self.progen = { - "target":"nucleo-l152re", - } - -class NUCLEO_L476RG(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4F" - self.extra_labels = ['STM', 'STM32L4', 'STM32L476RG'] - self.supported_toolchains = ["ARM", "uARM", "IAR", "GCC_ARM"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO", "MORPHO"] - self.detect_code = ["0765"] - self.progen = { - "target":"nucleo-l476rg", - } - -class STM32F3XX(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4" - self.extra_labels = ['STM', 'STM32F3XX'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"] - self.default_toolchain = "uARM" - -class STM32F407(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4F" - self.extra_labels = ['STM', 'STM32F4', 'STM32F4XX'] - self.supported_toolchains = ["ARM", "GCC_ARM", "IAR"] - -class ARCH_MAX(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4F" - self.extra_labels = ['STM', 'STM32F4', 'STM32F407', 'STM32F407VG'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"] - self.supported_form_factors = ["ARDUINO"] - self.macros = ['LSI_VALUE=32000'] - self.progen = { - "target":"lpc1768", - } - def program_cycle_s(self): - return 2 - -class DISCO_F051R8(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M0" - self.extra_labels = ['STM', 'STM32F0', 'STM32F051', 'STM32F051R8'] - self.supported_toolchains = ["GCC_ARM"] - self.default_toolchain = "uARM" - -class DISCO_F100RB(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M3" - self.extra_labels = ['STM', 'STM32F1', 'STM32F100RB'] - self.supported_toolchains = ["GCC_ARM"] - self.default_toolchain = "uARM" - -class DISCO_F303VC(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4F" - self.extra_labels = ['STM', 'STM32F3', 'STM32F303', 'STM32F303VC'] - self.supported_toolchains = ["GCC_ARM"] - self.default_toolchain = "uARM" - -class DISCO_F334C8(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4F" - self.extra_labels = ['STM', 'STM32F3', 'STM32F334C8'] - self.supported_toolchains = ["ARM", "uARM", "IAR", "GCC_ARM"] - self.default_toolchain = "uARM" - self.detect_code = ["0810"] - self.progen = { - "target":"disco-f334c8", - } - -class DISCO_F407VG(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4F" - self.extra_labels = ['STM', 'STM32F4', 'STM32F407', 'STM32F407VG'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"] - self.progen = { - "target":"disco-f407vg", - } - self.default_toolchain = "ARM" - -class DISCO_F429ZI(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4F" - self.extra_labels = ['STM', 'STM32F4', 'STM32F429', 'STM32F429ZI'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"] - self.default_toolchain = "uARM" - self.progen = { - "target":"", - } - -class DISCO_F469NI(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4F" - self.extra_labels = ['STM', 'STM32F4', 'STM32F469', 'STM32F469NI'] - self.supported_toolchains = ["ARM", "uARM", "IAR", "GCC_ARM"] - self.default_toolchain = "uARM" - self.supported_form_factors = ["ARDUINO"] - self.detect_code = ["0788"] - self.progen = { - "target":"disco-f469ni", - } - -class DISCO_L053C8(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M0+" - self.extra_labels = ['STM', 'STM32L0', 'STM32L053C8'] - self.supported_toolchains = ["ARM", "uARM", "IAR", "GCC_ARM"] - self.default_toolchain = "uARM" - self.progen = { - "target":"disco-l053c8", - } - -class DISCO_F746NG(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M7F" - self.extra_labels = ['STM', 'STM32F7', 'STM32F746', 'STM32F746NG'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"] - self.detect_code = ["0815"] - self.progen = { - "target":"disco-f746ng", - } - -class DISCO_L476VG(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4F" - self.extra_labels = ['STM', 'STM32L4', 'STM32L476VG'] - self.supported_toolchains = ["ARM", "uARM", "IAR", "GCC_ARM"] - self.default_toolchain = "uARM" - self.detect_code = ["0820"] - self.progen = { - "target":"disco-l476vg", - } - -class MTS_MDOT_F405RG(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4F" - self.extra_labels = ['STM', 'STM32F4', 'STM32F405RG'] - self.macros = ['HSE_VALUE=26000000', 'OS_CLOCK=48000000'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"] - self.is_disk_virtual = True - self.default_toolchain = "ARM" - self.progen = { - "target":"mts-mdot-f405rg", - } - -class MTS_MDOT_F411RE(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4F" - self.extra_labels = ['STM', 'STM32F4', 'STM32F411RE'] - self.macros = ['HSE_VALUE=26000000', 'OS_CLOCK=96000000', 'USE_PLL_HSE_EXTC=0', 'VECT_TAB_OFFSET=0x00010000'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"] - self.default_toolchain = "ARM" - self.progen = { - "target":"mts-mdot-f411re", - } - - def init_hooks(self, hook, toolchain_name): - if toolchain_name in ['GCC_ARM', 'ARM_STD', 'ARM_MICRO']: - hook.hook_add_binary("post", self.combine_bins) - - # combine application binary with bootloader - # bootloader + padding to 64kB + application + md5sum (16 bytes) +class MTSCode: @staticmethod - def combine_bins(t_self, resources, elf, binf): - loader = os.path.join(TOOLS_BOOTLOADERS, "MTS_MDOT_F411RE", "bootloader.bin") + def _combine_bins_helper(target_name, t_self, resources, elf, binf): + loader = os.path.join(TOOLS_BOOTLOADERS, target_name, "bootloader.bin") target = binf + ".tmp" if not os.path.exists(loader): print "Can't find bootloader binary: " + loader @@ -1196,147 +303,15 @@ def combine_bins(t_self, resources, elf, binf): os.remove(binf) os.rename(target, binf) -class MTS_DRAGONFLY_F411RE(Target): - def __init__(self): - Target.__init__(self) - self.core = "Cortex-M4F" - self.extra_labels = ['STM', 'STM32F4', 'STM32F411RE'] - self.macros = ['HSE_VALUE=26000000', 'VECT_TAB_OFFSET=0x08010000'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"] - self.default_toolchain = "ARM" - self.progen = { - "target":"mts-dragonfly-f411re", - } - - def init_hooks(self, hook, toolchain_name): - if toolchain_name in ['GCC_ARM', 'ARM_STD', 'ARM_MICRO']: - hook.hook_add_binary("post", self.combine_bins) - - # combine application binary with bootloader - # bootloader + padding to 64kB + application + md5sum (16 bytes) @staticmethod - def combine_bins(t_self, resources, elf, binf): - loader = os.path.join(TOOLS_BOOTLOADERS, "MTS_DRAGONFLY_F411RE", "bootloader.bin") - target = binf + ".tmp" - if not os.path.exists(loader): - print "Can't find bootloader binary: " + loader - return - outbin = open(target, 'w+b') - part = open(loader, 'rb') - data = part.read() - outbin.write(data) - outbin.write('\xFF' * (64*1024 - len(data))) - part.close() - part = open(binf, 'rb') - data = part.read() - outbin.write(data) - part.close() - outbin.seek(0, 0) - data = outbin.read() - outbin.seek(0, 1) - crc = struct.pack('