Skip to content

Commit 853208d

Browse files
committed
Allow to configure upload offset address using board_upload.offset_address option
1 parent 1727dae commit 853208d

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

boards/mxchip_az3166.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
],
3030
"name": "Microsoft Azure IoT Development Kit (MXChip AZ3166)",
3131
"upload": {
32-
"flash_start": "0x0800C000",
32+
"offset_address": "0x0800C000",
3333
"maximum_ram_size": 262144,
3434
"maximum_size": 1048576,
3535
"protocol": "stlink",

builder/main.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,13 @@ def _jlink_cmd_script(env, source):
146146
if not isdir(build_dir):
147147
makedirs(build_dir)
148148
script_path = join(build_dir, "upload.jlink")
149-
commands = ["h", "loadbin %s,0x0" % source, "r", "q"]
149+
commands = [
150+
"h",
151+
"loadbin %s, %s" % (source, env.BoardConfig().get(
152+
"upload.offset_address", "0x08000000")),
153+
"r",
154+
"q"
155+
]
150156
with open(script_path, "w") as fp:
151157
fp.write("\n".join(commands))
152158
return script_path
@@ -193,13 +199,14 @@ def __configure_upload_port(env):
193199
env.Replace(
194200
UPLOADER="openocd",
195201
UPLOADERFLAGS=["-s", platform.get_package_dir("tool-openocd") or ""] +
196-
debug_tools.get(upload_protocol).get("server").get("arguments", []) +
197-
["-c",
198-
"program {{$SOURCE}} %s verify reset; shutdown;" % env.BoardConfig().get(
199-
"upload").get("flash_start", "")],
202+
debug_tools.get(upload_protocol).get("server").get("arguments", []) + [
203+
"-c",
204+
"program {{$SOURCE}} verify reset %s; shutdown;" %
205+
env.BoardConfig().get("upload.offset_address", "")
206+
],
200207
UPLOADCMD="$UPLOADER $UPLOADERFLAGS")
201208

202-
if not env.BoardConfig().get("upload").get("flash_start"):
209+
if not env.BoardConfig().get("upload").get("offset_address"):
203210
upload_source = target_elf
204211
upload_actions = [env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")]
205212

0 commit comments

Comments
 (0)