Build Firmware - SundanceMultiprocessorTechnology/VCS-1 GitHub Wiki
The VCS-1 (Vision, Control and Sensors) is a hardware kit intended to perform vision applications in real time using ZYNQ (ARM + FPGA) architectures using embedded LINUX.
This kit is also known as TSK-AGRI (TULIPP Starter Kit - AGRI) from TULIPP whose design exploits the concept of low-power heterogeneous computing systems providing a platform useful for applications such as medical x-ray, embedded image processing for UAVs or automotive applications running under a defined RTOS. (www.tulipp.eu).
The VCS-1 kit is comprised of:
- EMC2-DP, a carrier board, compatible with different SoMs. https://www.sundance.technology/som-cariers/pc104-boards/emc2-dp/ Currently, software support is given for the following SoMs:
- TE0715-30 (Zynq 7000 Z7030) https://www.sundance.technology/som-cariers/pc104-boards/emc2-z7030/
- TE0820-3EG (Zynq Ultrascale+ ZU3EG) https://www.sundance.technology/som-cariers/pc104-boards/emc2-zu3eg/
- TE0820-4EV (Zynq Ultrascale+ ZU4EV) https://www.sundance.technology/som-cariers/pc104-boards/emc2-zu4ev/
- TE0820-4CG (Zynq Ultrascale+ ZU4CG) https://www.sundance.technology/som-cariers/pc104-boards/emc2-zu4cg/
- FM191-RU V1, FMC module https://www.sundance.technology/system-on-modules-som/fmc-modules/adc-dac-fmc-modules/fm191/
This repository assumes the user has the corresponding license for Vivado 17.4 or 18.3 or19.2, and the corresponding installed Petalinux 17.4 or 18.3 or 19.2.
The hardware design is automatically generated using scripts. The user should download the corresponding board files from here: https://github.com/SundanceMultiprocessorTechnology/VCS-1/tree/master/Hardware/Xilinx/BoardFiles
To create the hardware design, for each repository, "ZXXXX", which can be found here: https://github.com/SundanceMultiprocessorTechnology/VCS-1/tree/master/Hardware/Xilinx/Firmware/201X.X (being 201X.X either 2017.4, 2018.3 or 2019.2).
- .tcl script to generate the hardware design in Vivado.
- IP Repo folder with required custom IPs.
- .xdc constraints file.
- .sh script to generate the hardware platform, FSBL and standalone app.
- .c file with the standalone application code.
- .bif to specify boot file generation paths.
Follow the instructions to place the board files in the correct folders:
- Create a folder wherever you want.
2017.4 and 2018.3:
- Copy the generated .hdf file in it.
2019.2:
- Copy the generated .xsa file in it.
- Assuming Petalinux is installed, and the current directory is created previously:
$ petalinux-create --type project --template zynqMP --name FM191_kernel
2017.4 and 2018.3:
$ cd FM191_kernel && mv ../*.hdf .
2019.2:
$ cd FM191_kernel && mv ../*.xsa .
$ petalinux-config --get-hw-description -p .
Troubleshooting available here
Subsystem AUTO Hardware Settings -> Advanced bootable images storage Settings -> boot image settings -> image storage media -> primary SD
Subsystem AUTO Hardware Settings -> Advanced bootable images storage Settings -> dtb image settings -> image storage media -> from boot image
2017.4 and 2018.3:
Image Packaging Configurations -> Root filesystem type -> SD card
2019.2:
Image Packaging Configurations -> Root filesystem type -> EXT (SD/eMMC/QSPI/SATA/USB)
Save the configuration and exit
$ petalinux-config -c kernel
- Docker support
- WiFi support
- PYNQ support
- USB Serial support
- GNSS support
- Grapics support
- SPI support
- USB-c support
Troubleshooting available here
General Setup
Disable initramfs and PMBus support
General setup -> Initial RAM file system and RAM disk (initramfs/initrd) support
Device Drivers -> Hardware Monitoring support -> PMBus support->Maxim MAX20751
USB Support
Device Drivers -> USB support -> <*> UHCI HCD (Most Intel and VIA) support
Device Drivers -> USB support -> <*> USB Wireless Device Management support
Device Drivers -> USB support -> <*> USB/IP support
Other Devices
Device Drivers -> Userspace I/O drivers -> <*> Userspace I/O platform driver with generic IRQ handling
2019.2 Userspace I/O drivers -- start --
Device Drivers -> Userspace I/O drivers -> Xilinx AI Engine driver
2019.2 Userspace I/O drivers -- end --
Device Drivers -> Pulse-Width Modulation (PWM) Support
Save the configuration and exit
Edit system-user.dtsi
$ nano project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi
copying this content and save:
Note: If using 1GB instead of 2GB of DDR, uncomment the lines for 1GB assembly variant and comment the lines for 2GB assembly variant
/include/ "system-conf.dtsi"
/ {
chosen{
bootargs = "earlycon clk_ignore_unused console=ttyPS0,115200 earlyprintk root=/dev/mmcblk1p2 rw rootwait uio_pdrv_genirq.of_id=generic-uio";
// If booting from the filesystem on SATA drive change root= in bootargs, ie root=/dev/sda1
};
memory { // Reduce memory for framebuffers
device_type = "memory";
//reg = <0x0 0x0 0x0 0x3FC00000>; // Reduce memory for 1GB assembly variant
reg = <0x0 0x0 0x0 0x7FC00000>; // Reduce memory for 2GB assembly variant
};
//framebuffer0: framebuffer@0x3FC00000 { // HDMI out for 1GB assembly variant
framebuffer0: framebuffer@0x7FC00000 { // HDMI out for 2GB assembly variant
compatible = "simple-framebuffer";
//reg = <0x0 0x3FC00000 0x0 (1280 * 720 * 4)>; // 720p for 1GB assembly variant
reg = <0x0 0x7FC00000 0x0 (1280 * 720 * 4)>; // 720p for 2GB assembly variant
width = <1280>; // 720p
height = <720>; // 720p
stride = <(1280 * 4)>; // 720p
format = "a8b8g8r8";
};
};
&IOs {
compatible = "generic-uio";
};
&C_LEDs {
compatible = "generic-uio";
};
&M_LEDs {
compatible = "generic-uio";
};
&spi0 {
is-decoded-cs = <0>;
num-cs = <1>;
status = "okay";
spidev@0x00 {
compatible = "spidev";
spi-max-frequency = <1000000>;
reg = <0>;
};
};
&usb0 {
status = "okay";
};
&sata {
status = "okay";
};
&dwc3_0 {
status = "okay";
dr_mode = "host";
};
&sdhci1 {
disable-wp;
no-1-8-v;
};
&smmu {
status ="okay";
};
&FMC_I2C {
m24c04@50 {
compatible = "at,24c04";
reg = <0x50>;
};
};
&fclk0 {
status = "okay";
};
&fclk1 {
status = "okay";
};
&i2c1 {
status = "okay";
adv7511@39 {
compatible = "adi,adv7511";
reg = <0x39>;
adi,input-depth = <8>;
adi,input-colorspace = "yuv422";
adi,input-clock = "1x";
adi,input-style = <1>;
adi,input-justification = "evenly";
};
};
/* ETH PHY */
&gem0 {
status = "disabled";
};
&gem1 {
status = "disabled";
};
&gem2 {
status = "disabled";
};
&gem3 {
status = "okay";
//reg = <0x0 0xff0e0000 0x0 0x1000>;
//clock-names = "pclk", "hclk", "tx_clk", "rx_clk";
//clocks = <0x3 0x1f 0x3 0x34 0x3 0x30 0x3 0x34>;
phy-mode = "rgmii-id";
phy-handle = <ðPhy>;
ethPhy:phy@1{
reg = <0x1>;
ti,rx-internal-delay = <0x8>;
ti,tx-internal-delay = <0xa>;
ti,fifo-depth = <0x1>;
ti,rxctrl-strap-worka;
marvell,reg-init = <3 16 0xff00 0x12 3 17 0xfff0 0x00>;
};
};
&v_tpg_0 {
status = "disabled";
};
&axi_vdma_0 {
status = "disabled";
};
&v_tc_0 {
status = "disabled";
};
Create the file "0001-spi-mod.patch"
$ nano project-spec/meta-user/recipes-bsp/u-boot/files/0001-spi-mod.patch
copy the following and paste in the file:
2017.4:
From 01dffe11abd79b6813e157c47c7d9c0bb0d9fc17 Mon Sep 17 00:00:00 2001
From: OpenEmbedded <oe.patch@oe>
Date: Tue, 18 Sep 2018 11:56:55 +0100
Subject: [PATCH] spi mod
Signed-off-by: OpenEmbedded <oe.patch@oe>
---
drivers/spi/spi-cadence.c | 6 +++++-
drivers/spi/spidev.c | 1 +
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi-cadence.c b/drivers/spi/spi-cadence.c
index 2b1ab22da5db..e429d04698c2 100644
--- a/drivers/spi/spi-cadence.c
+++ b/drivers/spi/spi-cadence.c
@@ -58,6 +58,7 @@
#define CDNS_SPI_CR_DEFAULT (CDNS_SPI_CR_MSTREN | \
CDNS_SPI_CR_SSCTRL | \
CDNS_SPI_CR_SSFORCE | \
+ CDNS_SPI_CR_PERI_SEL| \
CDNS_SPI_CR_BAUD_DIV_4)
/*
@@ -177,9 +178,9 @@ static void cdns_spi_chipselect(struct spi_device *spi, bool is_high)
{
struct cdns_spi *xspi = spi_master_get_devdata(spi->master);
u32 ctrl_reg;
-
ctrl_reg = cdns_spi_read(xspi, CDNS_SPI_CR);
+
if (is_high) {
/* Deselect the slave */
ctrl_reg |= CDNS_SPI_CR_SSCTRL;
@@ -193,9 +194,12 @@ static void cdns_spi_chipselect(struct spi_device *spi, bool is_high)
else
ctrl_reg |= (spi->chip_select << CDNS_SPI_SS_SHIFT) &
CDNS_SPI_CR_SSCTRL;
+
}
+ cdns_spi_write(xspi, CDNS_SPI_ER, CDNS_SPI_ER_DISABLE);
cdns_spi_write(xspi, CDNS_SPI_CR, ctrl_reg);
+ cdns_spi_write(xspi, CDNS_SPI_ER, CDNS_SPI_ER_ENABLE);
}
/**
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index 2e05046f866b..d780491b8013 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -696,6 +696,7 @@ static struct class *spidev_class;
static const struct of_device_id spidev_dt_ids[] = {
{ .compatible = "rohm,dh2228fv" },
{ .compatible = "lineartechnology,ltc2488" },
+ { .compatible = "spidev" },
{},
};
MODULE_DEVICE_TABLE(of, spidev_dt_ids);
--
2.17.1
2018.3 and 2019.2:
From 8f56faf9275bb6926ed7294d47e789a4bf10cf31 Mon Sep 17 00:00:00 2001
From: EmilieWheatley <[email protected]>
Date: Tue, 2 Apr 2019 12:05:01 +0100
Subject: [PATCH] This is a spi patch
Signed-off-by: EmilieWheatley <[email protected]>
---
drivers/spi/spi-cadence.c | 3 +++
drivers/spi/spidev.c | 1 +
2 files changed, 4 insertions(+)
diff --git a/drivers/spi/spi-cadence.c b/drivers/spi/spi-cadence.c
index 7c88f74f7f47..64847bca911d 100644
--- a/drivers/spi/spi-cadence.c
+++ b/drivers/spi/spi-cadence.c
@@ -59,6 +59,7 @@
#define CDNS_SPI_CR_DEFAULT (CDNS_SPI_CR_MSTREN | \
CDNS_SPI_CR_SSCTRL | \
CDNS_SPI_CR_SSFORCE | \
++ CDNS_SPI_CR_PERI_SEL| \
CDNS_SPI_CR_BAUD_DIV_4)
/*
@@ -200,7 +201,9 @@ static void cdns_spi_chipselect(struct spi_device *spi, bool is_high)
CDNS_SPI_CR_SSCTRL;
}
+ cdns_spi_write(xspi, CDNS_SPI_ER, CDNS_SPI_ER_DISABLE);
cdns_spi_write(xspi, CDNS_SPI_CR, ctrl_reg);
+ cdns_spi_write(xspi, CDNS_SPI_ER, CDNS_SPI_ER_ENABLE);
}
/**
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index cda10719d1d1..4f3779d3aa09 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -669,6 +669,7 @@ static const struct of_device_id spidev_dt_ids[] = {
{ .compatible = "lineartechnology,ltc2488" },
{ .compatible = "ge,achc" },
{ .compatible = "semtech,sx1301" },
+ { .compatible = "spidev" },
{},
};
MODULE_DEVICE_TABLE(of, spidev_dt_ids);
--
2.17.1
Edit the file linux-xlnx%.bbappend_ add the file references (file://0001-spi-mod.patch):
$ nano project-spec/meta-user/recipes-bsp/u-boot/linux-xlnx_%.bbappend
SRC_URI += "file://user_<date>.cfg \
file://0001-spi-mod.patch"
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
NOTE Don't change the user_<date>.cfg (e.g. user_2018-08-29-12-34-00.cfg) because it was autogenerated
Build
$ petalinux-build
The First Stage Bootloader for the VCS-1 is based on Xilinx default FSBL for zynqMP. It is modified to configure the clock synthesizer, ethernet, USB, VTC, TPG and VDMA when the board is powered up.
-
In Xilinx SDK make a default FSBL: go to File -> New -> Application Project - > Zynq MP FSBL -> Finish
-
Add the following files (adv7511.c, adv7511.h, register_map_mod.h, si5338.c, si5338.h, tpg.c, tpg.h, vdma.c, vdma.h, vtc.c, vtc.h) from https://github.com/SundanceMultiprocessorTechnology/VCS-1/tree/master/Software/FSBL to your fsbl folder
-
Modified the files (xfsbl_board.c, xfsbl_board.h, xfsbl_main.c, xfsbl_hooks.c) searched for "SUN_MOD" in the source code from https://github.com/SundanceMultiprocessorTechnology/VCS-1/tree/master/Software/FSBL
xfsbl_board.c -> lines 55 - 58, 773 - 834, 851 - 873
xfsbl_board.h -> lines 62 - 74
xsflbl_hooks.c -> lines 55 - 60, 100 - 133
xfsbl_main.c -> lines 364 -367
- copy the fsbl.elf you just built in your petalinux project folder under images/linux
2017.4
$ petalinux-package --boot --format BIN --fsbl images/linux/fsbl.elf --fpga images/linux/design_1_wrapper.bit --u-boot --pmufw images/linux/pmufw.elf
2018.3 and 2019.2
$ petalinux-package --boot --format BIN --fsbl images/linux/fsbl.elf --fpga images/linux/system.bit --u-boot --pmufw images/linux/pmufw.elf
You need to load the UIO driver manually: copy the folder from the Petalinux project for <=2018.3
$ mkdir -p tmp/rootfs/lib/modules
2018.3
$ cp -r build/tmp/work/plnx_zynqmp-xilinx-linux/linux-xlnx/4.14-xilinx-v2018.3+gitAUTOINC+eeab73d120-r0/image/lib/modules/4.14.0-xilinx-v2018.3/ tmp/rootfs/lib/modules
2019.2
No need to create folder nor copy. empty source folder
where the is the system file on the uSD
in the system file on the uSD, open /etc/modules and add uio_pdrv_genirq.ko
- Install and run gparted for editing the partitions
$ sudo apt update && sudo apt upgrade -y && sudo apt install gparted
$ sudo gparted
- Connect the SD card to the PC using an SD card reader.
- Select the SD card in gparted. Please, make sure it's the SD card, otherwise you can do irreversible damage and lose your files.
- Make sure it's unmounted (you can right click on any partition of the SD card and select "unmount"), and delete the partition of the SD card so that it displays "unallocated".
- Right click the unallocated space and create a new partition (clicking on "new"):
Free Space Proceeding (MiB): 4
New Size (MiB) : 512
Free space following (MiB): it will automatically select the rest
Align to: MiB
Create as: Primary Partition
Filesystem : fat32
Label : BOOT
- Click on "Add"
- Right click the remaining unallocated space and click on "new":
Free Space Proceeding (MiB): 0
New size (MiB) : it automatically shows the full size
Free Space Following(MiB): 0
Align to: MiB
Create as: Primary Partition
Filesystem : ext4
Label : rootfs
- Click on "Add"
- Apply all operations to create the partitions (Edit -> Apply All Operations). Click on "Apply" when asked if you are sure. Click on "Close" when it finishes.
- Close gparted
11.a. If you want to run baremetal Linux on the board:
$ cd <path_to_Petalinux_project>/FM191_kernel
$ mkdir -p tmp/rootfs
$ mkdir -p tmp/BOOT
$ cp images/linux/BOOT.BIN tmp/BOOT
$ cp images/linux/image.ub tmp/BOOT
$ cp images/linux/system.dtb tmp/BOOT
$ cp images/linux/rootfs.tar.gz tmp/rootfs
$ cd tmp
$ zip boot_files.zip -r *
- Insert the SD card in the board, and when it boots, User="root", Password="root". 11.b. If you want to run Ubuntu Zynq on the board:
$ cd <path_to_Petalinux_project>/FM191_kernel
$ mkdir -p tmp/BOOT
$ cp images/linux/BOOT.BIN tmp/BOOT
$ cp images/linux/image.ub tmp/BOOT
$ cd tmp
$ zip boot_files.zip -r *
- Unzip and fix the permissions (Assuming the SD card is mounted at /media/sdcard)
$ unzip boot_files /media/sdcard
$ sudo chown root:root /media/sdcard/rootfs
$ sudo chmod 755 /media/sdcard/rootfs
$ cd /media/sdcard/rootfs
For baremetal linux:
$ sudo tar -xvzf rootfs.tar.gz
Check here on how to install ubuntu on the VCS-1.