Skip to content

Commit

Permalink
Merge pull request #35 from tknopp/JS/Z7020
Browse files Browse the repository at this point in the history
Add support for Zynq 7020-based Red Pitayas
  • Loading branch information
nHackel authored Feb 16, 2022
2 parents 7d2ec0a + 28a5819 commit 4014386
Show file tree
Hide file tree
Showing 265 changed files with 169,864 additions and 1,292 deletions.
17 changes: 15 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
build/
*.jou
*.log
*.txt
*log*.txt
*.asv
*.pyc
src/client/python/.pydevproject
Expand All @@ -10,9 +10,22 @@ src/examples/python/.pydevproject
src/examples/python/.project
src/examples/julia/images
core
bitfiles
*.jl.cov
*.jl.*.cov
*.jl.mem
docs/build/
Manifest.toml
vivado*
*.apk
*.bin
*.dtb
*.img
*.tar.gz
*.zip
vivado*
webtalk*
tmp
uImage
.vscode
vivado*
.Xil
170 changes: 166 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,176 @@
all:
# 'make' builds everything
# 'make clean' deletes everything except source files and Makefile
#
# You need to set NAME, PART and PROC for your project.
# NAME is the base name for most of the generated files.

# solves problem with awk while building linux kernel
# solution taken from http://www.googoolia.com/wp/2015/04/21/awk-symbol-lookup-error-awk-undefined-symbol-mpfr_z_sub/
LD_LIBRARY_PATH =

BUILD_DIR = build/linux-image

NAME = led_blinker
PART = xc7z010clg400-1
PROC = ps7_cortexa9_0

CORES = axi_axis_reader_v1_0 port_slicer_v1_0 dna_reader_v1_0 axi_sts_register_v1_0\

DAQ_PARTS = xc7z010clg400-1 xc7z020clg400-1\

VIVADO = vivado -nolog -nojournal -mode batch
XSCT = xsct
RM = rm -rf

UBOOT_TAG = 2021.04
LINUX_TAG = 5.10
DTREE_TAG = xilinx-v2020.2

UBOOT_DIR = $(BUILD_DIR)/tmp/u-boot-$(UBOOT_TAG)
LINUX_DIR = $(BUILD_DIR)/tmp/linux-$(LINUX_TAG)
DTREE_DIR = $(BUILD_DIR)/tmp/device-tree-xlnx-$(DTREE_TAG)

UBOOT_TAR = $(BUILD_DIR)/tmp/u-boot-$(UBOOT_TAG).tar.bz2
LINUX_TAR = $(BUILD_DIR)/tmp/linux-$(LINUX_TAG).tar.xz
DTREE_TAR = $(BUILD_DIR)/tmp/device-tree-xlnx-$(DTREE_TAG).tar.gz

UBOOT_URL = https://ftp.denx.de/pub/u-boot/u-boot-$(UBOOT_TAG).tar.bz2
LINUX_URL = https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-$(LINUX_TAG).80.tar.xz
DTREE_URL = https://github.com/Xilinx/device-tree-xlnx/archive/$(DTREE_TAG).tar.gz

RTL8188_TAR = $(BUILD_DIR)/tmp/rtl8188eu-v5.2.2.4.tar.gz
RTL8188_URL = https://github.com/lwfinger/rtl8188eu/archive/v5.2.2.4.tar.gz

RTL8192_TAR = $(BUILD_DIR)/tmp/rtl8192cu-fixes-master.tar.gz
RTL8192_URL = https://github.com/pvaret/rtl8192cu-fixes/archive/master.tar.gz

.PRECIOUS: $(BUILD_DIR)/tmp/cores/% $(BUILD_DIR)/tmp/%.xpr $(BUILD_DIR)/tmp/%.xsa $(BUILD_DIR)/tmp/%.bit $(BUILD_DIR)/tmp/%.fsbl/executable.elf $(BUILD_DIR)/tmp/%.tree/system-top.dts

