From 1513c33b09425b25b732bd9b5dedf193589b98cf Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Mon, 15 Jan 2024 15:46:52 +0100 Subject: [PATCH] merge small utils into one package --- default/rules/default.py | 7 -- default/rules/programmers.py | 115 -------------------------------- default/rules/utils.py | 75 ++++++++++++++++++++- default/scripts/dfu-util.sh | 4 -- default/scripts/ecpdap.sh | 2 - default/scripts/ecpprog.sh | 7 -- default/scripts/fujprog.sh | 7 -- default/scripts/iceprogduino.sh | 10 --- default/scripts/icesprog.sh | 7 -- default/scripts/openocd.sh | 28 -------- default/scripts/utils.sh | 85 +++++++++++++++++++++-- 11 files changed, 154 insertions(+), 193 deletions(-) delete mode 100644 default/scripts/dfu-util.sh delete mode 100644 default/scripts/ecpdap.sh delete mode 100644 default/scripts/ecpprog.sh delete mode 100644 default/scripts/fujprog.sh delete mode 100644 default/scripts/iceprogduino.sh delete mode 100644 default/scripts/icesprog.sh delete mode 100644 default/scripts/openocd.sh diff --git a/default/rules/default.py b/default/rules/default.py index f2592ff..f79664a 100644 --- a/default/rules/default.py +++ b/default/rules/default.py @@ -19,8 +19,6 @@ 'prjtrellis', 'prjoxide', 'apicula', - 'dfu-util', - 'ecpprog', 'openfpgaloader', 'aiger', 'avy', @@ -36,12 +34,7 @@ 'gtkwave', 'verilator', 'iverilog', - 'ecpdap', - 'fujprog', - 'iceprogduino', 'python-programmers', - 'openocd', - 'icesprog', 'utils', 'pyhdl', 'cocotb', diff --git a/default/rules/programmers.py b/default/rules/programmers.py index f1d985e..0cc844e 100644 --- a/default/rules/programmers.py +++ b/default/rules/programmers.py @@ -1,87 +1,5 @@ from src.base import SourceLocation, Target -# dfu-util - -SourceLocation( - name = 'dfu-util', - vcs = 'git', - location = 'https://git.code.sf.net/p/dfu-util/dfu-util', - revision = 'origin/master', - license_file = 'COPYING', -) - -Target( - name = 'dfu-util', - sources = [ 'dfu-util' ], - package = 'programmers', -) - -# ecpdap - -SourceLocation( - name = 'ecpdap', - vcs = 'git', - location = 'https://github.com/adamgreig/ecpdap', - revision = 'origin/master', - license_file = 'LICENSE-MIT', -) - -Target( - name = 'ecpdap', - sources = [ 'ecpdap' ], - package = 'programmers', -) - -# ecpprog - -SourceLocation( - name = 'ecpprog', - vcs = 'git', - location = 'https://github.com/gregdavill/ecpprog', - revision = 'origin/main', - license_file = 'COPYING', -) - -Target( - name = 'ecpprog', - sources = [ 'ecpprog' ], - package = 'programmers', -) - -# fujprog - -SourceLocation( - name = 'fujprog', - vcs = 'git', - location = 'https://github.com/kost/fujprog', - revision = 'origin/master', - license_file = 'LICENSE', -) - -Target( - name = 'fujprog', - sources = [ 'fujprog' ], - patches = [ 'Toolchain-mingw64.cmake' ], - package = 'programmers', -) - -# iceprogduino - -SourceLocation( - name = 'iceprogduino', - vcs = 'git', - location = 'https://github.com/OLIMEX/iCE40HX1K-EVB', - revision = 'origin/master', - license_file = 'LICENSE', -) - -Target( - name = 'iceprogduino', - sources = [ 'iceprogduino' ], - gitrev = [ ('iceprogduino', 'programmer'), ('iceprogduino', 'windows') ], - package = 'programmers', -) - # openfpgaloader SourceLocation( @@ -147,36 +65,3 @@ 'pyserial': ['pyserial-miniterm', 'pyserial-ports'], }, ) - -# openocd - -SourceLocation( - name = 'openocd', - vcs = 'git', - location = 'https://repo.or.cz/openocd.git', - revision = 'origin/master', - license_file = 'COPYING', -) - -Target( - name = 'openocd', - sources = [ 'openocd' ], - patches = [ 'openocd.diff' ], - package = 'programmers', -) - -# icesprog - -SourceLocation( - name = 'icesprog', - vcs = 'git', - location = 'https://github.com/wuxx/icesugar', - revision = 'origin/master', - no_submodules = True, -) - -Target( - name = 'icesprog', - sources = [ 'icesprog' ], - package = 'programmers', -) diff --git a/default/rules/utils.py b/default/rules/utils.py index 75170ad..a91d1d5 100644 --- a/default/rules/utils.py +++ b/default/rules/utils.py @@ -1,5 +1,6 @@ from src.base import SourceLocation, Target +# libusb SourceLocation( name = 'libusb', vcs = 'git', @@ -8,6 +9,7 @@ license_file = 'COPYING', ) +# libftdi SourceLocation( name = 'libftdi', vcs = 'git', @@ -16,9 +18,78 @@ license_file = 'LICENSE', ) +# dfu-util + +SourceLocation( + name = 'dfu-util', + vcs = 'git', + location = 'https://git.code.sf.net/p/dfu-util/dfu-util', + revision = 'origin/master', + license_file = 'COPYING', +) + +# ecpdap + +SourceLocation( + name = 'ecpdap', + vcs = 'git', + location = 'https://github.com/adamgreig/ecpdap', + revision = 'origin/master', + license_file = 'LICENSE-MIT', +) + +# ecpprog + +SourceLocation( + name = 'ecpprog', + vcs = 'git', + location = 'https://github.com/gregdavill/ecpprog', + revision = 'origin/main', + license_file = 'COPYING', +) + +# fujprog + +SourceLocation( + name = 'fujprog', + vcs = 'git', + location = 'https://github.com/kost/fujprog', + revision = 'origin/master', + license_file = 'LICENSE', +) + +# openocd + +SourceLocation( + name = 'openocd', + vcs = 'git', + location = 'https://repo.or.cz/openocd.git', + revision = 'origin/master', + license_file = 'COPYING', +) + +# iceprogduino + +SourceLocation( + name = 'iceprogduino', + vcs = 'git', + location = 'https://github.com/OLIMEX/iCE40HX1K-EVB', + revision = 'origin/master', + license_file = 'LICENSE', +) + +# icesprog + +SourceLocation( + name = 'icesprog', + vcs = 'git', + location = 'https://github.com/wuxx/icesugar', + revision = 'origin/master', + no_submodules = True, +) + Target( name = 'utils', - sources = [ 'libusb', 'libftdi' ], + sources = [ 'libusb', 'libftdi', 'dfu-util', 'ecpdap', 'ecpprog', 'fujprog', 'openocd', 'iceprogduino', 'icesprog' ], package = 'programmers', - tools = { 'libusb': ['libusb'], 'libftdi': ['libftdi'] }, ) diff --git a/default/scripts/dfu-util.sh b/default/scripts/dfu-util.sh deleted file mode 100644 index 5fa2d24..0000000 --- a/default/scripts/dfu-util.sh +++ /dev/null @@ -1,4 +0,0 @@ -cd dfu-util -./autogen.sh -./configure --prefix=${INSTALL_PREFIX} --host=${CROSS_NAME} -make DESTDIR=${OUTPUT_DIR} -j${NPROC} install diff --git a/default/scripts/ecpdap.sh b/default/scripts/ecpdap.sh deleted file mode 100644 index 93849cc..0000000 --- a/default/scripts/ecpdap.sh +++ /dev/null @@ -1,2 +0,0 @@ -export PKG_CONFIG_ALLOW_CROSS=YES -cargo install --no-track --path ecpdap --root ${OUTPUT_DIR}${INSTALL_PREFIX} --target=${CARGO_TARGET} diff --git a/default/scripts/ecpprog.sh b/default/scripts/ecpprog.sh deleted file mode 100644 index 9f488d3..0000000 --- a/default/scripts/ecpprog.sh +++ /dev/null @@ -1,7 +0,0 @@ -cd ecpprog -cd ecpprog -if [ ${ARCH} == 'darwin-arm64' ]; then -make CC=${CXX} C_STD=c++98 PREFIX=${INSTALL_PREFIX} DESTDIR=${OUTPUT_DIR} install -j${NPROC} -else -make C_STD=gnu99 PREFIX=${INSTALL_PREFIX} DESTDIR=${OUTPUT_DIR} install -j${NPROC} -fi diff --git a/default/scripts/fujprog.sh b/default/scripts/fujprog.sh deleted file mode 100644 index 15bdca9..0000000 --- a/default/scripts/fujprog.sh +++ /dev/null @@ -1,7 +0,0 @@ -cd fujprog -if [ ${ARCH} == 'windows-x64' ]; then - cp -f ftd2xx-amd64.lib ftd2xx.lib - export CMAKE_TOOLCHAIN_FILE=${PATCHES_DIR}/Toolchain-mingw64.cmake -fi -cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} . -make DESTDIR=${OUTPUT_DIR} -j${NPROC} install diff --git a/default/scripts/iceprogduino.sh b/default/scripts/iceprogduino.sh deleted file mode 100644 index 075abcb..0000000 --- a/default/scripts/iceprogduino.sh +++ /dev/null @@ -1,10 +0,0 @@ -mkdir -p ${OUTPUT_DIR}${INSTALL_PREFIX}/bin/ -if [ ${ARCH} == 'windows-x64' ]; then - cd iceprogduino/windows/winiceprogduino - sed -i 's,usleep,usleep2,g' main.c - ${CXX} main.c -o iceprogduino.exe -else - cd iceprogduino/programmer/iceprogduino - ${CXX} iceprogduino.c -o iceprogduino -fi -cp iceprogduino${EXE} ${OUTPUT_DIR}${INSTALL_PREFIX}/bin/. diff --git a/default/scripts/icesprog.sh b/default/scripts/icesprog.sh deleted file mode 100644 index 4cd173a..0000000 --- a/default/scripts/icesprog.sh +++ /dev/null @@ -1,7 +0,0 @@ -cd icesprog/tools/src -mkdir -p ${OUTPUT_DIR}${INSTALL_PREFIX}/bin/ -if [ ${ARCH} == 'windows-x64' ] || [ ${ARCH_BASE} == 'darwin' ]; then - sed -i 's,HIDAPI = hidapi-hidraw,HIDAPI = hidapi,g' Makefile -fi -make -cp icesprog${EXE} ${OUTPUT_DIR}${INSTALL_PREFIX}/bin/. diff --git a/default/scripts/openocd.sh b/default/scripts/openocd.sh deleted file mode 100644 index dd35c76..0000000 --- a/default/scripts/openocd.sh +++ /dev/null @@ -1,28 +0,0 @@ -cd openocd - -# Patches and recipe from Adam Jelinski : -# https://github.com/hdl/conda-prog/tree/master/tools/openocd -mv tcl/target/1986ве1т.cfg tcl/target/1986be1t.cfg -mv tcl/target/к1879xб1я.cfg tcl/target/k1879x61r.cfg - -patch -p1 < ${PATCHES_DIR}/openocd.diff - -if [ ${ARCH_BASE} == 'darwin' ]; then - sed -i 's,glibtoolize,libtoolize,g' src/jtag/drivers/libjaylink/autogen.sh -fi - -./bootstrap -mkdir -p build -cd build -../configure \ - --prefix=${INSTALL_PREFIX} \ - --host=${CROSS_NAME} \ - --enable-static \ - --disable-shared \ - --enable-usb-blaster-2 \ - --enable-usb_blaster_libftdi \ - --enable-jtag_vpi \ - --enable-remote-bitbang \ - CFLAGS="-Wno-error" - -make DESTDIR=${OUTPUT_DIR} -j${NPROC} install diff --git a/default/scripts/utils.sh b/default/scripts/utils.sh index 03ee1d9..fa6efa3 100644 --- a/default/scripts/utils.sh +++ b/default/scripts/utils.sh @@ -1,11 +1,88 @@ mkdir -p ${OUTPUT_DIR}${INSTALL_PREFIX}/bin -pushd libusb/examples + +# libusb +cd ${BUILD_DIR}/libusb/examples ${CC} -o lsusb${EXE} listdevs.c -lusb-1.0 -I../libusb ${STRIP} lsusb${EXE} cp lsusb${EXE} ${OUTPUT_DIR}${INSTALL_PREFIX}/bin/. -popd -pushd libftdi/examples + +# libftdi +cd ${BUILD_DIR}/libftdi/examples ${CC} -o lsftdi${EXE} find_all.c -lftdi1 -lusb-1.0 -I../src ${STRIP} lsftdi${EXE} cp lsftdi${EXE} ${OUTPUT_DIR}${INSTALL_PREFIX}/bin/. -popd + +# dfu-util +cd ${BUILD_DIR}/dfu-util +./autogen.sh +./configure --prefix=${INSTALL_PREFIX} --host=${CROSS_NAME} +make DESTDIR=${OUTPUT_DIR} -j${NPROC} install + +# ecpdap +cd ${BUILD_DIR} +export PKG_CONFIG_ALLOW_CROSS=YES +cargo install --no-track --path ecpdap --root ${OUTPUT_DIR}${INSTALL_PREFIX} --target=${CARGO_TARGET} + +# ecpprog +cd ${BUILD_DIR}/ecpprog/ecpprog +if [ ${ARCH} == 'darwin-arm64' ]; then +make CC=${CXX} C_STD=c++98 PREFIX=${INSTALL_PREFIX} DESTDIR=${OUTPUT_DIR} install -j${NPROC} +else +make C_STD=gnu99 PREFIX=${INSTALL_PREFIX} DESTDIR=${OUTPUT_DIR} install -j${NPROC} +fi + +# fujprog +cd ${BUILD_DIR}/fujprog +if [ ${ARCH} == 'windows-x64' ]; then + cp -f ftd2xx-amd64.lib ftd2xx.lib + export CMAKE_TOOLCHAIN_FILE=${PATCHES_DIR}/Toolchain-mingw64.cmake +fi +cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} . +make DESTDIR=${OUTPUT_DIR} -j${NPROC} install + +# iceprogduino +cd ${BUILD_DIR} +if [ ${ARCH} == 'windows-x64' ]; then + cd iceprogduino/windows/winiceprogduino + sed -i 's,usleep,usleep2,g' main.c + ${CXX} main.c -o iceprogduino.exe +else + cd iceprogduino/programmer/iceprogduino + ${CXX} iceprogduino.c -o iceprogduino +fi +cp iceprogduino${EXE} ${OUTPUT_DIR}${INSTALL_PREFIX}/bin/. + +# icesprog +cd ${BUILD_DIR}/icesprog/tools/src +if [ ${ARCH} == 'windows-x64' ] || [ ${ARCH_BASE} == 'darwin' ]; then + sed -i 's,HIDAPI = hidapi-hidraw,HIDAPI = hidapi,g' Makefile +fi +make +cp icesprog${EXE} ${OUTPUT_DIR}${INSTALL_PREFIX}/bin/. + + +# openocd +cd ${BUILD_DIR}/openocd +# Patches and recipe from Adam Jelinski : +# https://github.com/hdl/conda-prog/tree/master/tools/openocd +mv tcl/target/1986ве1т.cfg tcl/target/1986be1t.cfg +mv tcl/target/к1879xб1я.cfg tcl/target/k1879x61r.cfg +patch -p1 < ${PATCHES_DIR}/openocd.diff +if [ ${ARCH_BASE} == 'darwin' ]; then + sed -i 's,glibtoolize,libtoolize,g' src/jtag/drivers/libjaylink/autogen.sh +fi +./bootstrap +mkdir -p build +cd build +../configure \ + --prefix=${INSTALL_PREFIX} \ + --host=${CROSS_NAME} \ + --enable-static \ + --disable-shared \ + --enable-usb-blaster-2 \ + --enable-usb_blaster_libftdi \ + --enable-jtag_vpi \ + --enable-remote-bitbang \ + CFLAGS="-Wno-error" + +make DESTDIR=${OUTPUT_DIR} -j${NPROC} install