Skip to content

Commit 8c79132

Browse files
committed
Initial pluto-ori firmware
1 parent 75611ec commit 8c79132

File tree

210 files changed

+16443
-0
lines changed

Some content is hidden

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

210 files changed

+16443
-0
lines changed

firmware/Makefile

Lines changed: 305 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,305 @@
1+
2+
#VIVADO_VERSION ?= 2020.1
3+
VIVADO_VERSION ?= 2022.2
4+
#VIVADO_VERSION ?= 2023.1
5+
export ADI_IGNORE_VERSION_CHECK = 1
6+
SKIP_LEGAL=1
7+
# Use Buildroot External Linaro GCC 7.3-2018.05 arm-linux-gnueabihf Toolchain
8+
#CROSS_COMPILE = arm-linux-gnueabihf-
9+
CROSS_COMPILE = arm-none-linux-gnueabihf-
10+
TOOLS_PATH = PATH="$(CURDIR)/buildroot/output/host/bin:$(CURDIR)/buildroot/output/host/sbin:$(PATH)"
11+
TOOLCHAIN = $(CURDIR)/buildroot/output/host/bin/$(CROSS_COMPILE)gcc
12+
ABSOLUTE_PATH=$(shell cd `dirname "${BASH_SOURCE[0]}"` && pwd)
13+
BOARD=$(ABSOLUTE_PATH/board)/ori/board
14+
BR2_EXTERNAL=$(ABSOLUTE_PATH)/ori
15+
BR2_PACKAGE_BUSYBOX_CONFIG=$(BR2_EXTERNAL)/ori/board/pluto/busybox-1.25.0.config
16+
17+
BR2_EXTERNAL_PLUTOSDR_PATH=$(shell cd `dirname "${BASH_SOURCE[0]}"` && pwd)/ori
18+
NCORES = $(shell grep -c ^processor /proc/cpuinfo)
19+
VIVADO_SETTINGS ?= /opt/Xilinx/Vivado/$(VIVADO_VERSION)/settings64.sh
20+
VSUBDIRS = buildroot linux u-boot-xlnx
21+
22+
VERSION=$(shell git describe --abbrev=4 --always --tags)
23+
PATCH=$(shell cd ori && ./applypatch.sh )
24+
$(shell git log --pretty=format:"%h - %ad : %s" > ori/board/pluto/overlay/root/fwhistory.txt)
25+
#LATEST_TAG=$(shell git describe --abbrev=0 --tags)
26+
UBOOT_VERSION=$(shell echo -n "PlutoSDR " && cd u-boot-xlnx && git describe --abbrev=0 --dirty --always --tags)
27+
HAVE_VIVADO= $(shell bash -c "source $(VIVADO_SETTINGS) > /dev/null 2>&1 && vivado -version > /dev/null 2>&1 && echo 1 || echo 0")
28+
#XSA_URL ?= http://github.com/maia-sdr/plutosdr-fw/releases/download/${LATEST_TAG}/system_top.xsa
29+
30+
ifeq (1, ${HAVE_VIVADO})
31+
VIVADO_INSTALL= $(shell bash -c "source $(VIVADO_SETTINGS) > /dev/null 2>&1 && vivado -version | head -1 | awk '{print $2}'")
32+
ifeq (, $(findstring $(VIVADO_VERSION), $(VIVADO_INSTALL)))
33+
$(warning *** This repository has only been tested with $(VIVADO_VERSION),)
34+
$(warning *** and you have $(VIVADO_INSTALL))
35+
$(warning *** Please 1] set the path to Vivado $(VIVADO_VERSION) OR)
36+
$(warning *** 2] remove $(VIVADO_INSTALL) from the path OR)
37+
$(error " 3] export VIVADO_VERSION=v20xx.x")
38+
endif
39+
endif
40+
41+
##PATCH COMMAND NEED TO BE INVOCATED
42+
ifneq (1, ${PATCH})
43+
$(warning patch granted $(PATCH))
44+
endif
45+
46+
TARGET ?= pluto
47+
SUPPORTED_TARGETS:=pluto plutoplus e200
48+
#XSA_FILE ?= ori/bitstream/${TARGET}/system_top.xsa
49+
50+
$(warning *** Building target $(TARGET),)
51+
52+
# Include target specific constants
53+
include scripts/$(TARGET).mk
54+
55+
ifeq (, $(shell which dfu-suffix))
56+
$(warning "No dfu-utils in PATH consider doing: sudo apt-get install dfu-util")
57+
TARGETS = build/pluto.frm build/boot.frm
58+
else
59+
TARGETS = build/$(TARGET).dfu build/uboot-env.dfu build/pluto.frm build/boot.dfu build/boot.frm
60+
endif
61+
62+
ifeq ($(findstring $(TARGET),$(SUPPORTED_TARGETS)),)
63+
all:
64+
@echo "Invalid `TARGET variable ; valid values are: pluto, sidekiqz2, plutoplus" &&
65+
exit 1
66+
else
67+
all: clean-build $(TARGETS) zip-all legal-info
68+
endif
69+
70+
.NOTPARALLEL: all
71+
72+
TARGET_DTS_FILES:=$(foreach dts,$(TARGET_DTS_FILES),build/$(dts))
73+
74+
TOOLCHAIN:
75+
make BR2_EXTERNAL=$(ABSOLUTE_PATH)/ori -C buildroot ARCH=arm zynq_pluto_ori_defconfig
76+
make -C buildroot toolchain
77+
78+
build:
79+
mkdir -p $@
80+
81+
%: build/%
82+
cp $< $@
83+
84+
85+
### u-boot ###
86+
87+
u-boot-xlnx/u-boot u-boot-xlnx/tools/mkimage: TOOLCHAIN
88+
# $(TOOLS_PATH) make -C u-boot-xlnx ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) zynq_$(TARGET)_defconfig
89+
$(TOOLS_PATH) make -C u-boot-xlnx ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) zynq_$(TARGET)_defconfig
90+
$(TOOLS_PATH) make -C u-boot-xlnx ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) UBOOTVERSION="$(UBOOT_VERSION)"
91+
92+
.PHONY: u-boot-xlnx/u-boot
93+
94+
build/u-boot.elf: u-boot-xlnx/u-boot | build
95+
cp $< $@
96+
97+
build/uboot-env.txt: u-boot-xlnx/u-boot TOOLCHAIN | build
98+
$(TOOLS_PATH) CROSS_COMPILE=$(CROSS_COMPILE) scripts/get_default_envs.sh > $@
99+
100+
build/uboot-env.bin: build/uboot-env.txt
101+
u-boot-xlnx/tools/mkenvimage -s 0x20000 -o $@ $<
102+
103+
### Linux ###
104+
105+
linux/arch/arm/boot/zImage: TOOLCHAIN
106+
$(TOOLS_PATH) make -C linux -j $(NCORES) ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) zynq_$(TARGET)_linux_defconfig zImage UIMAGE_LOADADDR=0x8000
107+
$(TOOLS_PATH) make -C linux -j $(NCORES) ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) zynq_$(TARGET)_linux_defconfig uImage UIMAGE_LOADADDR=0x8000
108+
## $(TOOLS_PATH) make -C linux ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) defconfig zynq_$(TARGET)_defconfig
109+
##$(TOOLS_PATH) make BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE=$(ABSOLUTE_PATH)/datv/configs/zynq_$(TARGET)datv_linux_defconfig -C linux -j $(NCORES) ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) zImage UIMAGE_LOADADDR=0x8000
110+
111+
.PHONY: linux/arch/arm/boot/zImage
112+
.PHONY: linux/arch/arm/boot/uImage
113+
114+
build/zImage: linux/arch/arm/boot/zImage | build
115+
cp $< $@
116+
117+
build/uImage: linux/arch/arm/boot/uImage | build
118+
cp $< $@
119+
120+
121+
### Device Tree ###
122+
123+
linux/arch/arm/boot/dts/%.dtb: TOOLCHAIN linux/arch/arm/boot/dts/%.dts linux/arch/arm/boot/dts/zynq-pluto-sdr.dtsi linux/arch/arm/boot/dts/zynq-pluto-sdr.dtsi
124+
$(TOOLS_PATH) DTC_FLAGS=-@ make -C linux -j $(NCORES) ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) $(notdir $@)
125+
126+
build/%.dtb: linux/arch/arm/boot/dts/%.dtb | build
127+
dtc -q -@ -I dtb -O dts $< | sed 's/axi {/amba {/g' | dtc -q -@ -I dts -O dtb -o $@
128+
129+
130+
131+
### Buildroot ###
132+
133+
buildroot/output/images/rootfs.cpio.gz:
134+
@echo device-fw $(VERSION)> $(BR2_EXTERNAL)/board/pluto/VERSIONS
135+
@$(foreach dir,$(VSUBDIRS),echo $(dir) $(shell cd $(dir) && git describe --abbrev=4 --dirty --always --tags) >> $(BR2_EXTERNAL)/board/pluto/VERSIONS;)
136+
make BR2_EXTERNAL=$(ABSOLUTE_PATH)/ori -C buildroot ARCH=arm zynq_pluto_ori_defconfig
137+
## make -C buildroot ARCH=arm zynq_$(TARGET)_defconfig
138+
139+
ifneq (1, ${SKIP_LEGAL})
140+
make -C buildroot legal-info
141+
scripts/legal_info_html.sh "$(COMPLETE_NAME)" "$(CURDIR)/buildroot/board/pluto/VERSIONS"
142+
cp build/LICENSE.html buildroot/board/pluto/msd/LICENSE.html
143+
endif
144+
145+
make -C buildroot BUSYBOX_CONFIG_FILE=$(BR2_EXTERNAL)/board/pluto/busybox-1.25.0.config all
146+
147+
.PHONY: buildroot/output/images/rootfs.cpio.gz
148+
149+
150+
## Invoke again buildroot to add datv bin in rootfs
151+
build/rootfs.cpio.gz: buildroot/output/images/rootfs.cpio.gz | build
152+
make -C buildroot BUSYBOX_CONFIG_FILE=$(BR2_EXTERNAL)/board/pluto/busybox-1.25.0.config all
153+
cp $< $@
154+
155+
build/$(TARGET).itb: u-boot-xlnx/tools/mkimage build/zImage build/rootfs.cpio.gz $(TARGET_DTS_FILES) build/system_top.bit
156+
u-boot-xlnx/tools/mkimage -f scripts/$(TARGET).its $@
157+
158+
build/system_top.xsa: | build
159+
ifneq ($(XSA_FILE),)
160+
cp $(XSA_FILE) $@
161+
else ifneq ($(XSA_URL),)
162+
wget -T 3 -t 1 -N --directory-prefix build $(XSA_URL)
163+
else ifeq (1, ${HAVE_VIVADO})
164+
#bash -c "source $(VIVADO_SETTINGS) && make -C maia-sdr/maia-hdl/projects/$(TARGET) && cp maia-sdr/maia-hdl/projects/$(TARGET)/$(TARGET).sdk/system_top.xsa $@"
165+
#unzip -l $@ | grep -q ps7_init || cp maia-sdr/maia-hdl/projects/$(TARGET)/$(TARGET).srcs/sources_1/bd/system/ip/system_sys_ps7_0/ps7_init* build/
166+
ifeq ($(TARGET),pluto)
167+
bash -c "source $(VIVADO_SETTINGS) && make -C ../projects/pluto && cp ../projects/pluto/pluto.sdk/system_top.xsa $@"
168+
unzip -l $@ | grep -q ps7_init || cp ../projects/pluto/pluto.srcs/sources_1/bd/system/ip/system_sys_ps7_0/ps7_init* build/
169+
endif
170+
ifeq ($(TARGET),plutoplus)
171+
bash -c "source $(VIVADO_SETTINGS) && make -C ../hdl/projects/pluto-ori-plus && cp ../hdl/projects/pluto-ori-plus/pluto.sdk/system_top.xsa $@"
172+
unzip -l $@ | grep -q ps7_init || cp ../hdl/projects/pluto-ori-plus/pluto.srcs/sources_1/bd/system/ip/system_sys_ps7_0/ps7_init* build/
173+
endif
174+
ifeq ($(TARGET),e200)
175+
bash -c "source $(VIVADO_SETTINGS) && make -C ../hdl/projects/pluto-ori-e200 && cp ../hdl/projects/pluto-ori-e200/e200.sdk/system_top.xsa $@"
176+
unzip -l $@ | grep -q ps7_init || cp ../hdl/projects/pluto-ori-e200/e200.srcs/sources_1/bd/system/ip/system_sys_ps7_0/ps7_init* build/
177+
endif
178+
#bash -c "source $(VIVADO_SETTINGS) && make -C ../hdl/projects/pluto-ori-plus"
179+
endif
180+
181+
### TODO: Build system_top.xsa from src if dl fails ...
182+
183+
build/fsbl.elf build/system_top.bit : build/system_top.xsa
184+
rm -Rf build/sdk
185+
ifeq (1, ${HAVE_VIVADO})
186+
bash -c "source $(VIVADO_SETTINGS) && xsct scripts/create_fsbl_project.tcl"
187+
else
188+
unzip -o build/system_top.xsa system_top.bit -d build
189+
endif
190+
191+
build/boot.bin: build/fsbl.elf build/u-boot.elf
192+
@echo img:{[bootloader] $^ } > build/boot.bif
193+
ifeq (1, ${HAVE_VIVADO})
194+
cp build/sdk/fsbl/Release/fsbl.elf build/fsbl.elf
195+
bash -c "source $(VIVADO_SETTINGS) && bootgen -image build/boot.bif -w -o $@"
196+
else
197+
cp ori/bitstream/$(TARGET)/fsbl.elf build/fsbl.elf
198+
bash -c "bootgen -image build/boot.bif -w -o $@"
199+
endif
200+
### MSD update firmware file ###
201+
202+
build/pluto.frm: build/$(TARGET).itb
203+
md5sum $< | cut -d ' ' -f 1 > $@.md5
204+
cat $< $@.md5 > $@
205+
206+
build/boot.frm: build/boot.bin build/uboot-env.bin scripts/target_mtd_info.key
207+
cat $^ | tee $@ | md5sum | cut -d ' ' -f1 | tee -a $@
208+
209+
### DFU update firmware file ###
210+
211+
build/%.dfu: build/%.bin
212+
cp $< $<.tmp
213+
dfu-suffix -a $<.tmp -v $(DEVICE_VID) -p $(DEVICE_PID)
214+
mv $<.tmp $@
215+
216+
build/$(TARGET).dfu: build/$(TARGET).itb
217+
cp $< $<.tmp
218+
dfu-suffix -a $<.tmp -v $(DEVICE_VID) -p $(DEVICE_PID)
219+
mv $<.tmp $@
220+
221+
SDIMGDIR = build/sdimg
222+
sdimg: build | build/rootfs.cpio.gz
223+
mkdir -p $(SDIMGDIR)
224+
cp ori/bitstream/$(TARGET)/fsbl.elf $(SDIMGDIR)/fsbl.elf
225+
cp build/system_top.bit $(SDIMGDIR)/system_top.bit
226+
cp build/u-boot.elf $(SDIMGDIR)/u-boot.elf
227+
cp linux/arch/arm/boot/uImage $(SDIMGDIR)/uImage
228+
229+
ifeq ($(TARGET),pluto)
230+
cp build/zynq-pluto-sdr.dtb $(SDIMGDIR)/devicetree.dtb
231+
endif
232+
ifeq ($(TARGET),plutoplus)
233+
cp build/zynq-plutoplus-maiasdr.dtb $(SDIMGDIR)/devicetree.dtb
234+
endif
235+
ifeq ($(TARGET),e200)
236+
cp build/zynq-e200.dtb $(SDIMGDIR)/devicetree.dtb
237+
endif
238+
cp build/uboot-env.txt $(SDIMGDIR)/uEnv.txt
239+
cp build/rootfs.cpio.gz $(SDIMGDIR)/ramdisk.image.gz
240+
mkimage -A arm -T ramdisk -C gzip -d $(SDIMGDIR)/ramdisk.image.gz $(SDIMGDIR)/uramdisk.image.gz
241+
touch $(SDIMGDIR)/boot.bif
242+
echo "img : {[bootloader] $(SDIMGDIR)/fsbl.elf $(SDIMGDIR)/system_top.bit $(SDIMGDIR)/u-boot.elf}" > $(SDIMGDIR)/boot.bif
243+
bootgen -image $(SDIMGDIR)/boot.bif -w -o i $(SDIMGDIR)/BOOT.bin
244+
rm $(SDIMGDIR)/fsbl.elf
245+
rm $(SDIMGDIR)/system_top.bit
246+
rm $(SDIMGDIR)/u-boot.elf
247+
rm $(SDIMGDIR)/ramdisk.image.gz
248+
rm $(SDIMGDIR)/boot.bif
249+
250+
251+
clean-build:
252+
rm -f $(notdir $(wildcard build/*))
253+
rm -rf build/*
254+
255+
clean:
256+
make -C u-boot-xlnx clean
257+
make -C linux clean
258+
make -C buildroot clean
259+
rm -f $(notdir $(wildcard build/*))
260+
rm -rf build/*
261+
262+
zip-all: $(TARGETS)
263+
mkdir -p Release && cd build && zip -r ../Release/$(ZIP_ARCHIVE_PREFIX)-fw-$(VERSION).zip *.dfu *.frm
264+
265+
dfu-$(TARGET): build/$(TARGET).dfu
266+
dfu-util -D build/$(TARGET).dfu -a firmware.dfu
267+
dfu-util -e
268+
269+
dfu-sf-uboot: build/boot.dfu build/uboot-env.dfu
270+
echo "Erasing u-boot be careful - Press Return to continue... " && read key && \
271+
dfu-util -D build/boot.dfu -a boot.dfu && \
272+
dfu-util -D build/uboot-env.dfu -a uboot-env.dfu
273+
dfu-util -e
274+
275+
dfu-all: build/$(TARGET).dfu build/boot.dfu build/uboot-env.dfu
276+
echo "Erasing u-boot be careful - Press Return to continue... " && read key && \
277+
dfu-util -D build/$(TARGET).dfu -a firmware.dfu && \
278+
dfu-util -D build/boot.dfu -a boot.dfu && \
279+
dfu-util -D build/uboot-env.dfu -a uboot-env.dfu
280+
dfu-util -e
281+
282+
dfu-ram: build/$(TARGET).dfu
283+
sshpass -p analog ssh root@$(TARGET) '/usr/sbin/device_reboot ram;'
284+
sleep 7
285+
dfu-util -D build/$(TARGET).dfu -a firmware.dfu
286+
dfu-util -e
287+
288+
jtag-bootstrap: build/u-boot.elf build/ps7_init.tcl build/system_top.bit scripts/run.tcl scripts/run-xsdb.tcl
289+
$(TOOLS_PATH) $(CROSS_COMPILE)strip build/u-boot.elf
290+
zip -j build/$(ZIP_ARCHIVE_PREFIX)-$@-$(VERSION).zip $^
291+
292+
sysroot: buildroot/output/images/rootfs.cpio.gz
293+
tar czfh build/sysroot-$(VERSION).tar.gz --hard-dereference --exclude=usr/share/man --exclude=dev --exclude=etc -C buildroot/output staging
294+
295+
legal-info: buildroot/output/images/rootfs.cpio.gz
296+
ifneq (1, ${SKIP_LEGAL})
297+
tar czvf build/legal-info-$(VERSION).tar.gz -C buildroot/output legal-info
298+
endif
299+
300+
301+
git-update-all:
302+
git submodule update --recursive --remote
303+
304+
git-pull:
305+
git pull --recurse-submodules

firmware/download_and_test.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#~/bin/sh
2+
# This resets a connected pluto, loads firmware into ram, and boots it
3+
#
4+
5+
#default IP address
6+
ipaddr=192.168.2.1
7+
8+
if [ ! -f ./build/pluto.dfu ] ; then
9+
echo no file to upload
10+
exit
11+
fi
12+
13+
ssh_cmd()
14+
{
15+
sshpass -v -panalog ssh -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -oCheckHostIP=no root@${ipaddr} "$1" 2>/dev/null
16+
if [ "$?" -ne "0" ] ; then
17+
echo ssh command $1 failed
18+
exit
19+
fi
20+
}
21+
ssh_cmd "device_reboot ram"
22+
23+
lines=0
24+
attempt=0
25+
while [ "${lines}" -le "8" -a "${attempt}" -le "10" ]
26+
do
27+
lines=$(sudo dfu-util -l -d 0456:b673,0456:b674 | wc -l)
28+
if [ "${lines}" -le "8" ] ; then
29+
sleep 1
30+
fi
31+
((attempt++))
32+
done
33+
34+
# -R resets/terminates the dfu after we are done
35+
sudo dfu-util -R -d 0456:b673,0456:b674 -D ./build/pluto.dfu -a firmware.dfu

firmware/ori/Config.in

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#source pluto_cc.sh
2+
menu "SKRORG"
3+
4+
source "$BR2_EXTERNAL_PLUTOSDR_PATH/package/libfec/Config.in"
5+
source "$BR2_EXTERNAL_PLUTOSDR_PATH/package/libtuntap/Config.in"
6+
source "$BR2_EXTERNAL_PLUTOSDR_PATH/package/lamableu-apps/Config.in"
7+
source "$BR2_EXTERNAL_PLUTOSDR_PATH/package/rtl-433/Config.in"
8+
source "$BR2_EXTERNAL_PLUTOSDR_PATH/package/rtlsdr-airband/Config.in"
9+
source "$BR2_EXTERNAL_PLUTOSDR_PATH/package/luaradio-basic/Config.in"
10+
source "$BR2_EXTERNAL_PLUTOSDR_PATH/package/multimonng/Config.in"
11+
source "$BR2_EXTERNAL_PLUTOSDR_PATH/package/libdvbmod/Config.in"
12+
source "$BR2_EXTERNAL_PLUTOSDR_PATH/package/dvb2iq/Config.in"
13+
source "$BR2_EXTERNAL_PLUTOSDR_PATH/package/suscan/Config.in"
14+
source "$BR2_EXTERNAL_PLUTOSDR_PATH/package/sigutils/Config.in"
15+
source "$BR2_EXTERNAL_PLUTOSDR_PATH/package/soapysdr/Config.in"
16+
source "$BR2_EXTERNAL_PLUTOSDR_PATH/package/soapyplutosdr/Config.in"
17+
source "$BR2_EXTERNAL_PLUTOSDR_PATH/package/soapyremote/Config.in"
18+
source "$BR2_EXTERNAL_PLUTOSDR_PATH/package/rxtools/Config.in"
19+
source "$BR2_EXTERNAL_PLUTOSDR_PATH/package/tx-tools/Config.in"
20+
source "$BR2_EXTERNAL_PLUTOSDR_PATH/package/csdr/Config.in"
21+
source "$BR2_EXTERNAL_PLUTOSDR_PATH/package/dump1090-pluto/Config.in"
22+
source "$BR2_EXTERNAL_PLUTOSDR_PATH/package/civetwebws/Config.in"
23+
source "$BR2_EXTERNAL_PLUTOSDR_PATH/package/soapysdr-master/Config.in"
24+
source "$BR2_EXTERNAL_PLUTOSDR_PATH/package/soapyplutosdr-master/Config.in"
25+
source "$BR2_EXTERNAL_PLUTOSDR_PATH/package/libgse/Config.in"
26+
source "$BR2_EXTERNAL_PLUTOSDR_PATH/package/satdump/Config.in"
27+
source "$BR2_EXTERNAL_PLUTOSDR_PATH/package/nng/Config.in"
28+
source "$BR2_EXTERNAL_PLUTOSDR_PATH/package/srt/Config.in"
29+
endmenu

0 commit comments

Comments
 (0)