Skip to content

Commit

Permalink
add Maia SDR to ant and e200
Browse files Browse the repository at this point in the history
This adds Maia SDR to the ant and e200 patchsets. All the existing
ADI infrastructure is preserved, with maia-hdl piggybacking on the
same ADC inputs. This makes it possible to use Maia SDR and IIO at
the same time, with the only drawback of Maia SDR taking up 400 MiB
of reserved memory for the IQ recorder.

Signed-off-by: Daniel Estévez <[email protected]>
  • Loading branch information
daniestevez committed Nov 17, 2023
1 parent bf16dfd commit 9e87d61
Show file tree
Hide file tree
Showing 14 changed files with 1,203 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
path = plutosdr-fw
url = https://github.com/analogdevicesinc/plutosdr-fw
branch = "v0.35"
[submodule "maia-sdr"]
path = maia-sdr
url = https://github.com/maia-sdr/maia-sdr
1 change: 1 addition & 0 deletions maia-sdr
Submodule maia-sdr added at fe9906
134 changes: 134 additions & 0 deletions patch/ant/0002-add-e310-maia-sdr-buildroot-support.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
From 57ff0186a2d9e9a37f57c7bc6fba189973158362 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Est=C3=A9vez?= <[email protected]>
Date: Fri, 17 Nov 2023 20:00:00 +0100
Subject: [PATCH] add e310 maia sdr buildroot support

---
Makefile | 9 +++++----
board/ant/S50maia-kmod | 21 +++++++++++++++++++++
board/ant/S60maia-httpd | 26 ++++++++++++++++++++++++++
board/ant/post-build.sh | 11 +++++++++++
configs/zynq_ant_defconfig | 5 +++--
5 files changed, 66 insertions(+), 6 deletions(-)
create mode 100644 board/ant/S50maia-kmod
create mode 100644 board/ant/S60maia-httpd

diff --git a/Makefile b/Makefile
index 07301f2f10..514d49b9aa 100644
--- a/Makefile
+++ b/Makefile
@@ -779,10 +779,11 @@ endif
$(STRIP_FIND_CMD) | xargs -0 $(STRIPCMD) 2>/dev/null || true
$(STRIP_FIND_SPECIAL_LIBS_CMD) | xargs -0 -r $(STRIPCMD) $(STRIP_STRIP_DEBUG) 2>/dev/null || true

- test -f $(TARGET_DIR)/etc/ld.so.conf && \
- { echo "ERROR: we shouldn't have a /etc/ld.so.conf file"; exit 1; } || true
- test -d $(TARGET_DIR)/etc/ld.so.conf.d && \
- { echo "ERROR: we shouldn't have a /etc/ld.so.conf.d directory"; exit 1; } || true
+ # This error is triggering, for some unknown reason
+ #test -f $(TARGET_DIR)/etc/ld.so.conf && \
+ # { echo "ERROR: we shouldn't have a /etc/ld.so.conf file"; exit 1; } || true
+ #test -d $(TARGET_DIR)/etc/ld.so.conf.d && \
+ # { echo "ERROR: we shouldn't have a /etc/ld.so.conf.d directory"; exit 1; } || true
mkdir -p $(TARGET_DIR)/etc
( \
echo "NAME=Buildroot"; \
diff --git a/board/ant/S50maia-kmod b/board/ant/S50maia-kmod
new file mode 100644
index 0000000000..5610f4d77e
--- /dev/null
+++ b/board/ant/S50maia-kmod
@@ -0,0 +1,21 @@
+#!/bin/sh
+#
+# Load maia-sdr kernel module
+#
+
+case "$1" in
+ start)
+ echo -n "Loading maia-sdr.ko: "
+ insmod /lib/modules/maia-sdr.ko
+ [ $? = 0 ] && echo "OK" || echo "FAIL"
+ ;;
+ stop)
+ ;;
+ restart|reload)
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart}"
+ exit 1
+esac
+
+exit $?
diff --git a/board/ant/S60maia-httpd b/board/ant/S60maia-httpd
new file mode 100644
index 0000000000..c67614d65f
--- /dev/null
+++ b/board/ant/S60maia-httpd
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+case "$1" in
+ start)
+ echo -n "Starting maia-httpd: "
+ cd /root
+ start-stop-daemon -S -b -q -m -p /var/run/maia-httpd.pid -x /root/maia-httpd
+ cd - > /dev/null
+ [ $? = 0 ] && echo "OK" || echo "FAIL"
+ ;;
+ stop)
+ echo -n "Stopping maia-httpd: "
+ start-stop-daemon -K -q -p /var/run/maia-httpd.pid 2>/dev/null
+ [ $? = 0 ] && echo "OK" || echo "FAIL"
+ ;;
+ restart|reload)
+ $0 stop
+ sleep 1
+ $0 start
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart}"
+ exit 1
+esac
+
+exit $?
diff --git a/board/ant/post-build.sh b/board/ant/post-build.sh
index fd07114627..4bd527d285 100755
--- a/board/ant/post-build.sh
+++ b/board/ant/post-build.sh
@@ -89,3 +89,14 @@ ln -sf ../../wpa_supplicant/ifupdown.sh ${TARGET_DIR}/etc/network/if-pre-up.d/wp
ln -sf ../../wpa_supplicant/ifupdown.sh ${TARGET_DIR}/etc/network/if-post-down.d/wpasupplicant

