diff --git a/boards/arm/zybo/Kconfig.board b/boards/arm/zybo/Kconfig.board new file mode 100644 index 00000000000..30dfd50f3da --- /dev/null +++ b/boards/arm/zybo/Kconfig.board @@ -0,0 +1,8 @@ +# Digilent Zybo board configuration + +# Copyright (c) 2022 Henrik Brix Andersen +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_ZYBO + bool "Digilent Zybo" + depends on SOC_XILINX_XC7Z010 diff --git a/boards/arm/zybo/Kconfig.defconfig b/boards/arm/zybo/Kconfig.defconfig new file mode 100644 index 00000000000..5d0b1c7f5f3 --- /dev/null +++ b/boards/arm/zybo/Kconfig.defconfig @@ -0,0 +1,15 @@ +# Digilent Zybo board + +# Copyright (c) 2022 Henrik Brix Andersen +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_ZYBO + +config BOARD + default "zybo" + +config UART_XLNX_PS + default y + depends on SERIAL + +endif # BOARD_ZYBO diff --git a/boards/arm/zybo/board.cmake b/boards/arm/zybo/board.cmake new file mode 100644 index 00000000000..0d3dae9262a --- /dev/null +++ b/boards/arm/zybo/board.cmake @@ -0,0 +1,5 @@ +# Copyright (c) 2022 Henrik Brix Andersen +# SPDX-License-Identifier: Apache-2.0 + +board_runner_args(openocd "--use-elf" "--cmd-reset-halt" "halt") +include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) diff --git a/boards/arm/zybo/doc/index.rst b/boards/arm/zybo/doc/index.rst new file mode 100644 index 00000000000..d48e59801fa --- /dev/null +++ b/boards/arm/zybo/doc/index.rst @@ -0,0 +1,148 @@ +.. _zybo: + +Digilent Zybo +############# + +Overview +******** + +The `Digilent Zybo`_ (ZYnq BOard) is a feature-rich, ready-to-use embedded software and digital +circuit development board. It is built around the Xilinx Zynq-7000 family, which is based on the +Xilinx All Programmable System-on-Chip (AP SoC) architecture. This architecture tightly integrates a +dual-core ARM Cortex-A9 processor with Xilinx 7-series Field Programmable Gate Array (FPGA) logic. + +.. figure:: ./zybo-0.png + :width: 600px + :align: center + :alt: Digilent Zybo + + Digilent (Credit: Digilent) + +Hardware +******** + +Supported Features +================== + +The zybo board configuration supports the following hardware features: + ++------------+------------+-------------------------------------+ +| Interface | Controller | Driver/Component | ++============+============+=====================================+ +| GICv1 | on-chip | ARM generic interrupt controller v1 | ++------------+------------+-------------------------------------+ +| ARCH TIMER | on-chip | ARM architected timer | ++------------+------------+-------------------------------------+ +| PINCTRL | on-chip | pinctrl | ++------------+------------+-------------------------------------+ +| GPIO | on-chip | gpio | ++------------+------------+-------------------------------------+ +| UART | on-chip | serial port-polling; | +| | | serial port-interrupt | ++------------+------------+-------------------------------------+ + +The default configuration can be found in the defconfig file: +``boards/arm/zybo/zybo_defconfig``. + +Other hardware features are not currently supported by the port. + +Programming and Debugging +************************* + +The Zynq-7000 series SoC needs to be initialized prior to running a Zephyr application. This can be +achieved in a number of ways (e.g. using the Xilinx First Stage Boot Loader (FSBL), the Xilinx +Vivado generated ``ps_init.tcl`` JTAG script, Das U-Boot Secondary Program Loader (SPL), ...). + +The instructions here use the U-Boot SPL. For further details and instructions for using Das U-Boot +with Xilinx Zynq-7000 series SoCs, see the following documentation: + +- `Das U-Boot Website`_ +- `Using Distro Boot With Xilinx U-Boot`_ + +Building Das U-Boot +=================== + +Clone and build Das U-Boot for the Digilent Zybo: + +.. code-block:: console + + git clone -b v2022.04 https://source.denx.de/u-boot/u-boot.git + cd u-boot + make distclean + make xilinx_zynq_virt_defconfig + export PATH=/path/to/zephyr-sdk/arm-zephyr-eabi/bin/:$PATH + export CROSS_COMPILE=arm-zephyr-eabi- + export DEVICE_TREE="zynq-zybo" + make + +Flashing +======== + +Here is an example for running the :ref:`hello_world` application via JTAG. + +Ensure the board is configured for JTAG boot, open a serial terminal, turn on/reset the board (press +the ``PS-SRST`` button), and initialize the Zynq-7000 series SoC by uploading and running the U-Boot +SPL via JTAG. + +Next, upload and run the Zephyr application: + +.. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: zybo + :goals: flash + +You should see the following message in the terminal: + +.. code-block:: console + + *** Booting Zephyr OS vx.xx.x-xxx-gxxxxxxxxxxxx *** + Hello World! zybo + +Another option is to load and run the :ref:`hello_world` application via U-Boot. Copy +``u-boot/spl/boot.bin``, ``u-boot/u-boot.img``, and ``zephyr/zephyr.bin`` to a FAT32 formatted +microSD card, insert the card in the ``SD MICRO`` slot on the Zybo board, ensure the board is +configured for ``SD`` boot, and turn on the board. + +Once U-boot is done initializing, load an run the Zephyr application: + +.. code-block:: console + + Zynq> fatload mmc 0 0x0 zephyr.bin + 817120 bytes read in 56 ms (13.9 MiB/s) + Zynq> go 0x0 + ## Starting application at 0x00000000 ... + *** Booting Zephyr OS vx.xx.x-xxx-gxxxxxxxxxxxx *** + Hello World! zybo + +Debugging +========= + +Here is an example for the :ref:`hello_world` application. + +Ensure the board is configured for JTAG boot, open a serial terminal, turn on/reset the board (press +the ``PS-SRST`` button), and initialize the Zynq-7000 series SoC by uploading and running the U-Boot +SPL via JTAG. + +Next, upload and debug the Zephyr application: + +.. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: zybo + :goals: debug + +Step through the application in your debugger, and you should see the following message in the +terminal: + +.. code-block:: console + + *** Booting Zephyr OS vx.x.x-xxx-gxxxxxxxxxxxx *** + Hello World! zybo + +.. _Digilent Zybo: + https://digilent.com/reference/programmable-logic/zybo/start + +.. _Das U-Boot Website: + https://www.denx.de/wiki/U-Boot + +.. _Using Distro Boot With Xilinx U-Boot: + https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/749142017/Using+Distro+Boot+With+Xilinx+U-Boot diff --git a/boards/arm/zybo/doc/zybo-0.png b/boards/arm/zybo/doc/zybo-0.png new file mode 100644 index 00000000000..eb78e27b3af Binary files /dev/null and b/boards/arm/zybo/doc/zybo-0.png differ diff --git a/boards/arm/zybo/support/openocd.cfg b/boards/arm/zybo/support/openocd.cfg new file mode 100644 index 00000000000..e72b8ab6e1c --- /dev/null +++ b/boards/arm/zybo/support/openocd.cfg @@ -0,0 +1,3 @@ +source [find interface/ftdi/digilent-hs1.cfg] +transport select jtag +source [find target/zynq_7000.cfg] diff --git a/boards/arm/zybo/zybo-pinctrl.dtsi b/boards/arm/zybo/zybo-pinctrl.dtsi new file mode 100644 index 00000000000..a55aafd47c9 --- /dev/null +++ b/boards/arm/zybo/zybo-pinctrl.dtsi @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2022 Henrik Brix Andersen + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +&pinctrl0 { + pinctrl_uart1_default: uart1-default { + mux { + groups = "uart1_10_grp"; + function = "uart1"; + }; + + conf { + groups = "uart1_10_grp"; + slew-rate = ; + power-source = ; + }; + + conf-rx { + pins = "MIO49"; + bias-high-impedance; + }; + + conf-tx { + pins = "MIO48"; + bias-disable; + }; + }; +}; diff --git a/boards/arm/zybo/zybo.dts b/boards/arm/zybo/zybo.dts new file mode 100644 index 00000000000..95297c36384 --- /dev/null +++ b/boards/arm/zybo/zybo.dts @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2022 Henrik Brix Andersen + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include +#include + +#include "zybo-pinctrl.dtsi" + +/ { + model = "Digilent Zybo board"; + compatible = "digilent,zynq-zybo", "xlnx,zynq-7000"; + + #address-cells = <1>; + #size-cells = <1>; + + chosen { + zephyr,sram = &sram0; + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,ocm = &ocm_high; + }; + + aliases { + led0 = &ld_mio; + sw0 = &btn4; + sw1 = &btn5; + }; + + cpus { + #address-cells = <1>; + #size-cells = <0>; + + cpu0: cpu@0 { + device_type = "cpu"; + compatible = "arm,cortex-a9"; + reg = <0>; + }; + + cpu1: cpu@1 { + device_type = "cpu"; + compatible = "arm,cortex-a9"; + reg = <1>; + }; + }; + + sram0: memory@0 { + compatible = "mmio-sram"; + reg = <0x00000000 DT_SIZE_M(512)>; + }; + + leds { + compatible = "gpio-leds"; + ld_mio: led_mio { + gpios = <&psgpio_bank0 7 GPIO_ACTIVE_HIGH>; + label = "LD_MIO"; + }; + }; + + gpio_keys { + compatible = "gpio-keys"; + btn4: btn4 { + gpios = <&psgpio_bank1 18 GPIO_ACTIVE_LOW>; + label = "BTN4"; + }; + btn5: btn5 { + gpios = <&psgpio_bank1 19 GPIO_ACTIVE_LOW>; + label = "BTN5"; + }; + }; +}; + +&uart1 { + status = "okay"; + current-speed = <115200>; + clock-frequency = <100000000>; + pinctrl-0 = <&pinctrl_uart1_default>; + pinctrl-names = "default"; +}; + +&psgpio { + status = "okay"; +}; diff --git a/boards/arm/zybo/zybo.yaml b/boards/arm/zybo/zybo.yaml new file mode 100644 index 00000000000..24054386106 --- /dev/null +++ b/boards/arm/zybo/zybo.yaml @@ -0,0 +1,14 @@ +# Copyright (c) 2022 Henrik Brix Andersen +# SPDX-License-Identifier: Apache-2.0 + +identifier: zybo +name: Digilent Zybo +type: mcu +arch: arm +toolchain: + - zephyr + - gnuarmemb + - xtools +ram: 524288 +supported: + - gpio diff --git a/boards/arm/zybo/zybo_defconfig b/boards/arm/zybo/zybo_defconfig new file mode 100644 index 00000000000..ad4d88eaee3 --- /dev/null +++ b/boards/arm/zybo/zybo_defconfig @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_SOC_SERIES_XILINX_XC7ZXXX=y +CONFIG_SOC_XILINX_XC7Z010=y +CONFIG_BOARD_ZYBO=y + +# The GTC is always clocked at 1/2 of the CPU frequency (CPU_3x2x) +CONFIG_ARM_ARCH_TIMER=y +CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=325000000 + +CONFIG_PINCTRL=y +CONFIG_SERIAL=y +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y