Wiki

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
university:tools:pluto:building_the_image [26 Apr 2018 14:50] – [Prerequisites] Robin Getzuniversity:tools:pluto:building_the_image [25 May 2023 23:21] (current) – [Prerequisites] Charles Armer
Line 1: Line 1:
 ====== Building the Firmware Image ====== ====== Building the Firmware Image ======
 +
 +<WRAP important>
 +It is recommenced to use the pre-build images, which can be found at [[https://github.com/analogdevicesinc/plutosdr-fw/releases/latest|github.com/analogdevicesinc/plutosdr-fw/]]. These are build and tested by Analog Devices, and should work on your PlutoSDR without issues. If you want to change functionality, you will need to follow these instructions. To test your image, it is recommended to use the [[/university/tools/pluto/devs/reboot#reboot_to_dfu-ram|RAM Boot]] rather than writing to flash the first time. This keep the default firmware while you are testing your image, so if something goes wrong - its a quick power cycle to fix things.
 +</WRAP>
  
 ===== Prerequisites ===== ===== Prerequisites =====
  
-  - [[university:tools:pluto:obtaining_the_sources|Sources]] +  - Make sure to download, or upgrade your [[university:tools:pluto:obtaining_the_sources|Sources]] 
-  - [[https://www.xilinx.com/support/download.html|Xilinx Vivado Design Suite]] +    * Make sure you have the recommended/required Vivado versions. It's likely listed in the //archive// section of the Xilinx web site. To check out what you need, look at the following tcl file (which was checked out in the sources link above). <code shell> 
-  - [[https://www.xilinx.com/support/download.html|Xilinx Vivado SDK]] +rgetz@brain:~/github/temp/plutosdr-fw$ grep -REQUIRED_VIVADO_VERSION $(find .-name "adi*.tcl"| grep set 
-    * Make sure you have the recommended/required Vivado versions. It's likely listed in the //archive// section of the Xilinx web site. To check out what you need, look at the following tcl file (which was checked out in the sources link above). <xterm>michael@HAL9000:~/devel**grep -REQUIRED_VIVADO_VERSION m2k-fw/hdl/projects/scripts/adi_project.tcl | grep set** +  set required_vivado_version "2021.1
-  set REQUIRED_VIVADO_VERSION "2016.4" +</code
-michael@HAL9000:~/devel$ +  - You need [[xilinx>support/download.html|Xilinx Vivado Design Suite]] to compile the Verilog into the FPGA bit file. 
-</xterm+  - You need [[xilinx>support/download/index.html/content/xilinx/en/downloadNav/vitis.html|Xilinx Vivado Vitis]] to compile C code for the ARM inside the AMD Zynq. 
- +    * If you are using very old versions of Xilinx tools, you need to make sure that you have the 32-bit libraries (the Xilinx tools are distributed as 32-bit binaries).
-After installing the Xilinx tools, you need to make sure that you have the 32-bit libraries (the Xilinx tools are distributed as 32-bit binaries).+
 <WRAP box bggreen> <WRAP box bggreen>
 <wrap info>This specifies any shell prompt running on your Linux development host </wrap> <wrap info>This specifies any shell prompt running on your Linux development host </wrap>
 +<xterm>
 +rgetz@brain:~/github/temp/plutosdr-fw$ **find /opt/Xilinx/ -name vivado -executable -type f | xargs file | grep ELF**
 +/opt/Xilinx/Vivado/2021.2/bin/unwrapped/lnx64.o/vivado: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.18, not stripped
 +</xterm>
 +If it reports as a 32-bit binary (which the above did not), and you are running on a 64-bit system, do:
 <xterm> <xterm>
 michael@HAL9000:~/devel$ **dpkg --add-architecture i386**  michael@HAL9000:~/devel$ **dpkg --add-architecture i386** 
Line 25: Line 33:
 <wrap info>This specifies any shell prompt running on your Linux development host </wrap> <wrap info>This specifies any shell prompt running on your Linux development host </wrap>
 <xterm> <xterm>
-michael@HAL9000:~/devel$ **sudo apt-get install git build-essential ccache device-tree-compiler dfu-util fakeroot help2man libncurses5-dev libssl1.0-dev mtools rsync u-boot-tools**+michael@HAL9000:~/devel$ **sudo apt-get install git build-essential ccache device-tree-compiler dfu-util fakeroot help2man libncurses5-dev libssl1.0-dev mtools rsync u-boot-tools bc python cpio zip unzip file wget**
 </xterm> </xterm>
 </WRAP> </WRAP>
  
 ===== Building ===== ===== Building =====
 +<WRAP tip>
 +It is recommended that if you are building in a Virtual Machine (which is totally fine), the Base Memory be set to at least 4096 MBytes. The Xilinx [[xilinx>products/design-tools/vivado/memory.html|Vivado]] tools require at least 1.6 Gig of memory when compile for the ''XC7Z010''. It has been reported that 2048 Mbytes is not enough, and will cause the tools to hang.
 +</WRAP>
  
 Starting the build process is just a matter of typing ''make'' within the firmware repository. Starting the build process is just a matter of typing ''make'' within the firmware repository.
 The Makefile requires a few environmental variables being set, and of course the ARM GCC toolchain in the PATH. The Makefile requires a few environmental variables being set, and of course the ARM GCC toolchain in the PATH.
-Some paths maybe adjusted to match your Xilinx Vivado and SDK install folders.  +Some paths maybe adjusted to match your Xilinx Vivado and Vitis install folders.  
  
 <WRAP box bggreen> <WRAP box bggreen>
Line 39: Line 50:
 <xterm> <xterm>
 michael@HAL9000:~/devel$ **cd plutosdr-fw** or **m2k-fw** michael@HAL9000:~/devel$ **cd plutosdr-fw** or **m2k-fw**
-michael@HAL9000:~/devel/plutosdr-fw$ **export CROSS_COMPILE=arm-xilinx-linux-gnueabi-** +michael@HAL9000:~/devel/plutosdr-fw$ **export CROSS_COMPILE=arm-linux-gnueabihf-** 
-michael@HAL9000:~/devel/plutosdr-fw$ **export PATH=$PATH:/opt/Xilinx/SDK/2016.2/gnu/arm/lin/bin** +michael@HAL9000:~/devel/plutosdr-fw$ **export PATH=$PATH:/opt/Xilinx/Vitis/2021.2/gnu/aarch32/lin/gcc-arm-linux-gnueabi/bin** 
-michael@HAL9000:~/devel/plutosdr-fw$ **export VIVADO_SETTINGS=/opt/Xilinx/Vivado/2016.2/settings64.sh**+michael@HAL9000:~/devel/plutosdr-fw$ **export VIVADO_SETTINGS=/opt/Xilinx/Vivado/2021.2/settings64.sh**
 michael@HAL9000:~/devel/plutosdr-fw$ **make** michael@HAL9000:~/devel/plutosdr-fw$ **make**
 </xterm> </xterm>
Line 47: Line 58:
  
 The initial build takes some time to complete, and also requires an INTERNET connection, since [[https://buildroot.org/|buildroot]] downloads the source packages from the WEB. The initial build takes some time to complete, and also requires an INTERNET connection, since [[https://buildroot.org/|buildroot]] downloads the source packages from the WEB.
 +
 +<WRAP tip>
 +Depending on your distribution, you may need to force Vivado to use Gtk2. You can do that by adding:
 +<WRAP box bggreen>
 +<wrap info>This specifies any shell prompt running on your Linux development host </wrap>
 +<xterm>
 +michael@HAL9000:~/devel/plutosdr-fw$ **export SWT_GTK3=0**
 +</xterm>
 +</WRAP>
 +before you type ''make''.
 +</WRAP>
  
 ==== Build Artifacts ==== ==== Build Artifacts ====
Line 78: Line 100:
 </xterm> </xterm>
 </WRAP> </WRAP>
-  
-==== Main targets ==== 
  
 +==== Testing on the target ====
 +
 +There is a script in the [[github>plutosdr_scripts]] repo that will quickly download a build artifact (the ''pluto.dfu'' file) to an USB attached PlutoSDR. This will load the image into RAM, and not write to flash, enabling easy testing of images. However, since it is loading into RAM, it is not a persistent update over power cycles or further reboots.
 +
 +<WRAP box bggreen>
 +<wrap info>This specifies any shell prompt running on your Linux development host </wrap>
 +<xterm>
 +rgetz@brain:~/github/plutosdr-fw$ **sudo ../plutosdr_scripts/pluto_ramboot**
 +Found Pluto SDR at IP 192.168.3.1, running kernel:
 + Linux pluto 5.4.0-00535-g9c04de11ae53 #1 SMP PREEMPT Fri Aug 20 13:01:03 CEST 2021 armv7l GNU/Linux
 +Found Pluto SDR in dfu mode and downloading ./build/pluto.dfu
 +successfully downloaded
 +Found new PlutoSDR at 192.168.3.1, running kernel:
 + Linux pluto 5.4.0-00535-g9c04de11ae53 #1 SMP PREEMPT Tue Feb 15 16:17:50 EST 2022 armv7l GNU/Linux
 +rgetz@brain:~/github/plutosdr-fw$ 
 +</xterm>
 +</WRAP>
 +
 +==== Main targets ====
    
 ^ File  ^ Comment ^ ^ File  ^ Comment ^
Line 127: Line 166:
 </code> </code>
  
 +==== Making custom kernel changes ====
 +
 +<WRAP alert>Normal users should not need to change their kernel, and this is only described for advanced users, or developers who periodically forget things</WRAP>
 +
 +The command
 +<code>
 +make -C linux ARCH=arm zynq_pluto_defconfig
 +</code>
 +copies the file from ''arch/arm/configs/zynq_pluto_defconfig'' to ''.config'' and 
 +<code>
 +make -C linux -j 8 ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi- zImage UIMAGE_LOADADDR=0x8000
 +</code>
 +builds it.
 +
 +If you want to make a custom kernel, the easiest thing to do, is modify the ''.config'' with 
 +
 +<code>
 +make -C linux ARCH=arm zynq_pluto_defconfig
 +make -C linux ARCH=arm menuconfig
 +</code>
 +
 +and then make changes, save them, and then create the ''defconfig''.
 +
 +<code>
 +make -C linux ARCH=arm savedefconfig
 +</code>
 +
 +Check your changes against the default image
 +
 +<code>
 +diff -u ./linux/arch/arm/configs/zynq_pluto_defconfig linux/defconfig | less
 +</code>
 +
 +And if you are sure things are what you want, store them to the default file.
 +
 +<code>
 +cp ./linux/defconfig ./linux/arch/arm/configs/zynq_pluto_defconfig
 +</code>
 +
 +then this will work next time you type ''make'' to build the firmware image.
 ===== Build Devicetrees  ===== ===== Build Devicetrees  =====
  
Line 155: Line 234:
 </code> </code>
  
 +==== Configuring Buildroot ====
 +
 +You need to copy over the correct file, to the ''.config'', edit it (with ''menuconfig''), and then save it to the right place so that the main build system will use the new file.
 +<xterm>
 +make -C buildroot ARCH=arm zynq_pluto_defconfig
 +make -C buildroot ARCH=arm menuconfig
 +make -C buildroot ARCH=arm savedefconfig
 +make
 +</xterm>
 ===== Build FPGA Hardware Description File ===== ===== Build FPGA Hardware Description File =====
  
Line 161: Line 249:
  
 <code> <code>
-source /opt/Xilinx/Vivado/2016.2/settings64.sh+source /opt/Xilinx/Vivado/2021.2/settings64.sh
 make -C hdl/projects/pluto make -C hdl/projects/pluto
 cp hdl/projects/pluto/pluto.sdk/system_top.hdf build/system_top.hdf cp hdl/projects/pluto/pluto.sdk/system_top.hdf build/system_top.hdf
Line 173: Line 261:
  
 <code> <code>
-source /opt/Xilinx/Vivado/2016.2/settings64.sh+source /opt/Xilinx/Vivado/2021.2/settings64.sh
 xsdk -batch -source scripts/create_fsbl_project.tcl xsdk -batch -source scripts/create_fsbl_project.tcl
 cp build/sdk/hw_0/system_top.bit build/system_top.bit cp build/sdk/hw_0/system_top.bit build/system_top.bit
Line 221: Line 309:
 <code> <code>
 echo img:{[bootloader] build/sdk/fsbl/Release/fsbl.elf build/u-boot.elf } > build/boot.bif echo img:{[bootloader] build/sdk/fsbl/Release/fsbl.elf build/u-boot.elf } > build/boot.bif
-source /opt/Xilinx/Vivado/2016.2/settings64.sh+source /opt/Xilinx/Vivado/2021.2/settings64.sh
 bootgen -image build/boot.bif -w -o build/boot.bin bootgen -image build/boot.bif -w -o build/boot.bin
 </code> </code>
university/tools/pluto/building_the_image.1524747025.txt.gz · Last modified: 26 Apr 2018 14:50 by Robin Getz