Thanks to visit codestin.com
Credit goes to github.com

Skip to content

mpy_ld.py: Support modules larger than 4KiB on armv6m #12241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions tools/mpy_ld.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,33 @@ def asm_jump_x86(entry):


def asm_jump_thumb(entry):
# Only signed values that fit in 12 bits are supported
b_off = entry - 4
assert b_off >> 11 == 0 or b_off >> 11 == -1, b_off
return struct.pack("<H", 0xE000 | (b_off >> 1 & 0x07FF))

#short_jump = b_off >> 11 == 0 or b_off >> 11 == -1
short_jump = False
if short_jump:
assert b_off >> 11 == 0 or b_off >> 11 == -1, b_off
# Only signed values that fit in 12 bits are supported
return struct.pack("<H", 0xE000 | (b_off >> 1 & 0x07FF))
else:
# use a veneer / trampoline to do the far jump
# push {r0}
push = 0xB401
# ldr r0, [pc, #8]
ldr = 0x4802
# add r0, pc
addpc = 0x4478
# mov ip, r0
mov = 0x4684
# pop {r0}
pop = 0xbc01
# bx ip
bx = 0x4760
# .word OFFSET
target = b_off - 4 # FUDGE

out = struct.pack("<HHHHHHI", push, ldr, addpc, mov, pop, bx, target)
return out

def asm_jump_thumb2(entry):
b_off = entry - 4
Expand Down
Loading