Antsdr build notes

Prepare SD card:

To build basic linux for Zync board you need to follow those steps:

*I was building it from archlinux, so it doesn’t matter which distribution you are using.

Build Uboot — part of the BOOT.bin loader:

Use this source code — https://github.com/Xilinx/u-boot-xlnx

Install arm crosscompiler — arm-linux-gnueabihf

Make config using this command:

make bitmain_antminer_s9_defconfig

Build Uboot just using make command.

That’s not enough to create BOOT.bin. You will need to build fsbl:

1) In Vivado you will need to create hardware design file (XSA), that requires at least PS part created and customised in hardware design.

2) Create fsbl itself using Vitis and XSA file exported from Vivado.

3) Then pack fsbl and u-boot.elf using Vitis or using petalinux —https://docs.amd.com/r/en-US/ug1144-petalinux-tools-reference-guide/petalinux-package-boot-Examples

Also see additional info below.

Building kernel:

Use this repo — https://github.com/Xilinx/linux-xlnx

Install u-boot-tools.

Make config and image for Uboot:

make ARCH=arm xilinx_zynq_defconfig

make ARCH=arm UIMAGE_LOADADDR=0x8000 uImage

Rootfs I’m using:

https://rcn-ee.com/rootfs/eewiki/minfs

Uboot env:

setenv bootcmd "fatload mmc 0 0x3000000 uImage; fatload mmc 0 0x2A00000 devicetree.dtb; bootm 0x3000000 - 0x2A00000"

setenv bootargs "mem=500M console=tty7 console=ttyPS0,115200n8 root=/dev/mmcblk0p2 rw rootfstype=ext4 fsck.repair=yes rootwait"

You can save it on the SD card using simple command saveenv

Writing stuff to SD card:

You need at least two partitions — fat32 partition to store BOOT.bin — loader, devicetree.dtb and kernel — uImage

And second — ext4 to copy rootfs from archive.

Note:

So, how to create basic uImage (kernel), devicetree and u-boot.elf (part of the loader — BOOT.bin) described above.

Creating bootloader (BOOT.bin) from u-boot.elf is a bit more tricky and this is a bit more topics that I wanted to describe in this article 🙂 Anyway in the internet you can find tons of articles about those stuff.

After boot flash created:

For people like me, who is not using Ubuntu on a daily basis — setup DHCP client using netplan:

arm% cat /etc/netplan/99_config.yaml
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: true

Building bitstream:

To build bitstream you will need to clone red_pataya_notes repo https://github.com/pavel-demin/red-pitaya-notes

Then replace/copy files from my repo into it — https://github.com/enthru/antminer_sdr

Then you can build bitstream like Pavel wrote in his notes, however as I’m using new linux kernel that not supports old way to load bitstream, so few additional steps required.

New loader is using bin files, which is a bit file with a header. Simplest way to create bin from bit:

Create bit2bin.bif file with th content:

all:
{
my_bitstream.bit
}

Run command to convert bitstream to bin:

bootgen -image bit2bin.bif -arch zynq -process_bitstream bin -o bitstream.bin

Simplest way to load bitstream on the board:

Install fpgautil:

sudo apt-get -y install fpga-manager-xlnx

Load bitstream:

fpgautil -b /home/ubuntu/sdr_transceiver_hpsdr.bit.bin

Also you will need to build hpsdr server on the board itself or using crosscompiler (c code):

gcc -O3 -march=armv7-a -mtune=cortex-a9 -mfpu=neon -mfloat-abi=hard -D_GNU_SOURCE sdr-transceiver-hpsdr.c -lm -lpthread

Tips and tricks:

Generate project to check block design, for example, in Vivado GUI:


vivado -mode batch -source scripts/project.tcl

You will need to specify project and FPGA model inside project.tcl or pass it as argument.

The article may be corrected and supplemented.