From ea50ebd8ff8a7539e78fe8becc5fcb8b8e89a5c3 Mon Sep 17 00:00:00 2001 From: per1234 Date: Sun, 4 Apr 2021 02:13:10 -0700 Subject: [PATCH 01/15] Use established KEYWORD_TOKENTYPE for Wire keyword All the other platform bundled libraries use `KEYWORD1` for the library's global instance so this provides consistency. --- libraries/Wire/keywords.txt | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/libraries/Wire/keywords.txt b/libraries/Wire/keywords.txt index 5e3d2b1c..04b8301a 100644 --- a/libraries/Wire/keywords.txt +++ b/libraries/Wire/keywords.txt @@ -6,6 +6,8 @@ # Datatypes (KEYWORD1) ####################################### +Wire KEYWORD2 + ####################################### # Methods and Functions (KEYWORD2) ####################################### @@ -18,12 +20,6 @@ requestFrom KEYWORD2 onReceive KEYWORD2 onRequest KEYWORD2 -####################################### -# Instances (KEYWORD2) -####################################### - -Wire KEYWORD2 - ####################################### # Constants (LITERAL1) ####################################### From d1b989c4fa88838b9a52fcfd28234d391cc6c284 Mon Sep 17 00:00:00 2001 From: per1234 Date: Fri, 2 Apr 2021 02:05:53 -0700 Subject: [PATCH 02/15] Update action versions used in CI workflows The "smoke test" sketch compilation and reporting actions have been moved to dedicated repositories. The actions hosted at the old `arduino/actions/libraries/*` location will no longer be maintained. Since the time the actions were migrated to the dedicated repositories, a breaking change was made to the default value of the `sketches-report-path` input, which required a change to the values of the `name` and `path` inputs of the `actions/upload-artifact` action. --- .github/workflows/compile-examples.yml | 9 +++++---- .github/workflows/report-size-deltas.yml | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 28e61cad..9dfbf70a 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -54,6 +54,7 @@ jobs: - ~/Arduino/libraries/Arduino_LPS22HB/examples - ~/Arduino/libraries/ArduinoDMX/examples - ~/Arduino/libraries/ArduinoRS485/examples + SKETCHES_REPORTS_PATH: sketches-reports strategy: fail-fast: false @@ -108,7 +109,7 @@ jobs: # CapacitiveSensor library does not support megaAVR core yet rm -r "$GITHUB_WORKSPACE/extras/examples/10.StarterKit_BasicKit/p13_TouchSensorLamp" - name: Compile examples - uses: arduino/actions/libraries/compile-examples@master + uses: arduino/compile-sketches@v1 with: github-token: ${{ secrets.GITHUB_TOKEN }} fqbn: ${{ matrix.board.fqbn }} @@ -147,7 +148,7 @@ jobs: verbose: 'true' - name: Save memory usage change report as artifact - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v2 with: - name: size-deltas-reports - path: size-deltas-reports + path: ${{ env.SKETCHES_REPORTS_PATH }} + name: ${{ env.SKETCHES_REPORTS_PATH }} diff --git a/.github/workflows/report-size-deltas.yml b/.github/workflows/report-size-deltas.yml index a359b257..b30c25be 100644 --- a/.github/workflows/report-size-deltas.yml +++ b/.github/workflows/report-size-deltas.yml @@ -10,4 +10,4 @@ jobs: steps: - name: Comment size deltas reports to PRs - uses: arduino/actions/libraries/report-size-deltas@master \ No newline at end of file + uses: arduino/report-size-deltas@v1 From a95aef69c34c199cffd2478a02210039c1e860b4 Mon Sep 17 00:00:00 2001 From: per1234 Date: Fri, 2 Apr 2021 02:07:19 -0700 Subject: [PATCH 03/15] Specify sketches report input values for sketch compilation CI actions The reliance on the `actions/upload-artifacts` action as the transfer mechanism between workflow runs means that these values will always be hardcoded into the workflow. The result is that if the default values of the inputs are changed, it breaks the workflow, even if the changes are synchronized. So it's more robust to avoid dependening on the default values. --- .github/workflows/compile-examples.yml | 1 + .github/workflows/report-size-deltas.yml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 9dfbf70a..db79dd1d 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -146,6 +146,7 @@ jobs: ${{ matrix.additional-sketch-paths }} enable-deltas-report: 'true' verbose: 'true' + sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }} - name: Save memory usage change report as artifact uses: actions/upload-artifact@v2 diff --git a/.github/workflows/report-size-deltas.yml b/.github/workflows/report-size-deltas.yml index b30c25be..1e37a511 100644 --- a/.github/workflows/report-size-deltas.yml +++ b/.github/workflows/report-size-deltas.yml @@ -11,3 +11,6 @@ jobs: steps: - name: Comment size deltas reports to PRs uses: arduino/report-size-deltas@v1 + with: + # The name of the workflow artifact created by the sketch compilation workflow + sketches-reports-source: sketches-reports From 07d8dcde75cb6d3e31f36099f106ad4ffdbada12 Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 26 May 2021 01:10:22 -0700 Subject: [PATCH 04/15] Disable verbose output in sketch compilation CI logs The `arduino/compile-sketches` action was previously configured for verbose output.. This option is primarily intended to be used for troubleshooting and doesn't contain any information of value for general usage. Due to the extensive coverage of this CI workflow, the logs are massive, which makes it inconvenient for anyone to read them to identify the cause of a failure. Removing the verbose output will improve that situation --- .github/workflows/compile-examples.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index db79dd1d..07382034 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -145,7 +145,6 @@ jobs: ${{ env.UNIVERSAL_SKETCH_PATHS }} ${{ matrix.additional-sketch-paths }} enable-deltas-report: 'true' - verbose: 'true' sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }} - name: Save memory usage change report as artifact From d39a5ab3adecddc6d3b80ca212d1dbed805f77a7 Mon Sep 17 00:00:00 2001 From: per1234 Date: Sun, 30 May 2021 06:54:39 -0700 Subject: [PATCH 05/15] Add "smoke test" sketch compilation CI workflow for MuxTO firmware On every push and pull request that affects relevant files, and periodically, compile the Nano Every's MuxTO firmware sketch. The binary is saved as a workflow artifact to make it available for beta testers who might prefer flashing it directly over setting up the toolchain needed to compile it locally. Due to the standard output from Arduino CLI not providing the correct size data, a bespoke check is done for whether the compiled binary will fit in the available 12 kB of memory. If not, the workflow run fails. On creation or commit to a pull request, a report of the resulting change in memory usage of the sketch will be commented to the PR thread. --- .github/workflows/compile-muxto.yml | 103 ++++++++++++++++++++++++++++ README.md | 2 + 2 files changed, 105 insertions(+) create mode 100644 .github/workflows/compile-muxto.yml diff --git a/.github/workflows/compile-muxto.yml b/.github/workflows/compile-muxto.yml new file mode 100644 index 00000000..f0e8948b --- /dev/null +++ b/.github/workflows/compile-muxto.yml @@ -0,0 +1,103 @@ +name: Compile MuxTO + +# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows +on: + push: + paths: + - ".github/workflows/compile-muxto.yml" + - "firmwares/MuxTO/**" + pull_request: + paths: + - ".github/workflows/compile-muxto.yml" + - "firmwares/MuxTO/**" + schedule: + # Run every Tuesday at 8 AM UTC to catch breakage caused by changes to external resources (libraries, platforms). + - cron: "0 8 * * TUE" + workflow_dispatch: + repository_dispatch: + +env: + BINARY_FILENAME: MuxTO.ino.bin + BINARY_ARTIFACT_NAME: MuxTO + +jobs: + build: + name: Build firmware + runs-on: ubuntu-latest + + strategy: + fail-fast: false + + matrix: + board: + - fqbn: arduino:samd:muxto:float=default,config=enabled,clock=internal_usb,timer=timer_732Hz,bootloader=4kb,serial=two_uart,usb=cdc + platforms: | + # Install MattairTech_Arduino:samd via Boards Manager for the toolchain + - name: MattairTech_Arduino:samd + source-url: https://www.mattairtech.com/software/arduino/package_MattairTech_index.json + # This needs to match with the version of MattairTech_Arduino:samd the Arduino fork is based on in order to get the right tool versions + version: 1.6.17 + # Install the platform with MuxTO support + - name: arduino:samd + source-url: https://github.com/arduino/ArduinoCore-samd.git + version: muxto + + steps: + - name: Set environment variables + run: | + # See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable + echo "BINARY_OUTPUT_PATH=${{ runner.temp }}/output" >> "$GITHUB_ENV" + echo "SKETCHES_REPORTS_PATH=${{ runner.temp }}/sketches-reports" >> "$GITHUB_ENV" + + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Compile firmware + uses: arduino/compile-sketches@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + fqbn: ${{ matrix.board.fqbn }} + platforms: ${{ matrix.board.platforms }} + libraries: | + - + sketch-paths: | + - firmwares/MuxTO + cli-compile-flags: | + - --output-dir=${{ env.BINARY_OUTPUT_PATH }} + enable-deltas-report: true + sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }} + + - name: Save firmware binary as workflow artifact + uses: actions/upload-artifact@v2 + with: + if-no-files-found: error + path: ${{ env.BINARY_OUTPUT_PATH }}/${{ env.BINARY_FILENAME }} + name: ${{ env.BINARY_ARTIFACT_NAME }} + + - name: Save sketches report as workflow artifact + uses: actions/upload-artifact@v2 + with: + if-no-files-found: error + path: ${{ env.SKETCHES_REPORTS_PATH }} + name: sketches-reports + + size: + name: Check firmware size + needs: build + runs-on: ubuntu-latest + steps: + - name: Download binary artifact + uses: actions/download-artifact@v2 + with: + name: ${{ env.BINARY_ARTIFACT_NAME }} + + # The normal size check done by Arduino CLI is not working correctly, so it's necessary to check the size directly + - name: Check firmware binary size + run: | + BINARY_SIZE="$(stat --printf="%s" "${{ github.workspace }}/${{ env.BINARY_FILENAME }}")" + MAX_BINARY_SIZE=$((12 * 1024)) + echo "File size: ${BINARY_SIZE}/${MAX_BINARY_SIZE} B" + if [[ $BINARY_SIZE -gt $MAX_BINARY_SIZE ]]; then + echo "::error::Binary size of $BINARY_SIZE B exceeds the available memory ($MAX_BINARY_SIZE B)" + exit 1 + fi diff --git a/README.md b/README.md index f5ace4fd..4090cd7e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Arduino Core for ATMEGA4809 CPU +[![Compile MuxTO status](https://github.com/arduino/ArduinoCore-megaavr/actions/workflows/compile-muxto.yml/badge.svg)](https://github.com/arduino/ArduinoCore-megaavr/actions/workflows/compile-muxto.yml) + This repository contains the source code and configuration files of the Arduino Core for Microchip's ATMEGA4809 processor (used on the Arduino Uno WiFi Rev2 boards). From 1b7797be3639b21cc468855b506d30cad4cd99e0 Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 22 Sep 2021 02:14:46 -0700 Subject: [PATCH 06/15] Remove unnecessary HID library The library was inherited from the "Arduino AVR Boards" platform that was the model for this project. It is used by the ATmega32U4-based boards of Arduino AVR Boards, however this platform's boards do not have a native HID capability and so the library serves no purpose, and in fact will not even compile for this platform's boards. So it will be best to remove it. --- libraries/HID/keywords.txt | 21 ---- libraries/HID/library.properties | 9 -- libraries/HID/src/HID.cpp | 162 ------------------------------- libraries/HID/src/HID.h | 129 ------------------------ 4 files changed, 321 deletions(-) delete mode 100644 libraries/HID/keywords.txt delete mode 100644 libraries/HID/library.properties delete mode 100644 libraries/HID/src/HID.cpp delete mode 100644 libraries/HID/src/HID.h diff --git a/libraries/HID/keywords.txt b/libraries/HID/keywords.txt deleted file mode 100644 index 32a9ba5f..00000000 --- a/libraries/HID/keywords.txt +++ /dev/null @@ -1,21 +0,0 @@ -####################################### -# Syntax Coloring Map HID -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - -HID KEYWORD1 - -####################################### -# Methods and Functions (KEYWORD2) -####################################### -begin KEYWORD2 -SendReport KEYWORD2 -AppendDescriptor KEYWORD2 - -####################################### -# Constants (LITERAL1) -####################################### -HID_TX LITERAL1 \ No newline at end of file diff --git a/libraries/HID/library.properties b/libraries/HID/library.properties deleted file mode 100644 index 499286d4..00000000 --- a/libraries/HID/library.properties +++ /dev/null @@ -1,9 +0,0 @@ -name=HID -version=1.0 -author=Arduino -maintainer=Arduino -sentence=Module for PluggableUSB infrastructure. Exposes an API for devices like Keyboards, Mice and Gamepads. -paragraph= -category=Communication -url=http://www.arduino.cc/en/Reference/HID -architectures=megaavr diff --git a/libraries/HID/src/HID.cpp b/libraries/HID/src/HID.cpp deleted file mode 100644 index 21ede269..00000000 --- a/libraries/HID/src/HID.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* - Copyright (c) 2015, Arduino LLC - Original code (pre-library): Copyright (c) 2011, Peter Barrett - - Permission to use, copy, modify, and/or distribute this software for - any purpose with or without fee is hereby granted, provided that the - above copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL - WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR - BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES - OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, - ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - SOFTWARE. - */ - -#include "HID.h" - -#if defined(USBCON) - -HID_& HID() -{ - static HID_ obj; - return obj; -} - -int HID_::getInterface(uint8_t* interfaceCount) -{ - *interfaceCount += 1; // uses 1 - HIDDescriptor hidInterface = { - D_INTERFACE(pluggedInterface, 1, USB_DEVICE_CLASS_HUMAN_INTERFACE, HID_SUBCLASS_NONE, HID_PROTOCOL_NONE), - D_HIDREPORT(descriptorSize), - D_ENDPOINT(USB_ENDPOINT_IN(pluggedEndpoint), USB_ENDPOINT_TYPE_INTERRUPT, USB_EP_SIZE, 0x01) - }; - return USB_SendControl(0, &hidInterface, sizeof(hidInterface)); -} - -int HID_::getDescriptor(USBSetup& setup) -{ - // Check if this is a HID Class Descriptor request - if (setup.bmRequestType != REQUEST_DEVICETOHOST_STANDARD_INTERFACE) { return 0; } - if (setup.wValueH != HID_REPORT_DESCRIPTOR_TYPE) { return 0; } - - // In a HID Class Descriptor wIndex cointains the interface number - if (setup.wIndex != pluggedInterface) { return 0; } - - int total = 0; - HIDSubDescriptor* node; - for (node = rootNode; node; node = node->next) { - int res = USB_SendControl(TRANSFER_PGM, node->data, node->length); - if (res == -1) - return -1; - total += res; - } - - // Reset the protocol on reenumeration. Normally the host should not assume the state of the protocol - // due to the USB specs, but Windows and Linux just assumes its in report mode. - protocol = HID_REPORT_PROTOCOL; - - return total; -} - -uint8_t HID_::getShortName(char *name) -{ - name[0] = 'H'; - name[1] = 'I'; - name[2] = 'D'; - name[3] = 'A' + (descriptorSize & 0x0F); - name[4] = 'A' + ((descriptorSize >> 4) & 0x0F); - return 5; -} - -void HID_::AppendDescriptor(HIDSubDescriptor *node) -{ - if (!rootNode) { - rootNode = node; - } else { - HIDSubDescriptor *current = rootNode; - while (current->next) { - current = current->next; - } - current->next = node; - } - descriptorSize += node->length; -} - -int HID_::SendReport(uint8_t id, const void* data, int len) -{ - auto ret = USB_Send(pluggedEndpoint, &id, 1); - if (ret < 0) return ret; - auto ret2 = USB_Send(pluggedEndpoint | TRANSFER_RELEASE, data, len); - if (ret2 < 0) return ret2; - return ret + ret2; -} - -bool HID_::setup(USBSetup& setup) -{ - if (pluggedInterface != setup.wIndex) { - return false; - } - - uint8_t request = setup.bRequest; - uint8_t requestType = setup.bmRequestType; - - if (requestType == REQUEST_DEVICETOHOST_CLASS_INTERFACE) - { - if (request == HID_GET_REPORT) { - // TODO: HID_GetReport(); - return true; - } - if (request == HID_GET_PROTOCOL) { - // TODO: Send8(protocol); - return true; - } - if (request == HID_GET_IDLE) { - // TODO: Send8(idle); - } - } - - if (requestType == REQUEST_HOSTTODEVICE_CLASS_INTERFACE) - { - if (request == HID_SET_PROTOCOL) { - // The USB Host tells us if we are in boot or report mode. - // This only works with a real boot compatible device. - protocol = setup.wValueL; - return true; - } - if (request == HID_SET_IDLE) { - idle = setup.wValueL; - return true; - } - if (request == HID_SET_REPORT) - { - //uint8_t reportID = setup.wValueL; - //uint16_t length = setup.wLength; - //uint8_t data[length]; - // Make sure to not read more data than USB_EP_SIZE. - // You can read multiple times through a loop. - // The first byte (may!) contain the reportID on a multreport. - //USB_RecvControl(data, length); - } - } - - return false; -} - -HID_::HID_(void) : PluggableUSBModule(1, 1, epType), - rootNode(NULL), descriptorSize(0), - protocol(HID_REPORT_PROTOCOL), idle(1) -{ - epType[0] = EP_TYPE_INTERRUPT_IN; - PluggableUSB().plug(this); -} - -int HID_::begin(void) -{ - return 0; -} - -#endif /* if defined(USBCON) */ diff --git a/libraries/HID/src/HID.h b/libraries/HID/src/HID.h deleted file mode 100644 index ad2b06b1..00000000 --- a/libraries/HID/src/HID.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - Copyright (c) 2015, Arduino LLC - Original code (pre-library): Copyright (c) 2011, Peter Barrett - - Permission to use, copy, modify, and/or distribute this software for - any purpose with or without fee is hereby granted, provided that the - above copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL - WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR - BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES - OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, - ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - SOFTWARE. - */ - -#ifndef HID_h -#define HID_h - -#include -#include -#include "api/PluggableUSB.h" - -#if defined(USBCON) - -#define _USING_HID - -// HID 'Driver' -// ------------ -#define HID_GET_REPORT 0x01 -#define HID_GET_IDLE 0x02 -#define HID_GET_PROTOCOL 0x03 -#define HID_SET_REPORT 0x09 -#define HID_SET_IDLE 0x0A -#define HID_SET_PROTOCOL 0x0B - -#define HID_HID_DESCRIPTOR_TYPE 0x21 -#define HID_REPORT_DESCRIPTOR_TYPE 0x22 -#define HID_PHYSICAL_DESCRIPTOR_TYPE 0x23 - -// HID subclass HID1.11 Page 8 4.2 Subclass -#define HID_SUBCLASS_NONE 0 -#define HID_SUBCLASS_BOOT_INTERFACE 1 - -// HID Keyboard/Mouse bios compatible protocols HID1.11 Page 9 4.3 Protocols -#define HID_PROTOCOL_NONE 0 -#define HID_PROTOCOL_KEYBOARD 1 -#define HID_PROTOCOL_MOUSE 2 - -// Normal or bios protocol (Keyboard/Mouse) HID1.11 Page 54 7.2.5 Get_Protocol Request -// "protocol" variable is used for this purpose. -#define HID_BOOT_PROTOCOL 0 -#define HID_REPORT_PROTOCOL 1 - -// HID Request Type HID1.11 Page 51 7.2.1 Get_Report Request -#define HID_REPORT_TYPE_INPUT 1 -#define HID_REPORT_TYPE_OUTPUT 2 -#define HID_REPORT_TYPE_FEATURE 3 - -typedef struct -{ - uint8_t len; // 9 - uint8_t dtype; // 0x21 - uint8_t addr; - uint8_t versionL; // 0x101 - uint8_t versionH; // 0x101 - uint8_t country; - uint8_t desctype; // 0x22 report - uint8_t descLenL; - uint8_t descLenH; -} HIDDescDescriptor; - -typedef struct -{ - InterfaceDescriptor hid; - HIDDescDescriptor desc; - EndpointDescriptor in; -} HIDDescriptor; - -class HIDSubDescriptor { -public: - HIDSubDescriptor *next = NULL; - HIDSubDescriptor(const void *d, const uint16_t l) : data(d), length(l) { } - - const void* data; - const uint16_t length; -}; - -class HID_ : public PluggableUSBModule -{ -public: - HID_(void); - int begin(void); - int SendReport(uint8_t id, const void* data, int len); - void AppendDescriptor(HIDSubDescriptor* node); - -protected: - // Implementation of the PluggableUSBModule - int getInterface(uint8_t* interfaceCount); - int getDescriptor(USBSetup& setup); - bool setup(USBSetup& setup); - uint8_t getShortName(char* name); - -private: - unsigned int epType[1]; - - HIDSubDescriptor* rootNode; - uint16_t descriptorSize; - - uint8_t protocol; - uint8_t idle; -}; - -// Replacement for global singleton. -// This function prevents static-initialization-order-fiasco -// https://isocpp.org/wiki/faq/ctors#static-init-order-on-first-use -HID_& HID(); - -#define D_HIDREPORT(length) { 9, 0x21, 0x01, 0x01, 0, 1, 0x22, lowByte(length), highByte(length) } - -#else - -#error "No Native USB support available on this board" - -#endif // USBCON - -#endif // HID_h From 71437e7659812d763c88094f69a94ef2b0468ea3 Mon Sep 17 00:00:00 2001 From: christophelandret <19358486+landret@users.noreply.github.com> Date: Mon, 19 Apr 2021 12:32:43 -1000 Subject: [PATCH 07/15] Update platform.txt ldflags added to allow precompilation. --- platform.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform.txt b/platform.txt index e288636b..9de78cc4 100644 --- a/platform.txt +++ b/platform.txt @@ -34,6 +34,7 @@ compiler.elf2hex.flags=-O ihex -R .eeprom compiler.elf2hex.bin.flags=-O binary -R .eeprom compiler.elf2hex.cmd=avr-objcopy compiler.ldflags= +compiler.libraries.ldflags= compiler.size.cmd=avr-size # This can be overridden in boards.txt @@ -66,7 +67,7 @@ archive_file_path={build.path}/{archive_file} recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" ## Combine gc-sections, archives, and objects -recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mmcu={build.mcu} {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "-L{build.path}" -lm "-Wl,-Map,{build.path}/{build.project_name}.map" +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mmcu={build.mcu} {compiler.c.elf.extra_flags} {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} "{build.path}/{archive_file}" "-L{build.path}" -lm "-Wl,-Map,{build.path}/{build.project_name}.map" ## Create output files (.eep and .hex) recipe.objcopy.eep.pattern="{compiler.path}{compiler.objcopy.cmd}" {compiler.objcopy.eep.flags} {compiler.objcopy.eep.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.eep" From f52a87ecaf45cf37df8b9e31cbb2e64c1f2d6d81 Mon Sep 17 00:00:00 2001 From: Silvano Cerza Date: Tue, 5 Oct 2021 10:42:30 +0200 Subject: [PATCH 08/15] Add support for pluggable discovery --- boards.txt | 12 ++++++++++++ platform.txt | 17 ++++++++++++++--- programmers.txt | 3 ++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/boards.txt b/boards.txt index 4652ff1a..e5ca54b6 100644 --- a/boards.txt +++ b/boards.txt @@ -6,8 +6,13 @@ uno2018.name=Arduino Uno WiFi Rev2 uno2018.vid.0=0x03eb uno2018.pid.0=0x2145 +uno2018.upload_port.0.vid=0x03eb +uno2018.upload_port.0.pid=0x2145 +uno2018.upload_port.1.board=uno2018 uno2018.upload.tool=avrdude +uno2018.upload.tool.default=avrdude +uno2018.upload.tool.network=arduino_ota uno2018.upload.protocol=xplainedmini_updi uno2018.upload.maximum_size=48640 uno2018.upload.maximum_data_size=6144 @@ -25,6 +30,7 @@ uno2018.build.extra_flags={build.328emulation} -DMILLIS_USE_TIMERB3 #uno2018.build.extra_flags=-B{runtime.tools.atpack.path}/gcc/dev/{build.mcu} uno2018.bootloader.tool=avrdude +uno2018.bootloader.tool.default=avrdude uno2018.bootloader.file=atmega4809_uart_bl.hex uno2018.bootloader.SYSCFG0=0xC9 uno2018.bootloader.BOOTEND=0x02 @@ -43,8 +49,13 @@ nona4809.name=Arduino Nano Every nona4809.vid.0=0x2341 nona4809.pid.0=0x0058 +nona4809.upload_port.0.vid=0x2341 +nona4809.upload_port.0.pid=0x0058 +nona4809.upload_port.1.board=nona4809 nona4809.upload.tool=avrdude +nona4809.upload.tool.default=avrdude +nona4809.upload.tool.network=arduino_ota nona4809.upload.protocol=jtag2updi nona4809.upload.maximum_size=49152 nona4809.upload.maximum_data_size=6144 @@ -62,6 +73,7 @@ nona4809.build.extra_flags={build.328emulation} -DMILLIS_USE_TIMERB3 -DNO_EXTERN #nona4809.build.extra_flags=-B{runtime.tools.atpack.path}/gcc/dev/{build.mcu} nona4809.bootloader.tool=avrdude +nona4809.bootloader.tool.default=avrdude nona4809.bootloader.file=atmega4809_uart_bl.hex nona4809.bootloader.SYSCFG0=0xC9 nona4809.bootloader.BOOTEND=0x00 diff --git a/platform.txt b/platform.txt index 9de78cc4..91eea6af 100644 --- a/platform.txt +++ b/platform.txt @@ -91,6 +91,12 @@ recipe.preproc.includes="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} preproc.macros.flags=-w -x c++ -E -CC recipe.preproc.macros="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {preproc.macros.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} "-I{build.core.path}/api/deprecated" {includes} "{source_file}" -o "{preprocessed_file_path}" +# Required discoveries and monitors +# --------------------------------- +pluggable_discovery.required.0=builtin:serial-discovery +pluggable_discovery.required.1=builtin:mdns-discovery +pluggable_monitor.required.serial=builtin:serial-monitor + # AVR Uploader/Programmers tools # ------------------------------ @@ -98,8 +104,6 @@ tools.avrdude.path={runtime.tools.avrdude-6.3.0-arduino17.path} tools.avrdude.cmd.path={path}/bin/avrdude tools.avrdude.config.path={path}/etc/avrdude.conf -tools.avrdude.network_cmd={runtime.tools.arduinoOTA-1.3.0.path}/bin/arduinoOTA - tools.avrdude.upload.params.verbose=-v tools.avrdude.upload.params.quiet=-q -q # tools.avrdude.upload.verify is needed for backwards compatibility with IDE 1.6.8 or older, IDE 1.6.9 or newer overrides this value @@ -124,7 +128,14 @@ tools.avrdude.bootloader.pattern="{cmd.path}" "-C{config.path}" {bootloader.verb tools.avrdude_remote.upload.pattern=/usr/bin/run-avrdude /tmp/sketch.hex {upload.verbose} -p{build.mcu} -tools.avrdude.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -d -v +# this is deprecated by pluggable discovery: +tools.avrdude.upload.network_pattern="{tools.arduino_ota.cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -d -v + +# ArduinoOTA +tools.arduino_ota.cmd={runtime.tools.arduinoOTA-1.3.0.path}/bin/arduinoOTA +tools.arduino_ota.upload.field.password=Password +tools.arduino_ota.upload.field.password.secret=true +tools.arduino_ota.upload.pattern="{tools.arduino_ota.cmd}" -address {upload.port.address} -port 65280 -username arduino -password "{upload.field.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -d -v # USB Default Flags # Default blank usb manufacturer will be filled in at compile time diff --git a/programmers.txt b/programmers.txt index d9e83344..70af3a0a 100644 --- a/programmers.txt +++ b/programmers.txt @@ -3,4 +3,5 @@ medbg.communication=usb medbg.protocol=xplainedmini_updi medbg.program.protocol=xplainedmini_updi medbg.program.tool=avrdude -medbg.program.extra_params=-Pusb \ No newline at end of file +medbg.program.tool.default=avrdude +medbg.program.extra_params=-Pusb From c31614b921f4c44eb2b1a2d19b7b2f172fcb6b86 Mon Sep 17 00:00:00 2001 From: landret christophe <19358486+landret@users.noreply.github.com> Date: Wed, 13 Oct 2021 21:24:27 -1000 Subject: [PATCH 09/15] Fix bug in analogWrite when accessing 16 bit register (#94) Fix bug in analogWrite when accessing 16 bit register --- cores/arduino/wiring_analog.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cores/arduino/wiring_analog.c b/cores/arduino/wiring_analog.c index cda2b4da..36ddc680 100644 --- a/cores/arduino/wiring_analog.c +++ b/cores/arduino/wiring_analog.c @@ -145,6 +145,8 @@ void analogWrite(uint8_t pin, int val) uint16_t* timer_cmp_out; TCB_t *timer_B; + uint8_t savedSREG; + /* Find out Port and Pin to correctly handle port mux, and timer. */ switch (digital_pin_timer) { @@ -153,7 +155,10 @@ void analogWrite(uint8_t pin, int val) timer_cmp_out = ((uint16_t*) (&TCA0.SINGLE.CMP0BUF)) + bit_pos; /* Configure duty cycle for correct compare channel */ - (*timer_cmp_out) = (val); + savedSREG = SREG; + cli(); + (*timer_cmp_out) = (val); // non-atomic 16-bit write operation + SREG = savedSREG; /* Enable output on pin */ TCA0.SINGLE.CTRLB |= (1 << (TCA_SINGLE_CMP0EN_bp + bit_pos)); @@ -170,7 +175,12 @@ void analogWrite(uint8_t pin, int val) timer_B = ((TCB_t *)&TCB0 + (digital_pin_timer - TIMERB0)); /* set duty cycle */ - timer_B->CCMPH = val; + // (16-bit read/write operation are non-atomic and use a temporary register) + savedSREG = SREG; + cli(); + timer_B->CCMPL = timer_B->CCMPL; // copy CCMPL into temporary register + timer_B->CCMPH = val; // set CCMPH value + copy temporary register content into CCMPL + SREG = savedSREG; /* Enable Timer Output */ timer_B->CTRLB |= (TCB_CCMPEN_bm); From d794ffd0fd745e4f4c156adbed6e8054dc88bc03 Mon Sep 17 00:00:00 2001 From: Silvano Cerza Date: Tue, 30 Nov 2021 12:15:46 +0100 Subject: [PATCH 10/15] Fix legacy upload.network_pattern rule --- platform.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/platform.txt b/platform.txt index 91eea6af..f2ad0cb5 100644 --- a/platform.txt +++ b/platform.txt @@ -128,8 +128,10 @@ tools.avrdude.bootloader.pattern="{cmd.path}" "-C{config.path}" {bootloader.verb tools.avrdude_remote.upload.pattern=/usr/bin/run-avrdude /tmp/sketch.hex {upload.verbose} -p{build.mcu} -# this is deprecated by pluggable discovery: -tools.avrdude.upload.network_pattern="{tools.arduino_ota.cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -d -v +# The following rule is deprecated by pluggable discovery. +# We keep it to avoid breaking compatibility with the Arduino Java IDE. +tools.avrdude.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA +tools.avrdude.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -d -v # ArduinoOTA tools.arduino_ota.cmd={runtime.tools.arduinoOTA-1.3.0.path}/bin/arduinoOTA From 134ff962bf52645a6b18a1a9e082185de88d08ab Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Wed, 24 Aug 2022 11:13:00 +0200 Subject: [PATCH 11/15] Update compiler version for muxto (#122) --- .github/workflows/compile-muxto.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/compile-muxto.yml b/.github/workflows/compile-muxto.yml index f0e8948b..881699af 100644 --- a/.github/workflows/compile-muxto.yml +++ b/.github/workflows/compile-muxto.yml @@ -37,6 +37,8 @@ jobs: source-url: https://www.mattairtech.com/software/arduino/package_MattairTech_index.json # This needs to match with the version of MattairTech_Arduino:samd the Arduino fork is based on in order to get the right tool versions version: 1.6.17 + # Install officila samd version for compiler support + - name: arduino:samd # Install the platform with MuxTO support - name: arduino:samd source-url: https://github.com/arduino/ArduinoCore-samd.git From 01b56951ed2a8acfa7a4efc4e9a2687f626641d1 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Mon, 5 Dec 2022 10:26:17 +0100 Subject: [PATCH 12/15] Release 1.8.8 --- platform.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform.txt b/platform.txt index f2ad0cb5..50992217 100644 --- a/platform.txt +++ b/platform.txt @@ -6,7 +6,7 @@ # https://arduino.github.io/arduino-cli/latest/platform-specification/ name=Arduino megaAVR Boards -version=1.8.7 +version=1.8.8 # AVR compile variables # --------------------- From 7504ca7729ae4847f6b6db1df6b2e6af765649b7 Mon Sep 17 00:00:00 2001 From: Josefine Hansson <66409231+jhansson-ard@users.noreply.github.com> Date: Fri, 24 Feb 2023 12:03:34 +0100 Subject: [PATCH 13/15] Updated product names (#127) --- extras/package_index.json.NewTag.template | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extras/package_index.json.NewTag.template b/extras/package_index.json.NewTag.template index 1da2a8f8..fcc12676 100644 --- a/extras/package_index.json.NewTag.template +++ b/extras/package_index.json.NewTag.template @@ -23,7 +23,7 @@ }, "boards": [ { - "name": "Arduino Uno WiFi Rev2" + "name": "Arduino UNO WiFi Rev2" }, { "name": "Arduino Nano Every" @@ -51,4 +51,4 @@ "tools": [] } ] -} \ No newline at end of file +} From ffab9cb2e4bca7647f11d6e25727788aec597a03 Mon Sep 17 00:00:00 2001 From: Kateryna Lukina <94372596+kateryna-lukina@users.noreply.github.com> Date: Fri, 24 Feb 2023 12:04:02 +0100 Subject: [PATCH 14/15] Update boards.txt (#126) correct spelling of UNO --- boards.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boards.txt b/boards.txt index e5ca54b6..504c40af 100644 --- a/boards.txt +++ b/boards.txt @@ -2,7 +2,7 @@ ############################################################## -uno2018.name=Arduino Uno WiFi Rev2 +uno2018.name=Arduino UNO WiFi Rev2 uno2018.vid.0=0x03eb uno2018.pid.0=0x2145 From aa477bb589af002e7d974174eaf5594e74633b5f Mon Sep 17 00:00:00 2001 From: seaxwi <71350948+seaxwi@users.noreply.github.com> Date: Mon, 29 May 2023 11:51:16 +0200 Subject: [PATCH 15/15] New post_install.sh script that works for Nano Every --- post_install.sh | 28 ++++++++++++++++++++++++++++ scripts/create_dfu_udev_rule | 17 ----------------- 2 files changed, 28 insertions(+), 17 deletions(-) create mode 100644 post_install.sh delete mode 100755 scripts/create_dfu_udev_rule diff --git a/post_install.sh b/post_install.sh new file mode 100644 index 00000000..9a944e8a --- /dev/null +++ b/post_install.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +megaAVR_rules () { + echo "" + echo "# Arduino Mega AVR boards bootloader mode udev rules" + echo "" +cat < /etc/udev/rules.d/60-arduino-megaAVR.rules + +# reload udev rules +echo "Reload rules..." +udevadm control --reload-rules +udevadm trigger + diff --git a/scripts/create_dfu_udev_rule b/scripts/create_dfu_udev_rule deleted file mode 100755 index 89d2a8a3..00000000 --- a/scripts/create_dfu_udev_rule +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -# - -if [ "$(id -u)" != "0" ]; then - echo "This script must be run as root" - exit -fi - -NAME=99-arduino-uno-wifi-rev2.rules - -echo >/etc/udev/rules.d/$NAME -echo \# Arduino UNO WiFi Rev2 mEDBG CMSIS-DAP >>/etc/udev/rules.d/$NAME -echo SUBSYSTEM==\"tty\", ENV{ID_REVISION}==\"03eb\", ENV{ID_MODEL_ID}==\"2145\", MODE=\"0666\", ENV{ID_MM_DEVICE_IGNORE}=\"1\", ENV{ID_MM_CANDIDATE}=\"0\" >>/etc/udev/rules.d/$NAME -echo SUBSYSTEM==\"usb\", ATTR{idVendor}==\"03eb\", ATTR{idProduct}==\"2145\", MODE=\"0666\", ENV{ID_MM_DEVICE_IGNORE}=\"1\" >>/etc/udev/rules.d/$NAME - -udevadm control --reload-rules -udevadm trigger