py/dynruntime.mk: Add basic support for armv6m architecture.

The examples/natmod features0 and features1 examples now build and run on
ARMv6-M platforms.  More complicated examples are not yet supported because
the compiler emits references to built-in functions like __aeabi_uidiv.

Signed-off-by: Damien George <damien@micropython.org>
pull/8694/head
Damien George 2022-05-23 22:50:34 +10:00
rodzic 0e28a1f0e5
commit c1b9d2259e
3 zmienionych plików z 29 dodań i 5 usunięć

Wyświetl plik

@ -34,6 +34,7 @@ options for the ``ARCH`` variable, see below):
* ``x86`` (32 bit)
* ``x64`` (64 bit x86)
* ``armv6m`` (ARM Thumb, eg Cortex-M0)
* ``armv7m`` (ARM Thumb 2, eg Cortex-M3)
* ``armv7emsp`` (ARM Thumb 2, single precision float, eg Cortex-M4F, Cortex-M7)
* ``armv7emdp`` (ARM Thumb 2, double precision float, eg Cortex-M7)
@ -171,7 +172,7 @@ The file ``Makefile`` contains:
# Source files (.c or .py)
SRC = factorial.c
# Architecture to build for (x86, x64, armv7m, xtensa, xtensawin)
# Architecture to build for (x86, x64, armv6m, armv7m, xtensa, xtensawin)
ARCH = x64
# Include to get the rules for compiling and linking the module

Wyświetl plik

@ -55,6 +55,13 @@ CROSS =
CFLAGS += -fno-stack-protector
MICROPY_FLOAT_IMPL ?= double
else ifeq ($(ARCH),armv6m)
# thumb
CROSS = arm-none-eabi-
CFLAGS += -mthumb -mcpu=cortex-m0
MICROPY_FLOAT_IMPL ?= none
else ifeq ($(ARCH),armv7m)
# thumb

Wyświetl plik

@ -38,6 +38,7 @@ import makeqstrdata as qstrutil
MPY_VERSION = 6
MP_NATIVE_ARCH_X86 = 1
MP_NATIVE_ARCH_X64 = 2
MP_NATIVE_ARCH_ARMV6M = 4
MP_NATIVE_ARCH_ARMV7M = 5
MP_NATIVE_ARCH_ARMV7EMSP = 7
MP_NATIVE_ARCH_ARMV7EMDP = 8
@ -82,7 +83,14 @@ def asm_jump_x86(entry):
return struct.pack("<BI", 0xE9, entry - 5)
def asm_jump_arm(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))
def asm_jump_thumb2(entry):
b_off = entry - 4
if b_off >> 11 == 0 or b_off >> 11 == -1:
# Signed value fits in 12 bits
@ -129,13 +137,21 @@ ARCH_DATA = {
(R_X86_64_GOTPCREL, R_X86_64_REX_GOTPCRELX),
asm_jump_x86,
),
"armv6m": ArchData(
"EM_ARM",
MP_NATIVE_ARCH_ARMV6M << 2,
2,
4,
(R_ARM_GOT_BREL,),
asm_jump_thumb,
),
"armv7m": ArchData(
"EM_ARM",
MP_NATIVE_ARCH_ARMV7M << 2,
2,
4,
(R_ARM_GOT_BREL,),
asm_jump_arm,
asm_jump_thumb2,
),
"armv7emsp": ArchData(
"EM_ARM",
@ -143,7 +159,7 @@ ARCH_DATA = {
2,
4,
(R_ARM_GOT_BREL,),
asm_jump_arm,
asm_jump_thumb2,
),
"armv7emdp": ArchData(
"EM_ARM",
@ -151,7 +167,7 @@ ARCH_DATA = {
2,
4,
(R_ARM_GOT_BREL,),
asm_jump_arm,
asm_jump_thumb2,
),
"xtensa": ArchData(
"EM_XTENSA",