diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml new file mode 100644 index 0000000..f9aea7d --- /dev/null +++ b/.github/workflows/Build.yml @@ -0,0 +1,151 @@ +name: Build + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + PC_Application_Ubuntu: + needs: create_release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + + - name: Install dependencies + run: | + sudo apt-get install -y libusb-1.0-0-dev libqwt-qt5-dev qt5-default qt5-qmake qtbase5-dev + + - name: Build application + run: | + cd Software/PC_Application + qmake + make -j9 + shell: bash + + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: Application_Ubuntu + path: Software/PC_Application/Application + + PC_Application_Windows: + needs: create_release + runs-on: windows-latest + steps: + - uses: actions/checkout@v1 + + - name: Cache Qt + id: cache-qt + uses: pat-s/always-upload-cache@v2.1.0 + with: + path: ${{ runner.workspace }}/Qt + key: ${{ runner.os }}-QtCache + + - name: Cache Qwt + id: cache-qwt + uses: pat-s/always-upload-cache@v2.1.0 + with: + path: C:\Qwt-6.1.4 + key: ${{ runner.os }}-QwtCache + + - name: Install Qt + uses: jurplel/install-qt-action@v2 + with: + arch: 'win64_mingw73' + cached: ${{ steps.cache-qt.outputs.cache-hit }} + + - name: Download and Install Qwt + if: steps.cache-qwt.outputs.cache-hit != 'true' + run: | + curl -o qwt.zip -L https://sourceforge.net/projects/qwt/files/qwt/6.1.4/qwt-6.1.4.zip/download + 7z x qwt.zip -r -oQwt + cd Qwt\qwt-6.1.4 + qmake qwt.pro + make install + shell: cmd + + - name: Download libusb + run: | + curl -o libusb.7z -L https://github.com/libusb/libusb/releases/download/v1.0.23/libusb-1.0.23.7z + 7z x libusb.7z -r -olibusb + Xcopy /E /I /Y libusb\include ..\Qt\5.12.9\mingw73_64\include + Xcopy /E /I /Y libusb\MinGW64\static C:\Qwt-6.1.4\lib + dir + dir ..\Qt\5.12.9 + dir ..\Qt\5.12.9\mingw73_64 + dir C:\Qwt-6.1.4\lib + dir ..\Qt\5.12.9\mingw73_64\bin + shell: cmd + + - name: Build application + run: | + cd Software/PC_Application + qmake + make -j9 + cd release + del *.o *.cpp + windeployqt.exe . + copy ..\..\..\..\Qt\5.12.9\mingw73_64\bin\libwinpthread-1.dll . + copy ..\..\..\..\Qt\5.12.9\mingw73_64\bin\libgcc_s_seh-1.dll . + copy "..\..\..\..\Qt\5.12.9\mingw73_64\bin\libstdc++-6.dll" . + copy ..\..\..\..\Qt\5.12.9\mingw73_64\bin\Qt5OpenGL.dll . + copy C:\Qwt-6.1.4\lib\qwt.dll . + shell: cmd + + - name: Upload + uses: actions/upload-artifact@v2 + with: + name: Application_Windows + path: Software/PC_Application/release + + Embedded_Firmware: + needs: create_release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + + - name: Install toolchain + run: | + sudo apt-get install -y gcc-arm-none-eabi binutils-arm-none-eabi + + - name: Build application + run: | + cd Software/VNA_embedded + make -j9 + cp build/VNA_embedded.elf ../../ + shell: bash + + - name: Combine with FPGA bitstream + run: | + python3 AssembleFirmware.py + shell: bash + + - name: Upload + uses: actions/upload-artifact@v2 + with: + name: EmbeddedFirmware + path: | + VNA_embedded.elf + combined.vnafw + + # - name: Publish + # if: startsWith(github.ref, 'refs/tags/v') + # uses: actions/upload-release-asset@v1 + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # with: + # upload_url: ${{ needs.create_release.outputs.upload_url }} + # # This is how it will be named on the release page. Put hatever name + # # you like, remember that they need to be different for each platform. + # # You can choose any build matrix parameters. For Rust I use the + # # target triple. + # asset_name: Application_Windows + # # The path to the file you want to upload. + # asset_path: Software/PC_Application/release + # # probably you will need to change it, but most likely you are + # # uploading a binary file + # asset_content_type: application/octet-stream \ No newline at end of file diff --git a/AssembleFirmware.py b/AssembleFirmware.py index 3cce698..cd0ccc9 100755 --- a/AssembleFirmware.py +++ b/AssembleFirmware.py @@ -4,7 +4,7 @@ import os import binascii FPGA_BITSTREAM = "FPGA/VNA/top.bin" -MCU_FW = "Software/VNA_embedded/Debug/VNA_embedded.bin" +MCU_FW = ["Software/VNA_embedded/Debug/VNA_embedded.bin", "Software/VNA_embedded/Release/VNA_embedded.bin", "Software/VNA_embedded/build/VNA_embedded.bin"] HEADER_SIZE = 24 @@ -12,10 +12,24 @@ f = open("combined.vnafw", "wb") f.write(bytes("VNA!", 'utf-8')) bitstream = open(FPGA_BITSTREAM, "rb") -firmware = open(MCU_FW, "rb") +latest_modification = 0 +newest_mcu = "" +for path in MCU_FW: + try: + modified_time = os.path.getmtime(path) + if modified_time >= latest_modification: + latest_modification = modified_time + newest_mcu = path + except: + pass +if latest_modification == 0: + print("Couldn't find MCU firmware file") + exit(-1) +print("Using "+newest_mcu+" as MCU firmware") +firmware = open(newest_mcu, "rb") size_FPGA = os.path.getsize(FPGA_BITSTREAM) -size_MCU = os.path.getsize(MCU_FW) +size_MCU = os.path.getsize(newest_mcu) print("Got FPGA bitstream of size "+str(size_FPGA)) print("Got MCU firmware of size "+str(size_MCU)) @@ -37,7 +51,7 @@ def CRC32_from_file(filename, initial_CRC): print("Calculating CRC...", end="") CRC = CRC32_from_file(FPGA_BITSTREAM, 0xFFFFFFFF) -CRC = CRC32_from_file(MCU_FW, CRC) +CRC = CRC32_from_file(newest_mcu, CRC) print(":"+hex(CRC)) f.write(CRC.to_bytes(4, byteorder='little')) diff --git a/FPGA/.gitignore b/FPGA/.gitignore index de4e493..c853aaf 100644 --- a/FPGA/.gitignore +++ b/FPGA/.gitignore @@ -8,4 +8,4 @@ !*.gise !*.xise !*.py - +!*.bin diff --git a/FPGA/VNA/top.bin b/FPGA/VNA/top.bin new file mode 100644 index 0000000..527a259 Binary files /dev/null and b/FPGA/VNA/top.bin differ diff --git a/Software/.gitignore b/Software/.gitignore index e10e727..2d14f1f 100644 --- a/Software/.gitignore +++ b/Software/.gitignore @@ -1 +1,3 @@ /.metadata/ +RemoteSystemsTempFiles +build-* diff --git a/Software/PC_Application/Application b/Software/PC_Application/Application deleted file mode 100755 index ad6f00c..0000000 Binary files a/Software/PC_Application/Application and /dev/null differ diff --git a/Software/PC_Application/Device/firmwareupdatedialog.cpp b/Software/PC_Application/Device/firmwareupdatedialog.cpp index 65e20f7..e1cfcd7 100644 --- a/Software/PC_Application/Device/firmwareupdatedialog.cpp +++ b/Software/PC_Application/Device/firmwareupdatedialog.cpp @@ -1,6 +1,7 @@ #include "firmwareupdatedialog.h" #include "ui_firmwareupdatedialog.h" #include +#include FirmwareUpdateDialog::FirmwareUpdateDialog(Device *dev, QWidget *parent) : QDialog(parent), diff --git a/Software/VNA_embedded/.cproject b/Software/VNA_embedded/.cproject index 4dacaaa..af2efed 100644 --- a/Software/VNA_embedded/.cproject +++ b/Software/VNA_embedded/.cproject @@ -55,9 +55,11 @@