Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
dc9ecd58
Commit
dc9ecd58
authored
Aug 28, 2024
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qemu-arm: Factor board config to mk fragments.
Signed-off-by:
Damien George
<
damien@micropython.org
>
parent
9396572e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
86 additions
and
52 deletions
+86
-52
ports/qemu-arm/Makefile
ports/qemu-arm/Makefile
+11
-50
ports/qemu-arm/README.md
ports/qemu-arm/README.md
+18
-1
ports/qemu-arm/boards/MICROBIT.mk
ports/qemu-arm/boards/MICROBIT.mk
+13
-0
ports/qemu-arm/boards/MPS2_AN385.mk
ports/qemu-arm/boards/MPS2_AN385.mk
+12
-0
ports/qemu-arm/boards/NETDUINO2.mk
ports/qemu-arm/boards/NETDUINO2.mk
+12
-0
ports/qemu-arm/boards/SABRELITE.mk
ports/qemu-arm/boards/SABRELITE.mk
+19
-0
tools/ci.sh
tools/ci.sh
+1
-1
No files found.
ports/qemu-arm/Makefile
View file @
dc9ecd58
BOARD
?=
mps2-an
385
BOARD
?=
MPS2_AN
385
# Make the build directory reflect the board.
BUILD
?=
build-
$(BOARD)
...
...
@@ -6,6 +6,9 @@ BUILD ?= build-$(BOARD)
include
../../py/mkenv.mk
-include
mpconfigport.mk
# Include board specific .mk file.
include
boards/$(BOARD).mk
# qstr definitions (must come before including py.mk)
QSTR_DEFS
=
qstrdefsport.h
...
...
@@ -17,58 +20,16 @@ FROZEN_MANIFEST ?= "freeze('test-frzmpy')"
include
$(TOP)/py/py.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-
QEMU_SYSTEM
=
qemu-system-
$(QEMU_ARCH)
QEMU_ARGS
+=
-machine
$(QEMU_MACHINE)
-nographic
-monitor
null
-semihosting
INC
+=
-I
.
INC
+=
-I
$(TOP)
INC
+=
-I
$(BUILD)
CFLAGS
+=
-DMICROPY_HW_BOARD_NAME
=
'"
$(QEMU_MACHINE)
"'
CFLAGS
+=
$(INC)
-Wall
-Wpointer-arith
-Wdouble-promotion
-Wfloat-conversion
-Werror
-std
=
gnu99
$(COPT)
\
-ffunction-sections
-fdata-sections
CFLAGS
+=
$(CFLAGS_EXTRA)
...
...
@@ -135,16 +96,16 @@ all: $(BUILD)/firmware.elf
.PHONY
:
repl
repl
:
$(BUILD)/firmware.elf
$(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
run
:
$(BUILD)/firmware.elf
qemu-system-arm
$(QEMU_ARGS)
-serial
pty
-kernel
$<
$(QEMU_SYSTEM)
$(QEMU_ARGS)
-serial
pty
-kernel
$<
.PHONY
:
test
test
:
$(BUILD)/firmware.elf
$(
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.
$(BUILD)/firmware.elf
:
$(LDSCRIPT) $(ALL_OBJ_RUN)
...
...
ports/qemu-arm/README.md
View file @
dc9ecd58
...
...
@@ -32,7 +32,16 @@ Then build using:
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:
$ 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
-------
...
...
@@ -67,3 +76,11 @@ tests against the serial device, for example:
$ cd ../../tests
$ ./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`
.
ports/qemu-arm/boards/MICROBIT.mk
0 → 100644
View file @
dc9ecd58
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
ports/qemu-arm/boards/MPS2_AN385.mk
0 → 100644
View file @
dc9ecd58
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
ports/qemu-arm/boards/NETDUINO2.mk
0 → 100644
View file @
dc9ecd58
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
ports/qemu-arm/boards/SABRELITE.mk
0 → 100644
View file @
dc9ecd58
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'
tools/ci.sh
View file @
dc9ecd58
...
...
@@ -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 clean
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
}
########################################################################################
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment