Skip to content

Commit

Permalink
Makefile: Switch to buildroot Linaro toolchain
Browse files Browse the repository at this point in the history
Due to incompatibility between the AMD/Xilinx GCC toolchain supplied
with Vivado/Vitis and Buildroot.
This project switched to Buildroot external
Toolchain: Linaro GCC 7.3-2018.05 7.3.1

https://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/arm-linux-gnueabihf/

This toolchain is used to build: Buildroot, Linux and u-boot

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
  • Loading branch information
mhennerich committed Nov 3, 2023
1 parent 183c0f4 commit ea3d810
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 49 deletions.
50 changes: 22 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
#PATH=$PATH:/opt/Xilinx/SDK/2015.4/gnu/arm/lin/bin

VIVADO_VERSION ?= 2021.2
CROSS_COMPILE ?= arm-linux-gnueabihf-

HAVE_CROSS=$(shell which $(CROSS_COMPILE)gcc | wc -l)
ifeq (0, ${HAVE_CROSS})
$(warning *** can not find $(CROSS_COMPILE)gcc in PATH)
$(error please update PATH)
endif

#gives us path/bin/arm-linux-gnueabihf-gcc
TOOLCHAIN = $(shell which $(CROSS_COMPILE)gcc)
#gives us path/bin
TOOLCHAIN2 = $(shell dirname $(TOOLCHAIN))
#gives us path we need
TOOLCHAIN_PATH = $(shell dirname $(TOOLCHAIN2))

# Use Buildroot External Linaro GCC 7.3-2018.05 arm-linux-gnueabihf Toolchain
CROSS_COMPILE = arm-linux-gnueabihf-
TOOLS_PATH = PATH="$(CURDIR)/buildroot/output/host/bin:$(CURDIR)/buildroot/output/host/sbin:$(PATH)"
TOOLCHAIN = $(CURDIR)/buildroot/output/host/bin/$(CROSS_COMPILE)gcc

NCORES = $(shell grep -c ^processor /proc/cpuinfo)
VIVADO_SETTINGS ?= /opt/Xilinx/Vivado/$(VIVADO_VERSION)/settings64.sh
Expand Down Expand Up @@ -69,45 +58,50 @@ endif

TARGET_DTS_FILES:=$(foreach dts,$(TARGET_DTS_FILES),build/$(dts))

TOOLCHAIN:
make -C buildroot ARCH=arm zynq_$(TARGET)_defconfig
make -C buildroot toolchain

build:
mkdir -p $@

%: build/%
cp $< $@


### u-boot ###

u-boot-xlnx/u-boot u-boot-xlnx/tools/mkimage:
make -C u-boot-xlnx ARCH=arm zynq_$(TARGET)_defconfig
make -C u-boot-xlnx ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) UBOOTVERSION="$(UBOOT_VERSION)"
u-boot-xlnx/u-boot u-boot-xlnx/tools/mkimage: TOOLCHAIN
$(TOOLS_PATH) make -C u-boot-xlnx ARCH=arm zynq_$(TARGET)_defconfig
$(TOOLS_PATH) make -C u-boot-xlnx ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) UBOOTVERSION="$(UBOOT_VERSION)"

.PHONY: u-boot-xlnx/u-boot

build/u-boot.elf: u-boot-xlnx/u-boot | build
cp $< $@

build/uboot-env.txt: u-boot-xlnx/u-boot | build
CROSS_COMPILE=$(CROSS_COMPILE) scripts/get_default_envs.sh > $@
build/uboot-env.txt: u-boot-xlnx/u-boot TOOLCHAIN | build
$(TOOLS_PATH) CROSS_COMPILE=$(CROSS_COMPILE) scripts/get_default_envs.sh > $@

build/uboot-env.bin: build/uboot-env.txt
u-boot-xlnx/tools/mkenvimage -s 0x20000 -o $@ $<

### Linux ###

linux/arch/arm/boot/zImage:
make -C linux ARCH=arm zynq_$(TARGET)_defconfig
make -C linux -j $(NCORES) ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) zImage UIMAGE_LOADADDR=0x8000
linux/arch/arm/boot/zImage: TOOLCHAIN
$(TOOLS_PATH) make -C linux ARCH=arm zynq_$(TARGET)_defconfig
$(TOOLS_PATH) make -C linux -j $(NCORES) ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) zImage UIMAGE_LOADADDR=0x8000 KCFLAGS='-mcpu=cortex-a9 -mfpu=vfpv4 -mfloat-abi=soft -O2'

.PHONY: linux/arch/arm/boot/zImage


build/zImage: linux/arch/arm/boot/zImage | build
build/zImage: linux/arch/arm/boot/zImage | build
cp $< $@

### Device Tree ###

linux/arch/arm/boot/dts/%.dtb: linux/arch/arm/boot/dts/%.dts linux/arch/arm/boot/dts/zynq-pluto-sdr.dtsi
DTC_FLAGS=-@ make -C linux -j $(NCORES) ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) $(notdir $@)
linux/arch/arm/boot/dts/%.dtb: TOOLCHAIN linux/arch/arm/boot/dts/%.dts linux/arch/arm/boot/dts/zynq-pluto-sdr.dtsi
$(TOOLS_PATH) DTC_FLAGS=-@ make -C linux -j $(NCORES) ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) $(notdir $@)

build/%.dtb: linux/arch/arm/boot/dts/%.dtb | build
dtc -q -@ -I dtb -O dts $< | sed 's/axi {/amba {/g' | dtc -q -@ -I dts -O dtb -o $@
Expand All @@ -121,7 +115,7 @@ buildroot/output/images/rootfs.cpio.gz:
make -C buildroot legal-info
scripts/legal_info_html.sh "$(COMPLETE_NAME)" "$(CURDIR)/buildroot/board/$(TARGET)/VERSIONS"
cp build/LICENSE.html buildroot/board/$(TARGET)/msd/LICENSE.html
make -C buildroot TOOLCHAIN_EXTERNAL_INSTALL_DIR=$(TOOLCHAIN_PATH) ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) BUSYBOX_CONFIG_FILE=$(CURDIR)/buildroot/board/$(TARGET)/busybox-1.25.0.config all
make -C buildroot BUSYBOX_CONFIG_FILE=$(CURDIR)/buildroot/board/$(TARGET)/busybox-1.25.0.config all

.PHONY: buildroot/output/images/rootfs.cpio.gz

Expand Down Expand Up @@ -215,7 +209,7 @@ dfu-ram: build/$(TARGET).dfu
dfu-util -e

jtag-bootstrap: build/u-boot.elf build/ps7_init.tcl build/system_top.bit scripts/run.tcl
$(CROSS_COMPILE)strip build/u-boot.elf
$(TOOLS_PATH) $(CROSS_COMPILE)strip build/u-boot.elf
zip -j build/$(ZIP_ARCHIVE_PREFIX)-$@-$(VERSION).zip $^

sysroot: buildroot/output/images/rootfs.cpio.gz
Expand Down
24 changes: 4 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,19 @@ Firmware License : [![Many Licenses](https://img.shields.io/badge/license-LGPL2+
sudo apt-get install bc python cpio zip unzip rsync file wget
git clone --recursive https://github.com/analogdevicesinc/plutosdr-fw.git
cd plutosdr-fw
export CROSS_COMPILE=arm-linux-gnueabihf-
export PATH=$PATH:/opt/Xilinx/Vitis/2021.2/gnu/aarch32/lin/gcc-arm-linux-gnueabi/bin
export VIVADO_SETTINGS=/opt/Xilinx/Vivado/2021.2/settings64.sh
make

```

The project may build also using Vivado 2019.1 2018.2 2017.4, 2017.2, 2016.4 or 2016.2.
However 2021.2 is the current tested FPGA systhesis toolchain.
In the v0.30 release we swithched to the arm-linux-gnueabihf-gcc hard-float toolchain.
Due to incompatibility between the AMD/Xilinx GCC toolchain supplied with Vivado/Vitis and Buildroot.
This project switched to Buildroot external Toolchain: Linaro GCC 7.3-2018.05 7.3.1

If you want to use the former arm-xilinx-linux-gnueabi-gcc soft-float toolchain included in SDK 2017.2.
Following variables should be exported:
https://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/arm-linux-gnueabihf/

This toolchain is used to build: Buildroot, Linux and u-boot

```bash
export CROSS_COMPILE=arm-xilinx-linux-gnueabi-
export PATH=$PATH:/opt/Xilinx/SDK/2017.2/gnu/arm/lin/bin
export VIVADO_SETTINGS=/opt/Xilinx/Vivado/2017.4/settings64.sh
```

And you need to revert this patch:
https://github.com/analogdevicesinc/buildroot/commit/fea212afc7dc0ee530762a1921d9ae8180778ffa


If you receive an error similar to the following:
```
Starting SDK. This could take few seconds... timeout while establishing a connection with SDK
while executing
"error "timeout while establishing a connection with SDK""
(procedure "getsdkchan" line 108)
invoked from within
Expand Down
2 changes: 1 addition & 1 deletion buildroot
Submodule buildroot updated 6109 files

0 comments on commit ea3d810

Please sign in to comment.