Skip to content

Commit 6612cea

Browse files
committed
tools/mpy_ld.py: Extended for deepcraft model support.
Signed-off-by: jaenrig-ifx <enriquezgarcia.external@infineon.com>
1 parent 7db1f20 commit 6612cea

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

tools/mpy_ld.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -711,13 +711,13 @@ def do_relocation_text(env, text_addr, r):
711711
(addr, value) = process_riscv32_relocation(env, text_addr, r)
712712

713713
elif env.arch.name == "EM_ARM" and r_info_type == R_ARM_ABS32:
714-
# Absolute relocation, handled as a data relocation.
715-
do_relocation_data(env, text_addr, r)
716-
return
714+
addr = s.section.addr + s["st_value"]
715+
reloc = addr + r_addend
716+
reloc_type = "le32"
717717

718718
else:
719719
# Unknown/unsupported relocation
720-
assert 0, (r_info_type, s.name, s.entry, env.arch.name)
720+
assert 0, r_info_type
721721

722722
# Write relocation
723723
if env.arch.name == "EM_RISCV":
@@ -1140,7 +1140,7 @@ def load_object_file(env, f, felf):
11401140
elif sym.entry["st_shndx"] == "SHN_UNDEF" and sym["st_info"]["bind"] == "STB_GLOBAL":
11411141
# Undefined global symbol, needs resolving
11421142
env.unresolved_syms.append(sym)
1143-
if dup_errors:
1143+
if len(dup_errors) > 0:
11441144
raise LinkError("\n".join(dup_errors))
11451145

11461146

@@ -1202,7 +1202,6 @@ def link_objects(env, native_qstr_vals_len):
12021202
]
12031203
)
12041204
}
1205-
12061205
undef_errors = []
12071206
for sym in env.unresolved_syms:
12081207
assert sym["st_value"] == 0
@@ -1224,7 +1223,7 @@ def link_objects(env, native_qstr_vals_len):
12241223
sym.section = mp_fun_table_sec
12251224
sym.mp_fun_table_offset = fun_table[sym.name]
12261225
else:
1227-
undef_errors.append("{}: undefined symbol: {}".format(sym.filename, sym.name))
1226+
raise LinkError("{}: undefined symbol: {}".format(sym.filename, sym.name))
12281227

12291228
for sym in env.externs:
12301229
if sym in env.known_syms:
@@ -1235,7 +1234,7 @@ def link_objects(env, native_qstr_vals_len):
12351234
),
12361235
)
12371236

1238-
if undef_errors:
1237+
if len(undef_errors) > 0:
12391238
raise LinkError("\n".join(undef_errors))
12401239

12411240
# Align sections, assign their addresses, and create full_text
@@ -1500,7 +1499,6 @@ def do_link(args):
15001499
log(LOG_LEVEL_2, "using " + obj_name)
15011500
with ar.open(obj) as f:
15021501
load_object_file(env, f, obj_name)
1503-
15041502
link_objects(env, len(native_qstr_vals))
15051503
build_mpy(env, env.find_addr("mpy_init"), args.output, native_qstr_vals)
15061504
except LinkError as er:
@@ -1555,16 +1553,14 @@ def parse_linkerscript(source):
15551553
def main():
15561554
import argparse
15571555

1558-
cmd_parser = argparse.ArgumentParser(description="Link native object files into a MPY bundle.")
1556+
cmd_parser = argparse.ArgumentParser(description="Run scripts on the pyboard.")
15591557
cmd_parser.add_argument(
15601558
"--verbose", "-v", action="count", default=1, help="increase verbosity"
15611559
)
15621560
cmd_parser.add_argument("--arch", default="x64", help="architecture")
15631561
cmd_parser.add_argument("--preprocess", action="store_true", help="preprocess source files")
15641562
cmd_parser.add_argument("--qstrs", default=None, help="file defining additional qstrs")
1565-
cmd_parser.add_argument(
1566-
"--libs", "-l", dest="libs", action="append", help="static .a libraries to link"
1567-
)
1563+
cmd_parser.add_argument("-l", dest="libs", action="append", help="Static .a libraries to link")
15681564
cmd_parser.add_argument(
15691565
"--output", "-o", default=None, help="output .mpy file (default to input with .o->.mpy)"
15701566
)

0 commit comments

Comments
 (0)