Skip to content

Commit 0a7a5ba

Browse files
committed
boards: microblaze: add QEMU demo board with qemu hw-dtb
Internal references: FWRIVERHD-5063 Signed-off-by: Alp Sayin <alpsayin@gmail.com>
1 parent b4aba6f commit 0a7a5ba

15 files changed

+440
-0
lines changed

boards/qemu/microblaze/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright (c) 2023 Advanced Micro Devices, Inc. (AMD)
2+
# Copyright (c) 2023 Alp Sayin <alpsayin@gmail.com>
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
6+
config BOARD_QEMU_MICROBLAZE
7+
select QEMU_TARGET
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright (c) 2023 Advanced Micro Devices, Inc. (AMD)
2+
# Copyright (c) 2023 Alp Sayin <alpsayin@gmail.com>
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
6+
if BOARD_QEMU_MICROBLAZE
7+
8+
config BUILD_OUTPUT_BIN
9+
default n
10+
11+
endif # BOARD_QEMU_MICROBLAZE
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright (c) 2023 Advanced Micro Devices, Inc. (AMD)
2+
# Copyright (c) 2023 Alp Sayin <alpsayin@gmail.com>
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
6+
config BOARD_QEMU_MICROBLAZE
7+
select SOC_XLNX_MICROBLAZE_DEMO
Binary file not shown.

boards/qemu/microblaze/board.cmake

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright (c) 2023 Advanced Micro Devices, Inc. (AMD)
2+
# Copyright (c) 2023 Alp Sayin <alpsayin@gmail.com>
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
6+
set(SUPPORTED_EMU_PLATFORMS qemu)
7+
set(QEMU_ARCH xilinx-microblazeel)
8+
9+
set(QEMU_CPU_TYPE_${ARCH} microblaze)
10+
11+
set(QEMU_FLAGS_${ARCH}
12+
-machine microblaze-fdt
13+
-nographic
14+
-hw-dtb ${ZEPHYR_BASE}/boards/qemu/${ARCH}/board-qemu-microblaze-demo.dtb
15+
# TODO: introduce a feature flags for debug flags
16+
# -D /scratch/esnap_asayin/mb.log # if you enable anything from below, you probably want this too.
17+
# -d int # show interrupts/exceptions in short format
18+
# -d in_asm # show target assembly code for each compiled TB
19+
# -d exec # show trace before each executed TB (lots of logs)
20+
# --trace "memory_region_ops_*"
21+
# --trace "exec_tb*"
22+
)
23+
24+
set(QEMU_KERNEL_OPTION
25+
-kernel \$<TARGET_FILE:\${logical_target_for_zephyr_elf}>
26+
)
27+
28+
board_set_debugger_ifnset(qemu)
29+
30+
add_custom_target(debug_qemu
31+
COMMAND
32+
${CROSS_COMPILE}gdb
33+
-ex \"target extended-remote 127.0.0.1:${DEBUGSERVER_LISTEN_PORT}\"
34+
-ex \"set disassemble-next-line on\"
35+
${APPLICATION_BINARY_DIR}/zephyr/${KERNEL_ELF_NAME}
36+
USES_TERMINAL
37+
)

boards/qemu/microblaze/board.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
board:
2+
name: qemu_microblaze
3+
vendor: xlnx
4+
socs:
5+
- name: microblaze_demo

