qemu-arm: Factor board config to mk fragments.
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
BOARD ?= mps2-an385
|
BOARD ?= MPS2_AN385
|
||||||
|
|
||||||
# Make the build directory reflect the board.
|
# Make the build directory reflect the board.
|
||||||
BUILD ?= build-$(BOARD)
|
BUILD ?= build-$(BOARD)
|
||||||
@@ -6,6 +6,9 @@ BUILD ?= build-$(BOARD)
|
|||||||
include ../../py/mkenv.mk
|
include ../../py/mkenv.mk
|
||||||
-include mpconfigport.mk
|
-include mpconfigport.mk
|
||||||
|
|
||||||
|
# Include board specific .mk file.
|
||||||
|
include boards/$(BOARD).mk
|
||||||
|
|
||||||
# qstr definitions (must come before including py.mk)
|
# qstr definitions (must come before including py.mk)
|
||||||
QSTR_DEFS = qstrdefsport.h
|
QSTR_DEFS = qstrdefsport.h
|
||||||
|
|
||||||
@@ -17,58 +20,16 @@ FROZEN_MANIFEST ?= "freeze('test-frzmpy')"
|
|||||||
include $(TOP)/py/py.mk
|
include $(TOP)/py/py.mk
|
||||||
include $(TOP)/extmod/extmod.mk
|
include $(TOP)/extmod/extmod.mk
|
||||||
|
|
||||||
CFLAGS += -DMICROPY_HW_BOARD_NAME='"$(BOARD)"'
|
|
||||||
QEMU_ARGS += -machine $(BOARD) -nographic -monitor null -semihosting
|
|
||||||
|
|
||||||
ifeq ($(BOARD),netduino2)
|
|
||||||
CFLAGS += -mthumb -mcpu=cortex-m3 -mfloat-abi=soft
|
|
||||||
CFLAGS += -DQEMU_SOC_STM32
|
|
||||||
CFLAGS += -DMICROPY_HW_MCU_NAME='"STM32"'
|
|
||||||
LDSCRIPT = stm32.ld
|
|
||||||
SRC_BOARD_O = shared/runtime/gchelper_native.o shared/runtime/gchelper_thumb2.o
|
|
||||||
MPY_CROSS_FLAGS += -march=armv7m
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(BOARD),microbit)
|
|
||||||
CFLAGS += -mthumb -mcpu=cortex-m0 -mfloat-abi=soft
|
|
||||||
CFLAGS += -DQEMU_SOC_NRF51
|
|
||||||
CFLAGS += -DMICROPY_HW_MCU_NAME='"nRF51"'
|
|
||||||
LDSCRIPT = nrf51.ld
|
|
||||||
QEMU_ARGS += -global nrf51-soc.flash-size=1048576 -global nrf51-soc.sram-size=262144
|
|
||||||
SRC_BOARD_O = shared/runtime/gchelper_native.o shared/runtime/gchelper_thumb1.o
|
|
||||||
MPY_CROSS_FLAGS += -march=armv7m
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(BOARD),mps2-an385)
|
|
||||||
CFLAGS += -mthumb -mcpu=cortex-m3 -mfloat-abi=soft
|
|
||||||
CFLAGS += -DQEMU_SOC_MPS2
|
|
||||||
CFLAGS += -DMICROPY_HW_MCU_NAME='"Cortex-M3"'
|
|
||||||
LDSCRIPT = mps2.ld
|
|
||||||
SRC_BOARD_O = shared/runtime/gchelper_native.o shared/runtime/gchelper_thumb2.o
|
|
||||||
MPY_CROSS_FLAGS += -march=armv7m
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(BOARD),sabrelite)
|
|
||||||
CFLAGS += -mcpu=cortex-a9
|
|
||||||
CFLAGS += -DQEMU_SOC_IMX6
|
|
||||||
CFLAGS += -DMICROPY_HW_MCU_NAME='"Cortex-A9"'
|
|
||||||
LDSCRIPT = imx6.ld
|
|
||||||
QEMU_ARGS += -m 128M
|
|
||||||
SRC_BOARD_O = shared/runtime/gchelper_generic.o
|
|
||||||
# It's really armv7a but closest supported value is armv6.
|
|
||||||
MPY_CROSS_FLAGS += -march=armv6
|
|
||||||
# Cortex-A9 should support unaligned-access, but qemu doesn't seem to.
|
|
||||||
CFLAGS += -mno-unaligned-access
|
|
||||||
# These don't work on Cortex-A9.
|
|
||||||
TESTS_EXCLUDE = --exclude '(asmdiv|asmspecialregs).py'
|
|
||||||
endif
|
|
||||||
|
|
||||||
CROSS_COMPILE ?= arm-none-eabi-
|
CROSS_COMPILE ?= arm-none-eabi-
|
||||||
|
|
||||||
|
QEMU_SYSTEM = qemu-system-$(QEMU_ARCH)
|
||||||
|
QEMU_ARGS += -machine $(QEMU_MACHINE) -nographic -monitor null -semihosting
|
||||||
|
|
||||||
INC += -I.
|
INC += -I.
|
||||||
INC += -I$(TOP)
|
INC += -I$(TOP)
|
||||||
INC += -I$(BUILD)
|
INC += -I$(BUILD)
|
||||||
|
|
||||||
|
CFLAGS += -DMICROPY_HW_BOARD_NAME='"$(QEMU_MACHINE)"'
|
||||||
CFLAGS += $(INC) -Wall -Wpointer-arith -Wdouble-promotion -Wfloat-conversion -Werror -std=gnu99 $(COPT) \
|
CFLAGS += $(INC) -Wall -Wpointer-arith -Wdouble-promotion -Wfloat-conversion -Werror -std=gnu99 $(COPT) \
|
||||||
-ffunction-sections -fdata-sections
|
-ffunction-sections -fdata-sections
|
||||||
CFLAGS += $(CFLAGS_EXTRA)
|
CFLAGS += $(CFLAGS_EXTRA)
|
||||||
@@ -135,16 +96,16 @@ all: $(BUILD)/firmware.elf
|
|||||||
.PHONY: repl
|
.PHONY: repl
|
||||||
repl: $(BUILD)/firmware.elf
|
repl: $(BUILD)/firmware.elf
|
||||||
$(ECHO) "Use machine.reset() to exit"
|
$(ECHO) "Use machine.reset() to exit"
|
||||||
qemu-system-arm $(QEMU_ARGS) -serial mon:stdio -kernel $<
|
$(QEMU_SYSTEM) $(QEMU_ARGS) -serial mon:stdio -kernel $<
|
||||||
|
|
||||||
.PHONY: run
|
.PHONY: run
|
||||||
run: $(BUILD)/firmware.elf
|
run: $(BUILD)/firmware.elf
|
||||||
qemu-system-arm $(QEMU_ARGS) -serial pty -kernel $<
|
$(QEMU_SYSTEM) $(QEMU_ARGS) -serial pty -kernel $<
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: $(BUILD)/firmware.elf
|
test: $(BUILD)/firmware.elf
|
||||||
$(eval DIRNAME=ports/$(notdir $(CURDIR)))
|
$(eval DIRNAME=ports/$(notdir $(CURDIR)))
|
||||||
cd $(TOP)/tests && ./run-tests.py --target qemu-arm --device execpty:"qemu-system-arm $(QEMU_ARGS) -serial pty -kernel ../$(DIRNAME)/$<" $(TESTS_EXCLUDE)
|
cd $(TOP)/tests && ./run-tests.py --target qemu-arm --device execpty:"$(QEMU_SYSTEM) $(QEMU_ARGS) -serial pty -kernel ../$(DIRNAME)/$<" $(RUN_TESTS_ARGS) $(RUN_TESTS_EXTRA)
|
||||||
|
|
||||||
## `$(LD)` doesn't seem to like `--specs` for some reason, but we can just use `$(CC)` here.
|
## `$(LD)` doesn't seem to like `--specs` for some reason, but we can just use `$(CC)` here.
|
||||||
$(BUILD)/firmware.elf: $(LDSCRIPT) $(ALL_OBJ_RUN)
|
$(BUILD)/firmware.elf: $(LDSCRIPT) $(ALL_OBJ_RUN)
|
||||||
|
|||||||
@@ -32,7 +32,16 @@ Then build using:
|
|||||||
The default qemu-supported board is `mps2-an385`, a Cortex-M3 board. To select a
|
The default qemu-supported board is `mps2-an385`, a Cortex-M3 board. To select a
|
||||||
different board pass the `BOARD` argument to `make`, for example:
|
different board pass the `BOARD` argument to `make`, for example:
|
||||||
|
|
||||||
$ make BOARD=sabrelite
|
$ make BOARD=SABRELITE
|
||||||
|
|
||||||
|
Available boards are:
|
||||||
|
|
||||||
|
| Name for `BOARD=` | Corresponding qemu board |
|
||||||
|
| ----------------- | ------------------------ |
|
||||||
|
| `MICROBIT` | `microbit` |
|
||||||
|
| `MPS2_AN385` | `mps2-an385` |
|
||||||
|
| `NETDUINO2` | `netduino2` |
|
||||||
|
| `SABRELITE` | `sabrelite` |
|
||||||
|
|
||||||
Running
|
Running
|
||||||
-------
|
-------
|
||||||
@@ -67,3 +76,11 @@ tests against the serial device, for example:
|
|||||||
|
|
||||||
$ cd ../../tests
|
$ cd ../../tests
|
||||||
$ ./run-tests.py --target qemu-arm --device /dev/pts/1
|
$ ./run-tests.py --target qemu-arm --device /dev/pts/1
|
||||||
|
|
||||||
|
Extra make options
|
||||||
|
------------------
|
||||||
|
|
||||||
|
The following options can be specified on the `make` command line:
|
||||||
|
- `CFLAGS_EXTRA`: pass in extra flags for the compiler.
|
||||||
|
- `RUN_TESTS_EXTRA`: pass in extra flags for `run-tests.py` when invoked via
|
||||||
|
`make test`.
|
||||||
|
|||||||
13
ports/qemu-arm/boards/MICROBIT.mk
Normal file
13
ports/qemu-arm/boards/MICROBIT.mk
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
QEMU_ARCH = arm
|
||||||
|
QEMU_MACHINE = microbit
|
||||||
|
QEMU_ARGS += -global nrf51-soc.flash-size=1048576 -global nrf51-soc.sram-size=262144
|
||||||
|
|
||||||
|
CFLAGS += -mthumb -mcpu=cortex-m0 -mfloat-abi=soft
|
||||||
|
CFLAGS += -DQEMU_SOC_NRF51
|
||||||
|
CFLAGS += -DMICROPY_HW_MCU_NAME='"nRF51"'
|
||||||
|
|
||||||
|
LDSCRIPT = nrf51.ld
|
||||||
|
|
||||||
|
SRC_BOARD_O = shared/runtime/gchelper_native.o shared/runtime/gchelper_thumb1.o
|
||||||
|
|
||||||
|
MPY_CROSS_FLAGS += -march=armv7m
|
||||||
12
ports/qemu-arm/boards/MPS2_AN385.mk
Normal file
12
ports/qemu-arm/boards/MPS2_AN385.mk
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
QEMU_ARCH = arm
|
||||||
|
QEMU_MACHINE = mps2-an385
|
||||||
|
|
||||||
|
CFLAGS += -mthumb -mcpu=cortex-m3 -mfloat-abi=soft
|
||||||
|
CFLAGS += -DQEMU_SOC_MPS2
|
||||||
|
CFLAGS += -DMICROPY_HW_MCU_NAME='"Cortex-M3"'
|
||||||
|
|
||||||
|
LDSCRIPT = mps2.ld
|
||||||
|
|
||||||
|
SRC_BOARD_O = shared/runtime/gchelper_native.o shared/runtime/gchelper_thumb2.o
|
||||||
|
|
||||||
|
MPY_CROSS_FLAGS += -march=armv7m
|
||||||
12
ports/qemu-arm/boards/NETDUINO2.mk
Normal file
12
ports/qemu-arm/boards/NETDUINO2.mk
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
QEMU_ARCH = arm
|
||||||
|
QEMU_MACHINE = netduino2
|
||||||
|
|
||||||
|
CFLAGS += -mthumb -mcpu=cortex-m3 -mfloat-abi=soft
|
||||||
|
CFLAGS += -DQEMU_SOC_STM32
|
||||||
|
CFLAGS += -DMICROPY_HW_MCU_NAME='"STM32"'
|
||||||
|
|
||||||
|
LDSCRIPT = stm32.ld
|
||||||
|
|
||||||
|
SRC_BOARD_O = shared/runtime/gchelper_native.o shared/runtime/gchelper_thumb2.o
|
||||||
|
|
||||||
|
MPY_CROSS_FLAGS += -march=armv7m
|
||||||
19
ports/qemu-arm/boards/SABRELITE.mk
Normal file
19
ports/qemu-arm/boards/SABRELITE.mk
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
QEMU_ARCH = arm
|
||||||
|
QEMU_MACHINE = sabrelite
|
||||||
|
QEMU_ARGS += -m 128M
|
||||||
|
|
||||||
|
CFLAGS += -mcpu=cortex-a9
|
||||||
|
CFLAGS += -DQEMU_SOC_IMX6
|
||||||
|
CFLAGS += -DMICROPY_HW_MCU_NAME='"Cortex-A9"'
|
||||||
|
# Cortex-A9 should support unaligned-access, but qemu doesn't seem to.
|
||||||
|
CFLAGS += -mno-unaligned-access
|
||||||
|
|
||||||
|
LDSCRIPT = imx6.ld
|
||||||
|
|
||||||
|
SRC_BOARD_O = shared/runtime/gchelper_generic.o
|
||||||
|
|
||||||
|
# It's really armv7a but closest supported value is armv6.
|
||||||
|
MPY_CROSS_FLAGS += -march=armv6
|
||||||
|
|
||||||
|
# These tests don't work on Cortex-A9, so exclude them.
|
||||||
|
RUN_TESTS_ARGS = --exclude '(asmdiv|asmspecialregs).py'
|
||||||
@@ -259,7 +259,7 @@ function ci_qemu_arm_build {
|
|||||||
make ${MAKEOPTS} -C ports/qemu-arm CFLAGS_EXTRA=-DMP_ENDIANNESS_BIG=1
|
make ${MAKEOPTS} -C ports/qemu-arm CFLAGS_EXTRA=-DMP_ENDIANNESS_BIG=1
|
||||||
make ${MAKEOPTS} -C ports/qemu-arm clean
|
make ${MAKEOPTS} -C ports/qemu-arm clean
|
||||||
make ${MAKEOPTS} -C ports/qemu-arm test
|
make ${MAKEOPTS} -C ports/qemu-arm test
|
||||||
make ${MAKEOPTS} -C ports/qemu-arm BOARD=sabrelite test
|
make ${MAKEOPTS} -C ports/qemu-arm BOARD=SABRELITE test
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################################
|
########################################################################################
|
||||||
|
|||||||
Reference in New Issue
Block a user