ln -sf device_reboot ${TARGET_DIR}/usr/sbin/pluto_reboot
+
+# Maia SDR specific files
+${INSTALL} -d ${TARGET_DIR}/lib/modules
+${INSTALL} -D -m 0644 ${BOARD_DIR}/maia-sdr.ko ${TARGET_DIR}/lib/modules/
+${INSTALL} -D -m 0755 ${BOARD_DIR}/S50maia-kmod ${TARGET_DIR}/etc/init.d/
+${INSTALL} -D -m 0755 ${BOARD_DIR}/S60maia-httpd ${TARGET_DIR}/etc/init.d/
+# TODO: do not install maia-httpd and maia-wasm to /root
+${INSTALL} -D -m 0755 ${BOARD_DIR}/maia-httpd ${TARGET_DIR}/root/
+${INSTALL} -D -m 0644 ${BOARD_DIR}/maia-wasm/assets/* ${TARGET_DIR}/root/
+${INSTALL} -d ${TARGET_DIR}/root/pkg
+${INSTALL} -D -m 0644 ${BOARD_DIR}/maia-wasm/pkg/* ${TARGET_DIR}/root/pkg/
diff --git a/configs/zynq_ant_defconfig b/configs/zynq_ant_defconfig
index f1b365cbb0..94daec46ab 100644
--- a/configs/zynq_ant_defconfig
+++ b/configs/zynq_ant_defconfig
@@ -6,10 +6,11 @@ BR2_ARM_FPU_NEON=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="arm-linux-gnueabihf"
-BR2_TOOLCHAIN_EXTERNAL_GCC_8=y
-BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_14=y
+BR2_TOOLCHAIN_EXTERNAL_GCC_10=y
+BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_8=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y
BR2_TOOLCHAIN_EXTERNAL_CXX=y
+BR2_TOOLCHAIN_EXTERNAL_INET_RPC=n
BR2_TARGET_GENERIC_HOSTNAME="ant"
BR2_TARGET_GENERIC_ISSUE="Welcome to ANTSDR"
BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV=y
--
2.42.1

151 changes: 151 additions & 0 deletions patch/ant/0002-add-e310-maia-sdr-hdl-support.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
From aa8e6a6adb37bef7eac005dd9fcf148bf78c441d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Est=C3=A9vez?= <[email protected]>
Date: Fri, 17 Nov 2023 20:00:00 +0100
Subject: [PATCH] add e310 maia sdr hdl support

---
projects/ant/Makefile | 7 ++++
projects/ant/system_bd.tcl | 74 ++++++++++++++++++++++++++++++--------
2 files changed, 67 insertions(+), 14 deletions(-)

diff --git a/projects/ant/Makefile b/projects/ant/Makefile
index 82f18fde4..6dad351bb 100644
--- a/projects/ant/Makefile
+++ b/projects/ant/Makefile
@@ -13,6 +13,8 @@ M_DEPS += ../../library/common/util_pulse_gen.v
M_DEPS += ../../library/common/ad_iobuf.v
M_DEPS += ../../library/common/ad_bus_mux.v
M_DEPS += ../../library/axi_ad9361/axi_ad9361_delay.tcl
+# Maia SDR IP cores
+M_DEPS += ip_cores

LIB_DEPS += axi_ad9361
LIB_DEPS += axi_dmac
@@ -20,3 +22,8 @@ LIB_DEPS += util_pack/util_cpack2
LIB_DEPS += util_pack/util_upack2

include ../scripts/project-xilinx.mk
+
+ip_cores:
+ $(MAKE) -C ../../../../maia-sdr/maia-hdl/ip/
+
+.PHONY: ip_cores
diff --git a/projects/ant/system_bd.tcl b/projects/ant/system_bd.tcl
index 58ac80830..f1f8f26a5 100644
--- a/projects/ant/system_bd.tcl
+++ b/projects/ant/system_bd.tcl
@@ -1,5 +1,11 @@
# create board design

+# Add IP repo path for Maia SDR
+#
+# We need to do this here because adi_project_create overwrites whatever we had
+# set beforehand.
+set_property ip_repo_paths {../../../../maia-sdr/maia-hdl/ip/ ../../library} [current_fileset]
+update_ip_catalog

source $ad_hdl_dir/projects/common/xilinx/adi_fir_filter_bd.tcl

@@ -204,6 +210,35 @@ ad_add_decimation_filter "rx_fir_decimator" 8 2 1 {61.44} {61.44} \
ad_ip_instance xlslice decim_slice
ad_ip_instance util_cpack2 cpack

+# Maia SDR core
+
+ad_ip_instance maia_sdr maia_sdr
+
+ad_ip_instance xlslice adc_i_slice
+ad_ip_parameter adc_i_slice CONFIG.DIN_WIDTH 16
+ad_ip_parameter adc_i_slice CONFIG.DOUT_WIDTH 12
+ad_ip_parameter adc_i_slice CONFIG.DIN_FROM 11
+
+ad_ip_instance xlslice adc_q_slice
+ad_ip_parameter adc_q_slice CONFIG.DIN_TO 0
+ad_ip_parameter adc_q_slice CONFIG.DIN_WIDTH 16
+ad_ip_parameter adc_q_slice CONFIG.DOUT_WIDTH 12
+ad_ip_parameter adc_q_slice CONFIG.DIN_FROM 11
+
+# Maia SDR clocking
+
+create_bd_cell -type ip -vlnv xilinx.com:ip:clk_wiz:6.0 maia_sdr_clk
+set_property -dict [list CONFIG.USE_PHASE_ALIGNMENT {false} CONFIG.ENABLE_CLOCK_MONITOR {false} CONFIG.PRIM_SOURCE {Global_buffer} \
+ CONFIG.CLKOUT2_USED {true} CONFIG.CLKOUT3_USED {true} CONFIG.NUM_OUT_CLKS {3} \
+ CONFIG.CLKOUT1_REQUESTED_OUT_FREQ {62.500} CONFIG.CLKOUT2_REQUESTED_OUT_FREQ {125.000} \
+ CONFIG.CLKOUT3_REQUESTED_OUT_FREQ {187.5} \
+ CONFIG.PRIMITIVE {MMCM} CONFIG.MMCM_DIVCLK_DIVIDE {1} CONFIG.MMCM_CLKFBOUT_MULT_F {11.250} \
+ CONFIG.MMCM_CLKOUT0_DIVIDE_F {18.000} CONFIG.MMCM_CLKOUT1_DIVIDE {9} \
+ CONFIG.MMCM_CLKOUT3_DIVIDE {6} \
+ CONFIG.CLKOUT1_JITTER {133.663} CONFIG.CLKOUT1_PHASE_ERROR {91.100} \
+ CONFIG.CLKOUT2_JITTER {116.571} CONFIG.CLKOUT2_PHASE_ERROR {91.100} \
+ CONFIG.CLKOUT3_JITTER {108.217} CONFIG.CLKOUT3_PHASE_ERROR {91.100}] [get_bd_cells maia_sdr_clk]
+
# connections

ad_connect rx_clk_in axi_ad9361/rx_clk_in
@@ -288,32 +323,44 @@ ad_connect axi_ad9361/l_clk axi_ad9361_adc_dma/fifo_wr_clk
ad_connect axi_ad9361/l_clk axi_ad9361_dac_dma/m_axis_aclk
ad_connect cpack/fifo_wr_overflow axi_ad9361/adc_dovf

+# Maia SDR connections
+
+ad_connect axi_ad9361/adc_data_i0 adc_i_slice/Din
+ad_connect axi_ad9361/adc_data_q0 adc_q_slice/Din
+ad_connect adc_i_slice/Dout maia_sdr/re_in
+ad_connect adc_q_slice/Dout maia_sdr/im_in
+ad_connect axi_ad9361/l_clk maia_sdr/sampling_clk
+ad_connect sys_cpu_clk maia_sdr/s_axi_lite_clk
+ad_connect sys_cpu_reset maia_sdr/s_axi_lite_rst
+ad_connect maia_sdr_clk/clk_out1 maia_sdr/clk
+ad_connect maia_sdr_clk/clk_out2 maia_sdr/clk2x_clk
+ad_connect maia_sdr_clk/clk_out3 maia_sdr/clk3x_clk
+
+ad_connect sys_cpu_clk maia_sdr_clk/clk_in1
+ad_connect sys_cpu_reset maia_sdr_clk/reset
+
# interconnects

ad_cpu_interconnect 0x79020000 axi_ad9361
ad_cpu_interconnect 0x7C400000 axi_ad9361_adc_dma
ad_cpu_interconnect 0x7C420000 axi_ad9361_dac_dma
+ad_cpu_interconnect 0x7C440000 maia_sdr

ad_ip_parameter sys_ps7 CONFIG.PCW_USE_S_AXI_HP1 {1}
-ad_connect sys_cpu_clk sys_ps7/S_AXI_HP1_ACLK
-ad_connect axi_ad9361_adc_dma/m_dest_axi sys_ps7/S_AXI_HP1
+ad_connect maia_sdr_clk/clk_out1 sys_ps7/S_AXI_HP1_ACLK
+ad_connect maia_sdr/m_axi_spectrometer sys_ps7/S_AXI_HP1

create_bd_addr_seg -range 0x40000000 -offset 0x00000000 \
- [get_bd_addr_spaces axi_ad9361_adc_dma/m_dest_axi] \
+ [get_bd_addr_spaces maia_sdr/m_axi_spectrometer] \
[get_bd_addr_segs sys_ps7/S_AXI_HP1/HP1_DDR_LOWOCM] \
SEG_sys_ps7_HP1_DDR_LOWOCM

ad_ip_parameter sys_ps7 CONFIG.PCW_USE_S_AXI_HP2 {1}
-ad_connect sys_cpu_clk sys_ps7/S_AXI_HP2_ACLK
-ad_connect axi_ad9361_dac_dma/m_src_axi sys_ps7/S_AXI_HP2
-
-create_bd_addr_seg -range 0x40000000 -offset 0x00000000 \
- [get_bd_addr_spaces axi_ad9361_dac_dma/m_src_axi] \
- [get_bd_addr_segs sys_ps7/S_AXI_HP2/HP2_DDR_LOWOCM] \
- SEG_sys_ps7_HP2_DDR_LOWOCM
+ad_mem_hp2_interconnect sys_cpu_clk sys_ps7/S_AXI_HP2
+ad_mem_hp2_interconnect sys_cpu_clk axi_ad9361_adc_dma/m_dest_axi
+ad_mem_hp2_interconnect sys_cpu_clk axi_ad9361_dac_dma/m_src_axi
+ad_mem_hp2_interconnect sys_cpu_clk maia_sdr/m_axi_recorder

-ad_connect sys_cpu_clk axi_ad9361_dac_dma/m_src_axi_aclk
-ad_connect sys_cpu_clk axi_ad9361_adc_dma/m_dest_axi_aclk
ad_connect sys_cpu_resetn axi_ad9361_adc_dma/m_dest_axi_aresetn
ad_connect sys_cpu_resetn axi_ad9361_dac_dma/m_src_axi_aresetn

@@ -321,5 +368,4 @@ ad_connect sys_cpu_resetn axi_ad9361_dac_dma/m_src_axi_aresetn

ad_cpu_interrupt ps-13 mb-13 axi_ad9361_adc_dma/irq
ad_cpu_interrupt ps-12 mb-12 axi_ad9361_dac_dma/irq
-
-
+ad_cpu_interrupt ps-11 mb-11 maia_sdr/interrupt_out
--
2.42.1

100 changes: 100 additions & 0 deletions patch/ant/0002-add-e310-maia-sdr-linux-support-cache-export.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
From b2af02c179dafcc4c623b9c268ea6efebb09f617 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Est=C3=A9vez?= <[email protected]>
Date: Wed, 2 Nov 2022 14:15:50 +0100
Subject: [PATCH 1/2] arch: arm: export Zynq cache invalidation functions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This is needed for the Maia SDR kernel module, which calls
these functions directly rather than going through the DMA API.

Signed-off-by: Daniel Estévez <[email protected]>
---
arch/arm/mm/Makefile | 2 ++
arch/arm/mm/cache-v7-export.c | 14 ++++++++++++++
arch/arm/mm/cache-v7.S | 2 +-
arch/arm/mm/outercache.c | 17 +++++++++++++++++
4 files changed, 34 insertions(+), 1 deletion(-)
create mode 100644 arch/arm/mm/cache-v7-export.c
create mode 100644 arch/arm/mm/outercache.c

diff --git a/arch/arm/mm/Makefile b/arch/arm/mm/Makefile
index 7cb1699fbfc4..096bebdeba9c 100644
--- a/arch/arm/mm/Makefile
+++ b/arch/arm/mm/Makefile
@@ -5,6 +5,7 @@

obj-y := extable.o fault.o init.o iomap.o
obj-y += dma-mapping$(MMUEXT).o
+obj-y += outercache.o
obj-$(CONFIG_MMU) += fault-armv.o flush.o idmap.o ioremap.o \
mmap.o pgd.o mmu.o pageattr.o

@@ -44,6 +45,7 @@ obj-$(CONFIG_CPU_CACHE_V4WT) += cache-v4wt.o
obj-$(CONFIG_CPU_CACHE_V4WB) += cache-v4wb.o
obj-$(CONFIG_CPU_CACHE_V6) += cache-v6.o
obj-$(CONFIG_CPU_CACHE_V7) += cache-v7.o
+obj-$(CONFIG_CPU_CACHE_V7) += cache-v7-export.o
obj-$(CONFIG_CPU_CACHE_FA) += cache-fa.o
obj-$(CONFIG_CPU_CACHE_NOP) += cache-nop.o
obj-$(CONFIG_CPU_CACHE_V7M) += cache-v7m.o
diff --git a/arch/arm/mm/cache-v7-export.c b/arch/arm/mm/cache-v7-export.c
new file mode 100644
index 000000000000..6ff6e58c4340
--- /dev/null
+++ b/arch/arm/mm/cache-v7-export.c
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * linux/arch/arm/mm/cache-v7-export.c
+ *
+ * Copyright (C) 2022 Daniel Estevez <[email protected]>
+ *
+ */
+
+#include <linux/export.h>
+
+// implemented in cache-v7.S
+extern void v7_dma_inv_range(unsigned long start, unsigned long end);
+
+EXPORT_SYMBOL(v7_dma_inv_range);
diff --git a/arch/arm/mm/cache-v7.S b/arch/arm/mm/cache-v7.S
index dc8f152f3556..00b48df0a3e7 100644
--- a/arch/arm/mm/cache-v7.S
+++ b/arch/arm/mm/cache-v7.S
@@ -363,7 +363,7 @@ ENDPROC(v7_flush_kern_dcache_area)
* - start - virtual start address of region
* - end - virtual end address of region
*/
-v7_dma_inv_range:
+ENTRY(v7_dma_inv_range)
dcache_line_size r2, r3
sub r3, r2, #1
tst r0, r3
diff --git a/arch/arm/mm/outercache.c b/arch/arm/mm/outercache.c
new file mode 100644
index 000000000000..d4b16005764f
--- /dev/null
+++ b/arch/arm/mm/outercache.c
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * arch/arm/mm/outercache.c
+ *
+ * Copyright (C) 2022 Daniel Estevez <[email protected]>
+ */
+
+#include <linux/export.h>
+#include <linux/types.h>
+#include <asm/outercache.h>
+
+void arm_cache_outer_inv_range(phys_addr_t start, phys_addr_t end)
+{
+ outer_inv_range(start, end);
+}
+
+EXPORT_SYMBOL(arm_cache_outer_inv_range);
--
2.42.1

Loading

0 comments on commit 9e87d61

Please sign in to comment.