all: daq_bitfiles $(BUILD_DIR)/tmp/$(NAME).bit $(BUILD_DIR)/boot.bin $(BUILD_DIR)/uImage $(BUILD_DIR)/devicetree.dtb linux

daq_bitfiles: $(addsuffix .bit, $(addprefix bitfiles/daq_,$(DAQ_PARTS)))

bitfiles/daq_%.bit:
sh scripts/make_fpga_project.sh $*
sh scripts/make_implementation.sh $*

linux: daq_bitfiles $(BUILD_DIR)/tmp/$(NAME).bit $(BUILD_DIR)/boot.bin $(BUILD_DIR)/uImage $(BUILD_DIR)/devicetree.dtb
sh scripts/alpine.sh

cores: $(addprefix tmp/cores/, $(CORES))

xpr: $(BUILD_DIR)/tmp/$(NAME).xpr

bit: $(BUILD_DIR)/tmp/$(NAME).bit

$(UBOOT_TAR):
mkdir -p $(@D)
curl -L $(UBOOT_URL) -o $@

$(LINUX_TAR):
mkdir -p $(@D)
curl -L $(LINUX_URL) -o $@

$(DTREE_TAR):
mkdir -p $(@D)
curl -L $(DTREE_URL) -o $@

$(RTL8188_TAR):
mkdir -p $(@D)
curl -L $(RTL8188_URL) -o $@

$(RTL8192_TAR):
mkdir -p $(@D)
curl -L $(RTL8192_URL) -o $@

$(UBOOT_DIR): $(UBOOT_TAR)
mkdir -p $@
tar -jxf $< --strip-components=1 --directory=$@
patch -d $(BUILD_DIR)/tmp -p 0 < linux-image/patches/u-boot-$(UBOOT_TAG).patch
cp linux-image/patches/zynq_red_pitaya_defconfig $@/configs
cp linux-image/patches/zynq-red-pitaya.dts $@/arch/arm/dts

$(LINUX_DIR): $(LINUX_TAR) $(RTL8188_TAR) $(RTL8192_TAR)
mkdir -p $@
tar -Jxf $< --strip-components=1 --directory=$@
mkdir -p $@/drivers/net/wireless/realtek/rtl8188eu
mkdir -p $@/drivers/net/wireless/realtek/rtl8192cu
tar -zxf $(RTL8188_TAR) --strip-components=1 --directory=$@/drivers/net/wireless/realtek/rtl8188eu
tar -zxf $(RTL8192_TAR) --strip-components=1 --directory=$@/drivers/net/wireless/realtek/rtl8192cu
patch -d $(BUILD_DIR)/tmp -p 0 < linux-image/patches/linux-$(LINUX_TAG).patch
cp linux-image/patches/zynq_ocm.c $@/arch/arm/mach-zynq
cp linux-image/patches/cma.c $@/drivers/char
cp linux-image/patches/xilinx_devcfg.c $@/drivers/char
cp linux-image/patches/xilinx_zynq_defconfig $@/arch/arm/configs

$(DTREE_DIR): $(DTREE_TAR)
mkdir -p $@
tar -zxf $< --strip-components=1 --directory=$@

$(BUILD_DIR)/uImage: $(LINUX_DIR)
make -C $< mrproper
make -C $< ARCH=arm xilinx_zynq_defconfig
make -C $< ARCH=arm -j $(shell nproc 2> /dev/null || echo 1) \
CROSS_COMPILE=arm-linux-gnueabihf- UIMAGE_LOADADDR=0x8000 \
uImage modules
cp $</arch/arm/boot/uImage $@

$(UBOOT_DIR)/u-boot.bin: $(UBOOT_DIR)
mkdir -p $(@D)
make -C $< mrproper
make -C $< ARCH=arm zynq_red_pitaya_defconfig
make -C $< ARCH=arm -j $(shell nproc 2> /dev/null || echo 1) \
CROSS_COMPILE=arm-linux-gnueabihf- all

