forked from platformio/platformio-core
@ -28,6 +28,7 @@ http://mbed.org/
|
|||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
|
import json
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import xml.etree.ElementTree as ElementTree
|
import xml.etree.ElementTree as ElementTree
|
||||||
@ -251,6 +252,37 @@ eixdata = parse_eix_file(
|
|||||||
build_flags = get_build_flags(eixdata)
|
build_flags = get_build_flags(eixdata)
|
||||||
variant_dir = join("$PLATFORMFW_DIR", "variant", variant)
|
variant_dir = join("$PLATFORMFW_DIR", "variant", variant)
|
||||||
|
|
||||||
|
|
||||||
|
def _find_soft_device_hex():
|
||||||
|
|
||||||
|
if not isfile(join(env.subst("$PLATFORMFW_DIR"), "targets.json")):
|
||||||
|
return None
|
||||||
|
|
||||||
|
with open(join(env.subst("$PLATFORMFW_DIR"), "targets.json")) as fp:
|
||||||
|
data = json.load(fp)
|
||||||
|
|
||||||
|
def _find_hex(target_name):
|
||||||
|
assert isinstance(data, dict)
|
||||||
|
if target_name not in data:
|
||||||
|
return None
|
||||||
|
target = data[target_name]
|
||||||
|
if "EXPECTED_SOFTDEVICES_WITH_OFFSETS" not in target:
|
||||||
|
try:
|
||||||
|
return _find_hex(target.get("inherits", [])[0])
|
||||||
|
except IndexError:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
return target['EXPECTED_SOFTDEVICES_WITH_OFFSETS'][0]['name']
|
||||||
|
|
||||||
|
softdevice_name = _find_hex(variant)
|
||||||
|
if softdevice_name:
|
||||||
|
for root, _, files in walk(env.subst(variant_dir)):
|
||||||
|
if softdevice_name in files:
|
||||||
|
return join(root, softdevice_name)
|
||||||
|
|
||||||
|
env.Exit("Error: Cannot find SoftDevice binary file for your board!")
|
||||||
|
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
_mbed_whole_archive_hook=_mbed_whole_archive_hook,
|
_mbed_whole_archive_hook=_mbed_whole_archive_hook,
|
||||||
_LIBFLAGS="${_mbed_whole_archive_hook(%s)}" % env.get("_LIBFLAGS")[2:-1],
|
_LIBFLAGS="${_mbed_whole_archive_hook(%s)}" % env.get("_LIBFLAGS")[2:-1],
|
||||||
@ -263,6 +295,10 @@ env.Replace(
|
|||||||
join(variant_dir, eixdata.get("LDSCRIPT_PATH")[0]))
|
join(variant_dir, eixdata.get("LDSCRIPT_PATH")[0]))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if env.get("PLATFORM") == "nordicnrf51":
|
||||||
|
env.Append(SOFTDEVICEHEX=_find_soft_device_hex())
|
||||||
|
|
||||||
# restore external build flags
|
# restore external build flags
|
||||||
env.ProcessFlags(
|
env.ProcessFlags(
|
||||||
env.get("BOARD_OPTIONS", {}).get("build", {}).get("extra_flags"))
|
env.get("BOARD_OPTIONS", {}).get("build", {}).get("extra_flags"))
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
from os.path import join
|
from os.path import join
|
||||||
|
|
||||||
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default,
|
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default,
|
||||||
DefaultEnvironment, SConscript)
|
DefaultEnvironment, SConscript)
|
||||||
|
|
||||||
env = DefaultEnvironment()
|
env = DefaultEnvironment()
|
||||||
@ -35,6 +35,25 @@ if env.subst("$BOARD") == "rfduino":
|
|||||||
UPLOADERFLAGS=["-q", '"$UPLOAD_PORT"'],
|
UPLOADERFLAGS=["-q", '"$UPLOAD_PORT"'],
|
||||||
UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS $SOURCES'
|
UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS $SOURCES'
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
env.Append(
|
||||||
|
BUILDERS=dict(
|
||||||
|
MergeHex=Builder(
|
||||||
|
action=" ".join([
|
||||||
|
join("$PIOPACKAGES_DIR", "tool-sreccat", "srec_cat"),
|
||||||
|
"$SOFTDEVICEHEX",
|
||||||
|
"-intel",
|
||||||
|
"$SOURCES",
|
||||||
|
"-intel",
|
||||||
|
"-o",
|
||||||
|
"$TARGET",
|
||||||
|
"-intel",
|
||||||
|
"--line-length=44"
|
||||||
|
]),
|
||||||
|
suffix=".hex"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Build executable and linkable firmware
|
# Target: Build executable and linkable firmware
|
||||||
@ -49,7 +68,13 @@ target_elf = env.BuildProgram()
|
|||||||
if "uploadlazy" in COMMAND_LINE_TARGETS:
|
if "uploadlazy" in COMMAND_LINE_TARGETS:
|
||||||
target_firm = join("$BUILD_DIR", "firmware.hex")
|
target_firm = join("$BUILD_DIR", "firmware.hex")
|
||||||
else:
|
else:
|
||||||
target_firm = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf)
|
if env.subst("$BOARD") == "rfduino":
|
||||||
|
target_firm = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf)
|
||||||
|
else:
|
||||||
|
target_firm = env.MergeHex(
|
||||||
|
join("$BUILD_DIR", "firmware"),
|
||||||
|
env.ElfToHex(join("$BUILD_DIR", "userfirmware"), target_elf)
|
||||||
|
)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Print binary size
|
# Target: Print binary size
|
||||||
|
@ -181,6 +181,9 @@ PLATFORM_PACKAGES = {
|
|||||||
],
|
],
|
||||||
"tool-arduino101load": [
|
"tool-arduino101load": [
|
||||||
("Genuino101 uploader", "https://github.com/01org/intel-arduino-tools")
|
("Genuino101 uploader", "https://github.com/01org/intel-arduino-tools")
|
||||||
|
],
|
||||||
|
"tool-sreccat": [
|
||||||
|
("Merging tool", "https://github.com/marcows/SRecord")
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +43,10 @@ class Nordicnrf51Platform(BasePlatform):
|
|||||||
"alias": "framework"
|
"alias": "framework"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"tool-sreccat": {
|
||||||
|
"default": True
|
||||||
|
},
|
||||||
|
|
||||||
"tool-rfdloader": {
|
"tool-rfdloader": {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user