Enable microbit target for online compiler.

The online compiler mandates we maintain support for NRF51 targets in
the tools.

* Add NRF51 targets back into latest_targets.json.
* Reintroduce NRF51 post build hook.
tools-release-6.0.0
Rob Walton 2020-05-26 15:51:41 +01:00
parent f68ff23a8a
commit 7e8973f876
2 changed files with 620 additions and 0 deletions

View File

@ -7532,5 +7532,556 @@
"__build_tools_metadata__": {
"version": "1",
"public": false
},
"MCU_NRF51": {
"inherits": [
"Target"
],
"core": "Cortex-M0",
"OVERRIDE_BOOTLOADER_FILENAME": "nrf51822_bootloader.hex",
"macros": [
"NRF51",
"NRF5x",
"TARGET_NRF51822",
"CMSIS_VECTAB_VIRTUAL",
"CMSIS_VECTAB_VIRTUAL_HEADER_FILE=\"cmsis_nvic.h\""
],
"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,
"device_has": [
"ANALOGIN",
"I2C",
"INTERRUPTIN",
"PORTIN",
"PORTINOUT",
"PORTOUT",
"PWMOUT",
"SERIAL",
"SLEEP",
"SPI",
"SPISLAVE",
"USTICKER"
],
"overrides": {
"tickless-from-us-ticker": true,
"boot-stack-size": "0x400"
}
},
"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,
"default_lib": "small"
},
"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"
],
"extra_labels_add": [
"NRF51822",
"NRF51822_MKIT"
],
"macros_add": [
"TARGET_NRF51822_MKIT"
],
"release_versions": [
"2"
],
"device_name": "nRF51822_xxAA",
"detect_code": [
"1070"
]
},
"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"
],
"detect_code": [
"1075"
]
},
"NRF51_DK_LEGACY": {
"supported_form_factors": [
"ARDUINO"
],
"inherits": [
"MCU_NRF51_32K"
],
"extra_labels_add": [
"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"
],
"detect_code": [
"1105"
]
},
"NRF51_MICROBIT": {
"inherits": [
"MCU_NRF51_16K_S110"
],
"macros_add": [
"TARGET_NRF_LFCLK_RC"
],
"release_versions": [
"2"
],
"device_name": "nRF51822_xxAA",
"supported_toolchains": [
"ARMC5",
"GCC_ARM"
],
"detect_code": [
"9900"
]
},
"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"
],
"release_versions": [
"2"
]
},
"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"
]
},
"MCU_NRF51_UNIFIED": {
"inherits": [
"Target"
],
"core": "Cortex-M0",
"OVERRIDE_BOOTLOADER_FILENAME": "nrf51822_bootloader.hex",
"macros": [
"BOARD_PCA10028",
"NRF51",
"TARGET_NRF51822",
"TARGET_MCU_NRF51822",
"CMSIS_VECTAB_VIRTUAL",
"CMSIS_VECTAB_VIRTUAL_HEADER_FILE=\"cmsis_nvic.h\"",
"NO_SYSTICK",
"MBED_TICKLESS"
],
"MERGE_BOOTLOADER": false,
"extra_labels": [
"NORDIC",
"MCU_NRF51",
"MCU_NRF51822_UNIFIED",
"NRF5x",
"NRF51"
],
"OUTPUT_EXT": "hex",
"is_disk_virtual": true,
"supported_toolchains": [
"ARM",
"GCC_ARM",
"IAR"
],
"public": false,
"detect_code": [
"1070"
],
"post_binary_hook": {
"function": "MCU_NRF51Code.binary_hook",
"toolchains": [
"ARM_STD",
"GCC_ARM",
"IAR"
]
},
"program_cycle_s": 6,
"config": {
"lf_clock_src": {
"value": "NRF_LF_SRC_XTAL",
"macro_name": "MBED_CONF_NORDIC_NRF_LF_CLOCK_SRC"
},
"uart_hwfc": {
"help": "Value: 1 for enable, 0 for disable",
"value": 1,
"macro_name": "MBED_CONF_NORDIC_UART_HWFC"
}
},
"device_has": [
"ANALOGIN",
"I2C",
"INTERRUPTIN",
"PORTIN",
"PORTINOUT",
"PORTOUT",
"PWMOUT",
"SERIAL",
"SLEEP",
"SPI",
"SPISLAVE"
]
},
"MCU_NRF51_16K_UNIFIED_S130": {
"inherits": [
"MCU_NRF51_UNIFIED"
],
"extra_labels_add": [
"MCU_NORDIC_16K",
"MCU_NRF51_16K_S130",
"MCU_NRF51_16K"
],
"macros_add": [
"TARGET_MCU_NORDIC_16K",
"TARGET_MCU_NRF51_16K_S130",
"TARGET_MCU_NRF51_16K"
],
"public": false
},
"MCU_NRF51_32K_UNIFIED": {
"inherits": [
"MCU_NRF51_UNIFIED"
],
"extra_labels_add": [
"MCU_NORDIC_32K",
"MCU_NRF51_32K"
],
"macros_add": [
"TARGET_MCU_NORDIC_32K",
"TARGET_MCU_NRF51_32K"
],
"public": false
},
"NRF51_DK": {
"supported_form_factors": [
"ARDUINO"
],
"inherits": [
"MCU_NRF51_32K_UNIFIED"
],
"device_has": [
"USTICKER",
"LPTICKER",
"ANALOGIN",
"I2C",
"I2C_ASYNCH",
"INTERRUPTIN",
"PORTIN",
"PORTINOUT",
"PORTOUT",
"PWMOUT",
"SERIAL",
"SERIAL_ASYNCH",
"SERIAL_FC",
"SLEEP",
"SPI",
"SPI_ASYNCH",
"SPISLAVE"
],
"release_versions": [
"2",
"5"
],
"device_name": "nRF51822_xxAC",
"detect_code": [
"1100"
]
}
}