$(BUILD_DIR)/boot.bin: $(BUILD_DIR)/tmp/$(NAME).fsbl/executable.elf $(UBOOT_DIR)/u-boot.bin
echo "img:{[bootloader] $(BUILD_DIR)/tmp/$(NAME).fsbl/executable.elf [load=0x4000000,startup=0x4000000] $(UBOOT_DIR)/u-boot.bin}" > $(BUILD_DIR)/tmp/boot.bif
bootgen -image $(BUILD_DIR)/tmp/boot.bif -w -o i $@

$(BUILD_DIR)/devicetree.dtb: $(BUILD_DIR)/uImage $(BUILD_DIR)/tmp/$(NAME).tree/system-top.dts
$(LINUX_DIR)/scripts/dtc/dtc -I dts -O dtb -o $(BUILD_DIR)/devicetree.dtb \
-i $(BUILD_DIR)/tmp/$(NAME).tree $(BUILD_DIR)/tmp/$(NAME).tree/system-top.dts

$(BUILD_DIR)/tmp/cores/%: linux-image/cores/%/core_config.tcl linux-image/cores/%/*.v
mkdir -p $(@D)
$(VIVADO) -source linux-image/scripts/core.tcl -tclargs $* $(PART)

$(BUILD_DIR)/tmp/%.xpr: linux-image/projects/% $(addprefix $(BUILD_DIR)/tmp/cores/, $(CORES))
mkdir -p $(@D)
$(VIVADO) -source linux-image/scripts/project.tcl -tclargs $* $(PART)

$(BUILD_DIR)/tmp/%.xsa: $(BUILD_DIR)/tmp/%.xpr
mkdir -p $(@D)
$(VIVADO) -source linux-image/scripts/hwdef.tcl -tclargs $*

$(BUILD_DIR)/tmp/%.bit: $(BUILD_DIR)/tmp/%.xpr
mkdir -p $(@D)
$(VIVADO) -source linux-image/scripts/bitstream.tcl -tclargs $*

$(BUILD_DIR)/tmp/%.fsbl/executable.elf: $(BUILD_DIR)/tmp/%.xsa
mkdir -p $(@D)
$(XSCT) linux-image/scripts/fsbl.tcl $* $(PROC)

$(BUILD_DIR)/tmp/%.tree/system-top.dts: $(BUILD_DIR)/tmp/%.xsa $(DTREE_DIR)
mkdir -p $(@D)
$(XSCT) linux-image/scripts/devicetree.tcl $* $(PROC) $(DTREE_DIR)
sed -i 's|#include|/include/|' $@
patch -d $(@D) < linux-image/patches/devicetree.patch

server:
git submodule update --init
@$(MAKE) install -C libs/scpi-parser
@$(MAKE) -C libs/scpi-parser
@$(MAKE) -C src/lib
@$(MAKE) -C src/server
@$(MAKE) -C src/test
cp scripts/daqserver.start /etc/local.d/
# cp scripts/daq_server.service /etc/systemd/system/
cp scripts/daq_server_scpi /etc/init.d/
chmod +x /etc/init.d/daq_server_scpi
rc-update add daq_server_scpi default

.PHONY: clean
clean:
$(RM) $(BUILD_DIR)/uImage $(BUILD_DIR)/boot.bin $(BUILD_DIR)/devicetree.dtb $(BUILD_DIR)/tmp
$(RM) .Xil usage_statistics_webtalk.html usage_statistics_webtalk.xml
$(RM) vivado*.jou vivado*.log vivado*.str
$(RM) webtalk*.jou webtalk*.log
@$(MAKE) -C src/lib clean
@$(MAKE) -C src/server clean
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# RedPitayaDAQServer
This project contains software to be used with the STEMlab 125-14 device from RedPitaya. It allows for continuous generation and measurement of signals with up to 15.625 MS/s, which is not possible with the standard image of the RedPitaya. In addition, the software allows to synchronize a cluster of multiple RedPitayas.
This project contains software to be used with the STEMlab 125-14 device (including the Zynq 7020-variant) from RedPitaya. It allows for continuous generation and measurement of signals with up to 15.625 MS/s, which is not possible with the standard image of the RedPitaya. In addition, the software allows to synchronize a cluster of multiple RedPitayas.

## Documentation

Expand Down
Binary file removed bitfiles/master.bit
Binary file not shown.
Binary file removed bitfiles/master05.bit
Binary file not shown.
8 changes: 2 additions & 6 deletions docs/src/devtips.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Development Tips
# Development Hints

On this slide some development hints are summarized. These might change regularely if things
are properly integrated into the framework.
Expand All @@ -10,10 +10,6 @@ applications. To change this one can do
```
mount -o remount,size=1G /
```
* Right now no debugger is installed. This can be change after increasing / using:
```
apk add gdb
```

## DHCP Server

Expand All @@ -26,4 +22,4 @@ The following commands are useful when you have connection problems
nmap -sP 192.168.1.0/24
journalctl -f -u isc-dhcp-server
```
If you need internet at your RedPitaya you need to configure the firewall to allow this using iptables. In this repository there is in the `scripts` directory a script `rp-internet.sh` where you need to change the network adapters to allow traffic going from the internet network adapter to the RedPitaya network adapter.
If you need internet at your RedPitaya you need to configure the firewall to allow this using iptables. In this repository there is in the `scripts` directory a script `rp-internet.sh` where you need to change the network adapters to allow traffic going from the internet network adapter to the RedPitaya network adapter.
34 changes: 31 additions & 3 deletions docs/src/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,35 @@

## Alpine Linux Image

The RedPitayaDAQServer project uses a custom RedPitaya image that was derived from the [red-pitaya-notes](https://github.com/pavel-demin/red-pitaya-notes) project. It consists of an Alpine Linux with some development tools installed. Additionally the image reserves the upper 128 MB of main memory for the FPGA, which is used as a buffer for recording the data from the fast ADCs. The linux image can be downloaded [here](https://media.tuhh.de/ibi/2020.09RedPitayaDAQServerImage.zip). Just unzip the zip file and copy the content on an empty SD card that is formatted in FAT32. When you insert the SD card into the RedPitaya you should see a blinking LED.
The RedPitayaDAQServer project uses a custom RedPitaya image that was derived from the [red-pitaya-notes](https://github.com/pavel-demin/red-pitaya-notes) project. It consists of an Alpine Linux with some development tools installed. Additionally the image reserves the upper 128 MB of main memory for the FPGA, which is used as a buffer for recording the data from the fast ADCs. The Linux image can be downloaded [here](https://media.tuhh.de/ibi/2020.09RedPitayaDAQServerImage.zip). Just unzip the zip file and copy the content on an empty SD card that is formatted in FAT32. When you insert the SD card into the RedPitaya you should see a blinking LED.

If you want to build the Linux image yourself, you can install Xilinx Vivado and Vitis in an Ubuntu environment (bare metal or virtual machine). Then run

```
sudo apt-get update
sudo apt-get --no-install-recommends install \
build-essential bison flex git curl ca-certificates sudo \
xvfb fontconfig libxrender1 libxtst6 libxi6 make \
bc u-boot-tools device-tree-compiler libncurses5-dev \
libssl-dev qemu-user-static binfmt-support zip \
squashfs-tools dosfstools parted debootstrap zerofree
```

in order to get the essential tools. Afterwards clone the project with

```
git clone https://github.com/tknopp/RedPitayaDAQServer
```

Then switch into this directory. You can build the whole project using
```
make all
```.
For only building some parts please refer to the Makefile.
Note: `make` has to be run as root if you want to build the Linux image, since `chroot` requires `root` privileges.
## Setting Up the Server
Expand All @@ -28,7 +56,7 @@ Then cd into RedPitayaDAQServer
```
cd /root/apps/RedPitayaDAQServer
```
and enter `make`. This will compile the library, the server, and some example applications. After you restart the RedPitaya the DAQ server will automatically run and you can access it via TCP.
and enter `make server`. This will compile the library, the server, and some example applications. After you restart the RedPitaya the DAQ server will automatically run and you can access it via TCP.
## Setting Up the Julia Client Library
Expand All @@ -42,4 +70,4 @@ options to install the client library.
The first is installing the currently published version. The second is installing in development mode and put the files to `~/dev/RedPitayaDAQServer/` where you can the also modify the files, which is handy when trying out the examples. Right now we recommend to `dev` the package. You need to `git pull` from `~/dev/RedPitayaDAQServer/` if you want to get updates, i.e. Julia will not update developed packages automatically.
The client library is not an executable data acquisition program, but it can be used to implement one. The library encapsulates the communication with the server and implements various optimizations. As the communication with the server is language agnostic and one could therefore implement their own client in a different language. The Julia reference client library found in `src/client/julia`, the [SCPI commands](scpi.md) and the sections on the signal [acquisition](acqusition.md) and [generation](generation.md) are starting points for such a custom client.
The client library is not an executable data acquisition program, but it can be used to implement one. The library encapsulates the communication with the server and implements various optimizations. As the communication with the server is language agnostic and one could therefore implement their own client in a different language. The Julia reference client library found in `src/client/julia`, the [SCPI commands](scpi.md) and the sections on the signal [acquisition](acqusition.md) and [generation](generation.md) are starting points for such a custom client.
2 changes: 1 addition & 1 deletion libs/scpi-parser
Submodule scpi-parser updated 44 files
+1 −1 .travis.yml
+21 −20 LICENSE
+11 −3 README.md
+21 −20 examples/common/scpi-def.c
+21 −20 examples/common/scpi-def.cpp
+34 −0 examples/common/scpi-def.h
+105 −53 examples/test-LwIP-netconn/scpi_server.c
+49 −0 examples/test-LwIP-netconn/scpi_server.h
+21 −20 examples/test-interactive/main.c
+21 −20 examples/test-parser/main.c
+21 −20 examples/test-tcp-srq/main.c
+21 −21 examples/test-tcp/main.c
+21 −0 examples/test-vxi11/Makefile
+632 −0 examples/test-vxi11/main.c
+462 −0 examples/test-vxi11/vxi11_xdr.c
+58 −29 libscpi/inc/scpi/cc.h
+27 −22 libscpi/inc/scpi/config.h
+23 −22 libscpi/inc/scpi/constants.h
+21 −20 libscpi/inc/scpi/error.h
+22 −21 libscpi/inc/scpi/expression.h
+23 −22 libscpi/inc/scpi/ieee488.h
+24 −22 libscpi/inc/scpi/minimal.h
+21 −20 libscpi/inc/scpi/parser.h
+23 −22 libscpi/inc/scpi/scpi.h
+22 −22 libscpi/inc/scpi/types.h
+23 −22 libscpi/inc/scpi/units.h
+23 −22 libscpi/inc/scpi/utils.h
+24 −21 libscpi/src/error.c
+21 −20 libscpi/src/expression.c
+27 −0 libscpi/src/fifo.c
+23 −22 libscpi/src/fifo_private.h
+26 −22 libscpi/src/ieee488.c
+23 −22 libscpi/src/lexer.c
+23 −22 libscpi/src/lexer_private.h
+33 −20 libscpi/src/minimal.c
+23 −32 libscpi/src/parser.c
+23 −22 libscpi/src/parser_private.h
+21 −20 libscpi/src/units.c
+21 −22 libscpi/src/utils.c
+21 −20 libscpi/src/utils_private.h
+25 −4 libscpi/test/test_fifo.c
+25 −4 libscpi/test/test_lexer_parser.c
+42 −3 libscpi/test/test_parser.c
+20 −28 libscpi/test/test_scpi_utils.c
22 changes: 22 additions & 0 deletions linux-image/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The work in this folder is derived from https://github.com/pavel-demin/red-pitaya-notes. Please respect the following license.

The MIT License (MIT)

Copyright (c) 2014-present Pavel Demin

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Loading

0 comments on commit 4014386

Please sign in to comment.