Skip to content

Commit 4014386

Browse files
authored
Merge pull request #35 from tknopp/JS/Z7020
Add support for Zynq 7020-based Red Pitayas
2 parents 7d2ec0a + 28a5819 commit 4014386

File tree

265 files changed

+169864
-1292
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

265 files changed

+169864
-1292
lines changed

.gitignore

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
build/
22
*.jou
33
*.log
4-
*.txt
4+
*log*.txt
55
*.asv
66
*.pyc
77
src/client/python/.pydevproject
@@ -10,9 +10,22 @@ src/examples/python/.pydevproject
1010
src/examples/python/.project
1111
src/examples/julia/images
1212
core
13+
bitfiles
1314
*.jl.cov
1415
*.jl.*.cov
1516
*.jl.mem
1617
docs/build/
1718
Manifest.toml
18-
vivado*
19+
*.apk
20+
*.bin
21+
*.dtb
22+
*.img
23+
*.tar.gz
24+
*.zip
25+
vivado*
26+
webtalk*
27+
tmp
28+
uImage
29+
.vscode
30+
vivado*
31+
.Xil

Makefile

Lines changed: 166 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,176 @@
1-
all:
1+
# 'make' builds everything
2+
# 'make clean' deletes everything except source files and Makefile
3+
#
4+
# You need to set NAME, PART and PROC for your project.
5+
# NAME is the base name for most of the generated files.
6+
7+
# solves problem with awk while building linux kernel
8+
# solution taken from http://www.googoolia.com/wp/2015/04/21/awk-symbol-lookup-error-awk-undefined-symbol-mpfr_z_sub/
9+
LD_LIBRARY_PATH =
10+
11+
BUILD_DIR = build/linux-image
12+
13+
NAME = led_blinker
14+
PART = xc7z010clg400-1
15+
PROC = ps7_cortexa9_0
16+
17+
CORES = axi_axis_reader_v1_0 port_slicer_v1_0 dna_reader_v1_0 axi_sts_register_v1_0\
18+
19+
DAQ_PARTS = xc7z010clg400-1 xc7z020clg400-1\
20+
21+
VIVADO = vivado -nolog -nojournal -mode batch
22+
XSCT = xsct
23+
RM = rm -rf
24+
25+
UBOOT_TAG = 2021.04
26+
LINUX_TAG = 5.10
27+
DTREE_TAG = xilinx-v2020.2
28+
29+
UBOOT_DIR = $(BUILD_DIR)/tmp/u-boot-$(UBOOT_TAG)
30+
LINUX_DIR = $(BUILD_DIR)/tmp/linux-$(LINUX_TAG)
31+
DTREE_DIR = $(BUILD_DIR)/tmp/device-tree-xlnx-$(DTREE_TAG)
32+
33+
UBOOT_TAR = $(BUILD_DIR)/tmp/u-boot-$(UBOOT_TAG).tar.bz2
34+
LINUX_TAR = $(BUILD_DIR)/tmp/linux-$(LINUX_TAG).tar.xz
35+
DTREE_TAR = $(BUILD_DIR)/tmp/device-tree-xlnx-$(DTREE_TAG).tar.gz
36+
37+
UBOOT_URL = https://ftp.denx.de/pub/u-boot/u-boot-$(UBOOT_TAG).tar.bz2
38+
LINUX_URL = https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-$(LINUX_TAG).80.tar.xz
39+
DTREE_URL = https://github.com/Xilinx/device-tree-xlnx/archive/$(DTREE_TAG).tar.gz
40+
41+
RTL8188_TAR = $(BUILD_DIR)/tmp/rtl8188eu-v5.2.2.4.tar.gz
42+
RTL8188_URL = https://github.com/lwfinger/rtl8188eu/archive/v5.2.2.4.tar.gz
43+
44+
RTL8192_TAR = $(BUILD_DIR)/tmp/rtl8192cu-fixes-master.tar.gz
45+
RTL8192_URL = https://github.com/pvaret/rtl8192cu-fixes/archive/master.tar.gz
46+
47+
.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
48+
49+
all: daq_bitfiles $(BUILD_DIR)/tmp/$(NAME).bit $(BUILD_DIR)/boot.bin $(BUILD_DIR)/uImage $(BUILD_DIR)/devicetree.dtb linux
50+
51+
daq_bitfiles: $(addsuffix .bit, $(addprefix bitfiles/daq_,$(DAQ_PARTS)))
52+
53+
bitfiles/daq_%.bit:
54+
sh scripts/make_fpga_project.sh $*
55+
sh scripts/make_implementation.sh $*
56+
57+
linux: daq_bitfiles $(BUILD_DIR)/tmp/$(NAME).bit $(BUILD_DIR)/boot.bin $(BUILD_DIR)/uImage $(BUILD_DIR)/devicetree.dtb
58+
sh scripts/alpine.sh
59+
60+
cores: $(addprefix tmp/cores/, $(CORES))
61+
62+
xpr: $(BUILD_DIR)/tmp/$(NAME).xpr
63+
64+
bit: $(BUILD_DIR)/tmp/$(NAME).bit
65+
66+
$(UBOOT_TAR):
67+
mkdir -p $(@D)
68+
curl -L $(UBOOT_URL) -o $@
69+
70+
$(LINUX_TAR):
71+
mkdir -p $(@D)
72+
curl -L $(LINUX_URL) -o $@
73+
74+
$(DTREE_TAR):
75+
mkdir -p $(@D)
76+
curl -L $(DTREE_URL) -o $@
77+
78+
$(RTL8188_TAR):
79+
mkdir -p $(@D)
80+
curl -L $(RTL8188_URL) -o $@
81+
82+
$(RTL8192_TAR):
83+
mkdir -p $(@D)
84+
curl -L $(RTL8192_URL) -o $@
85+
86+
$(UBOOT_DIR): $(UBOOT_TAR)
87+
mkdir -p $@
88+
tar -jxf $< --strip-components=1 --directory=$@
89+
patch -d $(BUILD_DIR)/tmp -p 0 < linux-image/patches/u-boot-$(UBOOT_TAG).patch
90+
cp linux-image/patches/zynq_red_pitaya_defconfig $@/configs
91+
cp linux-image/patches/zynq-red-pitaya.dts $@/arch/arm/dts
92+
93+
$(LINUX_DIR): $(LINUX_TAR) $(RTL8188_TAR) $(RTL8192_TAR)
94+
mkdir -p $@
95+
tar -Jxf $< --strip-components=1 --directory=$@
96+
mkdir -p $@/drivers/net/wireless/realtek/rtl8188eu
97+
mkdir -p $@/drivers/net/wireless/realtek/rtl8192cu
98+
tar -zxf $(RTL8188_TAR) --strip-components=1 --directory=$@/drivers/net/wireless/realtek/rtl8188eu
99+
tar -zxf $(RTL8192_TAR) --strip-components=1 --directory=$@/drivers/net/wireless/realtek/rtl8192cu
100+
patch -d $(BUILD_DIR)/tmp -p 0 < linux-image/patches/linux-$(LINUX_TAG).patch
101+
cp linux-image/patches/zynq_ocm.c $@/arch/arm/mach-zynq
102+
cp linux-image/patches/cma.c $@/drivers/char
103+
cp linux-image/patches/xilinx_devcfg.c $@/drivers/char
104+
cp linux-image/patches/xilinx_zynq_defconfig $@/arch/arm/configs
105+
106+
$(DTREE_DIR): $(DTREE_TAR)
107+
mkdir -p $@
108+
tar -zxf $< --strip-components=1 --directory=$@
109+
110+
$(BUILD_DIR)/uImage: $(LINUX_DIR)
111+
make -C $< mrproper
112+
make -C $< ARCH=arm xilinx_zynq_defconfig
113+
make -C $< ARCH=arm -j $(shell nproc 2> /dev/null || echo 1) \
114+
CROSS_COMPILE=arm-linux-gnueabihf- UIMAGE_LOADADDR=0x8000 \
115+
uImage modules
116+
cp $</arch/arm/boot/uImage $@
117+
118+
$(UBOOT_DIR)/u-boot.bin: $(UBOOT_DIR)
119+
mkdir -p $(@D)
120+
make -C $< mrproper
121+
make -C $< ARCH=arm zynq_red_pitaya_defconfig
122+
make -C $< ARCH=arm -j $(shell nproc 2> /dev/null || echo 1) \
123+
CROSS_COMPILE=arm-linux-gnueabihf- all
124+
125+
$(BUILD_DIR)/boot.bin: $(BUILD_DIR)/tmp/$(NAME).fsbl/executable.elf $(UBOOT_DIR)/u-boot.bin
126+
echo "img:{[bootloader] $(BUILD_DIR)/tmp/$(NAME).fsbl/executable.elf [load=0x4000000,startup=0x4000000] $(UBOOT_DIR)/u-boot.bin}" > $(BUILD_DIR)/tmp/boot.bif
127+
bootgen -image $(BUILD_DIR)/tmp/boot.bif -w -o i $@
128+
129+
$(BUILD_DIR)/devicetree.dtb: $(BUILD_DIR)/uImage $(BUILD_DIR)/tmp/$(NAME).tree/system-top.dts
130+
$(LINUX_DIR)/scripts/dtc/dtc -I dts -O dtb -o $(BUILD_DIR)/devicetree.dtb \
131+
-i $(BUILD_DIR)/tmp/$(NAME).tree $(BUILD_DIR)/tmp/$(NAME).tree/system-top.dts
132+
133+
$(BUILD_DIR)/tmp/cores/%: linux-image/cores/%/core_config.tcl linux-image/cores/%/*.v
134+
mkdir -p $(@D)
135+
$(VIVADO) -source linux-image/scripts/core.tcl -tclargs $* $(PART)
136+
137+
$(BUILD_DIR)/tmp/%.xpr: linux-image/projects/% $(addprefix $(BUILD_DIR)/tmp/cores/, $(CORES))
138+
mkdir -p $(@D)
139+
$(VIVADO) -source linux-image/scripts/project.tcl -tclargs $* $(PART)
140+
141+
$(BUILD_DIR)/tmp/%.xsa: $(BUILD_DIR)/tmp/%.xpr
142+
mkdir -p $(@D)
143+
$(VIVADO) -source linux-image/scripts/hwdef.tcl -tclargs $*
144+
145+
$(BUILD_DIR)/tmp/%.bit: $(BUILD_DIR)/tmp/%.xpr
146+
mkdir -p $(@D)
147+
$(VIVADO) -source linux-image/scripts/bitstream.tcl -tclargs $*
148+
149+
$(BUILD_DIR)/tmp/%.fsbl/executable.elf: $(BUILD_DIR)/tmp/%.xsa
150+
mkdir -p $(@D)
151+
$(XSCT) linux-image/scripts/fsbl.tcl $* $(PROC)
152+
153+
$(BUILD_DIR)/tmp/%.tree/system-top.dts: $(BUILD_DIR)/tmp/%.xsa $(DTREE_DIR)
154+
mkdir -p $(@D)
155+
$(XSCT) linux-image/scripts/devicetree.tcl $* $(PROC) $(DTREE_DIR)
156+
sed -i 's|#include|/include/|' $@
157+
patch -d $(@D) < linux-image/patches/devicetree.patch
158+
159+
server:
2160
git submodule update --init
3161
@$(MAKE) install -C libs/scpi-parser
4162
@$(MAKE) -C libs/scpi-parser
5163
@$(MAKE) -C src/lib
6164
@$(MAKE) -C src/server
7165
@$(MAKE) -C src/test
8-
cp scripts/daqserver.start /etc/local.d/
9-
# cp scripts/daq_server.service /etc/systemd/system/
166+
cp scripts/daq_server_scpi /etc/init.d/
167+
chmod +x /etc/init.d/daq_server_scpi
168+
rc-update add daq_server_scpi default
10169

11-
.PHONY: clean
12170
clean:
171+
$(RM) $(BUILD_DIR)/uImage $(BUILD_DIR)/boot.bin $(BUILD_DIR)/devicetree.dtb $(BUILD_DIR)/tmp
172+
$(RM) .Xil usage_statistics_webtalk.html usage_statistics_webtalk.xml
173+
$(RM) vivado*.jou vivado*.log vivado*.str
174+
$(RM) webtalk*.jou webtalk*.log
13175
@$(MAKE) -C src/lib clean
14176
@$(MAKE) -C src/server clean

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# RedPitayaDAQServer
2-
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.
2+
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.
33

44
## Documentation
55

bitfiles/master.bit

-1.99 MB
Binary file not shown.

bitfiles/master05.bit

-1.99 MB
Binary file not shown.

docs/src/devtips.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Development Tips
1+
# Development Hints
22

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

1814
## DHCP Server
1915

@@ -26,4 +22,4 @@ The following commands are useful when you have connection problems
2622
nmap -sP 192.168.1.0/24
2723
journalctl -f -u isc-dhcp-server
2824
```
29-
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.
25+
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.

docs/src/installation.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,35 @@
22

33
## Alpine Linux Image
44

5-
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.
5+
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.
6+
7+
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
8+
9+
```
10+
sudo apt-get update
11+
12+
sudo apt-get --no-install-recommends install \
13+
build-essential bison flex git curl ca-certificates sudo \
14+
xvfb fontconfig libxrender1 libxtst6 libxi6 make \
15+
bc u-boot-tools device-tree-compiler libncurses5-dev \
16+
libssl-dev qemu-user-static binfmt-support zip \
17+
squashfs-tools dosfstools parted debootstrap zerofree
18+
```
19+
20+
in order to get the essential tools. Afterwards clone the project with
21+
22+
```
23+
git clone https://github.com/tknopp/RedPitayaDAQServer
24+
```
25+
26+
Then switch into this directory. You can build the whole project using
27+
```
28+
make all
29+
```.
30+
31+
For only building some parts please refer to the Makefile.
32+
33+
Note: `make` has to be run as root if you want to build the Linux image, since `chroot` requires `root` privileges.
634
735
## Setting Up the Server
836
@@ -28,7 +56,7 @@ Then cd into RedPitayaDAQServer
2856
```
2957
cd /root/apps/RedPitayaDAQServer
3058
```
31-
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.
59+
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.
3260
3361
3462
## Setting Up the Julia Client Library
@@ -42,4 +70,4 @@ options to install the client library.
4270
4371
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.
4472
45-
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.
73+
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.

linux-image/LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The work in this folder is derived from https://github.com/pavel-demin/red-pitaya-notes. Please respect the following license.
2+
3+
The MIT License (MIT)
4+
5+
Copyright (c) 2014-present Pavel Demin
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy of
8+
this software and associated documentation files (the "Software"), to deal in
9+
the Software without restriction, including without limitation the rights to
10+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11+
the Software, and to permit persons to whom the Software is furnished to do so,
12+
subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in all
15+
copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)