diff --git a/.github/workflows/avr.yml b/.github/workflows/avr.yml new file mode 100644 index 000000000..330d8a632 --- /dev/null +++ b/.github/workflows/avr.yml @@ -0,0 +1,58 @@ +name: Build firmware + +permissions: + contents: read + pull-requests: write + +on: + workflow_call: + outputs: + firstword: + description: the run-id of the workflow run + value: ${{ jobs.build-hex.outputs.output1 }} + workflow_dispatch: + push: + + +jobs: + build-hex: + runs-on: ubuntu-latest + outputs: + output1: ${{ steps.step_get_run_id.outputs.RUN_ID }} + steps: + - name : Checkout repository + uses: actions/checkout@v4 + + - name : make 01 + uses: bazhenov/action-avr-make@v1.1 + with: + dir: AVR_Code + target: '01' + env: + FIRMWARE_VERSION_ID: ${{ vars.AVR_VER }} + + - name : make clean + uses: bazhenov/action-avr-make@v1.1 + with: + dir: AVR_Code + target: clean_o_d + + - name : make 02 + uses: bazhenov/action-avr-make@v1.1 + with: + dir: AVR_Code + target: '02' + env: + FIRMWARE_VERSION_ID: ${{ vars.AVR_VER }} + + - name: Upload hex artifacts + uses: actions/upload-artifact@v4 + with: + name: asset-hex + path: AVR_Code/labrafirm*.hex + compression-level: 0 + if-no-files-found: error + + - name: Prepare workflow run ID output + id: step_get_run_id + run: echo "RUN_ID=${{ github.run_id }}" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/continuous.yml b/.github/workflows/continuous.yml index 18c3a4094..d225e5b98 100644 --- a/.github/workflows/continuous.yml +++ b/.github/workflows/continuous.yml @@ -8,27 +8,42 @@ on: workflow_dispatch: jobs: - build-android: - uses: ./.github/workflows/android.yml - secrets: inherit - build-linux: - uses: ./.github/workflows/linux.yml + build-avr: + uses: ./.github/workflows/avr.yml secrets: inherit +# build-android: +# uses: ./.github/workflows/android.yml +# secrets: inherit +# needs: +# - build-avr +# build-linux: +# uses: ./.github/workflows/linux.yml +# secrets: inherit +# needs: +# - build-avr build-mac: + needs: + - build-avr uses: ./.github/workflows/mac.yml + with: + AVR_RUN_ID: ${{ needs.build-avr.outputs.firstword }} secrets: inherit - build-windows: - uses: ./.github/workflows/windows.yml - secrets: inherit + +# build-windows: +# uses: ./.github/workflows/windows.yml +# secrets: inherit +# needs: +# - build-avr release: permissions: contents: write needs: - - build-android - - build-linux + - build-avr +# - build-android +# - build-linux - build-mac - - build-windows +# - build-windows if: github.ref == 'refs/heads/master' runs-on: ubuntu-latest steps: diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index c74bd2c01..045a608d7 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -7,6 +7,10 @@ permissions: on: workflow_dispatch: workflow_call: + inputs: + AVR_RUN_ID: + required: true + type: string push: pull_request: @@ -17,6 +21,42 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + - name: Download firmware from most recent continuous release + if: github.event.workflow != '.github/workflows/continuous.yml' + run: | + mkdir asset-hex + HEX_URL=$(gh api graphql -f query='query {repository ( owner : "brentfpage", name: "Labrador") {release ( tagName: "continuous" ) {releaseAssets(first:10) {nodes {downloadUrl}}}}}' | jq -r '.data.repository.release.releaseAssets.nodes[] | select(.downloadUrl| test("02.hex")) | .[]') + wget --directory-prefix=asset-hex $HEX_URL + env: + GH_TOKEN: ${{ github.token }} + +# better alternative to the graphql query above would be to somehow retrieve the run-id of the most recent continuous.yml workflow run, then download the hex asset associated with the run-id using actions/download-artifact. +# query description: get at most 10 assets from the most recent continuous release (assume there are fewer than 10), find the one that includes 02.hex in the download url +# prettified (ish) query: +# query {\ +# repository ( owner : "espotek-org", name: "Labrador") {\ +# release ( tagName: "continuous" ) {\ +# releaseAssets(first:10) {\ +# nodes {\ +# downloadUrl\ +# }\ +# }\ +# }\ +# }\ +# }\ +# ' | jq -r '.data.repository.release.releaseAssets.nodes[] | select(.downloadUrl| test("02.hex")) | .[]' + + - name: Download firmware from in-process continuous release + if: github.event.workflow == '.github/workflows/continuous.yml' + uses: actions/download-artifact@v4 + with: + run-id: ${{ inputs.AVR_RUN_ID }} + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: move firmware to appropriate directory + run: | + mv asset-hex/*02.hex Desktop_Interface/resources/firmware + - name: Setup Homebrew dependencies run: | brew update @@ -27,25 +67,28 @@ jobs: - name: Build librador working-directory: Librador_API/___librador/librador run: | - qmake -config release + qmake -config release EXPECTED_FIRMWARE_VERSION=${{ vars.AVR_VER }} make -j$(sysctl -n hw.ncpu) - name: Build librademo working-directory: Librador_API/___librador/librademo run: | - qmake -config release + qmake -config release EXPECTED_FIRMWARE_VERSION=${{ vars.AVR_VER }} make -j$(sysctl -n hw.ncpu) - name: Build basicdemo working-directory: Librador_API/___librador/basicdemo run: | - qmake -config release + qmake -config release EXPECTED_FIRMWARE_VERSION=${{ vars.AVR_VER }} make -j$(sysctl -n hw.ncpu) - name: Import code signing certificate env: MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }} MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }} + # secrets are only provided in original repo + if: env.MACOS_CERTIFICATE != '' && env.MACOS_CERTIFICATE_PWD != '' + working-directory: Desktop_Interface run: | # Create keychain KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db @@ -67,12 +110,18 @@ jobs: - name: Build macOS app working-directory: Desktop_Interface run: | - qmake -config release + if ( env.MACOS_CERTIFICATE != '' && env.MACOS_CERTIFICATE_PWD != '' ); then + qmake -config release EXPECTED_FIRMWARE_VERSION=${{ vars.AVR_VER }} + else + # for debugging + qmake -config debug EXPECTED_FIRMWARE_VERSION=${{ vars.AVR_VER }} + fi make -j$(sysctl -n hw.ncpu) macdeployqt Labrador.app -verbose=2 -libpath=build_mac/libdfuprog/lib/ - name: Code sign app bundle working-directory: Desktop_Interface + if: ( env.MACOS_CERTIFICATE != '' && env.MACOS_CERTIFICATE_PWD != '' ) run: | # Find the signing identity IDENTITY=$(security find-identity -v -p codesigning | grep "Developer ID Application" | head -1 | awk -F'"' '{print $2}') @@ -92,6 +141,7 @@ jobs: - name: Create and sign DMG working-directory: Desktop_Interface + if: ( env.MACOS_CERTIFICATE != '' && env.MACOS_CERTIFICATE_PWD != '' ) run: | # Get the git hash for the filename GIT_HASH=$(git rev-parse --short HEAD) @@ -122,6 +172,7 @@ jobs: APPLE_ID: ${{ secrets.APPLE_ID }} APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} + if: ( env.MACOS_CERTIFICATE != '' && env.MACOS_CERTIFICATE_PWD != '' ) run: | GIT_HASH=$(git rev-parse --short HEAD) DMG_PATH="Labrador-${GIT_HASH}.dmg" @@ -144,6 +195,7 @@ jobs: spctl -a -vvv -t install "$DMG_PATH" - name: Upload artifacts + if: ( env.MACOS_CERTIFICATE != '' && env.MACOS_CERTIFICATE_PWD != '' ) uses: actions/upload-artifact@v4 with: name: asset-dmg diff --git a/AVR_Code/Makefile b/AVR_Code/Makefile new file mode 100755 index 000000000..72bba7866 --- /dev/null +++ b/AVR_Code/Makefile @@ -0,0 +1,249 @@ +# see https://github.com/espotek-org/Labrador/wiki/Building-from-source#building-the-firmware +# Usage : +# make 01 +# build a version of the firmware compatible with Windows x64 OSs +# make 02 +# build a version of the firmware compatible with all other OSs +# Here, OS refers to that of the machine with which the Labrador board will interface. +# After running 'make 01', to switch to building variant 02 instead, first run 'make clean'. +# The same goes for switching from building the 02 variant to building the 01 variant. +# Some details: +# In the build process for variant 01, the macro SINGLE_ENDPOINT_INTERFACE +# is undefined, while in the build process for variant 02, +# SINGLE_ENDPOINT_INTERFACE is defined. In several regions of the source +# code, the undefined/defined status of this macro determines which of two +# possible code blocks are compiled into the firmware. The collective effect +# of having SINGLE_ENDPOINT_INTERFACE defined is to "change the headers so +# that it uses 1x 1023-byte isochronous endpoint, rather than 6x 128-byte +# endpoints to send the scope/logic analyzer data" (from +# https://github.com/espotek-org/Labrador/issues/260) +# *NOTE* : there is a commented-out line defining SINGLE_ENDPOINT_INTERFACE in +# globals.h. If it is uncommented, both 'make 01' and 'make 02' will +# produce variant 02. Further, 'make 01' will mislabel the firmware with +# the suffix 01. It is recommended that this line in globals.h be left +# commented-out, which ensures that `make 01` and `make 02` work as +# expected. +LIB_DEP := +LIBS := +USER_OBJS := +OUTPUT_FILE_PATH := +OUTPUT_FILE_PATH =$(NAME).elf +OUTPUT_FILE_PATH_AS_ARGS +=$(NAME).elf +AVR_APP_PATH :=$$$AVR_APP_PATH$$$ + +CC=avr-gcc +SRC_DIR=./USB_BULK_TEST/src + +INCLUDES=-I"$(SRC_DIR)/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained" -I"$(SRC_DIR)/ASF/common/services/usb/class/vendor/device/example" -I"$(SRC_DIR)/ASF/common/services/usb/udc" -I"$(SRC_DIR)/ASF/xmega/drivers/nvm" -I"$(SRC_DIR)/ASF/common/services/sleepmgr" -I"$(SRC_DIR)/ASF/common/services/clock" -I"$(SRC_DIR)/ASF/xmega/drivers/sleep" -I"$(SRC_DIR)/ASF/xmega/drivers/usb" -I"$(SRC_DIR)/ASF/xmega/drivers/cpu" -I"$(SRC_DIR)/ASF/common/services/usb/class/vendor" -I"$(SRC_DIR)/ASF/common/services/usb/class/vendor/device" -I"$(SRC_DIR)/ASF/common/services/usb" -I"$(SRC_DIR)mon/applications/user_application/user_board/config" -I"$(SRC_DIR)/ASF/xmega/utils" -I"$(SRC_DIR)/config" -I"$(SRC_DIR)/ASF/common/boards" -I"$(SRC_DIR)/ASF/xmega/utils/preprocessor" -I"$(SRC_DIR)/ASF/common/utils" -I"$(SRC_DIR)" -I"$(SRC_DIR)/ASF/common/boards/user_board" -I"$(SRC_DIR)/ASF/common/services/ioport" + +CFLAGS=-std=gnu99 -ffunction-sections -mmcu=atxmega32a4u -fsigned-char -funsigned-bitfields -fdata-sections -fshort-enums -fno-strict-aliasing -fno-jump-tables -fpack-struct -Wall -O2 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -DFIRMWARE_VERSION_ID=$(FIRMWARE_VERSION_ID) + +SHORT_FIRMWARE_VERSION_ID := $(shell fv='$(FIRMWARE_VERSION_ID)'; echo "$${fv:2:4}") +NAME=labrafirm_$(SHORT_FIRMWARE_VERSION_ID)_$(SUFFIX) + +OBJS += \ +$(SRC_DIR)/tiny_calibration.o \ +$(SRC_DIR)/tiny_dig.o \ +$(SRC_DIR)/tiny_eeprom.o \ +$(SRC_DIR)/ASF/common/boards/user_board/init.o \ +$(SRC_DIR)/ASF/common/services/ioport/xmega/ioport_compat.o \ +$(SRC_DIR)/main.o \ +$(SRC_DIR)/tiny_adc.o \ +$(SRC_DIR)/tiny_dac.o \ +$(SRC_DIR)/tiny_dma.o \ +$(SRC_DIR)/tiny_timer.o \ +$(SRC_DIR)/tiny_uart.o \ +$(SRC_DIR)/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained/ui.o \ +$(SRC_DIR)/ASF/common/services/clock/xmega/sysclk.o \ +$(SRC_DIR)/ASF/common/services/sleepmgr/xmega/sleepmgr.o \ +$(SRC_DIR)/ASF/common/services/usb/class/vendor/device/udi_vendor.o \ +$(SRC_DIR)/ASF/common/services/usb/class/vendor/device/udi_vendor_desc.o \ +$(SRC_DIR)/ASF/common/services/usb/udc/udc.o \ +$(SRC_DIR)/ASF/xmega/drivers/nvm/nvm.o \ +$(SRC_DIR)/ASF/xmega/drivers/nvm/nvm_asm.o \ +$(SRC_DIR)/ASF/xmega/drivers/cpu/ccp.o \ +$(SRC_DIR)/ASF/xmega/drivers/usb/usb_device.o + +C_DEPS_AS_ARGS += \ +$(SRC_DIR)/tiny_calibration.d \ +$(SRC_DIR)/tiny_dig.d \ +$(SRC_DIR)/tiny_eeprom.d \ +$(SRC_DIR)/ASF/common/boards/user_board/init.d \ +$(SRC_DIR)/ASF/common/services/ioport/xmega/ioport_compat.d \ +$(SRC_DIR)/main.d \ +$(SRC_DIR)/tiny_adc.d \ +$(SRC_DIR)/tiny_dac.d \ +$(SRC_DIR)/tiny_dma.d \ +$(SRC_DIR)/tiny_timer.d \ +$(SRC_DIR)/tiny_uart.d \ +$(SRC_DIR)/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained/ui.d \ +$(SRC_DIR)/ASF/common/services/clock/xmega/sysclk.d \ +$(SRC_DIR)/ASF/common/services/sleepmgr/xmega/sleepmgr.d \ +$(SRC_DIR)/ASF/common/services/usb/class/vendor/device/udi_vendor.d \ +$(SRC_DIR)/ASF/common/services/usb/class/vendor/device/udi_vendor_desc.d \ +$(SRC_DIR)/ASF/common/services/usb/udc/udc.d \ +$(SRC_DIR)/ASF/xmega/drivers/nvm/nvm.d \ +$(SRC_DIR)/ASF/xmega/drivers/nvm/nvm_asm.d \ +$(SRC_DIR)/ASF/xmega/drivers/cpu/ccp.d \ +$(SRC_DIR)/ASF/xmega/drivers/usb/usb_device.d + +OBJS_AS_ARGS += \ +$(SRC_DIR)/tiny_calibration.o \ +$(SRC_DIR)/tiny_dig.o \ +$(SRC_DIR)/tiny_eeprom.o \ +$(SRC_DIR)/ASF/common/boards/user_board/init.o \ +$(SRC_DIR)/ASF/common/services/ioport/xmega/ioport_compat.o \ +$(SRC_DIR)/main.o \ +$(SRC_DIR)/tiny_adc.o \ +$(SRC_DIR)/tiny_dac.o \ +$(SRC_DIR)/tiny_dma.o \ +$(SRC_DIR)/tiny_timer.o \ +$(SRC_DIR)/tiny_uart.o \ +$(SRC_DIR)/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained/ui.o \ +$(SRC_DIR)/ASF/common/services/clock/xmega/sysclk.o \ +$(SRC_DIR)/ASF/common/services/sleepmgr/xmega/sleepmgr.o \ +$(SRC_DIR)/ASF/common/services/usb/class/vendor/device/udi_vendor.o \ +$(SRC_DIR)/ASF/common/services/usb/class/vendor/device/udi_vendor_desc.o \ +$(SRC_DIR)/ASF/common/services/usb/udc/udc.o \ +$(SRC_DIR)/ASF/xmega/drivers/nvm/nvm.o \ +$(SRC_DIR)/ASF/xmega/drivers/nvm/nvm_asm.o \ +$(SRC_DIR)/ASF/xmega/drivers/cpu/ccp.o \ +$(SRC_DIR)/ASF/xmega/drivers/usb/usb_device.o + +01: SUFFIX=01 +01: $(OUTPUT_FILE_PATH) + @echo NAME:$(NAME) + @echo CFLAGS:$(CFLAGS) + +02: CFLAGS+=-DSINGLE_ENDPOINT_INTERFACE +02: SUFFIX=02 +02: $(OUTPUT_FILE_PATH) + @echo NAME:$(NAME) + @echo CFLAGS:$(CFLAGS) + +$(SRC_DIR)/tiny_calibration.o: $(SRC_DIR)/tiny_calibration.c + @echo Building file: $< + @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" + @echo Finished building: $< + +$(SRC_DIR)/tiny_dig.o: $(SRC_DIR)/tiny_dig.c + @echo Building file: $< + @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" + @echo Finished building: $< + +$(SRC_DIR)/tiny_eeprom.o: $(SRC_DIR)/tiny_eeprom.c + @echo Building file: $< + @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" + @echo Finished building: $< + +$(SRC_DIR)/ASF/common/boards/user_board/init.o: $(SRC_DIR)/ASF/common/boards/user_board/init.c + @echo Building file: $< + @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" + @echo Finished building: $< + +$(SRC_DIR)/ASF/common/services/ioport/xmega/ioport_compat.o: $(SRC_DIR)/ASF/common/services/ioport/xmega/ioport_compat.c + @echo Building file: $< + @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" + @echo Finished building: $< + +$(SRC_DIR)/main.o: $(SRC_DIR)/main.c + @echo Building file: $< + @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" + @echo Finished building: $< + +$(SRC_DIR)/tiny_adc.o: $(SRC_DIR)/tiny_adc.c + @echo Building file: $< + @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" + @echo Finished building: $< + +$(SRC_DIR)/tiny_dac.o: $(SRC_DIR)/tiny_dac.c + @echo Building file: $< + @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" + @echo Finished building: $< + +$(SRC_DIR)/tiny_dma.o: $(SRC_DIR)/tiny_dma.c + @echo Building file: $< + @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" + @echo Finished building: $< + +$(SRC_DIR)/tiny_timer.o: $(SRC_DIR)/tiny_timer.c + @echo Building file: $< + @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" + @echo Finished building: $< + +$(SRC_DIR)/tiny_uart.o: $(SRC_DIR)/tiny_uart.c + @echo Building file: $< + @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" + @echo Finished building: $< + +$(SRC_DIR)/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained/ui.o: $(SRC_DIR)/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained/ui.c + @echo Building file: $< + @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" + @echo Finished building: $< + +$(SRC_DIR)/ASF/common/services/clock/xmega/sysclk.o: $(SRC_DIR)/ASF/common/services/clock/xmega/sysclk.c + @echo Building file: $< + @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" + @echo Finished building: $< + +$(SRC_DIR)/ASF/common/services/sleepmgr/xmega/sleepmgr.o: $(SRC_DIR)/ASF/common/services/sleepmgr/xmega/sleepmgr.c + @echo Building file: $< + @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" + @echo Finished building: $< + +$(SRC_DIR)/ASF/common/services/usb/class/vendor/device/udi_vendor.o: $(SRC_DIR)/ASF/common/services/usb/class/vendor/device/udi_vendor.c + @echo Building file: $< + @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" + @echo Finished building: $< + +$(SRC_DIR)/ASF/common/services/usb/class/vendor/device/udi_vendor_desc.o: $(SRC_DIR)/ASF/common/services/usb/class/vendor/device/udi_vendor_desc.c + @echo Building file: $< + @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" + @echo Finished building: $< + +$(SRC_DIR)/ASF/common/services/usb/udc/udc.o: $(SRC_DIR)/ASF/common/services/usb/udc/udc.c + @echo Building file: $< + @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" + @echo Finished building: $< + +$(SRC_DIR)/ASF/xmega/drivers/cpu/ccp.o: $(SRC_DIR)/ASF/xmega/drivers/cpu/ccp.s + @echo Building file: $< + @$(CC) -x assembler-with-cpp -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" + @echo Finished building: $< + +$(SRC_DIR)/ASF/xmega/drivers/nvm/nvm.o: $(SRC_DIR)/ASF/xmega/drivers/nvm/nvm.c + @echo Building file: $< + @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" + @echo Finished building: $< + +$(SRC_DIR)/ASF/xmega/drivers/nvm/nvm_asm.o: $(SRC_DIR)/ASF/xmega/drivers/nvm/nvm_asm.s + @echo Building file: $< + @$(CC) -x assembler-with-cpp -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" + @echo Finished building: $< + +$(SRC_DIR)/ASF/xmega/drivers/usb/usb_device.o: $(SRC_DIR)/ASF/xmega/drivers/usb/usb_device.c + @echo Building file: $< + @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" + @echo Finished building: $< + +$(OUTPUT_FILE_PATH): $(OBJS) $(USER_OBJS) $(OUTPUT_FILE_DEP) $(LIB_DEP) $(LINKER_SCRIPT_DEP) + @echo Building target: $@ + $(CC) -o$(OUTPUT_FILE_PATH_AS_ARGS) $(OBJS_AS_ARGS) $(USER_OBJS) $(LIBS) -Wl,-Map=$(NAME)".map" -Wl,-lm -mmcu=atxmega32a4u -Wl,--gc-sections -Wl,--relax + avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature $(NAME)".elf" $(NAME)".hex" + avr-objdump -h -S $(NAME)".elf" > $(NAME)".lss" + avr-objcopy -j .eeprom --set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O binary $(NAME)".elf" $(NAME)".eep" || exit 0 + avr-objcopy -O srec -R .eeprom -R .fuse -R .lock -R .signature $(NAME)".elf" $(NAME)".srec" + avr-size $(NAME)".elf" + @echo Finished successfully: $(NAME) + +clean_o_d : + -rm -rf $(OBJS_AS_ARGS) + -rm -rf $(C_DEPS_AS_ARGS) +VARIANTS = 01 02 +clean : clean_o_d + $(foreach SUFFIX,$(VARIANTS), \ + rm -rf $(NAME).hex ; \ + rm -rf $(NAME).lss ; \ + rm -rf $(NAME).eep ; \ + rm -rf $(NAME).srec ; \ + rm -rf $(NAME).elf $(NAME).a $(NAME).map) diff --git a/AVR_Code/USB_BULK_TEST/Makefile b/AVR_Code/USB_BULK_TEST/Makefile deleted file mode 100755 index d14e3a548..000000000 --- a/AVR_Code/USB_BULK_TEST/Makefile +++ /dev/null @@ -1,242 +0,0 @@ -# see https://github.com/espotek-org/Labrador/wiki/Building-from-source#building-the-firmware -# Usage : -# make 0x01 -# build a version of the firmware compatible with Windows x64 OSs -# make 0x02 -# build a version of the firmware compatible with all other OSs -# Here, OS refers to that of the machine with which the Labrador board will interface. -# After running 'make 0x01', to switch to building variant 0x02 instead, first run 'make clean'. -# The same goes for switching from building the 0x02 variant to building the 0x01 variant. -# Some details: -# In the build process for variant 0x01, the macro SINGLE_ENDPOINT_INTERFACE -# is undefined, while in the build process for variant 0x02, -# SINGLE_ENDPOINT_INTERFACE is defined. In several regions of the source -# code, the undefined/defined status of this macro determines which of two -# possible code blocks are compiled into the firmware. The collective effect -# of having SINGLE_ENDPOINT_INTERFACE defined is to "change the headers so -# that it uses 1x 1023-byte isochronous endpoint, rather than 6x 128-byte -# endpoints to send the scope/logic analyzer data" (from -# https://github.com/espotek-org/Labrador/issues/260) -# *NOTE* : there is a commented-out line defining SINGLE_ENDPOINT_INTERFACE in -# globals.h. If it is uncommented, both 'make 0x01' and 'make 0x02' will -# produce variant 0x02. Further, 'make 0x01' will mislabel the firmware with -# the suffix 0x01. It is recommended that this line in globals.h be left -# commented-out, which ensures that `make 0x01` and `make 0x02` work as -# expected. -EXECUTABLES := -LIB_DEP := -LIBS := -USER_OBJS := -OUTPUT_FILE_PATH := -OUTPUT_FILE_PATH =$(NAME).elf -OUTPUT_FILE_PATH_AS_ARGS +=$(NAME).elf -AVR_APP_PATH :=$$$AVR_APP_PATH$$$ - -AVRDIR= -CC=$(AVRDIR)/bin/avr-gcc -INCLUDES=-I"./common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained" -I"./common/services/usb/class/vendor/device/example" -I"./src/ASF/common/services/usb/udc" -I"./src/ASF/xmega/drivers/nvm" -I"./src/ASF/common/services/sleepmgr" -I"./src/ASF/common/services/clock" -I"./src/ASF/xmega/drivers/sleep" -I"./src/ASF/xmega/drivers/usb" -I"./src/ASF/xmega/drivers/cpu" -I"./src/ASF/common/services/usb/class/vendor" -I"./src/ASF/common/services/usb/class/vendor/device" -I"./src/ASF/common/services/usb" -I"./common/applications/user_application/user_board/config" -I"./src/ASF/xmega/utils" -I"./src/config" -I"./src/ASF/common/boards" -I"./src/ASF/xmega/utils/preprocessor" -I"./src/ASF/common/utils" -I"./src" -I"./src/ASF/common/boards/user_board" -I"./src/ASF/common/services/ioport" - -CFLAGS=-std=gnu99 -ffunction-sections -mmcu=atxmega32a4u -fsigned-char -funsigned-bitfields -fdata-sections -fshort-enums -fno-strict-aliasing -fno-jump-tables -fpack-struct -Wall -O2 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -NAME=labrafirm_$(SUFFIX) - -OBJS += \ -./src/tiny_calibration.o \ -./src/tiny_dig.o \ -./src/tiny_eeprom.o \ -./src/ASF/common/boards/user_board/init.o \ -./src/ASF/common/services/ioport/xmega/ioport_compat.o \ -./src/main.o \ -./src/tiny_adc.o \ -./src/tiny_dac.o \ -./src/tiny_dma.o \ -./src/tiny_timer.o \ -./src/tiny_uart.o \ -./src/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained/ui.o \ -./src/ASF/common/services/clock/xmega/sysclk.o \ -./src/ASF/common/services/sleepmgr/xmega/sleepmgr.o \ -./src/ASF/common/services/usb/class/vendor/device/udi_vendor.o \ -./src/ASF/common/services/usb/class/vendor/device/udi_vendor_desc.o \ -./src/ASF/common/services/usb/udc/udc.o \ -./src/ASF/xmega/drivers/nvm/nvm.o \ -./src/ASF/xmega/drivers/nvm/nvm_asm.o \ -./src/ASF/xmega/drivers/cpu/ccp.o \ -./src/ASF/xmega/drivers/usb/usb_device.o - -C_DEPS_AS_ARGS += \ -./src/tiny_calibration.d \ -./src/tiny_dig.d \ -./src/tiny_eeprom.d \ -./src/ASF/common/boards/user_board/init.d \ -./src/ASF/common/services/ioport/xmega/ioport_compat.d \ -./src/main.d \ -./src/tiny_adc.d \ -./src/tiny_dac.d \ -./src/tiny_dma.d \ -./src/tiny_timer.d \ -./src/tiny_uart.d \ -./src/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained/ui.d \ -./src/ASF/common/services/clock/xmega/sysclk.d \ -./src/ASF/common/services/sleepmgr/xmega/sleepmgr.d \ -./src/ASF/common/services/usb/class/vendor/device/udi_vendor.d \ -./src/ASF/common/services/usb/class/vendor/device/udi_vendor_desc.d \ -./src/ASF/common/services/usb/udc/udc.d \ -./src/ASF/xmega/drivers/nvm/nvm.d \ -./src/ASF/xmega/drivers/nvm/nvm_asm.d \ -./src/ASF/xmega/drivers/cpu/ccp.d \ -./src/ASF/xmega/drivers/usb/usb_device.d - -OBJS_AS_ARGS += \ -./src/tiny_calibration.o \ -./src/tiny_dig.o \ -./src/tiny_eeprom.o \ -./src/ASF/common/boards/user_board/init.o \ -./src/ASF/common/services/ioport/xmega/ioport_compat.o \ -./src/main.o \ -./src/tiny_adc.o \ -./src/tiny_dac.o \ -./src/tiny_dma.o \ -./src/tiny_timer.o \ -./src/tiny_uart.o \ -./src/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained/ui.o \ -./src/ASF/common/services/clock/xmega/sysclk.o \ -./src/ASF/common/services/sleepmgr/xmega/sleepmgr.o \ -./src/ASF/common/services/usb/class/vendor/device/udi_vendor.o \ -./src/ASF/common/services/usb/class/vendor/device/udi_vendor_desc.o \ -./src/ASF/common/services/usb/udc/udc.o \ -./src/ASF/xmega/drivers/nvm/nvm.o \ -./src/ASF/xmega/drivers/nvm/nvm_asm.o \ -./src/ASF/xmega/drivers/cpu/ccp.o \ -./src/ASF/xmega/drivers/usb/usb_device.o - -./src/tiny_calibration.o: ./src/tiny_calibration.c - @echo Building file: $< - @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" - @echo Finished building: $< - -./src/tiny_dig.o: ./src/tiny_dig.c - @echo Building file: $< - @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" - @echo Finished building: $< - -./src/tiny_eeprom.o: ./src/tiny_eeprom.c - @echo Building file: $< - @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" - @echo Finished building: $< - -./src/ASF/common/boards/user_board/init.o: ./src/ASF/common/boards/user_board/init.c - @echo Building file: $< - @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" - @echo Finished building: $< - -./src/ASF/common/services/ioport/xmega/ioport_compat.o: ./src/ASF/common/services/ioport/xmega/ioport_compat.c - @echo Building file: $< - @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" - @echo Finished building: $< - -./src/main.o: ./src/main.c - @echo Building file: $< - @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" - @echo Finished building: $< - -./src/tiny_adc.o: ./src/tiny_adc.c - @echo Building file: $< - @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" - @echo Finished building: $< - -./src/tiny_dac.o: ./src/tiny_dac.c - @echo Building file: $< - @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" - @echo Finished building: $< - -./src/tiny_dma.o: ./src/tiny_dma.c - @echo Building file: $< - @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" - @echo Finished building: $< - -./src/tiny_timer.o: ./src/tiny_timer.c - @echo Building file: $< - @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" - @echo Finished building: $< - -./src/tiny_uart.o: ./src/tiny_uart.c - @echo Building file: $< - @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" - @echo Finished building: $< - -./src/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained/ui.o: ./src/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained/ui.c - @echo Building file: $< - @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" - @echo Finished building: $< - -./src/ASF/common/services/clock/xmega/sysclk.o: ./src/ASF/common/services/clock/xmega/sysclk.c - @echo Building file: $< - @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" - @echo Finished building: $< - -./src/ASF/common/services/sleepmgr/xmega/sleepmgr.o: ./src/ASF/common/services/sleepmgr/xmega/sleepmgr.c - @echo Building file: $< - @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" - @echo Finished building: $< - -./src/ASF/common/services/usb/class/vendor/device/udi_vendor.o: ./src/ASF/common/services/usb/class/vendor/device/udi_vendor.c - @echo Building file: $< - @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" - @echo Finished building: $< - -./src/ASF/common/services/usb/class/vendor/device/udi_vendor_desc.o: ./src/ASF/common/services/usb/class/vendor/device/udi_vendor_desc.c - @echo Building file: $< - @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" - @echo Finished building: $< - -./src/ASF/common/services/usb/udc/udc.o: ./src/ASF/common/services/usb/udc/udc.c - @echo Building file: $< - @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" - @echo Finished building: $< - -./src/ASF/xmega/drivers/cpu/ccp.o: ./src/ASF/xmega/drivers/cpu/ccp.s - @echo Building file: $< - @$(CC) -x assembler-with-cpp -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" - @echo Finished building: $< - -./src/ASF/xmega/drivers/nvm/nvm.o: ./src/ASF/xmega/drivers/nvm/nvm.c - @echo Building file: $< - @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" - @echo Finished building: $< - -./src/ASF/xmega/drivers/nvm/nvm_asm.o: ./src/ASF/xmega/drivers/nvm/nvm_asm.s - @echo Building file: $< - @$(CC) -x assembler-with-cpp -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" - @echo Finished building: $< - -./src/ASF/xmega/drivers/usb/usb_device.o: ./src/ASF/xmega/drivers/usb/usb_device.c - @echo Building file: $< - @$(CC) -DNDEBUG -DBOARD=USER_BOARD $(INCLUDES) $(CFLAGS) -c -o "$@" "$<" - @echo Finished building: $< - -0x01: SUFFIX=0x01 -0x01: $(OUTPUT_FILE_PATH) - -0x02: CFLAGS+=-DSINGLE_ENDPOINT_INTERFACE -0x02: SUFFIX=0x02 -0x02: $(OUTPUT_FILE_PATH) - -$(OUTPUT_FILE_PATH): $(OBJS) $(USER_OBJS) $(OUTPUT_FILE_DEP) $(LIB_DEP) $(LINKER_SCRIPT_DEP) - @echo Building target: $@ - $(CC) -o$(OUTPUT_FILE_PATH_AS_ARGS) $(OBJS_AS_ARGS) $(USER_OBJS) $(LIBS) -Wl,-Map=$(NAME)".map" -Wl,-lm -mmcu=atxmega32a4u -Wl,--gc-sections -Wl,--relax - $(AVRDIR)/bin/avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature $(NAME)".elf" $(NAME)".hex" - $(AVRDIR)/bin/avr-objdump -h -S $(NAME)".elf" > $(NAME)".lss" - $(AVRDIR)/bin/avr-objcopy -j .eeprom --set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O binary $(NAME)".elf" $(NAME)".eep" || exit 0 - $(AVRDIR)/bin/avr-objcopy -O srec -R .eeprom -R .fuse -R .lock -R .signature $(NAME)".elf" $(NAME)".srec" - $(AVRDIR)/bin/avr-size $(NAME)".elf" - @echo Finished successfully: $(NAME) - -VARIANTS = 0x01 0x02 -clean : - -rm -rf $(OBJS_AS_ARGS) $(EXECUTABLES) - -rm -rf $(C_DEPS_AS_ARGS) - $(foreach SUFFIX,$(VARIANTS), \ - rm -rf $(NAME).hex ; \ - rm -rf $(NAME).lss ; \ - rm -rf $(NAME).eep ; \ - rm -rf $(NAME).srec ; \ - rm -rf $(NAME).elf $(NAME).a $(NAME).map) diff --git a/AVR_Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udc.c b/AVR_Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udc.c index 123928a27..bdb4bfb32 100644 --- a/AVR_Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udc.c +++ b/AVR_Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udc.c @@ -1102,7 +1102,7 @@ static bool udc_reqvend(void){ uds.calValPos = cali_value_positive_gradient; uds.CALA = DFLLRC2M.CALA; uds.CALB = DFLLRC2M.CALB; - udd_set_setup_payload(&uds, udd_g_ctrlreq.req.wLength); + udd_set_setup_payload((uint8_t *) &uds, udd_g_ctrlreq.req.wLength); //asm("nop"); return 1; case 0xa1: //Receive waveform for signal gen @@ -1212,7 +1212,7 @@ static bool udc_reqvend(void){ : "memory"); __builtin_unreachable(); case 0xa8: //Firmware Version Request - udd_set_setup_payload(&firmver, udd_g_ctrlreq.req.wLength); + udd_set_setup_payload((uint8_t *) &firmver, udd_g_ctrlreq.req.wLength); return 1; case 0xa9: //Variant Version Request udd_set_setup_payload(&variant, udd_g_ctrlreq.req.wLength); diff --git a/AVR_Code/USB_BULK_TEST/src/ASF/xmega/drivers/usb/usb_device.c b/AVR_Code/USB_BULK_TEST/src/ASF/xmega/drivers/usb/usb_device.c index a0b77ded8..5d21fd567 100644 --- a/AVR_Code/USB_BULK_TEST/src/ASF/xmega/drivers/usb/usb_device.c +++ b/AVR_Code/USB_BULK_TEST/src/ASF/xmega/drivers/usb/usb_device.c @@ -249,7 +249,7 @@ static UDD_EP_t *udd_ep_get_ctrl(udd_ep_id_t ep); //@{ //! Global variable to give and record information about setup request management -udd_ctrl_request_t udd_g_ctrlreq; +extern udd_ctrl_request_t udd_g_ctrlreq; //! Bit definitions about endpoint control state machine for udd_ep_control_state typedef enum { diff --git a/AVR_Code/USB_BULK_TEST/src/globals.h b/AVR_Code/USB_BULK_TEST/src/globals.h index e85cc0b87..f2c00e808 100644 --- a/AVR_Code/USB_BULK_TEST/src/globals.h +++ b/AVR_Code/USB_BULK_TEST/src/globals.h @@ -13,7 +13,7 @@ //#define VERO #define OVERCLOCK 48 -#define FIRMWARE_VERSION_ID 0x0007 +// #define FIRMWARE_VERSION_ID 0x0007 #define ATMEL_DFU_OFFSET 0x01fc #define TC_SPISLAVE TCD0 @@ -71,4 +71,4 @@ extern const unsigned char variant; #include "unified_debug_structure.h" extern unified_debug uds; -#endif /* GLOBALS_H_ */ \ No newline at end of file +#endif /* GLOBALS_H_ */ diff --git a/AVR_Code/USB_BULK_TEST/src/tiny_calibration.c b/AVR_Code/USB_BULK_TEST/src/tiny_calibration.c index a1ac1c4c9..64374af8a 100644 --- a/AVR_Code/USB_BULK_TEST/src/tiny_calibration.c +++ b/AVR_Code/USB_BULK_TEST/src/tiny_calibration.c @@ -10,6 +10,8 @@ #include "tiny_adc.h" volatile unsigned char median_TRFCNT_delay = 255; +volatile unsigned char cali_value_positive_gradient; +volatile unsigned char cali_value_negative_gradient; void tiny_calibration_init(){ //Set up 48MHz DFLL for USB. @@ -46,7 +48,7 @@ void tiny_calibration_init(){ return; } -tiny_calibration_first_sof(){ +void tiny_calibration_first_sof(){ PR.PRPE &= 0b11111110; TC_CALI.PER = 23999; TC_CALI.CNT = 12000; diff --git a/AVR_Code/USB_BULK_TEST/src/tiny_calibration.h b/AVR_Code/USB_BULK_TEST/src/tiny_calibration.h index edd9e0f35..1e580a9ad 100644 --- a/AVR_Code/USB_BULK_TEST/src/tiny_calibration.h +++ b/AVR_Code/USB_BULK_TEST/src/tiny_calibration.h @@ -25,8 +25,8 @@ void tiny_calibration_synchronise_phase(unsigned int phase, unsigned int precisi extern volatile unsigned char calibration_values_found; extern volatile unsigned char median_TRFCNT_delay; -volatile unsigned char cali_value_negative_gradient; -volatile unsigned char cali_value_positive_gradient; +extern volatile unsigned char cali_value_negative_gradient; +extern volatile unsigned char cali_value_positive_gradient; -#endif /* TINY_CALIBRATION_H_ */ \ No newline at end of file +#endif /* TINY_CALIBRATION_H_ */ diff --git a/Desktop_Interface/Labrador.pro b/Desktop_Interface/Labrador.pro index fc6d1b480..77659350f 100644 --- a/Desktop_Interface/Labrador.pro +++ b/Desktop_Interface/Labrador.pro @@ -32,6 +32,8 @@ equals(QCP_VER,"2"){ message("Using QCP2 with OpenGL support") } +DEFINES += "EXPECTED_FIRMWARE_VERSION=$${EXPECTED_FIRMWARE_VERSION}" + include(ui_elements.pri) MOC_DIR = moc diff --git a/Desktop_Interface/genericusbdriver.h b/Desktop_Interface/genericusbdriver.h index 95dcc7a57..3407a9344 100644 --- a/Desktop_Interface/genericusbdriver.h +++ b/Desktop_Interface/genericusbdriver.h @@ -16,7 +16,7 @@ //#include "buffercontrol.h" #include "unified_debug_structure.h" -#define EXPECTED_FIRMWARE_VERSION 0x0007 +//#define EXPECTED_FIRMWARE_VERSION 0x0007 #ifdef WINDOWS_64_BIT #define DEFINED_EXPECTED_VARIANT 1