Skip to contentSkip to conversation

semihosting_tests: include a32 and t32 hlt variants in all target

PATCH In review Alex Bennée 2 participants 5 messages Jul 10, 2019 – Jul 11, 2019 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 semihosting_tests: include a32 and t32 hlt variants in all target

While this would likely be triggered by "make run" we should also include them in the default "make (all)" build target.

---
 Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Makefile +3 -1
index 1fea97e..7ad2512 100644
@@ -60,7 +60,9 @@ QEMU_SYSTEM_ARM = $(QEMU_BUILDDIR)/arm-softmmu/qemu-system-arm $(SYSGDB)
 QEMU_SYSTEM_AARCH64 = $(QEMU_BUILDDIR)/aarch64-softmmu/qemu-system-aarch64 $(SYSGDB)
 
 all: usertest-a32 usertest-a64 usertest-t32 \
-	systest-a32.axf systest-t32.axf systest-a64.axf
+	systest-a32.axf systest-t32.axf \
+	systest-a32-hlt.axf systest-t32-hlt.axf \
+	systest-a64.axf
 
 usertest-srcs = usertest.c semihosting.c semicall.S printf/printf.c
 
Signature · 1 line
2.20.1
#1 lore raw

PATCH 2/2 semihosting tests: add v7m tests

M-profile has yet another way of triggering semihosting calls using the BKPT instruction. To support this we need to add a M-profile setup so we use the nice and simple microbit model which has a Cortex-M0 in it.

---
v2
- add copyright headers
- better linker script
- use .type foo, function instead of hacks

---
 Makefile         | 14 ++++++++++++-
 microbit.lds     | 47 ++++++++++++++++++++++++++++++++++++++++++++
 semicall.S       |  8 +++++++-
 start-microbit.S | 51 ++++++++++++++++++++++++++++++++++++++++++++++++
 usertest.c       |  4 +++-
 5 files changed, 121 insertions(+), 3 deletions(-)
 create mode 100644 microbit.lds
 create mode 100644 start-microbit.S
Makefile +13 -1
index 7ad2512..1296fde 100644
@@ -40,6 +40,7 @@
 
 A32GCC := arm-linux-gnueabihf-gcc -marm
 T32GCC := arm-linux-gnueabihf-gcc -mthumb
+V7MGCC := arm-none-eabi-gcc -mcpu=cortex-m0 -mfloat-abi=soft
 A64GCC := aarch64-linux-gnu-gcc
 
 A32LD := arm-linux-gnueabihf-ld
@@ -47,6 +48,8 @@ A32LD := arm-linux-gnueabihf-ld
 A32LINKOPTS := -nostdlib -lgcc -Xlinker --script=baremetal.lds -Xlinker --build-id=none
 A64LINKOPTS := -nostdlib -lgcc -Xlinker --script=baremetal-a64.lds -Xlinker --build-id=none
 
+AV7MLINKOPTS := -nostdlib -lgcc -Xlinker --script=microbit.lds -Xlinker --build-id=none
+
 QEMU_BUILDDIR := ~/linaro/qemu-from-laptop/qemu/build/x86
 
 ifdef GDBPORT
