├── flash.sh ├── scripts ├── sidekiqz2.mk ├── run.tcl ├── pluto.mk ├── create_fsbl_project.tcl ├── 53-adi-plutosdr-usb.rules ├── target_mtd_info.key ├── get_default_envs.sh ├── pluto.its ├── sidekiqz2.its └── legal_info_html.sh ├── commit.sh ├── prep.sh ├── .gitignore ├── .gitmodules ├── LICENSE.md ├── README.md └── Makefile /flash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | dfu-util -a firmware.dfu -D build/pluto.dfu && dfu-util -e 3 | -------------------------------------------------------------------------------- /scripts/sidekiqz2.mk: -------------------------------------------------------------------------------- 1 | 2 | TARGET_DTS_FILES:= zynq-sidekiqz2-revb.dtb 3 | COMPLETE_NAME:=SidekiqZ2 4 | ZIP_ARCHIVE_PREFIX:=sidekiqz2 5 | DEVICE_VID:=0x2fa2 6 | DEVICE_PID:=0x5a02 7 | 8 | -------------------------------------------------------------------------------- /commit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "Copying .config to PlutoWeb/plutoweb/zynq_pluto_defconfig..." 3 | cp buildroot/.config ../PlutoWeb/plutoweb/zynq_pluto_defconfig 4 | cd build 5 | echo "Copying boot.dfu boot.frm pluto.frm pluto.dfu to PlutoWeb/plutoweb/images/..." 6 | cp boot.dfu boot.frm pluto.frm pluto.dfu ../../PlutoWeb/plutoweb/images/ 7 | -------------------------------------------------------------------------------- /scripts/run.tcl: -------------------------------------------------------------------------------- 1 | ## JTAG bootstrap u-boot for initial SF/SPI flash programming 2 | ## Open Xilinx Command Line Tool 3 | ## type: xmd -tcl run.tcl 4 | 5 | #fpga -f system_top.bit 6 | 7 | connect arm hw 8 | stop 9 | xreset 64 10 | 11 | source ps7_init.tcl 12 | ps7_init 13 | ps7_post_config 14 | 15 | dow u-boot.elf 16 | run 17 | disconnect 64 18 | -------------------------------------------------------------------------------- /scripts/pluto.mk: -------------------------------------------------------------------------------- 1 | 2 | # Target specific constants go here 3 | 4 | HDF_URL:=http://github.com/analogdevicesinc/plutosdr-fw/releases/download/${LATEST_TAG}/system_top.hdf 5 | TARGET_DTS_FILES:= zynq-pluto-sdr.dtb zynq-pluto-sdr-revb.dtb zynq-pluto-sdr-revc.dtb 6 | COMPLETE_NAME:=PlutoSDR 7 | ZIP_ARCHIVE_PREFIX:=plutosdr 8 | DEVICE_VID:=0x0456 9 | DEVICE_PID:=0xb673 10 | 11 | -------------------------------------------------------------------------------- /prep.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | export CROSS_COMPILE=arm-linux-gnueabihf- 3 | export PATH=$PATH:/opt/Xilinx/SDK/2018.3/gnu/aarch32/lin/gcc-arm-linux-gnueabi/bin 4 | export VIVADO_SETTINGS=/opt/Xilinx/Vivado/2018.3/settings64.sh 5 | # Below is needed for Ubuntu 16.04 (at least?) 6 | export SWT_GTK3=0 7 | export DISPLAY=:0 8 | # 0.31 complains if you have newer Vivado 9 | export VIVADO_VERSION=v2018.3 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Vim swap files 2 | *.swp 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Libraries 15 | *.lib 16 | *.a 17 | *.la 18 | *.lo 19 | 20 | # Shared objects (inc. Windows DLLs) 21 | *.dll 22 | *.so 23 | *.so.* 24 | *.dylib 25 | 26 | # Executables 27 | *.exe 28 | *.out 29 | *.app 30 | *.i*86 31 | *.x86_64 32 | *.hex 33 | 34 | # Debug files 35 | *.dSYM/ 36 | *.su 37 | 38 | build/ 39 | .config 40 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "u-boot-xlnx"] 2 | path = u-boot-xlnx 3 | url = https://github.com/analogdevicesinc/u-boot-xlnx.git 4 | branch = pluto 5 | [submodule "buildroot"] 6 | path = buildroot 7 | url = https://github.com/analogdevicesinc/buildroot.git 8 | [submodule "linux"] 9 | path = linux 10 | url = https://github.com/analogdevicesinc/linux 11 | branch = 2018_R1 12 | [submodule "hdl"] 13 | path = hdl 14 | url = https://github.com/analogdevicesinc/hdl 15 | branch = hdl_2018_r1 16 | -------------------------------------------------------------------------------- /scripts/create_fsbl_project.tcl: -------------------------------------------------------------------------------- 1 | hsi open_hw_design build/system_top.hdf 2 | set cpu_name [lindex [hsi get_cells -filter {IP_TYPE==PROCESSOR}] 0] 3 | 4 | sdk setws ./build/sdk 5 | sdk createhw -name hw_0 -hwspec build/system_top.hdf 6 | 7 | # Workaround for broken write_sysdev in vivado 2018.2 8 | catch { 9 | set copyfiles [glob ./build/ps7_init*] 10 | if {[llength $copyfiles]} { 11 | file copy {*}$copyfiles ./build/sdk/hw_0/ 12 | } 13 | } 14 | sdk createapp -name fsbl -hwproject hw_0 -proc $cpu_name -os standalone -lang C -app {Zynq FSBL} 15 | configapp -app fsbl build-config release 16 | sdk projects -build -type all 17 | #xsdk -batch -source create_fsbl_project.tcl 18 | -------------------------------------------------------------------------------- /scripts/53-adi-plutosdr-usb.rules: -------------------------------------------------------------------------------- 1 | # allow "plugdev" group read/write access to ADI PlutoSDR devices 2 | # DFU Device 3 | SUBSYSTEM=="usb", ATTRS{idVendor}=="0456", ATTRS{idProduct}=="b674", MODE="0664", GROUP="plugdev" 4 | SUBSYSTEM=="usb", ATTRS{idVendor}=="2fa2", ATTRS{idProduct}=="5a32", MODE="0664", GROUP="plugdev" 5 | # SDR Device 6 | SUBSYSTEM=="usb", ATTRS{idVendor}=="0456", ATTRS{idProduct}=="b673", MODE="0664", GROUP="plugdev" 7 | SUBSYSTEM=="usb", ATTRS{idVendor}=="2fa2", ATTRS{idProduct}=="5a02", MODE="0664", GROUP="plugdev" 8 | # tell the ModemManager (part of the NetworkManager suite) that the device is not a modem, 9 | # and don't send AT commands to it 10 | SUBSYSTEM=="usb", ATTRS{idVendor}=="0456", ATTRS{idProduct}=="b673", ENV{ID_MM_DEVICE_IGNORE}="1" 11 | SUBSYSTEM=="usb", ATTRS{idVendor}=="2fa2", ATTRS{idProduct}=="5a02", ENV{ID_MM_DEVICE_IGNORE}="1" 12 | -------------------------------------------------------------------------------- /scripts/target_mtd_info.key: -------------------------------------------------------------------------------- 1 | dev: size erasesize name 2 | mtd0: 00100000 00001000 "qspi-fsbl-uboot" 3 | mtd1: 00020000 00001000 "qspi-uboot-env" 4 | mtd2: 000e0000 00001000 "qspi-nvmfs" 5 | mtd3: 01e00000 00001000 "qspi-linux" 6 | -------------------------------------------------------------------------------- /scripts/get_default_envs.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # 3 | # Copyright (C) 2016, Lukasz Majewski 4 | # 5 | # SPDX-License-Identifier: GPL-2.0+ 6 | # 7 | 8 | # This file extracts default envs from built u-boot 9 | # usage: get_default_envs.sh > u-boot-env-default.txt 10 | set -ue 11 | 12 | ENV_OBJ_FILE="env_common.o" 13 | ENV_OBJ_FILE_COPY="copy_${ENV_OBJ_FILE}" 14 | 15 | echoerr() { echo "$@" 1>&2; } 16 | 17 | path=$(readlink -f $0) 18 | env_obj_file_path=$(find ${path%/scripts*} -not -path "*/spl/*" \ 19 | -name "${ENV_OBJ_FILE}") 20 | [ -z "${env_obj_file_path}" ] && \ 21 | { echoerr "File '${ENV_OBJ_FILE}' not found!"; exit 1; } 22 | 23 | cp ${env_obj_file_path} ${ENV_OBJ_FILE_COPY} 24 | 25 | # NOTE: objcopy saves its output to file passed in 26 | # (copy_env_common.o in this case) 27 | ${CROSS_COMPILE}objcopy -O binary -j ".rodata.default_environment" ${ENV_OBJ_FILE_COPY} 28 | 29 | # Replace default '\0' with '\n' and sort entries 30 | tr '\0' '\n' < ${ENV_OBJ_FILE_COPY} | sort -u 31 | 32 | rm ${ENV_OBJ_FILE_COPY} 33 | 34 | exit 0 35 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # plutosdr-fw 2 | PlutoSDR Firmware for the [ADALM-PLUTO](https://wiki.analog.com/university/tools/pluto "PlutoSDR Wiki Page") Active Learning Module 3 | 4 | The ADALM-PLUTO SDR firmware is an [aggregation](https://www.gnu.org/licenses/old-licenses/gpl-2.0-faq.en.html#MereAggregation "GPL FAQ") of components, computer programs and documents which communicate thought standard kernel/userspace ABIs, pipes, sockets and command-line arguments. 5 | These separate and unique programs are created by a range of individuals, teams and companies. 6 | Many of the components are open source packages, developed independently, and accompanied by separate license terms (such as GPL, LGPL, BSD, MIT, Apache, modified BSD or others). 7 | Your license rights with respect to individual components accompanied by separate license terms are defined by those terms (the license agreement for each component is generally located in the component's source code); nothing shall restrict, limit, or otherwise affect any rights or obligations you may have, or conditions to which you may be subject, under such license terms. 8 | This agreement does not limit your rights under, or grant you rights that supersede, the license terms of any particular component. 9 | 10 | With the potential exception of certain firmware files, the license terms of components normally included in the ADALM-PLUTO SDR firmware normally permit you to copy, modify, and redistribute the component, in both source code and binary code forms. 11 | 12 | Unless otherwise stated in the individual component license, nominally you have various rights and obligations by using free software, 13 | (1) you are free to to run the program as you wish, for any purpose, 14 | (2) you are free to study how the program works, and change it, 15 | (3) you are free to redistribute verbatim copies so you can help others, 16 | (4) you are free to distribute copies of your modified versions to others, 17 | (5) if you decide to distribute copies (modified or verbatim), you are obligated to pass these rights and obligations to the recipients. 18 | These freedoms and obligations may have an impact on Makers, Enthusiasts, or OEMs, who are also making hardware products. 19 | By using individual or multiple components in an end product that you create, but it is up to you and your legal team to make sure your product complies with the licensing requirements of whatever software package that you include in your product. 20 | 21 | You may make and use unlimited copies of the ADALM-PLUTO SDR firmware for your distribution and use within your organization. 22 | You may make and distribute unlimited copies of the ADALM-PLUTO SDR firmware outside your organization. 23 | 24 | # NO WARRANTY 25 | 26 | BECAUSE THE ADALM-PLUTO SDR FIRMWARE IS LICENSED FREE OF CHARGE, THERE IS NO 27 | WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 28 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE 29 | THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, 30 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 31 | FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND 32 | PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU 33 | ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 34 | 35 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY 36 | COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE 37 | PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, 38 | SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY 39 | TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 40 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF 41 | THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER 42 | PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 43 | -------------------------------------------------------------------------------- /scripts/pluto.its: -------------------------------------------------------------------------------- 1 | /* 2 | * U-Boot uImage source file with multiple kernels, ramdisks and FDT blobs 3 | * This example makes use of the 'loadables' field 4 | */ 5 | 6 | /* 7 | * fdt get addr foo /images/fdt@1 data 8 | */ 9 | 10 | /dts-v1/; 11 | 12 | / { 13 | description = "Configuration to load fpga before Kernel"; 14 | magic = "ITB PlutoSDR (ADALM-PLUTO)"; 15 | #address-cells = <1>; 16 | images { 17 | 18 | fdt@1 { 19 | description = "zynq-pluto-sdr"; 20 | data = /incbin/("../build/zynq-pluto-sdr.dtb"); 21 | type = "flat_dt"; 22 | arch = "arm"; 23 | compression = "none"; 24 | }; 25 | 26 | fdt@2 { 27 | description = "zynq-pluto-sdr-revb"; 28 | data = /incbin/("../build/zynq-pluto-sdr-revb.dtb"); 29 | type = "flat_dt"; 30 | arch = "arm"; 31 | compression = "none"; 32 | }; 33 | 34 | fdt@3 { 35 | description = "zynq-pluto-sdr-revc"; 36 | data = /incbin/("../build/zynq-pluto-sdr-revb.dtb"); 37 | type = "flat_dt"; 38 | arch = "arm"; 39 | compression = "none"; 40 | }; 41 | 42 | fpga@1 { 43 | description = "FPGA"; 44 | data = /incbin/("../build/system_top.bit"); 45 | type = "fpga"; 46 | arch = "arm"; 47 | compression = "none"; 48 | load = <0xF000000>; 49 | hash@1 { 50 | algo = "md5"; 51 | }; 52 | }; 53 | 54 | linux_kernel@1 { 55 | description = "Linux"; 56 | data = /incbin/("../build/zImage"); 57 | type = "kernel"; 58 | arch = "arm"; 59 | os = "linux"; 60 | compression = "none"; 61 | load = <0x8000>; 62 | entry = <0x8000>; 63 | hash@1 { 64 | algo = "md5"; 65 | }; 66 | }; 67 | ramdisk@1 { 68 | description = "Ramdisk"; 69 | data = /incbin/("../build/rootfs.cpio.gz"); 70 | type = "ramdisk"; 71 | arch = "arm"; 72 | os = "linux"; 73 | compression = "gzip"; 74 | hash@1 { 75 | algo = "md5"; 76 | }; 77 | }; 78 | 79 | }; 80 | 81 | configurations { 82 | default = "config@0"; 83 | config@0 { 84 | description = "Linux with fpga RevA"; 85 | fdt = "fdt@1"; 86 | kernel = "linux_kernel@1"; 87 | ramdisk = "ramdisk@1"; 88 | fpga = "fpga@1"; 89 | }; 90 | 91 | /* all below is currently RevB ! */ 92 | 93 | config@1 { 94 | description = "Linux with fpga RevB"; 95 | fdt = "fdt@2"; 96 | kernel = "linux_kernel@1"; 97 | ramdisk = "ramdisk@1"; 98 | fpga = "fpga@1"; 99 | }; 100 | 101 | config@2 { 102 | description = "Linux with fpga RevB"; 103 | fdt = "fdt@2"; 104 | kernel = "linux_kernel@1"; 105 | ramdisk = "ramdisk@1"; 106 | fpga = "fpga@1"; 107 | }; 108 | 109 | config@3 { 110 | description = "Linux with fpga RevB"; 111 | fdt = "fdt@2"; 112 | kernel = "linux_kernel@1"; 113 | ramdisk = "ramdisk@1"; 114 | fpga = "fpga@1"; 115 | }; 116 | 117 | config@4 { 118 | description = "Linux with fpga RevB"; 119 | fdt = "fdt@2"; 120 | kernel = "linux_kernel@1"; 121 | ramdisk = "ramdisk@1"; 122 | fpga = "fpga@1"; 123 | }; 124 | 125 | config@5 { 126 | description = "Linux with fpga RevB"; 127 | fdt = "fdt@2"; 128 | kernel = "linux_kernel@1"; 129 | ramdisk = "ramdisk@1"; 130 | fpga = "fpga@1"; 131 | }; 132 | 133 | config@6 { 134 | description = "Linux with fpga RevB"; 135 | fdt = "fdt@2"; 136 | kernel = "linux_kernel@1"; 137 | ramdisk = "ramdisk@1"; 138 | fpga = "fpga@1"; 139 | }; 140 | 141 | 142 | config@7 { 143 | description = "Linux with fpga RevB"; 144 | fdt = "fdt@2"; 145 | kernel = "linux_kernel@1"; 146 | ramdisk = "ramdisk@1"; 147 | fpga = "fpga@1"; 148 | }; 149 | 150 | config@8 { /* This one is actually RevC */ 151 | description = "Linux with fpga RevC"; 152 | fdt = "fdt@3"; 153 | kernel = "linux_kernel@1"; 154 | ramdisk = "ramdisk@1"; 155 | fpga = "fpga@1"; 156 | }; 157 | 158 | config@9 { /* This one is actually RevB */ 159 | description = "Linux with fpga RevB"; 160 | fdt = "fdt@2"; 161 | kernel = "linux_kernel@1"; 162 | ramdisk = "ramdisk@1"; 163 | fpga = "fpga@1"; 164 | }; 165 | 166 | config@10 { 167 | description = "Linux with fpga RevB"; 168 | fdt = "fdt@2"; 169 | kernel = "linux_kernel@1"; 170 | ramdisk = "ramdisk@1"; 171 | fpga = "fpga@1"; 172 | }; 173 | }; 174 | }; 175 | -------------------------------------------------------------------------------- /scripts/sidekiqz2.its: -------------------------------------------------------------------------------- 1 | /* 2 | * U-Boot uImage source file with multiple kernels, ramdisks and FDT blobs 3 | * This example makes use of the 'loadables' field 4 | */ 5 | 6 | /* 7 | * fdt get addr foo /images/fdt@1 data 8 | */ 9 | 10 | /dts-v1/; 11 | 12 | / { 13 | description = "Configuration to load fpga before Kernel"; 14 | magic = "ITB Sidekiq Z2"; 15 | #address-cells = <1>; 16 | images { 17 | 18 | fdt@1 { 19 | description = "zynq-sidekiqz2"; 20 | data = /incbin/("../build/zynq-sidekiqz2-revb.dtb"); 21 | type = "flat_dt"; 22 | arch = "arm"; 23 | compression = "none"; 24 | }; 25 | 26 | fdt@2 { 27 | description = "zynq-sidekiqz2-revb"; 28 | data = /incbin/("../build/zynq-sidekiqz2-revb.dtb"); 29 | type = "flat_dt"; 30 | arch = "arm"; 31 | compression = "none"; 32 | }; 33 | 34 | fdt@3 { 35 | description = "zynq-sidekiqz2-revc"; 36 | data = /incbin/("../build/zynq-sidekiqz2-revb.dtb"); 37 | type = "flat_dt"; 38 | arch = "arm"; 39 | compression = "none"; 40 | }; 41 | 42 | fpga@1 { 43 | description = "FPGA"; 44 | data = /incbin/("../build/system_top.bit"); 45 | type = "fpga"; 46 | arch = "arm"; 47 | compression = "none"; 48 | load = <0xF000000>; 49 | hash@1 { 50 | algo = "md5"; 51 | }; 52 | }; 53 | 54 | linux_kernel@1 { 55 | description = "Linux"; 56 | data = /incbin/("../build/zImage"); 57 | type = "kernel"; 58 | arch = "arm"; 59 | os = "linux"; 60 | compression = "none"; 61 | load = <0x8000>; 62 | entry = <0x8000>; 63 | hash@1 { 64 | algo = "md5"; 65 | }; 66 | }; 67 | ramdisk@1 { 68 | description = "Ramdisk"; 69 | data = /incbin/("../build/rootfs.cpio.gz"); 70 | type = "ramdisk"; 71 | arch = "arm"; 72 | os = "linux"; 73 | compression = "gzip"; 74 | hash@1 { 75 | algo = "md5"; 76 | }; 77 | }; 78 | 79 | }; 80 | 81 | configurations { 82 | default = "config@0"; 83 | config@0 { 84 | description = "Linux with fpga RevA"; 85 | fdt = "fdt@1"; 86 | kernel = "linux_kernel@1"; 87 | ramdisk = "ramdisk@1"; 88 | fpga = "fpga@1"; 89 | }; 90 | 91 | /* all below is currently RevB ! */ 92 | 93 | config@1 { 94 | description = "Linux with fpga RevB"; 95 | fdt = "fdt@2"; 96 | kernel = "linux_kernel@1"; 97 | ramdisk = "ramdisk@1"; 98 | fpga = "fpga@1"; 99 | }; 100 | 101 | config@2 { 102 | description = "Linux with fpga RevB"; 103 | fdt = "fdt@2"; 104 | kernel = "linux_kernel@1"; 105 | ramdisk = "ramdisk@1"; 106 | fpga = "fpga@1"; 107 | }; 108 | 109 | config@3 { 110 | description = "Linux with fpga RevB"; 111 | fdt = "fdt@2"; 112 | kernel = "linux_kernel@1"; 113 | ramdisk = "ramdisk@1"; 114 | fpga = "fpga@1"; 115 | }; 116 | 117 | config@4 { 118 | description = "Linux with fpga RevB"; 119 | fdt = "fdt@2"; 120 | kernel = "linux_kernel@1"; 121 | ramdisk = "ramdisk@1"; 122 | fpga = "fpga@1"; 123 | }; 124 | 125 | config@5 { 126 | description = "Linux with fpga RevB"; 127 | fdt = "fdt@2"; 128 | kernel = "linux_kernel@1"; 129 | ramdisk = "ramdisk@1"; 130 | fpga = "fpga@1"; 131 | }; 132 | 133 | config@6 { 134 | description = "Linux with fpga RevB"; 135 | fdt = "fdt@2"; 136 | kernel = "linux_kernel@1"; 137 | ramdisk = "ramdisk@1"; 138 | fpga = "fpga@1"; 139 | }; 140 | 141 | 142 | config@7 { 143 | description = "Linux with fpga RevB"; 144 | fdt = "fdt@2"; 145 | kernel = "linux_kernel@1"; 146 | ramdisk = "ramdisk@1"; 147 | fpga = "fpga@1"; 148 | }; 149 | 150 | config@8 { /* This one is actually RevC */ 151 | description = "Linux with fpga RevC"; 152 | fdt = "fdt@3"; 153 | kernel = "linux_kernel@1"; 154 | ramdisk = "ramdisk@1"; 155 | fpga = "fpga@1"; 156 | }; 157 | 158 | config@9 { /* This one is actually RevB */ 159 | description = "Linux with fpga RevB"; 160 | fdt = "fdt@2"; 161 | kernel = "linux_kernel@1"; 162 | ramdisk = "ramdisk@1"; 163 | fpga = "fpga@1"; 164 | }; 165 | 166 | config@10 { 167 | description = "Linux with fpga RevB"; 168 | fdt = "fdt@2"; 169 | kernel = "linux_kernel@1"; 170 | ramdisk = "ramdisk@1"; 171 | fpga = "fpga@1"; 172 | }; 173 | }; 174 | }; 175 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # plutosdr-fw 2 | PlutoSDR Firmware for the [ADALM-PLUTO](https://wiki.analog.com/university/tools/pluto "PlutoSDR Wiki Page") Active Learning Module 3 | 4 | Latest binary Release : [![GitHub release](https://img.shields.io/github/release/analogdevicesinc/plutosdr-fw.svg)](https://github.com/analogdevicesinc/plutosdr-fw/releases/latest) 5 | 6 | [Instructions from the Wiki: Building the image](https://wiki.analog.com/university/tools/pluto/building_the_image) 7 | 8 | * Build Instructions 9 | ```bash 10 | sudo apt-get install git build-essential fakeroot libncurses5-dev libssl-dev ccache 11 | sudo apt-get install dfu-util u-boot-tools device-tree-compiler libssl1.0-dev mtools 12 | sudo apt-get install bc python cpio zip unzip rsync file wget 13 | git clone --recursive https://github.com/analogdevicesinc/plutosdr-fw.git 14 | cd plutosdr-fw 15 | export CROSS_COMPILE=arm-linux-gnueabihf- 16 | export PATH=$PATH:/opt/Xilinx/SDK/2018.2/gnu/aarch32/lin/gcc-arm-linux-gnueabi/bin 17 | export VIVADO_SETTINGS=/opt/Xilinx/Vivado/2018.2/settings64.sh 18 | make 19 | 20 | ``` 21 | 22 | The project may build also using Vivado 2017.4, 2017.2, 2016.4 or 2016.2. 23 | However 2018.2 is the current tested FPGA systhesis toolchain. 24 | In the v0.30 release we swithched to the arm-linux-gnueabihf-gcc hard-float toolchain. 25 | 26 | If you want to use the former arm-xilinx-linux-gnueabi-gcc soft-float toolchain included in SDK 2017.2. 27 | Following variables should be exported: 28 | 29 | 30 | ```bash 31 | <<<<<<< HEAD 32 | sudo apt-get install git build-essential fakeroot libncurses5-dev libssl-dev ccache 33 | sudo apt-get install dfu-util u-boot-tools device-tree-compiler libssl1.0-dev mtools 34 | git clone --recursive https://github.com/analogdevicesinc/plutosdr-fw.git 35 | cd plutosdr-fw 36 | . ./prep.sh 37 | make 38 | 39 | ======= 40 | export CROSS_COMPILE=arm-xilinx-linux-gnueabi- 41 | export PATH=$PATH:/opt/Xilinx/SDK/2017.2/gnu/arm/lin/bin 42 | export VIVADO_SETTINGS=/opt/Xilinx/Vivado/2017.4/settings64.sh 43 | >>>>>>> upstream/master 44 | ``` 45 | 46 | And you need to revert this patch: 47 | https://github.com/analogdevicesinc/buildroot/commit/fea212afc7dc0ee530762a1921d9ae8180778ffa 48 | 49 | 50 | If you receive an error similar to the following: 51 | ``` 52 | Starting SDK. This could take few seconds... timeout while establishing a connection with SDK 53 | while executing 54 | "error "timeout while establishing a connection with SDK"" 55 | (procedure "getsdkchan" line 108) 56 | invoked from within 57 | "getsdkchan" 58 | (procedure "createhw" line 26) 59 | invoked from within 60 | "createhw {*}$args" 61 | (procedure "::sdk::create_hw_project" line 3) 62 | invoked from within 63 | "sdk create_hw_project -name hw_0 -hwspec build/system_top.hdf" 64 | (file "scripts/create_fsbl_project.tcl" line 5) 65 | ``` 66 | you may be able to work around it by preventing eclipse from using GTK3 for the Standard Widget Toolkit (SWT). Prior to running make, also set the following environment variable: 67 | ```bash 68 | export SWT_GTK3=0 69 | ``` 70 | This problem seems to affect Ubuntu 16.04LTS only. 71 | 72 | * Updating your local repository 73 | ```bash 74 | git pull 75 | git submodule update --init --recursive 76 | ``` 77 | 78 | * Build Artifacts 79 | ```bash 80 | michael@HAL9000:~/devel/plutosdr-fw$ ls -AGhl build 81 | total 55M 82 | -rw-rw-r-- 1 michael 69 Okt 9 14:24 boot.bif 83 | -rw-rw-r-- 1 michael 446K Okt 9 14:24 boot.bin 84 | -rw-rw-r-- 1 michael 446K Okt 9 14:24 boot.dfu 85 | -rw-rw-r-- 1 michael 575K Okt 9 14:24 boot.frm 86 | -rw-rw-r-- 1 michael 8,8M Okt 9 14:24 pluto.dfu 87 | -rw-rw-r-- 1 michael 8,8M Okt 9 14:24 pluto.frm 88 | -rw-rw-r-- 1 michael 33 Okt 9 14:24 pluto.frm.md5 89 | -rw-rw-r-- 1 michael 8,8M Okt 9 14:24 pluto.itb 90 | -rw-rw-r-- 1 michael 17M Okt 9 14:24 plutosdr-fw-v0.23.zip 91 | -rw-rw-r-- 1 michael 466K Okt 9 14:24 plutosdr-jtag-bootstrap-v0.23.zip 92 | -rw-r--r-- 1 michael 4,7M Okt 9 14:23 rootfs.cpio.gz 93 | drwxrwxr-x 6 michael 4,0K Okt 9 14:24 sdk 94 | -rw-rw-r-- 1 michael 940K Okt 9 14:24 system_top.bit 95 | -rw-rw-r-- 1 michael 358K Okt 9 14:23 system_top.hdf 96 | -rwxrwxr-x 1 michael 409K Okt 9 14:24 u-boot.elf 97 | -rw-rw---- 1 michael 128K Okt 9 14:24 uboot-env.bin 98 | -rw-rw---- 1 michael 129K Okt 9 14:24 uboot-env.dfu 99 | -rw-rw-r-- 1 michael 4,6K Okt 9 14:24 uboot-env.txt 100 | -rwxrwxr-x 1 michael 3,2M Okt 9 14:23 zImage 101 | -rw-rw-r-- 1 michael 17K Okt 9 14:23 zynq-pluto-sdr.dtb 102 | -rw-rw-r-- 1 michael 17K Okt 9 14:23 zynq-pluto-sdr-revb.dtb 103 | ``` 104 | 105 | * Main targets 106 | 107 | | File | Comment | 108 | | ------------- | ------------- | 109 | | pluto.frm | Main PlutoSDR firmware file used with the USB Mass Storage Device | 110 | | pluto.dfu | Main PlutoSDR firmware file used in DFU mode | 111 | | boot.frm | First and Second Stage Bootloader (u-boot + fsbl + uEnv) used with the USB Mass Storage Device | 112 | | boot.dfu | First and Second Stage Bootloader (u-boot + fsbl) used in DFU mode | 113 | | uboot-env.dfu | u-boot default environment used in DFU mode | 114 | | plutosdr-fw-vX.XX.zip | ZIP archive containg all of the files above | 115 | | plutosdr-jtag-bootstrap-vX.XX.zip | ZIP archive containg u-boot and Vivao TCL used for JATG bootstrapping | 116 | 117 | * Other intermediate targets 118 | 119 | | File | Comment | 120 | | ------------- | ------------- | 121 | | boot.bif | Boot Image Format file used to generate the Boot Image | 122 | | boot.bin | Final Boot Image | 123 | | pluto.frm.md5 | md5sum of the pluto.frm file | 124 | | pluto.itb | u-boot Flattened Image Tree | 125 | | rootfs.cpio.gz | The Root Filesystem archive | 126 | | sdk | Vivado/XSDK Build folder including the FSBL | 127 | | system_top.bit | FPGA Bitstream (from HDF) | 128 | | system_top.hdf | FPGA Hardware Description File exported by Vivado | 129 | | u-boot.elf | u-boot ELF Binary | 130 | | uboot-env.bin | u-boot default environment in binary format created form uboot-env.txt | 131 | | uboot-env.txt | u-boot default environment in human readable text format | 132 | | zImage | Compressed Linux Kernel Image | 133 | | zynq-pluto-sdr.dtb | Device Tree Blob for Rev.A | 134 | | zynq-pluto-sdr-revb.dtb | Device Tree Blob for Rev.B| 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | #PATH=$PATH:/opt/Xilinx/SDK/2015.4/gnu/arm/lin/bin 2 | 3 | VIVADO_VERSION ?= 2018.2 4 | CROSS_COMPILE ?= arm-linux-gnueabihf- 5 | 6 | HAVE_CROSS=$(shell which $(CROSS_COMPILE)gcc | wc -l) 7 | ifeq (0, ${HAVE_CROSS}) 8 | $(warning *** can not find $(CROSS_COMPILE)gcc in PATH) 9 | $(error please update PATH) 10 | endif 11 | 12 | #gives us path/bin/arm-linux-gnueabihf-gcc 13 | TOOLCHAIN = $(shell which $(CROSS_COMPILE)gcc) 14 | #gives us path/bin 15 | TOOLCHAIN2 = $(shell dirname $(TOOLCHAIN)) 16 | #gives us path we need 17 | TOOLCHAIN_PATH = $(shell dirname $(TOOLCHAIN2)) 18 | 19 | 20 | NCORES = $(shell grep -c ^processor /proc/cpuinfo) 21 | VIVADO_SETTINGS ?= /opt/Xilinx/Vivado/$(VIVADO_VERSION)/settings64.sh 22 | VSUBDIRS = hdl buildroot linux u-boot-xlnx 23 | 24 | VERSION=$(shell git describe --abbrev=4 --dirty --always --tags) 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 | 29 | ifeq (1, ${HAVE_VIVADO}) 30 | VIVADO_INSTALL= $(shell bash -c "source $(VIVADO_SETTINGS) > /dev/null 2>&1 && vivado -version | head -1 | awk '{print $2}'") 31 | ifeq (, $(findstring $(VIVADO_VERSION), $(VIVADO_INSTALL))) 32 | $(warning *** This repository has only been tested with $(VIVADO_VERSION),) 33 | $(warning *** and you have $(VIVADO_INSTALL)) 34 | $(warning *** Please 1] set the path to Vivado $(VIVADO_VERSION) OR) 35 | $(warning *** 2] remove $(VIVADO_INSTALL) from the path OR) 36 | $(error " 3] export VIVADO_VERSION=v20xx.x") 37 | endif 38 | endif 39 | 40 | TARGET ?= pluto 41 | SUPPORTED_TARGETS:=pluto sidekiqz2 42 | 43 | # Include target specific constants 44 | include scripts/$(TARGET).mk 45 | 46 | ifeq (, $(shell which dfu-suffix)) 47 | $(warning "No dfu-utils in PATH consider doing: sudo apt-get install dfu-util") 48 | TARGETS = build/$(TARGET).frm 49 | ifeq (1, ${HAVE_VIVADO}) 50 | TARGETS += build/boot.frm jtag-bootstrap 51 | endif 52 | else 53 | TARGETS = build/$(TARGET).dfu build/uboot-env.dfu build/$(TARGET).frm 54 | ifeq (1, ${HAVE_VIVADO}) 55 | TARGETS += build/boot.dfu build/boot.frm jtag-bootstrap 56 | endif 57 | endif 58 | 59 | ifeq ($(findstring $(TARGET),$(SUPPORTED_TARGETS)),) 60 | all: 61 | @echo "Invalid `TARGET variable ; valid values are: pluto, sidekiqz2" && 62 | exit 1 63 | else 64 | all: clean-build $(TARGETS) zip-all legal-info 65 | endif 66 | 67 | .NOTPARALLEL: all 68 | 69 | TARGET_DTS_FILES:=$(foreach dts,$(TARGET_DTS_FILES),build/$(dts)) 70 | 71 | build: 72 | mkdir -p $@ 73 | 74 | %: build/% 75 | cp $< $@ 76 | 77 | ### u-boot ### 78 | 79 | u-boot-xlnx/u-boot u-boot-xlnx/tools/mkimage: 80 | make -C u-boot-xlnx ARCH=arm zynq_$(TARGET)_defconfig 81 | make -C u-boot-xlnx ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) UBOOTVERSION="$(UBOOT_VERSION)" 82 | 83 | .PHONY: u-boot-xlnx/u-boot 84 | 85 | build/u-boot.elf: u-boot-xlnx/u-boot | build 86 | cp $< $@ 87 | 88 | build/uboot-env.txt: u-boot-xlnx/u-boot | build 89 | CROSS_COMPILE=$(CROSS_COMPILE) scripts/get_default_envs.sh > $@ 90 | 91 | build/uboot-env.bin: build/uboot-env.txt 92 | u-boot-xlnx/tools/mkenvimage -s 0x20000 -o $@ $< 93 | 94 | ### Linux ### 95 | 96 | linux/arch/arm/boot/zImage: 97 | make -C linux ARCH=arm zynq_$(TARGET)_defconfig 98 | make -C linux -j $(NCORES) ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) zImage UIMAGE_LOADADDR=0x8000 99 | 100 | .PHONY: linux/arch/arm/boot/zImage 101 | 102 | 103 | build/zImage: linux/arch/arm/boot/zImage | build 104 | cp $< $@ 105 | 106 | ### Device Tree ### 107 | 108 | linux/arch/arm/boot/dts/%.dtb: linux/arch/arm/boot/dts/%.dts linux/arch/arm/boot/dts/zynq-pluto-sdr.dtsi 109 | make -C linux -j $(NCORES) ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) $(notdir $@) 110 | 111 | build/%.dtb: linux/arch/arm/boot/dts/%.dtb | build 112 | cp $< $@ 113 | 114 | ### Buildroot ### 115 | 116 | buildroot/output/images/rootfs.cpio.gz: 117 | @echo device-fw $(VERSION)> $(CURDIR)/buildroot/board/$(TARGET)/VERSIONS 118 | @$(foreach dir,$(VSUBDIRS),echo $(dir) $(shell cd $(dir) && git describe --abbrev=4 --dirty --always --tags) >> $(CURDIR)/buildroot/board/$(TARGET)/VERSIONS;) 119 | make -C buildroot ARCH=arm zynq_$(TARGET)_defconfig 120 | make -C buildroot legal-info 121 | scripts/legal_info_html.sh "$(COMPLETE_NAME)" "$(CURDIR)/buildroot/board/$(TARGET)/VERSIONS" 122 | cp build/LICENSE.html buildroot/board/$(TARGET)/msd/LICENSE.html 123 | 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 124 | 125 | .PHONY: buildroot/output/images/rootfs.cpio.gz 126 | 127 | build/rootfs.cpio.gz: buildroot/output/images/rootfs.cpio.gz | build 128 | cp $< $@ 129 | 130 | build/$(TARGET).itb: u-boot-xlnx/tools/mkimage build/zImage build/rootfs.cpio.gz $(TARGET_DTS_FILES) build/system_top.bit 131 | u-boot-xlnx/tools/mkimage -f scripts/$(TARGET).its $@ 132 | 133 | build/system_top.hdf: | build 134 | ifeq (1, ${HAVE_VIVADO}) 135 | bash -c "source $(VIVADO_SETTINGS) && make -C hdl/projects/$(TARGET) && cp hdl/projects/$(TARGET)/$(TARGET).sdk/system_top.hdf $@" 136 | unzip -l $@ | grep -q ps7_init || cp hdl/projects/$(TARGET)/$(TARGET).srcs/sources_1/bd/system/ip/system_sys_ps7_0/ps7_init* build/ 137 | else 138 | ifneq ($(HDF_URL),) 139 | wget -T 3 -t 1 -N --directory-prefix build $(HDF_URL) 140 | endif 141 | endif 142 | 143 | ### TODO: Build system_top.hdf from src if dl fails - need 2016.2 for that ... 144 | 145 | build/sdk/fsbl/Release/fsbl.elf build/sdk/hw_0/system_top.bit : build/system_top.hdf 146 | rm -Rf build/sdk 147 | ifeq (1, ${HAVE_VIVADO}) 148 | bash -c "source $(VIVADO_SETTINGS) && xsdk -batch -source scripts/create_fsbl_project.tcl" 149 | else 150 | mkdir -p build/sdk/hw_0 151 | unzip -o build/system_top.hdf system_top.bit -d build/sdk/hw_0 152 | endif 153 | 154 | build/system_top.bit: build/sdk/hw_0/system_top.bit 155 | cp $< $@ 156 | 157 | build/boot.bin: build/sdk/fsbl/Release/fsbl.elf build/u-boot.elf 158 | @echo img:{[bootloader] $^ } > build/boot.bif 159 | bash -c "source $(VIVADO_SETTINGS) && bootgen -image build/boot.bif -w -o $@" 160 | 161 | ### MSD update firmware file ### 162 | 163 | build/$(TARGET).frm: build/$(TARGET).itb 164 | md5sum $< | cut -d ' ' -f 1 > $@.md5 165 | cat $< $@.md5 > $@ 166 | 167 | build/boot.frm: build/boot.bin build/uboot-env.bin scripts/target_mtd_info.key 168 | cat $^ | tee $@ | md5sum | cut -d ' ' -f1 | tee -a $@ 169 | 170 | ### DFU update firmware file ### 171 | 172 | build/%.dfu: build/%.bin 173 | cp $< $<.tmp 174 | dfu-suffix -a $<.tmp -v $(DEVICE_VID) -p $(DEVICE_PID) 175 | mv $<.tmp $@ 176 | 177 | build/$(TARGET).dfu: build/$(TARGET).itb 178 | cp $< $<.tmp 179 | dfu-suffix -a $<.tmp -v $(DEVICE_VID) -p $(DEVICE_PID) 180 | mv $<.tmp $@ 181 | 182 | clean-build: 183 | rm -f $(notdir $(wildcard build/*)) 184 | rm -rf build/* 185 | 186 | clean: 187 | make -C u-boot-xlnx clean 188 | make -C linux clean 189 | make -C buildroot clean 190 | make -C hdl clean 191 | rm -f $(notdir $(wildcard build/*)) 192 | rm -rf build/* 193 | 194 | zip-all: $(TARGETS) 195 | zip -j build/$(ZIP_ARCHIVE_PREFIX)-fw-$(VERSION).zip $^ 196 | 197 | dfu-$(TARGET): build/$(TARGET).dfu 198 | dfu-util -D build/$(TARGET).dfu -a firmware.dfu 199 | dfu-util -e 200 | 201 | dfu-sf-uboot: build/boot.dfu build/uboot-env.dfu 202 | echo "Erasing u-boot be careful - Press Return to continue... " && read key && \ 203 | dfu-util -D build/boot.dfu -a boot.dfu && \ 204 | dfu-util -D build/uboot-env.dfu -a uboot-env.dfu 205 | dfu-util -e 206 | 207 | dfu-all: build/$(TARGET).dfu build/boot.dfu build/uboot-env.dfu 208 | echo "Erasing u-boot be careful - Press Return to continue... " && read key && \ 209 | dfu-util -D build/$(TARGET).dfu -a firmware.dfu && \ 210 | dfu-util -D build/boot.dfu -a boot.dfu && \ 211 | dfu-util -D build/uboot-env.dfu -a uboot-env.dfu 212 | dfu-util -e 213 | 214 | dfu-ram: build/$(TARGET).dfu 215 | sshpass -p analog ssh root@$(TARGET) '/usr/sbin/device_reboot ram;' 216 | sleep 5 217 | dfu-util -D build/$(TARGET).dfu -a firmware.dfu 218 | dfu-util -e 219 | 220 | jtag-bootstrap: build/u-boot.elf build/sdk/hw_0/ps7_init.tcl build/sdk/hw_0/system_top.bit scripts/run.tcl 221 | $(CROSS_COMPILE)strip build/u-boot.elf 222 | zip -j build/$(ZIP_ARCHIVE_PREFIX)-$@-$(VERSION).zip $^ 223 | 224 | sysroot: buildroot/output/images/rootfs.cpio.gz 225 | tar czfh build/sysroot-$(VERSION).tar.gz --hard-dereference --exclude=usr/share/man -C buildroot/output staging 226 | 227 | legal-info: buildroot/output/images/rootfs.cpio.gz 228 | tar czvf build/legal-info-$(VERSION).tar.gz -C buildroot/output legal-info 229 | 230 | git-update-all: 231 | git submodule update --recursive --remote 232 | 233 | git-pull: 234 | git pull --recurse-submodules 235 | -------------------------------------------------------------------------------- /scripts/legal_info_html.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright 2018(c) Analog Devices, Inc. 4 | # 5 | # All rights reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without modification, 8 | # are permitted provided that the following conditions are met: 9 | # - Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # - Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in 13 | # the documentation and/or other materials provided with the 14 | # distribution. 15 | # - Neither the name of Analog Devices, Inc. nor the names of its 16 | # contributors may be used to endorse or promote products derived 17 | # from this software without specific prior written permission. 18 | # - The use of this software may or may not infringe the patent rights 19 | # of one or more patent holders. This license does not release you 20 | # from the requirement that you obtain separate licenses from these 21 | # patent holders to use this software. 22 | # 23 | # THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 24 | # INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A 25 | # PARTICULAR PURPOSE ARE DISCLAIMED. 26 | # 27 | # IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY 29 | # RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 30 | # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 | # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 32 | # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | 34 | TARGET=$1 35 | TARGET_VERSIONS=$2 36 | 37 | MANIFEST=buildroot/output/legal-info/manifest.csv 38 | MANIFEST_SORT=/tmp/manifest.?? 39 | sort ${MANIFEST} > ${MANIFEST_SORT} 40 | 41 | PACKAGE=1 42 | VERSION=2 43 | LICENSE=3 44 | LICENSE_FILES=4 45 | SOURCE_ARCHIVE=5 46 | SOURCE_SITE=6 47 | 48 | FILE=build/LICENSE.html 49 | 50 | html_header () { 51 | echo "" > ${FILE} 52 | echo "" >> ${FILE} 53 | echo "" >> ${FILE} 54 | echo "" >> ${FILE} 55 | echo "" >> ${FILE} 56 | echo "" >> ${FILE} 57 | echo "$1" >> ${FILE} 58 | echo "" >> ${FILE} 59 | echo "" >> ${FILE} 60 | echo "" >> ${FILE} 61 | echo "" >> ${FILE} 62 | echo "" >> ${FILE} 63 | echo "" >> ${FILE} 64 | echo "" >> ${FILE} 67 | 68 | echo "
" >> ${FILE} 69 | echo "" >> ${FILE} 70 | echo "\"Analog" >> ${FILE} 71 | echo "" >> ${FILE} 72 | echo "
" >> ${FILE} 73 | echo "Index" >> ${FILE} 74 | echo "
" >> ${FILE} 75 | 76 | echo "
" >> ${FILE} 77 | echo "
" >> ${FILE} 78 | } 79 | 80 | html_footer () { 81 | echo "" >> ${FILE} 82 | echo "" >> ${FILE} 83 | } 84 | 85 | html_h1 () { 86 | echo "