View File

@ -504,6 +504,75 @@ class MTSCode(object):
"""A hoof for the MTS Dragonfly"""
MTSCode._combine_bins_helper("MTS_DRAGONFLY_F411RE", binf)
class MCU_NRF51Code(object):
"""NRF51 Hooks"""
@staticmethod
def binary_hook(t_self, resources, _, binf):
"""Hook that merges the soft device with the bin file"""
# Scan to find the actual paths of soft device
sdf = None
sd_with_offsets = t_self.target.EXPECTED_SOFTDEVICES_WITH_OFFSETS
for softdevice_and_offset_entry in sd_with_offsets:
for hexf in resources.get_file_paths(FileType.HEX):
if hexf.find(softdevice_and_offset_entry['name']) != -1:
t_self.notify.debug("SoftDevice file found %s."
% softdevice_and_offset_entry['name'])
sdf = hexf
if sdf is not None:
break
if sdf is not None:
break
if sdf is None:
t_self.notify.debug("Hex file not found. Aborting.")
return
# Look for bootloader file that matches this soft device or bootloader
# override image
blf = None
if t_self.target.MERGE_BOOTLOADER is True:
for hexf in resources.get_file_paths(FileType.HEX):
if hexf.find(t_self.target.OVERRIDE_BOOTLOADER_FILENAME) != -1:
t_self.notify.debug(
"Bootloader file found %s."
% t_self.target.OVERRIDE_BOOTLOADER_FILENAME
)
blf = hexf
break
elif hexf.find(softdevice_and_offset_entry['boot']) != -1:
t_self.notify.debug("Bootloader file found %s."
% softdevice_and_offset_entry['boot'])
blf = hexf
break
# Merge user code with softdevice
from intelhex import IntelHex
binh = IntelHex()
_, ext = os.path.splitext(binf)
if ext == ".hex":
binh.loadhex(binf)
elif ext == ".bin":
binh.loadbin(binf, softdevice_and_offset_entry['offset'])
if t_self.target.MERGE_SOFT_DEVICE is True:
t_self.notify.debug("Merge SoftDevice file %s"
% softdevice_and_offset_entry['name'])
sdh = IntelHex(sdf)
sdh.start_addr = None
binh.merge(sdh)
if t_self.target.MERGE_BOOTLOADER is True and blf is not None:
t_self.notify.debug("Merge BootLoader file %s" % blf)
blh = IntelHex(blf)
blh.start_addr = None
binh.merge(blh)
with open(binf.replace(".bin", ".hex"), "w") as fileout:
binh.write_hex_file(fileout, write_start_addr=False)
class RTL8195ACode(object):
"""RTL8195A Hooks"""
@staticmethod