@@ -62,11 +65,13 @@ QEMU_SYSTEM_AARCH64 = $(QEMU_BUILDDIR)/aarch64-softmmu/qemu-system-aarch64 $(SYS
 all: usertest-a32 usertest-a64 usertest-t32 \
 	systest-a32.axf systest-t32.axf \
 	systest-a32-hlt.axf systest-t32-hlt.axf \
+	systest-t32-bkpt.axf \
 	systest-a64.axf
 
 usertest-srcs = usertest.c semihosting.c semicall.S printf/printf.c
 
 systest-srcs = start.S string.c $(usertest-srcs)
+microbit-systest-srcs = microbit.lds start-microbit.S string.c $(usertest-srcs)
 
 usertest-a32: $(usertest-srcs)
 	$(A32GCC) --static -o $@ $^
@@ -95,6 +100,9 @@ systest-a32-hlt.axf: $(systest-srcs)
 systest-t32-hlt.axf: $(systest-srcs)
 	$(T32GCC) -DUSE_HLT -o $@ $^ $(A32LINKOPTS)
 
+systest-t32-bkpt.axf: $(microbit-systest-srcs)
+	$(V7MGCC) -DUSE_BKPT -o $@ $^ $(AV7MLINKOPTS)
+
 systest-a64.axf: $(systest-srcs)
 	$(A64GCC) -nostdlib -o $@ $^ $(A64LINKOPTS)
 
@@ -125,6 +133,9 @@ run-systest-a32-hlt: systest-a32-hlt.axf
 run-systest-t32-hlt: systest-t32-hlt.axf
 	$(QEMU_SYSTEM_ARM) -M virt --display none --semihosting -kernel $^
 
+run-systest-t32-bkpt: systest-t32-bkpt.axf
+	$(QEMU_SYSTEM_ARM) -M microbit --display none --semihosting -kernel $^
+
 run-systest-a64: systest-a64.axf
 	$(QEMU_SYSTEM_AARCH64) -M virt --display none --semihosting \
 		-cpu cortex-a57 -kernel $^
@@ -132,4 +143,5 @@ run-systest-a64: systest-a64.axf
 run: run-usertest-a32 run-usertest-t32 run-usertest-a64 \
 	run-systest-a32 run-systest-t32 run-systest-a64 \
 	run-usertest-a32-hlt run-usertest-t32-hlt \
-	run-systest-a32-hlt run-systest-t32-hlt
+	run-systest-a32-hlt run-systest-t32-hlt \
+	run-systest-t32-bkpt
microbit.lds new file +47 -0

47 lines not on this page · raw message

semicall.S +7 -1
index 1418a42..6213cea 100644
@@ -29,6 +29,7 @@
 #endif
 
         .globl __semi_call
+        .type __semi_call, function
 __semi_call:
 #if defined(__aarch64__)
         hlt 0xf000
@@ -51,8 +52,13 @@ __semi_call:
 #else
         /* traditional svc */
 #if defined(__thumb__)
-        /* NB: assumes not M-profile (which is BKPT) */
+#if defined(USE_BKPT)
+        /* M-profile T32 */
+        bkpt 0xab
+#else
+        /* A+R Profile T32 */
         svc 0xab
+#endif
 #else
         svc 0x123456
 #endif
start-microbit.S new file +51 -0

51 lines not on this page · raw message

usertest.c +3 -1
index 16ef0fe..d95cf90 100644
@@ -1,5 +1,7 @@
 /*
- * usertest.c -- top level test file for usermode tests
+ * usertest.c -- top level test file for usermode tests.
+ *
+ * System tests also call this main after start[-microbit].S
  *
  * Copyright (c) 2015 Linaro Limited
  * All rights reserved.
Signature · 1 line
2.20.1
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH for semihosting-tests 2/2] semihosting tests: add v7m tests

Quoted 7 lines · Alex Bennée

M-profile has yet another way of triggering semihosting calls using the BKPT instruction. To support this we need to add a M-profile setup so we use the nice and simple microbit model which has a Cortex-M0 in it.

This generally looks good. One issue: when linking the compiler prints this warning:

arm-none-eabi-gcc -mcpu=cortex-m0 -mfloat-abi=soft -DUSE_BKPT -o systest-t32-bkpt.axf microbit.lds start-microbit.S string.c usertest.c semihosting.c semicall.S printf/printf.c -nostdlib -lgcc -Xlinker --script=microbit.lds -Xlinker --build-id=none /usr/lib/gcc/arm-none-eabi/6.3.1/../../../arm-none-eabi/bin/ld:
warning: cannot find entry symbol exc_reset_thumb; defaulting to 0000000000000000

Quoted 1 line

+ENTRY(exc_reset_thumb)

I guess this should say "reset_thumb" to match the actual definition:

start-microbit.S line 46

Quoted 3 lines
start-microbit.S new file +3 -0
+        /* declare as a function so pointers are appropriatley "thumbed" */
+        .type reset_thumb, function
+reset_thumb:

?

Otherwise

PS: are you deliberately sending these to qemu-arm only and not qemu-devel ?

thanks
-- PMM

#3 lore raw

Re: [PATCH for semihosting-tests 2/2] semihosting tests: add v7m tests

Quoted 20 lines · Peter Maydell
Quoted 7 lines · Alex Bennée

M-profile has yet another way of triggering semihosting calls using the BKPT instruction. To support this we need to add a M-profile setup so we use the nice and simple microbit model which has a Cortex-M0 in it.

This generally looks good. One issue: when linking the compiler prints this warning:

arm-none-eabi-gcc -mcpu=cortex-m0 -mfloat-abi=soft -DUSE_BKPT -o systest-t32-bkpt.axf microbit.lds start-microbit.S string.c usertest.c semihosting.c semicall.S printf/printf.c -nostdlib -lgcc -Xlinker --script=microbit.lds -Xlinker --build-id=none /usr/lib/gcc/arm-none-eabi/6.3.1/../../../arm-none-eabi/bin/ld:
warning: cannot find entry symbol exc_reset_thumb; defaulting to 0000000000000000

Quoted 4 lines
Quoted 1 line

+ENTRY(exc_reset_thumb)

I guess this should say "reset_thumb" to match the actual definition:

oops missed that.

Quoted 7 lines

start-microbit.S line 46

Quoted 5 lines
start-microbit.S new file +3 -0
+        /* declare as a function so pointers are appropriatley "thumbed" */
+        .type reset_thumb, function
+reset_thumb:
Quoted 5 lines

Otherwise

PS: are you deliberately sending these to qemu-arm only and not qemu-devel ?

yes.. given they were ARM testcase specific. I can include qemu-devel on the next iteration if you wish.

Quoted 3 lines

thanks
-- PMM

--
Alex Bennée

#4 lore raw
In reply to Alex Bennée
Quoted 14 lines · Alex Bennée

While this would likely be triggered by "make run" we should also include them in the default "make (all)" build target.

---
 Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Makefile +0 -0
index 1fea97e..7ad2512 100644

Makefile QEMU_SYSTEM_ARM = $(QEMU_BUILDDIR)/arm-softmmu/qemu-system-arm $(SYSGDB) · line 67

Quoted 9 lines
Makefile +3 -1
@@ -60,7 +60,9 @@ QEMU_SYSTEM_ARM = $(QEMU_BUILDDIR)/arm-softmmu/qemu-system-arm $(SYSGDB)
 QEMU_SYSTEM_AARCH64 = $(QEMU_BUILDDIR)/aarch64-softmmu/qemu-system-aarch64 $(SYSGDB)
 
 all: usertest-a32 usertest-a64 usertest-t32 \
-       systest-a32.axf systest-t32.axf systest-a64.axf
+       systest-a32.axf systest-t32.axf \
+       systest-a32-hlt.axf systest-t32-hlt.axf \
+       systest-a64.axf
 
 usertest-srcs = usertest.c semihosting.c semicall.S printf/printf.c

Applied to the semihosting-tests repo, thanks.

-- PMM