$1

" >> ${FILE} 87 | } 88 | 89 | html_h1_id () { 90 | echo "
Back to list | Back to top
" >> ${FILE} 91 | echo "

$1

" >> ${FILE} 92 | } 93 | 94 | html_h2 () { 95 | echo "

$1

" >> ${FILE} 96 | } 97 | 98 | html_p () { 99 | echo "

$1

" >> ${FILE} 100 | } 101 | 102 | html_pre_file () { 103 | echo "
" >> ${FILE}
104 | 	# get the file, but html sanitize a few things
105 | 	find $1 -type f -exec cat {} + | sed -e "s/\o14//g" -e "s/\o302\o251/\©/g" -e "s/'/\'/g" -e "s//\>/g" >> ${FILE}
106 | 	echo "
" >> ${FILE} 107 | } 108 | 109 | html_li () { 110 | echo "
  • $1
  • " >> ${FILE} 111 | } 112 | 113 | html_li_start () { 114 | echo "" >> ${FILE} 119 | } 120 | 121 | html_hr () { 122 | echo "
    " >> ${FILE} 123 | } 124 | 125 | get_column () { 126 | echo ${1} | cut -d \" -f $(expr ${2} \* 2) 127 | } 128 | 129 | get_version () { 130 | cat ${TARGET_VERSIONS} | grep ${1} | cut -d ' ' -f2 131 | } 132 | 133 | package_list_items () { 134 | html_li_start 135 | html_li "Version: ${1}" 136 | html_li "License: ${2}" 137 | html_li "Source Site: ${3}" 138 | html_li_stop 139 | } 140 | 141 | strstr () { 142 | echo $1 | grep --quiet $2 143 | } 144 | 145 | # package_table_items $((var++)) Linux $(get_version linux) "GPLv2" "https://github.com/analogdevicesinc/linux" 146 | # 1 2 3 4 5 147 | package_table_items () { 148 | url=$5 149 | 150 | command curl -h > /dev/null 2>&1 151 | if [ "$?" = "0" ] ; then 152 | if $(strstr $url sourceforge) ; then 153 | url=$(echo ${url} | sed -e 's/downloads\.//' -e 's/project/projects/') 154 | fi 155 | while [ 1 ] ; do 156 | if $(strstr $url "ftp://") ; then 157 | break 158 | fi 159 | # We should use curl's -L, but then we couldn't track things 160 | tmp=$(curl -IsS $url) 161 | if [ $(echo "$tmp" | head -1 | grep -E "301|302" | wc -l) -gt 0 ] ; then 162 | url=$(echo "$tmp" | grep -i "Location:" | awk '{print $2}' | sed -e 's/^[ \t]*//;s/[ \t]*$//') 163 | url=${url%$'\r'} 164 | elif [ $(echo "$tmp" | head -1 | grep "404" | wc -l) -gt 0 ] ; then 165 | url=$(echo $url | sed 's#/[^/]*$##' ) 166 | elif [ $(echo "$tmp" | head -1 | grep "200" | wc -l) -gt 0 ] ; then 167 | break 168 | else 169 | echo "err: ${url}" $(echo "$tmp" | head -1) "" >> ${FILE} 170 | echo unknown error while trying ${url} 171 | echo "${tmp}" 172 | break 173 | fi 174 | done 175 | fi 176 | 177 | echo "" >> ${FILE} 178 | echo "${2}" >> ${FILE} 179 | echo "${4}" >> ${FILE} 180 | echo "${3}" >> ${FILE} 181 | echo -n "" >> ${FILE} 182 | if $(strstr $5 github) ; then 183 | echo -n "Github" >> ${FILE} 184 | elif $(strstr $5 sourceforge) ; then 185 | echo -n "SourceForge" >> ${FILE} 186 | elif $(strstr $5 freedesktop) ; then 187 | echo -n "Freedesktop" >> ${FILE} 188 | elif $(strstr $5 debian) ; then 189 | echo -n "Debian Project" >> ${FILE} 190 | elif $(strstr $5 kernel) ; then 191 | echo -n "Kernel.org" >> ${FILE} 192 | else 193 | echo -n "Project" >> ${FILE} 194 | fi 195 | echo "" >> ${FILE} 196 | echo "" >> ${FILE} 197 | } 198 | 199 | # Borrowed concepts from : 200 | # https://github.com/chadbraunduin/markdown.bash/blob/master/markdown.sh 201 | # MIT License 202 | # Copyright (c) 2016 Chad Braun-Duin 203 | # Permission is hereby granted, free of charge, to any person obtaining a copy 204 | # of this software and associated documentation files (the "Software"), to deal 205 | # in the Software without restriction, including without limitation the rights 206 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 207 | # copies of the Software, and to permit persons to whom the Software is 208 | # furnished to do so, subject to the following conditions: 209 | # 210 | # The above copyright notice and this permission notice shall be included in all 211 | # copies or substantial portions of the Software. 212 | # 213 | convert_md2html () { 214 | temp_file="/tmp/markdown.$$" 215 | cat "$1" > "$temp_file" 216 | # All of this below business is for reference-style links and images 217 | # We need to loop across newlines and not spaces 218 | IFS=' 219 | ' 220 | refs=$(sed -nr "/\[.+\]/p" "$1") 221 | for ref in $refs 222 | do 223 | ref=$(echo -n "$ref" | sed "s/^.*\[/\[/") 224 | ref_id=$(echo -n "$ref" | sed -nr "s/^\[(.+)\].*/\1/p" | tr -d '\n') 225 | ref_url=$(echo -n "$ref" | sed -nr "s/^\[.+\]\((.+)/\1/p" | cut -d' ' -f1 | tr -d '\n') 226 | ref_title=$(echo -n "$ref" | sed -nr "s/^\[.+\](.+) \"(.+)\"/\2/p" | sed 's@|@!@g' | tr -d '\n' | sed 's/).*$//') 227 | # reference-style image using the label 228 | sed -ri "s|!\[([^]]+)\]\[($ref_id)\]|\"\1\"|gI" "$temp_file" 229 | # reference-style link using the label 230 | sed -ri "s|\[($ref_id)\].*\($ref_url \"$ref_title\"\)|\1|gI" "$temp_file" 231 | # implicit reference-style 232 | sed -ri "s|!\[($ref_id)\]\[\]|\"\1\"|gI" "$temp_file" 233 | # implicit reference-style 234 | sed -ri "s|\[($ref_id)\]\[\]|\1|gI" "$temp_file" 235 | done 236 | 237 | # delete the reference lines 238 | sed -ri "/^\[.+\]: +/d" "$temp_file" 239 | sed -nri "/^# /,/^# / { /^# /d ; p } " "$temp_file" 240 | sed -ri -e 's/^$/

    /' "$temp_file" 241 | cat ${temp_file} 242 | rm ${temp_file} 243 | } 244 | 245 | ### main 246 | 247 | html_header "${TARGET} Legal Information" 248 | 249 | html_h1 "Legal Information" 250 | html_h1 "${TARGET} Firmware $(get_version device-fw)" 251 | 252 | convert_md2html LICENSE.md >> ${FILE} 253 | 254 | echo "

    " >> ${FILE} 255 | html_h2 "Written Offer" 256 | 257 | echo "

    As described above, the firmware included in the ${TARGET} contains copyrighted software that is released and distributed under many licenses, including the GPL. 258 | A copy of the licenses are included in this file (below)." >> ${FILE} 259 | if [ "$TARGET" == "PlutoSDR" ] ; then 260 | echo "You may obtain the complete Corresponding Source code from us for a period of three years after our last shipment of this product, which will be no earlier than 01Jan2021, by sending a money order or check for \$15 (USD) to:

    261 |
    262 | Analog Devices Inc.
    263 | Systems Development Group
    264 | GPL Compliance
    265 | Attention: Robin Getz
    266 | 1 Analog Way
    267 | Wilmington, Massachusetts
    268 | 01887
    269 | USA
    270 | 
    271 |

    Please write “source for the ${TARGET}” in the memo line of your payment. 272 | Since the source does not fit on a DVD-RW, it will be delivered on a USB Thumb drive (hense the higher cost than just DVD or CD).

    273 |

    You will also find a the source on-line, and are encouraged to obtain it for zero cost, at the project web sites.

    274 |
    " >> ${FILE} 275 | else # not PlutoSDR 276 | echo "Since you, the end user built this from source, for ${TARGET}, and didn't get a binary, there is no requirement for a written offer. 277 | " >> ${FILE} 278 | fi 279 | 280 | html_h2 "NO WARRANTY" 281 | 282 | echo "
    " >> ${FILE}
    283 | cat LICENSE.md | sed  -n '1,/# NO WARRANTY/!p' | sed "1d" >> ${FILE}
    284 | echo "
    " >> ${FILE} 285 | 286 | ### Table of packages 287 | html_h1 "Open source components/packages:" 288 | 289 | var=0 290 | echo "

    Version Information:

    " >> ${FILE} 291 | echo "" >> ${FILE} 292 | echo "" >> ${FILE} 293 | echo "" >> ${FILE} 294 | echo "" >> ${FILE} 295 | echo "" >> ${FILE} 296 | echo "" >> ${FILE} 297 | echo "" >> ${FILE} 298 | echo "" >> ${FILE} 299 | echo "" >> ${FILE} 300 | echo "" >> ${FILE} 301 | package_table_items $((var++)) Linux $(get_version linux) "GPLv2" "https://github.com/analogdevicesinc/linux" 302 | package_table_items $((var++)) U-Boot $(get_version u-boot-xlnx) "GPLv2" "https://github.com/analogdevicesinc/u-boot-xlnx" 303 | while read -r line 304 | do 305 | package=$(get_column "${line}" $PACKAGE) 306 | 307 | if [ "$package" == "PACKAGE" ];then 308 | continue 309 | fi 310 | 311 | version=$(get_column "${line}" $VERSION) 312 | license_file=$(get_column "${line}" $LICENSE_FILES) 313 | license=$(get_column "${line}" $LICENSE) 314 | source_site=$(get_column "${line}" $SOURCE_SITE) 315 | 316 | package_table_items $((var++)) $package $version $license $source_site 317 | 318 | done < "${MANIFEST_SORT}" 319 | 320 | echo "" >> ${FILE} 321 | echo "
    PackageLicenseVersionLocation
    " >> ${FILE} 322 | 323 | var=0 324 | ### Linux 325 | html_hr 326 | html_h1_id "Package: linux" "$((var++))" 327 | package_list_items $(get_version linux) "GPLv2" "https://github.com/analogdevicesinc/linux" 328 | html_h2 "License:" 329 | html_pre_file linux/COPYING 330 | html_hr 331 | ### U-Boot 332 | html_h1_id "Package: u-boot" "$((var++))" 333 | package_list_items $(get_version u-boot-xlnx) "GPLv2" "https://github.com/analogdevicesinc/u-boot-xlnx" 334 | html_h2 "License:" 335 | html_pre_file u-boot-xlnx/Licenses/gpl-2.0.txt 336 | html_hr 337 | 338 | #### All other Buildroot Packages 339 | while read -r line 340 | do 341 | package=$(get_column "${line}" $PACKAGE) 342 | 343 | if [ "$package" == "PACKAGE" ];then 344 | continue 345 | fi 346 | 347 | version=$(get_column "${line}" $VERSION) 348 | license_file=$(get_column "${line}" $LICENSE_FILES) 349 | license=$(get_column "${line}" $LICENSE) 350 | source_site=$(get_column "${line}" $SOURCE_SITE) 351 | 352 | html_h1_id "Package: $package" "$((var++))" 353 | 354 | package_list_items $version $license $source_site 355 | 356 | html_h2 "License:" 357 | html_pre_file "$(dirname $MANIFEST)/licenses/$package-$version/" 358 | html_hr 359 | done < "${MANIFEST_SORT}" 360 | 361 | html_footer 362 | 363 | rm ${MANIFEST_SORT} 364 | --------------------------------------------------------------------------------