boards/qemu/microblaze/doc/index.rst

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
.. _qemu_microblaze:
2+
3+
Microblaze Emulation (QEMU)
4+
###########################
5+
6+
Overview
7+
********
8+
9+
The Microblaze QEMU board configuration is used to emulate the Microblaze architecture.
10+
The Microblaze QEMU machine instantiates its peripherals using a Devicetree Blob (DTB)
11+
file located at `boards/microblaze/qemu_microblaze/board-qemu-microblaze-demo.dtb`.
12+
This file has been produced by compiling the QEMU system devicetree inside
13+
`boards/microblaze/qemu_microblaze/hw-dtb`. This directory also includes a Makefile
14+
and a README explaining the compilation process to produce the DTB file.
15+
For the applications to work properly, Zephyr devicetree and QEMU system devicetree must match.
16+
17+
Programming and Debugging
18+
*************************
19+
20+
Applications for the ``qemu_microblaze`` board configuration can be built and run in
21+
the usual way for emulated boards (see :ref:`build_an_application` and
22+
:ref:`application_run` for more details).
23+
24+
Flashing
25+
========
26+
27+
While this board is emulated and you can't "flash" it, you can use this
28+
configuration to run basic Zephyr applications and kernel tests in the QEMU
29+
emulated environment. For example, with the :ref:`synchronization_sample`:
30+
31+
.. zephyr-app-commands::
32+
:zephyr-app: samples/synchronization
33+
:host-os: unix
34+
:board: qemu_microblaze
35+
:goals: run
36+
37+
This will build an image with the synchronization sample app, boot it using
38+
QEMU, and display the following console output:
39+
40+
.. code-block:: console
41+
42+
*** Booting Zephyr OS build v3.4.0-rc3-271-g230a121f6740 ***
43+
thread_a: Hello World from cpu 0 on qemu_microblaze!
44+
thread_b: Hello World from cpu 0 on qemu_microblaze!
45+
thread_a: Hello World from cpu 0 on qemu_microblaze!
46+
thread_b: Hello World from cpu 0 on qemu_microblaze!
47+
thread_a: Hello World from cpu 0 on qemu_microblaze!
48+
thread_b: Hello World from cpu 0 on qemu_microblaze!
49+
50+
Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`.
51+
52+
Debugging
53+
=========
54+
55+
Refer to the detailed overview about :ref:`application_debugging`.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright (c) 2016 Xilinx Inc
2+
# Copyright (c) 2023 Advanced Micro Devices, Inc. (AMD)
3+
# Copyright (c) 2023 Alp Sayin <alpsayin@gmail.com>
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Makefile to build the device trees
7+
#
8+
9+
OUTDIR ?= ./
10+
GCC ?= gcc
11+
DTC ?= dtc
12+
13+
ifeq ($V,)
14+
QUIET=@
15+
.SILENT:
16+
else
17+
QUIET=
18+
endif
19+
20+
SINGLE_ARCH_OUTDIR := $(OUTDIR)/LATEST
21+
22+
DTS_FILES := $(wildcard *.dts)
23+
DTSI_FILES := $(wildcard *.dtsi)
24+
HEADER_FILES := $(wildcard *.dtsh)
25+
HEADER_FILES += $(wildcard include/*.dtsh)
26+
27+
28+
CPPFLAGS = -I. -Iinclude/
29+
30+
.PHONY: all source
31+
32+
TARGETS = \
33+
$(patsubst %.dts,$(SINGLE_ARCH_OUTDIR)/%.$(1),$(DTS_FILES))
34+
35+
COMPILE = \
36+
$(QUIET)mkdir -p $(1); \
37+
$(GCC) -E -nostdinc ${CPPFLAGS} -x assembler-with-cpp $(3) -MD -MF $@.cd -o - $< | \
38+
$(DTC) -q -O $(2) -I dts -o $@ - -b 0; \
39+
cp $(SINGLE_ARCH_OUTDIR)/board-qemu-microblaze-demo.dtb ..; \
40+
rm -rf LATEST;
41+
42+
all: $(call TARGETS,dtb)
43+
44+
-include $(call TARGETS, cd)
45+
46+
source: all $(call TARGETS,dts)
47+
48+
$(SINGLE_ARCH_OUTDIR)/%.dtb: %.dts $(DTSI_FILES) $(HEADER_FILES)
49+
$(call COMPILE,$(SINGLE_ARCH_OUTDIR),dtb)
50+
$(SINGLE_ARCH_OUTDIR)/%.dts: %.dts $(DTSI_FILES) $(HEADER_FILES)
51+
$(call COMPILE,$(SINGLE_ARCH_OUTDIR),dts)
52+
53+
clean:
54+
@rm -rf LATEST;

boards/qemu/microblaze/hw-dtb/README

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
This folder is used to build QEMU specific device trees for MicroBlaze architecture.
2+
These device trees are used by the QEMU provided by Xilinx to internally generate machine models.
3+
4+
To build the device trees:
5+
1. Obtain device-tree-compiler from a package manager.
6+
2. You must have dtc on your PATH, or specify DTC= env to a dtc executable.
7+
3. Run make in this directory
8+
9+
This will overwrite board-microblaze-zephyr-demo.dtb in the parent directory.
10+
The command should clean all temporary files.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) 2023 Advanced Micro Devices, Inc. (AMD)
3+
* Copyright (c) 2023 Alp Sayin <alpsayin@gmail.com>
4+
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
/dts-v1/;
9+
10+
/ {
11+
cpus: cpus {
12+
#address-cells = <1>;
13+
#cpus = <0x1>;
14+
#size-cells = <0>;
15+
};
16+
17+
amba_root: amba_root {
18+
#address-cells = <2>;
19+
#size-cells = <2>;
20+
#priority-cells = <1>;
21+
22+
amba: amba {
23+
compatible = "simple-bus";
24+
};
25+
};
26+
};
27+
28+
#include "qemu-microblaze-demo.dtsi"

0 commit comments

Comments
 (0)